Langevin C++ source

Loading...
Searching...
No Matches
sim_dplangevin.hpp
Go to the documentation of this file.
1
5
6#ifndef SIMDP_HPP
7#define SIMDP_HPP
8
9#include "dplangevin.hpp"
10
18 class SimDP
19{
20 private:
22 Coefficients coefficients;
24 Parameters p;
26 rng_t *rng;
28 DPLangevin *dpLangevin;
30 void (DPLangevin::*integrator)(rng_t&);
31
33 int n_epochs;
35 int i_current_epoch = 0;
37 int i_next_epoch;
39 double t_current_epoch = 0.0;
41 double t_next_epoch;
43 dbl_vec_t t_epochs;
45 int n_decimals;
47 dbl_vec_t mean_densities;
49 py_array_t pyarray_t_epochs;
51 py_array_t pyarray_mean_densities;
53 py_array_t pyarray_density;
55 bool did_integrate = false;
57 bool is_initialized = false;
59 bool do_snapshot_grid = true;
61 bool do_verbose = false;
62
64 int count_epochs() const;
66 bool choose_integrator();
68 bool integrate(const int n_next_epochs);
69
71 bool pyprep_t_epochs();
73 bool pyprep_mean_densities();
75 bool pyprep_density_grid();
76
77 public:
79 SimDP(
80 const double linear, const double quadratic,
81 const double diffusion, const double noise,
82 const double t_final,
83 const double dx, const double dt,
84 const int random_seed,
85 const GridDimension grid_dimension,
86 const int_vec_t grid_size,
87 const gt_vec_t grid_topologies,
88 const bc_vec_t boundary_conditions,
89 const dbl_vec_t bc_values,
90 const InitialCondition initial_condition,
91 const dbl_vec_t ic_values,
92 const IntegrationMethod integration_method,
93 const bool do_snapshot_grid,
94 const bool do_verbose
95 );
97 bool initialize(int n_decimals);
99 bool run(const int n_next_epochs);
101 bool postprocess();
102
103 // Utilities provided to Python via the wrapper
104
106 int get_n_epochs() const;
108 int get_i_current_epoch() const;
110 int get_i_next_epoch() const;
112 double get_t_current_epoch() const;
114 double get_t_next_epoch() const;
116 py_array_t get_t_epochs() const;
118 py_array_t get_mean_densities() const;
120 py_array_t get_density() const;
121};
122
123
124#endif
DPLangevin
DPLangevin model application of BaseLangevin class integrator.
Definition dplangevin.hpp:16
SimDP::initialize
bool initialize(int n_decimals)
Initialize the model simulation.
Definition sim_dplangevin.cpp:58
SimDP::get_i_current_epoch
int get_i_current_epoch() const
Fetch the index of the current epoch of the simulation.
Definition sim_dplangevin_utilities.cpp:9
SimDP::i_current_epoch
int i_current_epoch
Index of current epoch aka time step.
Definition sim_dplangevin.hpp:35
SimDP::run
bool run(const int n_next_epochs)
Execute the model simulation for n_next_epochs
Definition sim_dplangevin.cpp:99
SimDP::postprocess
bool postprocess()
Process the model results data if available.
Definition sim_dplangevin.cpp:114
SimDP::do_verbose
bool do_verbose
Flag whether to report sim parameters etc.
Definition sim_dplangevin.hpp:61
SimDP::i_next_epoch
int i_next_epoch
Index of next epoch aka time step.
Definition sim_dplangevin.hpp:37
SimDP::get_density
py_array_t get_density() const
Fetch the current Langevin density field grid as a Python array.
Definition sim_dplangevin_utilities.cpp:15
SimDP::do_snapshot_grid
bool do_snapshot_grid
Flag whether to take density grid snapshots.
Definition sim_dplangevin.hpp:59
SimDP::p
Parameters p
Model simulation parameters.
Definition sim_dplangevin.hpp:24
SimDP::pyarray_t_epochs
py_array_t pyarray_t_epochs
Python-compatible array of epochs time-series.
Definition sim_dplangevin.hpp:49
SimDP::mean_densities
dbl_vec_t mean_densities
Vector time-series of grid-averaged field density values.
Definition sim_dplangevin.hpp:47
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, const bool do_snapshot_grid, const bool do_verbose)
Constructor.
Definition sim_dplangevin.cpp:11
SimDP::count_epochs
int count_epochs() const
Count upcoming number of epochs by running a dummy time-stepping loop.
Definition sim_dplangevin_private.cpp:32
SimDP::coefficients
Coefficients coefficients
Langevin equation coefficients.
Definition sim_dplangevin.hpp:22
SimDP::choose_integrator
bool choose_integrator()
Chooses function implementing either Runge-Kutta or Euler integration methods.
Definition sim_dplangevin_private.cpp:43
SimDP::t_next_epoch
double t_next_epoch
Time of next epoch.
Definition sim_dplangevin.hpp:41
SimDP::get_t_epochs
py_array_t get_t_epochs() const
Fetch a times-series vector of the simulation epochs as a Python array.
Definition sim_dplangevin_utilities.cpp:13
SimDP::is_initialized
bool is_initialized
Flag whether simulation has been initialized or not.
Definition sim_dplangevin.hpp:57
SimDP::integrator
void(DPLangevin::* integrator)(rng_t &)
Integrator: either a Runge-Kutta or an Euler method.
Definition sim_dplangevin.hpp:30
SimDP::get_t_next_epoch
double get_t_next_epoch() const
Fetch the next epoch (time) of the simulation.
Definition sim_dplangevin_utilities.cpp:12
SimDP::pyprep_mean_densities
bool pyprep_mean_densities()
Generate a Python-compatible version of the mean densities time-series vector.
Definition sim_dplangevin_private.cpp:120
SimDP::n_epochs
int n_epochs
Total number of simulation time steps aka "epochs".
Definition sim_dplangevin.hpp:33
SimDP::t_epochs
dbl_vec_t t_epochs
Vector time-series of epochs.
Definition sim_dplangevin.hpp:43
SimDP::pyarray_density
py_array_t pyarray_density
Python-compatible array of current density grid.
Definition sim_dplangevin.hpp:53
SimDP::pyarray_mean_densities
py_array_t pyarray_mean_densities
Python-compatible array of mean density time-series.
Definition sim_dplangevin.hpp:51
SimDP::pyprep_t_epochs
bool pyprep_t_epochs()
Generate a Python-compatible version of the epochs time-series vector.
Definition sim_dplangevin_private.cpp:108
SimDP::n_decimals
int n_decimals
Truncation number of decimal places when summing Δt.
Definition sim_dplangevin.hpp:45
SimDP::get_t_current_epoch
double get_t_current_epoch() const
Fetch the current epoch (time) of the simulation.
Definition sim_dplangevin_utilities.cpp:11
SimDP::dpLangevin
DPLangevin * dpLangevin
Instance of DP Langevin integrator class (pointer to instance)
Definition sim_dplangevin.hpp:28
SimDP::get_mean_densities
py_array_t get_mean_densities() const
Fetch a times-series vector of the grid-averaged density field over time as a Python array.
Definition sim_dplangevin_utilities.cpp:14
SimDP::did_integrate
bool did_integrate
Flag whether integration step was successful or not.
Definition sim_dplangevin.hpp:55
SimDP::get_n_epochs
int get_n_epochs() const
Fetch the total number of simulation epochs.
Definition sim_dplangevin_utilities.cpp:8
SimDP::get_i_next_epoch
int get_i_next_epoch() const
Fetch the index of the next epoch of the simulation.
Definition sim_dplangevin_utilities.cpp:10
SimDP::pyprep_density_grid
bool pyprep_density_grid()
Generate a Python-compatible version of the current density grid.
Definition sim_dplangevin_private.cpp:132
SimDP::rng
rng_t * rng
Random number generation function (Mersenne prime) (pointer to RNG)
Definition sim_dplangevin.hpp:26
SimDP::integrate
bool integrate(const int n_next_epochs)
Perform Dornic-type integration of the DP Langevin equation for n_next_epochs
Definition sim_dplangevin_private.cpp:58
SimDP::t_current_epoch
double t_current_epoch
Time of current epoch.
Definition sim_dplangevin.hpp:39
dplangevin.hpp
DPLangevin model application of BaseLangevin class integrator.
GridDimension
GridDimension
Density field grid dimension: only 1D or 2D grids implemented so far.
Definition langevin_enums.hpp:15
IntegrationMethod
IntegrationMethod
Deterministic integration method: default is 4th-order Runge-Kutta; can be explicit Euler.
Definition langevin_enums.hpp:58
InitialCondition
InitialCondition
Grid density field initial condition: random uniform or Gaussian variates; constant everywhere; or ce...
Definition langevin_enums.hpp:49
py_array_t
py::array_t< double, py::array::c_style > py_array_t
Type for Python arrays of doubles.
Definition langevin_types.hpp:50
gt_vec_t
std::vector< GridTopology > gt_vec_t
Type for specifying grid topology in each direction x, y, z...
Definition langevin_types.hpp:45
int_vec_t
std::vector< int > int_vec_t
Type for vectors of integers.
Definition langevin_types.hpp:21
dbl_vec_t
std::vector< double > dbl_vec_t
Type for vectors of doubles.
Definition langevin_types.hpp:19
rng_t
std::mt19937 rng_t
Use Mersenne Twister random number generator.
Definition langevin_types.hpp:16
Coefficients
Container for nonlinear Langevin equation coefficients.
Definition langevin_coefficients.hpp:24
Parameters
Container for BaseLangevin integrator parameters.
Definition langevin_parameters.hpp:21