|
Langevin C++ source
|
Class that manages simulation of DPLangevin equation. More...
#include <sim_dplangevin.hpp>
Public Member Functions | |
| SimDP (const double linear, const double quadratic, const double diffusion, const double noise, const double t_final, const double dx, const double dt, const int random_seed, const GridDimension grid_dimension, const int_vec_t grid_size, const gt_vec_t grid_topologies, const bc_vec_t boundary_conditions, const dbl_vec_t bc_values, const InitialCondition initial_condition, const dbl_vec_t ic_values, const IntegrationMethod integration_method, const bool do_snapshot_grid, const bool do_verbose) | |
| Constructor. | |
| bool | initialize (int n_decimals) |
| Initialize the model simulation. | |
| bool | run (const int n_next_epochs) |
| Execute the model simulation for n_next_epochs | |
| bool | postprocess () |
| Process the model results data if available. | |
| int | get_n_epochs () const |
| Fetch the total number of simulation epochs. | |
| int | get_i_current_epoch () const |
| Fetch the index of the current epoch of the simulation. | |
| int | get_i_next_epoch () const |
| Fetch the index of the next epoch of the simulation. | |
| double | get_t_current_epoch () const |
| Fetch the current epoch (time) of the simulation. | |
| double | get_t_next_epoch () const |
| Fetch the next epoch (time) of the simulation. | |
| py_array_t | get_t_epochs () const |
| Fetch a times-series vector of the simulation epochs as a Python array. | |
| py_array_t | get_mean_densities () const |
| Fetch a times-series vector of the grid-averaged density field over time as a Python array. | |
| py_array_t | get_density () const |
| Fetch the current Langevin density field grid as a Python array. | |
Private Member Functions | |
| int | count_epochs () const |
| Count upcoming number of epochs by running a dummy time-stepping loop. | |
| bool | choose_integrator () |
| Chooses function implementing either Runge-Kutta or Euler integration methods. | |
| bool | integrate (const int n_next_epochs) |
| Perform Dornic-type integration of the DP Langevin equation for n_next_epochs | |
| bool | pyprep_t_epochs () |
| Generate a Python-compatible version of the epochs time-series vector. | |
| bool | pyprep_mean_densities () |
| Generate a Python-compatible version of the mean densities time-series vector. | |
| bool | pyprep_density_grid () |
| Generate a Python-compatible version of the current density grid. | |
Private Attributes | |
| Coefficients | coefficients |
| Langevin equation coefficients. | |
| Parameters | p |
| Model simulation parameters. | |
| rng_t * | rng |
| Random number generation function (Mersenne prime) (pointer to RNG) | |
| DPLangevin * | dpLangevin |
| Instance of DP Langevin integrator class (pointer to instance) | |
| void(DPLangevin::* | integrator )(rng_t &) |
| Integrator: either a Runge-Kutta or an Euler method. | |
| int | n_epochs |
| Total number of simulation time steps aka "epochs". | |
| int | i_current_epoch = 0 |
| Index of current epoch aka time step. | |
| int | i_next_epoch |
| Index of next epoch aka time step. | |
| double | t_current_epoch = 0.0 |
| Time of current epoch. | |
| double | t_next_epoch |
| Time of next epoch. | |
| dbl_vec_t | t_epochs |
| Vector time-series of epochs. | |
| int | n_decimals |
| Truncation number of decimal places when summing Δt. | |
| dbl_vec_t | mean_densities |
| Vector time-series of grid-averaged field density values. | |
| py_array_t | pyarray_t_epochs |
| Python-compatible array of epochs time-series. | |
| py_array_t | pyarray_mean_densities |
| Python-compatible array of mean density time-series. | |
| py_array_t | pyarray_density |
| Python-compatible array of current density grid. | |
| bool | did_integrate = false |
| Flag whether integration step was successful or not. | |
| bool | is_initialized = false |
| Flag whether simulation has been initialized or not. | |
| bool | do_snapshot_grid = true |
| Flag whether to take density grid snapshots. | |
| bool | do_verbose = false |
| Flag whether to report sim parameters etc. | |
Class that manages simulation of DPLangevin equation.
Manages & executes model simulation using instances of the DPLangevin integrator class, the Coefficients struct, and the Parameters struct.
Definition at line 18 of file sim_dplangevin.hpp.
| SimDP::SimDP | ( | const double | linear, |
| const double | quadratic, | ||
| const double | diffusion, | ||
| const double | noise, | ||
| const double | t_final, | ||
| const double | dx, | ||
| const double | dt, | ||
| const int | random_seed, | ||
| const GridDimension | grid_dimension, | ||
| const int_vec_t | grid_size, | ||
| const gt_vec_t | grid_topologies, | ||
| const bc_vec_t | boundary_conditions, | ||
| const dbl_vec_t | bc_values, | ||
| const InitialCondition | initial_condition, | ||
| const dbl_vec_t | ic_values, | ||
| const IntegrationMethod | integration_method, | ||
| const bool | do_snapshot_grid, | ||
| const bool | do_verbose ) |
Constructor.
Constructor for class that manages simulation of DP Langevin equations.
Definition at line 11 of file sim_dplangevin.cpp.
|
private |
Chooses function implementing either Runge-Kutta or Euler integration methods.
Definition at line 43 of file sim_dplangevin_private.cpp.
|
private |
Count upcoming number of epochs by running a dummy time-stepping loop.
Count total number of time steps, just in case rounding causes problems.
Definition at line 32 of file sim_dplangevin_private.cpp.
| py_array_t SimDP::get_density | ( | ) | const |
Fetch the current Langevin density field grid as a Python array.
Definition at line 15 of file sim_dplangevin_utilities.cpp.
| int SimDP::get_i_current_epoch | ( | ) | const |
Fetch the index of the current epoch of the simulation.
Definition at line 9 of file sim_dplangevin_utilities.cpp.
| int SimDP::get_i_next_epoch | ( | ) | const |
Fetch the index of the next epoch of the simulation.
Definition at line 10 of file sim_dplangevin_utilities.cpp.
| py_array_t SimDP::get_mean_densities | ( | ) | const |
Fetch a times-series vector of the grid-averaged density field over time as a Python array.
Definition at line 14 of file sim_dplangevin_utilities.cpp.
| int SimDP::get_n_epochs | ( | ) | const |
Fetch the total number of simulation epochs.
Definition at line 8 of file sim_dplangevin_utilities.cpp.
| double SimDP::get_t_current_epoch | ( | ) | const |
Fetch the current epoch (time) of the simulation.
Definition at line 11 of file sim_dplangevin_utilities.cpp.
| py_array_t SimDP::get_t_epochs | ( | ) | const |
Fetch a times-series vector of the simulation epochs as a Python array.
Definition at line 13 of file sim_dplangevin_utilities.cpp.
| double SimDP::get_t_next_epoch | ( | ) | const |
Fetch the next epoch (time) of the simulation.
Definition at line 12 of file sim_dplangevin_utilities.cpp.
| bool SimDP::initialize | ( | int | n_decimals | ) |
Initialize the model simulation.
Method to be called first to set up simulation: a grid is constructed; initial conditions are applied; the Langevin equation is prepared; the zeroth-epoch solution state is recorded (after applying boundary conditions).
Definition at line 58 of file sim_dplangevin.cpp.
|
private |
Perform Dornic-type integration of the DP Langevin equation for n_next_epochs
Definition at line 58 of file sim_dplangevin_private.cpp.
| bool SimDP::postprocess | ( | ) |
Process the model results data if available.
Method to be called after each run: the density grid and grid-average time series are then packed and made available to Python through the wrapper. This method should be called every time a "snapshot" of the simulation state is desired.
Definition at line 114 of file sim_dplangevin.cpp.
|
private |
Generate a Python-compatible version of the current density grid.
Definition at line 132 of file sim_dplangevin_private.cpp.
|
private |
Generate a Python-compatible version of the mean densities time-series vector.
Definition at line 120 of file sim_dplangevin_private.cpp.
|
private |
Generate a Python-compatible version of the epochs time-series vector.
Definition at line 108 of file sim_dplangevin_private.cpp.
| bool SimDP::run | ( | const int | n_next_epochs | ) |
Execute the model simulation for n_next_epochs
Method to carry out a set of integration steps; can be rerun repeatedly to allow segmentation of the overall simulation and to allow return of the density grid state to Python as a series of time slices.
Definition at line 99 of file sim_dplangevin.cpp.
|
private |
Langevin equation coefficients.
Definition at line 22 of file sim_dplangevin.hpp.
|
private |
Flag whether integration step was successful or not.
Definition at line 55 of file sim_dplangevin.hpp.
|
private |
Flag whether to take density grid snapshots.
Definition at line 59 of file sim_dplangevin.hpp.
|
private |
Flag whether to report sim parameters etc.
Definition at line 61 of file sim_dplangevin.hpp.
|
private |
Instance of DP Langevin integrator class (pointer to instance)
Definition at line 28 of file sim_dplangevin.hpp.
|
private |
Index of current epoch aka time step.
Definition at line 35 of file sim_dplangevin.hpp.
|
private |
Index of next epoch aka time step.
Definition at line 37 of file sim_dplangevin.hpp.
|
private |
Integrator: either a Runge-Kutta or an Euler method.
Definition at line 30 of file sim_dplangevin.hpp.
|
private |
Flag whether simulation has been initialized or not.
Definition at line 57 of file sim_dplangevin.hpp.
|
private |
Vector time-series of grid-averaged field density values.
Definition at line 47 of file sim_dplangevin.hpp.
|
private |
Truncation number of decimal places when summing Δt.
Definition at line 45 of file sim_dplangevin.hpp.
|
private |
Total number of simulation time steps aka "epochs".
Definition at line 33 of file sim_dplangevin.hpp.
|
private |
Model simulation parameters.
Definition at line 24 of file sim_dplangevin.hpp.
|
private |
Python-compatible array of current density grid.
Definition at line 53 of file sim_dplangevin.hpp.
|
private |
Python-compatible array of mean density time-series.
Definition at line 51 of file sim_dplangevin.hpp.
|
private |
Python-compatible array of epochs time-series.
Definition at line 49 of file sim_dplangevin.hpp.
|
private |
Random number generation function (Mersenne prime) (pointer to RNG)
Definition at line 26 of file sim_dplangevin.hpp.
|
private |
Time of current epoch.
Definition at line 39 of file sim_dplangevin.hpp.
|
private |
Vector time-series of epochs.
Definition at line 43 of file sim_dplangevin.hpp.
|
private |
Time of next epoch.
Definition at line 41 of file sim_dplangevin.hpp.