Ramper#
- class fridom.framework.modules.Ramper(start_time: float, ramp_period: float, update_parameters: Callable[[fr.ModelState, float], None] = <function Ramper.<lambda>>, ramp_function: Literal['exponential', 'power_3', 'cosine', 'linear'] | Callable[[float], float] = 'exponential')[source]#
Bases:
ModuleA module for ramping up and down parameters during a simulation.
Parameters#
- start_timefloat
The time at which the ramping should start.
- ramp_periodfloat
The period over which the ramping should occur.
- update_parametersCallable[[fr.ModelState, float], None], optional
A method that updates the model parameters based on the ramped value. It should take the model state and the ramped value which is between 0 and 1.
- ramp_functionstr or Callable[[float], float], optional
The ramp function. It can be one of the following strings: “exponential”, “power_3”, “cosine”, “linear” or a custom callable. The default is “exponential”.
Description#
This module contains a list of ramp functions that can be used to ramp up and down parameters during a simulation. This can be useful for adiabatic processes or for slowly changing parameters. For example to ramp up the nonlinear term.
- __init__(start_time: float, ramp_period: float, update_parameters: Callable[[fr.ModelState, float], None] = <function Ramper.<lambda>>, ramp_function: Literal['exponential', 'power_3', 'cosine', 'linear'] | Callable[[float], float] = 'exponential') None[source]#
Methods
__init__(start_time, ramp_period[, ...])cosine_ramp_func(theta)Cosine ramp function.
disable()Disable the module.
enable()Enable the module.
exponential_ramp_func(theta)Exponential ramp function.
is_enabled()Whether the module is enabled or not.
linear_ramp_func(theta)Linear ramp function.
power_3_ramp_func(theta)Power 3 ramp function.
reset()Stop and start the module.
setup(mset[, setup_mode])Set the module up.
start()Start the module.
stop()Stop the module.
update(mz)Update the model state.
Attributes
diff_moduleThe differentiation module to be used by this module.
gridThe grid of the model settings.
Return a dictionary with information about the time stepper.
interp_moduleThe interpolation module to be used by this module.
is_setupWhether the module is set up.
msetThe model settings.
The ramp function.
required_haloThe required halo points for this module.
- name = 'Ramper'#
- update(mz: ModelState) ModelState[source]#
Update the model state.
Description#
This method is called by the model at each time step. Child classes should overwrite this method to update the module. Make sure to decorate the method with the @module_method decorator.
Parameters#
- mzfr.ModelState
The model state at the current time step.
Returns#
- fr.ModelState
The updated model state.
- static exponential_ramp_func(theta: float) float[source]#
Exponential ramp function.
\[f(\theta) = \frac{e^{-\frac{1}{\theta}}} {e^{-\frac{1}{\theta}} + e^{-\frac{1}{1-\theta}}}\]
- static power_3_ramp_func(theta: float) float[source]#
Power 3 ramp function.
\[f(\theta) = \frac{\theta^3}{\theta^3 + (1 - \theta)^3}\]
- static cosine_ramp_func(theta: float) float[source]#
Cosine ramp function.
\[f(\theta) = \frac{1}{2} \left(1 - \cos(\pi \theta)\right)\]