Stepsize#
- class Stepsize(initial_value=0.0, stepsize_change_ratio=None, t_stop=None, stepsize_stop_max=None, max_stepsize=None, dt_min=None, milestones=None)[source]#
Bases:
objectDescription of Stepsize
- Parameters:
initial_value (float, optional) – initial stepsize. Defaults to 0.0.
stepsize_change_ratio (float, optional) – stepsize change ratio. Defaults to None.
t_stop (float, optional) – time at which the adaptive stepsize stops. Defaults to None.
stepsize_stop_max (float, optional) – Maximum stepsize after t_stop. Defaults to None.
max_stepsize (float or callable, optional) – Maximum stepsize. Can be a function of festim.t. Defaults to None.
dt_min (float, optional) – Minimum stepsize below which an error is raised. Defaults to None.
milestones (list, optional) – list of times by which the simulation must pass. Defaults to None.
- Variables:
adaptive_stepsize (dict) – contains the parameters for adaptive stepsize
value (fenics.Constant) – value of dt
milestones (list) – list of times by which the simulation must pass.
Example:
my_stepsize = Stepsize( initial_value=0.5, stepsize_change_ratio=1.1, max_stepsize=lambda t: None if t < 1 else 2, dt_min=1e-05 )
- adapt(t, nb_it, converged)[source]#
Changes the stepsize based on convergence.
- Parameters:
t (float) – current time.
nb_it (int) – number of iterations the solver required to converge.
converged (bool) – True if the solver converged, else False.