Langevin C++ source

Loading...
Searching...
No Matches
langevin_base.hpp
Go to the documentation of this file.
1
5
6#ifndef BASE_HPP
7#define BASE_HPP
8
9#include "langevin_coefficients.hpp"
10#include "langevin_parameters.hpp"
11
15 class BaseLangevin
16{
17 protected:
19 int n_cells;
21 grid_t density_grid;
23 grid_wiring_t grid_wiring;
24
26 double dt;
28 double dx;
30 double mean_density;
31
33 poisson_dist_t poisson_sampler;
35 gamma_dist_t gamma_sampler;
37 gaussian_dist_t gaussian_sampler;
38
40 double linear_coefficient;
42 double noise_coefficient;
44 double lambda;
46 double lambda_on_explcdt;
47
49 grid_t k1_grid;
51 grid_t k2_grid;
53 grid_t k3_grid;
55 grid_t aux_grid1;
57 grid_t aux_grid2;
58
59 public:
61 BaseLangevin() = default;
63 bool construct_grid(const Parameters parameters);
65 bool construct_1D_grid(const Parameters parameters);
67 bool construct_2D_grid(const Parameters parameters);
69 bool initialize_grid(const Parameters parameters, rng_t& rng);
71 void prepare(const Coefficients& coefficients);
73 bool check_boundary_conditions(const Parameters parameters);
75 void apply_boundary_conditions(const Parameters parameters, int i_epoch);
77 void integrate_rungekutta(rng_t& rng);
79 void integrate_euler(rng_t& rng);
80 double get_density_grid_value(const int) const;
82 double get_mean_density() const;
84 double get_poisson_mean() const;
85
87 virtual void set_nonlinear_coefficients(const Coefficients& coefficients) {};
89 virtual double nonlinear_rhs(const int i_cell, const grid_t& field) const
90 { return 0; };
91};
92
93#endif
BaseLangevin::poisson_sampler
poisson_dist_t poisson_sampler
Function generating Poisson variates.
Definition langevin_base.hpp:33
BaseLangevin::density_grid
grid_t density_grid
Density field grid.
Definition langevin_base.hpp:21
BaseLangevin::lambda
double lambda
Dornic method stochastic-step variable.
Definition langevin_base.hpp:44
BaseLangevin::dt
double dt
Time step, i.e, epoch-to-epoch Δt.
Definition langevin_base.hpp:26
BaseLangevin::construct_2D_grid
bool construct_2D_grid(const Parameters parameters)
Build 2d Langevin density field grid & mixed topology.
Definition langevin_construct_grid2d.cpp:26
BaseLangevin::initialize_grid
bool initialize_grid(const Parameters parameters, rng_t &rng)
Initial condition for density field: uniformly random.
Definition langevin_ic.cpp:9
BaseLangevin::n_cells
int n_cells
Total number of cells in n-D grid.
Definition langevin_base.hpp:19
BaseLangevin::check_boundary_conditions
bool check_boundary_conditions(const Parameters parameters)
Check we have 2N boundary conditions for an N-dimensional grid.
Definition langevin_bc.cpp:10
BaseLangevin::lambda_on_explcdt
double lambda_on_explcdt
Dornic method stochastic-step variable.
Definition langevin_base.hpp:46
BaseLangevin::nonlinear_rhs
virtual double nonlinear_rhs(const int i_cell, const grid_t &field) const
Method to set nonlinear RHS of Langevin equation for deterministic integration step: to be defined by...
Definition langevin_base.hpp:89
BaseLangevin::noise_coefficient
double noise_coefficient
Dornic method coefficient.
Definition langevin_base.hpp:42
BaseLangevin::get_poisson_mean
double get_poisson_mean() const
Compute Poisson RNG mean.
Definition langevin_utilities.cpp:23
BaseLangevin::aux_grid1
grid_t aux_grid1
Temporary density grid used to perform an integration step.
Definition langevin_base.hpp:55
BaseLangevin::linear_coefficient
double linear_coefficient
Dornic method coefficient.
Definition langevin_base.hpp:40
BaseLangevin::get_mean_density
double get_mean_density() const
Expose mean density.
Definition langevin_utilities.cpp:16
BaseLangevin::construct_grid
bool construct_grid(const Parameters parameters)
Construct Langevin density field grid of appropriate n-D dimension.
Definition langevin_construct_grid.cpp:9
BaseLangevin::mean_density
double mean_density
Grid-average of density field.
Definition langevin_base.hpp:30
BaseLangevin::integrate_rungekutta
void integrate_rungekutta(rng_t &rng)
Runge-Kutta + stochastic integration + grid update.
Definition langevin_integrate_rungekutta.cpp:13
BaseLangevin::get_density_grid_value
double get_density_grid_value(const int) const
Return the Langevin density field grid value at a given "node".
Definition langevin_utilities.cpp:10
BaseLangevin::integrate_euler
void integrate_euler(rng_t &rng)
Explicit Euler + stochastic integration + grid update.
Definition langevin_integrate_euler.cpp:10
BaseLangevin::grid_wiring
grid_wiring_t grid_wiring
Neighorhood topology for all grid cells.
Definition langevin_base.hpp:23
BaseLangevin::BaseLangevin
BaseLangevin()=default
Default constructor.
BaseLangevin::aux_grid2
grid_t aux_grid2
Temporary density grid used to perform an integration step.
Definition langevin_base.hpp:57
BaseLangevin::apply_boundary_conditions
void apply_boundary_conditions(const Parameters parameters, int i_epoch)
Set density field values only the grid edges per bc specs.
Definition langevin_bc.cpp:26
BaseLangevin::gaussian_sampler
gaussian_dist_t gaussian_sampler
Function generating normal variates.
Definition langevin_base.hpp:37
BaseLangevin::k1_grid
grid_t k1_grid
Runge-Kutta variable grid #1.
Definition langevin_base.hpp:49
BaseLangevin::set_nonlinear_coefficients
virtual void set_nonlinear_coefficients(const Coefficients &coefficients)
Method to set nonlinear coefficients for deterministic integration step: to be defined by application...
Definition langevin_base.hpp:87
BaseLangevin::prepare
void prepare(const Coefficients &coefficients)
Set initial condition of Langevin density field grid.
Definition langevin_prepare.cpp:11
BaseLangevin::k2_grid
grid_t k2_grid
Runge-Kutta variable grid #2.
Definition langevin_base.hpp:51
BaseLangevin::gamma_sampler
gamma_dist_t gamma_sampler
Function generating gamma variates.
Definition langevin_base.hpp:35
BaseLangevin::k3_grid
grid_t k3_grid
Runge-Kutta variable grid #3.
Definition langevin_base.hpp:53
BaseLangevin::construct_1D_grid
bool construct_1D_grid(const Parameters parameters)
Build 1d Langevin density field grid & topology.
Definition langevin_construct_grid1d.cpp:10
BaseLangevin::dx
double dx
Grid spacing, i.e., spacing Δx between cell centers in all directions.
Definition langevin_base.hpp:28
langevin_coefficients.hpp
Container for nonlinear Langevin equation coefficients.
langevin_parameters.hpp
Container for BaseLangevin integrator parameters.
gamma_dist_t
std::gamma_distribution< double > gamma_dist_t
Type for function generating gamma variates.
Definition langevin_types.hpp:37
grid_t
std::vector< double > grid_t
Type for density grid.
Definition langevin_types.hpp:24
poisson_dist_t
std::poisson_distribution< int > poisson_dist_t
Type for function generating Poisson variates.
Definition langevin_types.hpp:35
grid_wiring_t
std::vector< neighborhood_t > grid_wiring_t
Type for grid-cell neighborhood connections.
Definition langevin_types.hpp:30
gaussian_dist_t
std::normal_distribution< double > gaussian_dist_t
Type for function generating Gaussian variates.
Definition langevin_types.hpp:39
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