Module lattice_qcd_rs::integrator
source · Expand description
Numerical integrators to carry out simulations.
See SymplecticIntegrator
. The simulations are done on LatticeStateWithEField
It also require a notion of SimulationStateSynchronous
and SimulationStateLeapFrog
.
Even thought it is effortless to implement both SimulationStateSynchronous
and SimulationStateLeapFrog
.
I advice against it and implement only SimulationStateSynchronous
and
use super::simulation::SimulationStateLeap
for leap frog states as it gives a compile time check that you did not forget
doing a half steps.
This library gives two implementations of SymplecticIntegrator
:
SymplecticEuler
and SymplecticEulerRayon
.
I would advice using SymplecticEulerRayon
if you do not mind the little
more memory it uses.
Example
let us create a basic random state and let us simulate.
use lattice_qcd_rs::integrator::{SymplecticEuler, SymplecticIntegrator};
use lattice_qcd_rs::simulation::{
LatticeStateDefault, LatticeStateEFSyncDefault, LatticeStateWithEField,
};
use rand::SeedableRng;
let mut rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed
let state1 = LatticeStateEFSyncDefault::new_random_e_state(
LatticeStateDefault::<3>::new_determinist(100_f64, 1_f64, 4, &mut rng)?,
&mut rng,
);
let integrator = SymplecticEuler::default();
let state2 = integrator.integrate_sync_sync(&state1, 0.000_1_f64)?;
let state3 = integrator.integrate_sync_sync(&state2, 0.000_1_f64)?;
Let us then compute and compare the Hamiltonian.
let h = state1.hamiltonian_total();
let h2 = state3.hamiltonian_total();
println!("The error on the Hamiltonian is {}", h - h2);
See SimulationStateSynchronous
for more convenient methods.
Re-exports
pub use symplectic_euler::SymplecticEuler;
pub use symplectic_euler_rayon::SymplecticEulerRayon;
Modules
- Basic symplectic Euler integrator.
- Basic symplectic Euler integrator using
Rayon
.
Traits
- Define an symplectic numerical integrator