DP Langevin
Loading...
Searching...
No Matches
SimDP Class Reference

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)
 Constructor.
bool initialize ()
 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_trng
 Random number generation function (Mersenne prime) (pointer to RNG)
DPLangevindpLangevin
 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
 Index of current epoch aka time step.
int i_next_epoch
 Index of next epoch aka time step.
double t_current_epoch
 Time of current epoch.
double t_next_epoch
 Time of next epoch.
dbl_vec_t t_epochs
 Vector time-series of epochs.
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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ SimDP()

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 )

Constructor.

Constructor for class that manages simulation of DP Langevin equations.

Definition at line 11 of file sim_dplangevin.cpp.

Member Function Documentation

◆ choose_integrator()

bool SimDP::choose_integrator ( )
private

Chooses function implementing either Runge-Kutta or Euler integration methods.

Definition at line 17 of file sim_dplangevin_private.cpp.

◆ count_epochs()

int SimDP::count_epochs ( ) const
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 9 of file sim_dplangevin_private.cpp.

◆ get_density()

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.

◆ get_i_current_epoch()

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.

◆ get_i_next_epoch()

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.

◆ get_mean_densities()

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.

◆ get_n_epochs()

int SimDP::get_n_epochs ( ) const

Fetch the total number of simulation epochs.

Definition at line 8 of file sim_dplangevin_utilities.cpp.

◆ get_t_current_epoch()

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.

◆ get_t_epochs()

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.

◆ get_t_next_epoch()

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.

◆ initialize()

bool SimDP::initialize ( )

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 51 of file sim_dplangevin.cpp.

◆ integrate()

bool SimDP::integrate ( const int n_next_epochs)
private

Perform Dornic-type integration of the DP Langevin equation for n_next_epochs

Definition at line 32 of file sim_dplangevin_private.cpp.

◆ postprocess()

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 106 of file sim_dplangevin.cpp.

◆ pyprep_density_grid()

bool SimDP::pyprep_density_grid ( )
private

Generate a Python-compatible version of the current density grid.

Definition at line 105 of file sim_dplangevin_private.cpp.

◆ pyprep_mean_densities()

bool SimDP::pyprep_mean_densities ( )
private

Generate a Python-compatible version of the mean densities time-series vector.

Definition at line 93 of file sim_dplangevin_private.cpp.

◆ pyprep_t_epochs()

bool SimDP::pyprep_t_epochs ( )
private

Generate a Python-compatible version of the epochs time-series vector.

Definition at line 81 of file sim_dplangevin_private.cpp.

◆ run()

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 91 of file sim_dplangevin.cpp.

Member Data Documentation

◆ coefficients

Coefficients SimDP::coefficients
private

Langevin equation coefficients.

Definition at line 22 of file sim_dplangevin.hpp.

◆ did_integrate

bool SimDP::did_integrate = false
private

Flag whether integration step was successful or not.

Definition at line 53 of file sim_dplangevin.hpp.

◆ dpLangevin

DPLangevin* SimDP::dpLangevin
private

Instance of DP Langevin integrator class (pointer to instance)

Definition at line 28 of file sim_dplangevin.hpp.

◆ i_current_epoch

int SimDP::i_current_epoch
private

Index of current epoch aka time step.

Definition at line 35 of file sim_dplangevin.hpp.

◆ i_next_epoch

int SimDP::i_next_epoch
private

Index of next epoch aka time step.

Definition at line 37 of file sim_dplangevin.hpp.

◆ integrator

void(DPLangevin::* SimDP::integrator) (rng_t &)
private

Integrator: either a Runge-Kutta or an Euler method.

Definition at line 30 of file sim_dplangevin.hpp.

◆ is_initialized

bool SimDP::is_initialized = false
private

Flag whether simulation has been initialized or not.

Definition at line 55 of file sim_dplangevin.hpp.

◆ mean_densities

dbl_vec_t SimDP::mean_densities
private

Vector time-series of grid-averaged field density values.

Definition at line 45 of file sim_dplangevin.hpp.

◆ n_epochs

int SimDP::n_epochs
private

Total number of simulation time steps aka "epochs".

Definition at line 33 of file sim_dplangevin.hpp.

◆ p

Parameters SimDP::p
private

Model simulation parameters.

Definition at line 24 of file sim_dplangevin.hpp.

◆ pyarray_density

py_array_t SimDP::pyarray_density
private

Python-compatible array of current density grid.

Definition at line 51 of file sim_dplangevin.hpp.

◆ pyarray_mean_densities

py_array_t SimDP::pyarray_mean_densities
private

Python-compatible array of mean density time-series.

Definition at line 49 of file sim_dplangevin.hpp.

◆ pyarray_t_epochs

py_array_t SimDP::pyarray_t_epochs
private

Python-compatible array of epochs time-series.

Definition at line 47 of file sim_dplangevin.hpp.

◆ rng

rng_t* SimDP::rng
private

Random number generation function (Mersenne prime) (pointer to RNG)

Definition at line 26 of file sim_dplangevin.hpp.

◆ t_current_epoch

double SimDP::t_current_epoch
private

Time of current epoch.

Definition at line 39 of file sim_dplangevin.hpp.

◆ t_epochs

dbl_vec_t SimDP::t_epochs
private

Vector time-series of epochs.

Definition at line 43 of file sim_dplangevin.hpp.

◆ t_next_epoch

double SimDP::t_next_epoch
private

Time of next epoch.

Definition at line 41 of file sim_dplangevin.hpp.


The documentation for this class was generated from the following files: