|
14 | 14 | Examples |
15 | 15 | -------- |
16 | 16 |
|
17 | | ->>> coll:QGenerator = ... # any QGenerator object implemented in qmat.qcoeff.[...] |
| 17 | +>>> qGen:QGenerator = ... # any QGenerator object implemented in qmat.qcoeff.[...] |
18 | 18 | >>> |
19 | 19 | >>> # Generate QDelta coefficients with generic function |
20 | 20 | >>> from qmat.qdelta import genQDeltaCoeffs |
21 | | ->>> qDeltaBE = genQDeltaCoeffs("BE", nodes=coll.nodes) # Backward Euler approximation |
22 | | ->>> qDeltaLU = genQDeltaCoeffs("LU", Q=coll.Q) # LU approximation |
| 21 | +>>> qDeltaBE = genQDeltaCoeffs("BE", nodes=qGen.nodes) # Backward Euler approximation |
| 22 | +>>> qDeltaLU = genQDeltaCoeffs("LU", Q=qGen.Q) # LU approximation |
23 | 23 | >>> |
24 | 24 | >>> # Generate QDelta coefficients with QDeltaGenerator objects |
25 | 25 | >>> from qmat.qdelta.timestepping import BE |
26 | | ->>> qDeltaBE = BE(nodes=coll.nodes).getQDelta() |
| 26 | +>>> qDeltaBE = BE(nodes=qGen.nodes).getQDelta() |
27 | 27 | >>> from qmat.qdelta.algebraic import LU |
28 | | ->>> qDeltaLU = LU(Q=coll.Q) |
| 28 | +>>> qDeltaLU = LU(Q=qGen.Q) |
29 | 29 | >>> |
30 | 30 | >>> # Simplified import for all QDeltaGenerator objects |
31 | 31 | >>> from qmat.qdelta import QDELTA_GENERATORS # 💡 can also be imported from qmat directly |
32 | | ->>> qDeltaBE = QDELTA_GENERATORS["BE"](nodes=coll.nodes).getQDelta() |
33 | | ->>> qDeltaLU = QDELTA_GENERATORS["LU"](Q=coll.Q).getQDelta() |
| 32 | +>>> qDeltaBE = QDELTA_GENERATORS["BE"](nodes=qGen.nodes).getQDelta() |
| 33 | +>>> qDeltaLU = QDELTA_GENERATORS["LU"](Q=qGen.Q).getQDelta() |
34 | 34 |
|
35 | 35 | Note |
36 | 36 | ---- |
37 | 37 | All :math:`Q_\Delta` approximations may need different parameters to be computed (e.g `nodes` for BE or `Q` for LU). |
38 | 38 | But **you don't need a different call for each approximation** : additional keyword arguments may be given, |
39 | 39 | and ignored when the approximation don't need them ... |
40 | 40 |
|
41 | | ->>> coll:QGenerator = ... # any QGenerator object implemented in qmat.qcoeff.[...] |
| 41 | +>>> qGen:QGenerator = ... # any QGenerator object implemented in qmat.qcoeff.[...] |
42 | 42 | >>> |
43 | 43 | >>> # Generic call with generic function |
44 | 44 | >>> from qmat.qdelta import genQDeltaCoeffs |
45 | 45 | >>> for qdType in ["BE", "LU"]: |
46 | | ->>> qDelta = genQDeltaCoeffs(qdType, nodes=coll.nodes, Q=coll.Q) |
| 46 | +>>> qDelta = genQDeltaCoeffs(qdType, nodes=qGen.nodes, Q=qGen.Q) |
47 | 47 | >>> |
48 | 48 | >>> # Generic call with generic QDeltaGenerator objects import |
49 | 49 | >>> from qmat.qdelta import QDELTA_GENERATORS |
50 | 50 | >>> for qdType in ["BE", "LU"]: |
51 | | ->>> qDelta = QDELTA_GENERATORS[qdType](nodes=coll.nodes, Q=coll.Q).getQDelta() |
| 51 | +>>> qDelta = QDELTA_GENERATORS[qdType](nodes=qGen.nodes, Q=qGen.Q).getQDelta() |
52 | 52 |
|
53 | 53 | 📣 If you want to **cover all available approximations** implemented in `qmat`, |
54 | 54 | we highly suggest to use the `qGen` keyword argument, allowing to extract any |
55 | 55 | required parameter from a `QGenerator` object, e.g : |
56 | 56 |
|
57 | 57 | >>> # Using generic function |
58 | 58 | >>> for qdType in ["BE", "LU", "MIN-SR-S", "MIN-SR-NS", "MIN-SR-FLEX"]: |
59 | | ->>> qDelta = genQDeltaCoeffs(qdType, qGen=coll) |
| 59 | +>>> qDelta = genQDeltaCoeffs(qdType, qGen=qGen) |
60 | 60 | >>> |
61 | 61 | >>> # Using QDeltaGenerator objects |
62 | 62 | >>> for qdType in ["BE", "LU", "MIN-SR-S", "MIN-SR-NS", "MIN-SR-FLEX"]: |
63 | | ->>> qDelta = QDELTA_GENERATORS[qdType](qGen=coll).getQDelta() |
| 63 | +>>> qDelta = QDELTA_GENERATORS[qdType](qGen=qGen).getQDelta() |
64 | 64 |
|
65 | 65 | 💡 This ensure forward compatibility in your code, so it can use any other |
66 | 66 | :math:`Q_\Delta` approximations added later in `qmat` without modification. |
|
0 commit comments