Skip to content

Commit

Permalink
[build-bib, build-latex] Solver + consistency section, fix bug with b…
Browse files Browse the repository at this point in the history
…ackslash plague in bib file (#101)

* [build-bib, build-latex] Numerical solver section, fix bib bug

* 📚 Automated compiled Latex PDF

Signed-off-by: My GitHub Actions Bot <41898282+github-actions[bot]@users.noreply.github.com>

* [build-bib] Build bib

* 📁 Automated biblatex merge [build-latex]

Signed-off-by: My GitHub Actions Bot <41898282+github-actions[bot]@users.noreply.github.com>

* [build-bib] Fixing backslash plague in pybtex manually

* [build-bib] fix Python typo

* 📁 Automated biblatex merge [build-latex]

Signed-off-by: My GitHub Actions Bot <41898282+github-actions[bot]@users.noreply.github.com>

* [build-bib, build-latex] Reorganized consistency section

* 📚 Automated compiled Latex PDF

Signed-off-by: My GitHub Actions Bot <41898282+github-actions[bot]@users.noreply.github.com>

---------

Signed-off-by: My GitHub Actions Bot <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Author <[email protected]>
  • Loading branch information
facusapienza21 and actions-user authored Mar 19, 2024
1 parent 4675d01 commit 431ec8f
Show file tree
Hide file tree
Showing 19 changed files with 2,313 additions and 2,125 deletions.
20 changes: 17 additions & 3 deletions .utils/biblatex_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,26 @@ def merge_bib(path):
return filtered_bib_data


def save_bib(bib_data, file):
bib_data.to_file(file, bib_format="bibtex")
def save_bib(bib_data, file, manual_backslash_plague_fix=True):
if manual_backslash_plague_fix:
astr = bib_data.to_string(bib_format='bibtex')
astr = astr.replace("\\\\\\\&", "\&")
astr = astr.replace("\\\\\\&", "\&")
astr = astr.replace("\\\\\&", "\&")
astr = astr.replace("\\\\&", "\&")
astr = astr.replace("\\\&", "\&")
astr = astr.replace("\\&", "\&")
# astr = astr.replace("\_", "_")
# astr = astr.replace("\&", "&")
# astr = astr.replace("\%", "%")
with open(file, "w") as f_handle:
f_handle.write(astr)
else:
bib_data.to_file(file, bib_format="bibtex")


if __name__ == "__main__":
working_directory = sys.argv[1]
output_file = sys.argv[2]
filtered_bib_data = merge_bib(working_directory)
save_bib(filtered_bib_data, output_file)
save_bib(filtered_bib_data, output_file, manual_backslash_plague_fix=True)
Binary file modified main.pdf
Binary file not shown.
5 changes: 1 addition & 4 deletions tex/appendix/lagrangian.tex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ \subsubsection{Discrete adjoint}
Given that for every choice of the parameter $\theta$ we have $G(U; \theta) = 0$, we have that $I(U, \theta) = L(U, \theta)$.
Then, the gradient of $L$ with respect to the vector parameter $\theta$ can be computed as
\begin{align}
\begin{split}
\frac{dL}{d\theta}
=
\frac{dI}{d\theta}
Expand All @@ -33,9 +32,7 @@ \subsubsection{Discrete adjoint}
&=
\frac{\partial L}{\partial \theta} + \lambda^T \frac{\partial G}{\partial U}
+
\left( \frac{\partial L}{\partial \theta} + \lambda^T \frac{\partial G}{\partial U} \right) \frac{\partial U}{\partial \theta}.
\end{split}
\label{eq:appendix-discrete-adjoint}
\left( \frac{\partial L}{\partial \theta} + \lambda^T \frac{\partial G}{\partial U} \right) \frac{\partial U}{\partial \theta}. \label{eq:appendix-discrete-adjoint}
\end{align}
The important trick in the last term involved grouping all the terms involving the sensitivity $\frac{\partial U}{\partial \theta}$ together.
In order to avoid the computation of the sensitivity at all, we can define $\lambda$ as the vector that makes the last term in the right hand side of Equation \eqref{eq:appendix-discrete-adjoint} which results in the same results we obtained in Equation \eqref{eq:adjoint-state-equation} and \eqref{eq:def_adjoint}, that is,
Expand Down
Loading

0 comments on commit 431ec8f

Please sign in to comment.