Langevin C++ source

Loading...
Searching...
No Matches
langevin_integrate_euler.cpp
Go to the documentation of this file.
1
5
6#include "langevin_types.hpp"
7#include "langevin_base.hpp"
8
10 void BaseLangevin::integrate_euler(rng_t& rng)
11{
12 mean_density = 0.0;
13 for (auto i=0; i<n_cells; i++)
14 {
15 double f = nonlinear_rhs(i, density_grid);
16 aux_grid1[i] = density_grid[i] + f*dt;
17 poisson_sampler = poisson_dist_t(lambda_on_explcdt * aux_grid1[i]);
18 gamma_sampler = gamma_dist_t(poisson_sampler(rng), 1/lambda);
19 aux_grid1[i]= gamma_sampler(rng);
20 mean_density += aux_grid1[i];
21 }
22 mean_density /= static_cast<double>(n_cells);
23 // Update density field grid with result of integration
24 density_grid.swap(aux_grid1);
25}
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::n_cells
int n_cells
Total number of cells in n-D grid.
Definition langevin_base.hpp:19
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::aux_grid1
grid_t aux_grid1
Temporary density grid used to perform an integration step.
Definition langevin_base.hpp:55
BaseLangevin::mean_density
double mean_density
Grid-average of density field.
Definition langevin_base.hpp:30
BaseLangevin::integrate_euler
void integrate_euler(rng_t &rng)
Explicit Euler + stochastic integration + grid update.
Definition langevin_integrate_euler.cpp:10
BaseLangevin::gamma_sampler
gamma_dist_t gamma_sampler
Function generating gamma variates.
Definition langevin_base.hpp:35
langevin_base.hpp
Base class for Langevin equation integrator.
langevin_types.hpp
Type definitions for BaseLangevin integrator.
gamma_dist_t
std::gamma_distribution< double > gamma_dist_t
Type for function generating gamma variates.
Definition langevin_types.hpp:37
poisson_dist_t
std::poisson_distribution< int > poisson_dist_t
Type for function generating Poisson variates.
Definition langevin_types.hpp:35
rng_t
std::mt19937 rng_t
Use Mersenne Twister random number generator.
Definition langevin_types.hpp:16