Skip to content

Commit

Permalink
add more details about reducedbasis in python #219 #151
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-saigre committed Nov 16, 2022
1 parent 03dee45 commit 5593f0f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 20 deletions.
1 change: 1 addition & 0 deletions docs/mor/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
** xref:pbdw.adoc#_using_pbdw[Using PBDW]
* xref:index.adoc#_cases[Cases]
** xref:opusheat:index.adoc[OpusHeat]
** xref:thermalfin:index.adoc[ThermalFin]
1 change: 1 addition & 0 deletions docs/mor/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ The Parametrized Background Data Weak (xref:pbdw.adoc[PBDW]) method has also bee
== Cases

- xref:opusheat:index.adoc[OpusHeat]
- xref:thermalfin:index.adoc[ThermalFin]
1 change: 1 addition & 0 deletions docs/mor/modules/thermalfin/nav.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* xref:index.adoc[Thermal fin]
3 changes: 3 additions & 0 deletions docs/mor/modules/thermalfin/pages/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= Thermal fin

This comment has been minimized.

Copy link
@prudhomm

prudhomm Nov 16, 2022

Member

add

;page-jupyter: true 

to allow generation of a notebook

The redaction of this page is in progress.
49 changes: 32 additions & 17 deletions docs/user/modules/python/pages/pyfeelppmor/reducedbasis.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,24 @@ To set the environment, those module also need to be imported :
[source, python]
----
import sys, os
from feelpp.toolboxes.heat import *
import feelpp.toolboxes.core as core
from feelpp.operators import mass
import feelpp.mor as mor
from feelpp.toolboxes.heat import * <1>
import feelpp.toolboxes.core as core <2>
from feelpp.operators import mass <3>
import feelpp.mor as mor <4>

This comment has been minimized.

Copy link
@prudhomm

prudhomm Nov 16, 2022

Member

use # before the callouts so # <1> for example

import feelpp
----

<1> The toolbox heat is used to simulate the heat equation on the case studied.
<2> The module `core` is used to set the environment.
<3> The `mass` function is needed to create the mass matrix if we work on a time-dependent case.
<4> The module `mor` is used to get the functions neededd by the toolbox mor.


== Set the environment

[source, python]
----
config = feelpp.globalRepository("reducedbasis")
config = feelpp.localRepository("reducedbasis")
sys.argv = ["reducedbasis"]
o = core.toolboxes_options("heat")
o.add(mor.makeToolboxMorOptions())
Expand All @@ -43,22 +48,39 @@ e = feelpp.Environment(sys.argv, opts=o, config=config)

== Set the model

=== Description of the model

In this document, the cases used is `thermal-fin` in 2D, with a stem:[\mathbb{P}_1] discretization and stationnary.
This model is described in xref:mor:thermalfin:index.adoc[this page].

The usage would be the same for another case.


=== Code

Set the parameters nedded to the model :

- `config_file` : path to the cfg file
- `dim` : the dimension of the case
- `order` : the order of discretization (`1` for stem:[\mathbb{P}_1], `2` for stem:[\mathbb{P}_2])
- `time_dependant` : is the case stationnary or transient ? (for now always to `False`)
- `time_depedent` : is the case stationnary or transient ? (for now always to `False`)
- `name` : name of the CRB case



[source,python]
----
config_file = "thermal-fin.cfg"
dim = 2
order = 1
time_dependant = False
time_depedent = False
name = "thermalfin-2d"
----

The configuration files for this case are available on github : https://raw.githubusercontent.com/feelpp/feelpp/develop/mor/cases/thermal-fin/2d/fin.geo[geometry file], https://raw.githubusercontent.com/feelpp/feelpp/develop/mor/cases/thermal-fin/2d/thermal-fin.cfg[cfg file], and https://raw.githubusercontent.com/feelpp/feelpp/develop/mor/cases/thermal-fin/2d/thermal-fin.json[json file].

Then, we can create the model :

[source,python]
----
cfg = feelpp.readCfg(config_file)
Expand Down Expand Up @@ -118,7 +140,7 @@ default_parameter = modelParameters.toParameterValues()

[source, python]
----
model = mor.toolboxmor(name=name, dim=dim, time_dependent=time_dependant)
model = mor.toolboxmor(name=name, dim=dim, time_dependent=time_depedent)
model.setFunctionSpaces( Vh=heatBox.spaceTemperature() )
def assembleDEIM(mu):
Expand Down Expand Up @@ -305,6 +327,8 @@ rb.computeOfflineErrorRhs()
rb.computeOfflineError()
----

The script `generate_basis.py` run this offline part. See the xref:pyfeelppmor/reducedbasis_offline.adoc[dedicated page] for more details.

== Online phase

[source, python]
Expand Down Expand Up @@ -358,12 +382,3 @@ rb.getSolutionsFE(mu, k=0)
The two functions `getSolutions` (resp. `getSolutionsFE`) return the solution stem:[u_N(\mu)] (resp. stem:[u(\mu)]) and the value of the output stem:[s_N^k(\mu)] (res. stem:[s^k(\mu)]).
See xref:pyfeelppmor/parameters.adoc[the dedicated page] for the API of `ParameterSpaceElement`.



== Offline stage :

See the xref:pyfeelppmor/reducedbasis_offline.adoc[offline stage] page.

== Online stage :

See the xref:pyfeelppmor/reducedbasis_online.adoc[online stage] page.
7 changes: 4 additions & 3 deletions docs/user/modules/python/pages/pyfeelppmor/toolboxmor.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

= Toolboxmor

For the configuration of the case, and the usage in a C++ application, refer to xref:mor:toolboxmor.adoc[ToolboxMor] documentation.
For the configuration of the case, and the usage in a C++ application, refer to xref:mor:ROOT:toolboxmor.adoc[ToolboxMor] documentation.
More details on the functions of the toolbox can be found in xref:pyfeelppmor/reducedbasis.adoc[this page].

== Model

Expand All @@ -13,7 +14,7 @@ We assume that we have the following decompositions :
[stem]
++++
\begin{align}
a(u, v; mu) &= \displaystyle\sum_{q=1}^{Q_a} \beta_A^q(\mu) a^q(u, v) \\
a(u, v; \mu) &= \displaystyle\sum_{q=1}^{Q_a} \beta_A^q(\mu) a^q(u, v) \\
f(v; \mu) &= \displaystyle\sum_{p=1}^{Q_f} \beta_F^p(\mu) f^p(v)\\
l_i(v; \mu) &= \displaystyle\sum_{p=1}^{Q_{l_i}} \beta_{s_i}^p(\mu) l_i^p(v)
\end{align}
Expand Down Expand Up @@ -48,7 +49,7 @@ L_i(\mu) &= \displaystyle\sum_{p=1}^{Q_{l_i}} \beta_{L_i}^p(\mu) L_i^p
[betaA, betaF] = model.computeBetaQm(mu)
----

where `mu` is a `ParameterSpaceElement` (see xref:parameters.adoc[Parameters]).
where `mu` is a `ParameterSpaceElement` (see xref:pyfeelppmor/parameters.adoc[Parameters]).

* `betaA` is a list of length 1, and `betaA[0]` contains the coefficients of the affine decomposition `betaA[0] = [` stem:[\beta_A^1]`,...,` stem:[\beta_A^{Q_a}] `]`.
* `betaF` is a list of length stem:[1 + n_\text{outputs}] contains the coefficients of the affine decompositions of stem:[f], and stem:[s_i] :
Expand Down

0 comments on commit 5593f0f

Please sign in to comment.