From ddc66f731d1c55a9389dd60ba0d357eced4aadd2 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Mon, 10 Jun 2024 16:37:48 +0200 Subject: [PATCH] finished testing --- docs/source/userguide/settings.rst | 2 +- docs/source/userguide/sources.rst | 8 ++++---- docs/source/userguide/stepsize.rst | 10 +++++----- docs/source/userguide/temperature.rst | 14 +++++++++----- docs/source/userguide/traps.rst | 12 ++++++------ docs/source/userguide/troubleshooting.rst | 8 ++++---- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/docs/source/userguide/settings.rst b/docs/source/userguide/settings.rst index 90f4cd4c8..cdead3f97 100644 --- a/docs/source/userguide/settings.rst +++ b/docs/source/userguide/settings.rst @@ -6,7 +6,7 @@ Settings The settings of a FESTIM simulation are defined with a :class:`festim.Settings` object. -.. code-block:: python +.. testcode:: import festim as F diff --git a/docs/source/userguide/sources.rst b/docs/source/userguide/sources.rst index 8ae5ecc27..983185a68 100644 --- a/docs/source/userguide/sources.rst +++ b/docs/source/userguide/sources.rst @@ -10,7 +10,7 @@ Volumetric sources Volumetric sources can be set in a simulation by using the :class:`festim.Source` class. -.. code:: python +.. testcode:: import festim as F @@ -28,7 +28,7 @@ Implantation flux Hydrogen implanted in a material can be simulated by a Gaussian-shaped volumetric source with the :class:`festim.ImplantationFlux` class. -.. code:: python +.. testcode:: import festim as F @@ -51,7 +51,7 @@ Radioactive decay Radioactive decay can be simulated by a volumetric source with the :class:`festim.RadioactiveDecay` class. -.. code:: python +.. testcode:: import festim as F @@ -61,6 +61,6 @@ Radioactive decay can be simulated by a volumetric source with the :class:`festi F.RadioactiveDecay( decay_constant=1.78e-9, volume=1, - fields="all", + field="all", ), ] diff --git a/docs/source/userguide/stepsize.rst b/docs/source/userguide/stepsize.rst index 971b299ca..8cc30b3a3 100644 --- a/docs/source/userguide/stepsize.rst +++ b/docs/source/userguide/stepsize.rst @@ -7,14 +7,14 @@ For transient problems, a :class:`festim.Stepsize` is required. It represents the time discretisation of the problem. Here is an example creating a stepsize of 1.2 seconds: -.. code-block:: python +.. testcode:: import festim as F my_stepsize = F.Stepsize(initial_value=1.2) To use the adaptive time stepping implemented in FESTIM, the arguments ``stepsize_change_ratio`` needs to be set to a value above 1. -.. code-block:: python +.. testcode:: my_stepsize = F.Stepsize(initial_value=1.2, stepsize_change_ratio=1.5) @@ -25,7 +25,7 @@ Moreover, if the solver doesn't converge, the stepsize will be reduced and the s Setting the ``dt_min`` argument will prevent the stepsize from becoming too small and will stop the simulation when this happens. To cap the stepsize after some time, the parameters ``t_stop`` and ``stepsize_stop_max`` can be used. -.. code-block:: python +.. testcode:: my_stepsize = F.Stepsize( initial_value=1.2, @@ -41,7 +41,7 @@ To cap the stepsize after some time, the parameters ``t_stop`` and ``stepsize_st Another option for controlling the stepsize is to use the ``max_stepsize`` parameter. This parameter defines the maximal value of the stepsize during simulations, and it can be set as a constant or a callable function of time: -.. code-block:: python +.. testcode:: def max_stepsize(t): if t <= 5: @@ -60,7 +60,7 @@ and it can be set as a constant or a callable function of time: The ``milestones`` argument can be used to make sure the simulation passes through specific times. This will modify the stepsize as needed. -.. code-block:: python +.. testcode:: my_stepsize = F.Stepsize( initial_value=1.2, diff --git a/docs/source/userguide/temperature.rst b/docs/source/userguide/temperature.rst index 8a93268c3..0100a237e 100644 --- a/docs/source/userguide/temperature.rst +++ b/docs/source/userguide/temperature.rst @@ -2,6 +2,10 @@ Temperature =========== +.. testsetup:: + + from festim import HeatTransferProblem, TemperatureFromXDMF + Definition of a temperature field or problem is essential for hydrogen transport and FESTIM as a whole. Regardless of how you define the temperature of the problem, it is passed to the :code:`T` attribute of the :class:`festim.Simulation` object. @@ -12,7 +16,7 @@ Analytical expressions The temperature can be defined as a constant value in Kelvin (K): -.. code-block:: python +.. testcode:: my_temperature = 300 @@ -40,7 +44,7 @@ More complex expressions can be expressed with sympy: would be passed to FESTIM as: -.. code-block:: python +.. testcode:: from festim import x, t import sympy as sp @@ -49,12 +53,12 @@ would be passed to FESTIM as: Conditional expressions are also possible: -.. code-block:: python +.. testcode:: from festim import x, t import sympy as sp - my_temp = sp.Piecewise((400, F.t < 10), (300, True)) + my_temp = sp.Piecewise((400, t < 10), (300, True)) --------------------------- From a heat transfer solver @@ -64,7 +68,7 @@ Temperature can also be obtained by solving the heat equation. Users can define heat transfer problems using :class:`festim.HeatTransferProblem`. -.. code-block:: python +.. testcode:: my_temp = HeatTransferProblem() diff --git a/docs/source/userguide/traps.rst b/docs/source/userguide/traps.rst index 6cc7dcb7f..43586ca27 100644 --- a/docs/source/userguide/traps.rst +++ b/docs/source/userguide/traps.rst @@ -16,7 +16,7 @@ A trap in FESTIM is defined by: * its density * the materials where it is located -.. code-block:: python +.. testcode:: import festim as F @@ -26,7 +26,7 @@ A trap in FESTIM is defined by: If the trap is located in several materials, instead of creating another :class:`festim.Trap` object, simply use a list of materials: -.. code-block:: python +.. testcode:: import festim as F @@ -37,7 +37,7 @@ If the trap is located in several materials, instead of creating another :class: The trap density can be a function of space and time. For example: -.. code-block:: python +.. testcode:: import festim as F @@ -52,7 +52,7 @@ The trap density can be a function of space and time. For example: Boolean expressions can also be used to restrict the trap to certain regions: -.. code-block:: python +.. testcode:: import festim as F @@ -76,7 +76,7 @@ Extrinsic traps An extrinsic trap is defined as a trap with a density evolving over time. If the temporal evolution of the trap's density is known `a priori`, then a "normal" trap can be used with a time dependent expression as density (see above). -.. code-block:: python +.. testcode:: import festim as F @@ -94,7 +94,7 @@ Let's imagine a case where you have two subdomains. Trap 1 is defined only in th It would be possible to define one trap in each subdomain. Grouping traps together helps save computational time by reducing the number of degrees of freedom. -.. code-block:: python +.. testcode:: import festim as F diff --git a/docs/source/userguide/troubleshooting.rst b/docs/source/userguide/troubleshooting.rst index a999a8884..0f44586f2 100644 --- a/docs/source/userguide/troubleshooting.rst +++ b/docs/source/userguide/troubleshooting.rst @@ -23,7 +23,7 @@ The first thing to check is the details of the Newton solver iterations. To do so, you must set the ``log_level`` to ``20`` (default is ``40``). This will provide more information during the solving stage. -.. code-block:: python +.. testcode:: import festim as F @@ -47,7 +47,7 @@ This is often due to an excessively high absolute tolerance. The Newton solver then converges in zero iterations. In other words, nothing is solved. First, check that this is the case by setting the log level to 20: -.. code-block:: python +.. testcode:: import festim as F @@ -57,9 +57,9 @@ First, check that this is the case by setting the log level to 20: Then increase the absolute tolerance of the solver: -.. code-block:: python +.. testcode:: my_model.settings = F.Settings( - ..., absolute_tolerance=1e10, + relative_tolerance=1e-10, ) \ No newline at end of file