Commit 16f90126 authored by René Fritze's avatar René Fritze
Browse files

[docs] fix round-trip conversion of tutorials through jupytext

parent 28af4c95
Pipeline #152476 failed with stages
in 29 minutes and 29 seconds
......@@ -21,11 +21,12 @@ kernelspec:
```
```{code-cell}
:tags: [remove-cell]
:load: myst_code_init.py
```
:tags: [remove-cell]
```
Tutorial: Building a Reduced Basis
==================================
......@@ -299,6 +300,7 @@ which will give us a {math}`25\times 1` {{ NumPy_array }} of all inner products.
```{code-cell}
:tags: [remove-cell]
assert R.shape == (25,1)
```
......@@ -530,6 +532,7 @@ re-orthogonalization to improve numerical accuracy:
```{code-cell}
:tags: [remove-output]
gram_schmidt(greedy_basis, product=fom.h1_0_semi_product, copy=False)
gram_schmidt(trivial_basis, product=fom.h1_0_semi_product, copy=False)
```
......
......@@ -21,11 +21,12 @@ kernelspec:
```
```{code-cell}
:tags: [remove-cell]
:load: myst_code_init.py
```
:tags: [remove-cell]
```
# Tutorial: Reducing an LTI system using balanced truncation
......@@ -50,6 +51,8 @@ Then we build the matrices
```{code-cell}
:load: heat_equation.py
```
and form the full-order model.
......@@ -267,5 +270,3 @@ print(f'Relative Hankel error: {err.hankel_norm() / fom.hankel_norm():.3e}')
Download the code:
{download}`tutorial_bt.md`,
{nb-download}`tutorial_bt.ipynb`.
......@@ -21,8 +21,10 @@ kernelspec:
```
```{code-cell}
:tags: [remove-cell]
:load: myst_code_init.py
:tags: [remove-cell]
```
# Tutorial: Using pyMOR’s discretization toolkit
......@@ -501,5 +503,3 @@ for all possible parameter value combinations.
Download the code:
{download}`tutorial_builtin_discretizer.md`
{nb-download}`tutorial_builtin_discretizer.ipynb`
......@@ -21,8 +21,10 @@ kernelspec:
```
```{code-cell}
:tags: [remove-cell]
:load: myst_code_init.py
:tags: [remove-cell]
```
# Tutorial: Binding an external PDE solver to pyMOR
......@@ -41,16 +43,18 @@ First, we need a class to store our data in and with some basic linear algebra o
declared on it.
```{literalinclude} minimal_cpp_demo/model.hh
:lines: 4-19
:language: cpp
:lines: 4-19
```
Next, we need the operator that discretizes our PDE.
```{literalinclude} minimal_cpp_demo/model.hh
:lines: 22-32
:language: cpp
:lines: 22-32
```
......@@ -59,16 +63,16 @@ Together with some header guards, these two snippets make up our {download}`mode
The definitions for the `Vector` class are pretty straightforward:
```{literalinclude} minimal_cpp_demo/model.cc
:lines: 7-35
:language: cpp
:lines: 7-35
```
Just like the diffusion operator that computes a central differences stencil:
```{literalinclude} minimal_cpp_demo/model.cc
:lines: 39-49
:language: cpp
:lines: 39-49
```
......@@ -97,8 +101,8 @@ to represent the full-order model.
All of the C++ code related to the extension module is defined inside a scope started with
```{literalinclude} minimal_cpp_demo/model.cc
:lines: 56-57
:language: cpp
:lines: 56-57
```
......@@ -190,13 +194,13 @@ compilation.
```{code-cell}
:tags: [raises-exception]
%%bash
mkdir -p minimal_cpp_demo/build
cmake -B minimal_cpp_demo/build -S minimal_cpp_demo
make -C minimal_cpp_demo/build
```
To be able to use this extension module we need to insert the build directory into the path where the Python
interpreter looks for things to import. Afterwards we can import the module and create and use the exported classes.
......@@ -209,7 +213,6 @@ mymodel = model.DiffusionOperator(10, 0, 1)
myvector = model.Vector(10, 0)
mymodel.apply(myvector, myvector)
dir(model)
```
## Using the exported Python classes with pyMOR
......@@ -437,5 +440,3 @@ fom.visualize((U-U_RB), title=f'mu = {mu}', legend=('error'))
You can download this demonstration plus the wrapper definitions as a
notebook {nb-download}`tutorial_external_solver.ipynb` or
as Markdown text {download}`tutorial_external_solver.md`.
......@@ -21,8 +21,10 @@ kernelspec:
```
```{code-cell}
:tags: [remove-cell]
:load: myst_code_init.py
:tags: [remove-cell]
```
# Tutorial: Linear time-invariant systems
......@@ -108,6 +110,8 @@ approximation using standard methods of NumPy and SciPy.
```{code-cell}
:load: heat_equation.py
```
Then, we can create an {{ LTIModel }} from NumPy and SciPy matrices `A`, `B`, `C`,
......@@ -503,4 +507,3 @@ fom.hankel_norm()
Download the code:
{download}`tutorial_lti_systems.md`,
{nb-download}`tutorial_lti_systems.ipynb`.
......@@ -21,8 +21,10 @@ kernelspec:
```
```{code-cell}
:tags: [remove-cell]
:load: myst_code_init.py
:tags: [remove-cell]
```
# Tutorial: Model order reduction with artificial neural networks
......@@ -167,8 +169,8 @@ To train the neural network, we create a training and a validation set
consisting of 100 and 20 randomly chosen {{ parameter_values }}, respectively:
```{code-cell}
training_set = parameter_space.sample_uniformly(100)
validation_set = parameter_space.sample_randomly(20)
training_set = parameter_space.sample_uniformly(100)
validation_set = parameter_space.sample_randomly(20)
```
In this tutorial, we construct the reduced basis such that no more modes than
......@@ -407,5 +409,3 @@ corresponding {class}`~pymor.models.neural_network.NeuralNetworkInstationaryStat
Download the code:
{download}`tutorial_mor_with_anns.md`
{nb-download}`tutorial_mor_with_anns.ipynb`
......@@ -21,8 +21,10 @@ kernelspec:
```
```{code-cell}
:tags: [remove-cell]
:load: myst_code_init.py
:tags: [remove-cell]
```
# Tutorial: Model order reduction for PDE-constrained optimization problems
......@@ -766,7 +768,8 @@ report(opt_along_path_adaptively_result, opt_along_path_adaptively_minimization_
```
```{code-cell}
:tags: [hide-code,hide-output]
:tags: [hide-code, hide-output]
assert fom_result.nit == 7
assert opt_along_path_result.nit == 7
assert opt_along_path_minimization_data['num_evals'] == 9
......
......@@ -21,8 +21,10 @@ kernelspec:
```
```{code-cell}
:tags: [remove-cell]
:load: myst_code_init.py
:tags: [remove-cell]
```
# Tutorial: Projecting a Model
......@@ -564,7 +566,7 @@ In the case of `fom.operator`, which is a {{ LincombOperator }}, the rule with i
be the first matching rule. We can take a look at it:
```{code-cell}
:tags: [hide-code,hide-output]
:tags: [hide-code, hide-output]
assert ProjectRules.rules[8].action_description == 'LincombOperator'
```
......@@ -588,7 +590,8 @@ In our case, `ProjectRules` will be applied to all {{ NumpyMatrixOperators }} he
will apply:
```{code-cell}
:tags: [hide-code,hide-output]
:tags: [hide-code, hide-output]
assert ProjectRules.rules[3].action_description == 'apply_basis'
```
......@@ -674,5 +677,3 @@ print_source(reductor.reconstruct)
Download the code:
{download}`tutorial_projection.md`
{nb-download}`tutorial_projection.ipynb`
......@@ -21,8 +21,10 @@ kernelspec:
```
```{code-cell}
:tags: [remove-cell]
:load: myst_code_init.py
:tags: [remove-cell]
```
# Tutorial: Model order reduction for unstable LTI systems
......@@ -89,6 +91,8 @@ approximation using standard methods of NumPy and SciPy. Here we use
```{code-cell}
:load: unstable_heat_equation.py
```
Then, we can create an {{ LTIModel }} from NumPy and SciPy matrices `A`, `B`, `C`,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment