pub trait SymplecticIntegrator<StateSync, StateLeap, const D: usize>where
    StateSync: SimulationStateSynchronous<D>,
    StateLeap: SimulationStateLeapFrog<D>,{
    type Error;

    // Required methods
    fn integrate_sync_sync(
        &self,
        l: &StateSync,
        delta_t: Real
    ) -> Result<StateSync, Self::Error>;
    fn integrate_leap_leap(
        &self,
        l: &StateLeap,
        delta_t: Real
    ) -> Result<StateLeap, Self::Error>;
    fn integrate_sync_leap(
        &self,
        l: &StateSync,
        delta_t: Real
    ) -> Result<StateLeap, Self::Error>;
    fn integrate_leap_sync(
        &self,
        l: &StateLeap,
        delta_t: Real
    ) -> Result<StateSync, Self::Error>;

    // Provided method
    fn integrate_symplectic(
        &self,
        l: &StateSync,
        delta_t: Real
    ) -> Result<StateSync, Self::Error> { ... }
}
Expand description

Define an symplectic numerical integrator

The integrator evolve the state in time.

The integrator should be capable of switching between Sync state (q (or link matrices) at time T , p (or e_field) at time T ) and leap frog (a at time T, p at time T + 1/2)

Example

For an example see the module level documentation super::integrator.

Required Associated Types§

source

type Error

Type of error returned by the Integrator.

Required Methods§

source

fn integrate_sync_sync( &self, l: &StateSync, delta_t: Real ) -> Result<StateSync, Self::Error>

Integrate a sync state to a sync state by advancing the link matrices and the electrical field simultaneously.

Example

see the module level documentation super::integrator.

Errors

Return an error if the integration encounter a problem

source

fn integrate_leap_leap( &self, l: &StateLeap, delta_t: Real ) -> Result<StateLeap, Self::Error>

Integrate a leap state to a leap state using leap frog algorithm.

Example
use lattice_qcd_rs::integrator::{SymplecticEulerRayon, 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 state = LatticeStateEFSyncDefault::new_random_e_state(
    LatticeStateDefault::<3>::new_determinist(1_f64, 2_f64, 4, &mut rng)?,
    &mut rng,
);
let h = state.hamiltonian_total();
let integrator = SymplecticEulerRayon::default();
let mut leap_frog = integrator.integrate_sync_leap(&state, 0.000_001_f64)?;
drop(state);
for _ in 0..2 {
    // Realistically you would want more steps
    leap_frog = integrator.integrate_leap_leap(&leap_frog, 0.000_001_f64)?;
}
let state = integrator.integrate_leap_sync(&leap_frog, 0.000_001_f64)?;
let h2 = state.hamiltonian_total();

println!("The error on the Hamiltonian is {}", h - h2);
Errors

Return an error if the integration encounter a problem

source

fn integrate_sync_leap( &self, l: &StateSync, delta_t: Real ) -> Result<StateLeap, Self::Error>

Integrate a sync state to a leap state by doing a half step for the conjugate momenta.

Example

see SymplecticIntegrator::integrate_leap_leap

Errors

Return an error if the integration encounter a problem

source

fn integrate_leap_sync( &self, l: &StateLeap, delta_t: Real ) -> Result<StateSync, Self::Error>

Integrate a leap state to a sync state by finishing doing a step for the position and finishing the half step for the conjugate momenta.

Example

see SymplecticIntegrator::integrate_leap_leap

Errors

Return an error if the integration encounter a problem

Provided Methods§

source

fn integrate_symplectic( &self, l: &StateSync, delta_t: Real ) -> Result<StateSync, Self::Error>

Integrate a Sync state by going to leap and then back to sync. This is the symplectic method of integration, which should conserve approximately the hamiltonian

Note that you might want to override this method as it can save you from a clone.

Example
use lattice_qcd_rs::integrator::{SymplecticEulerRayon, 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 mut state = LatticeStateEFSyncDefault::new_random_e_state(
    LatticeStateDefault::<3>::new_determinist(1_f64, 2_f64, 4, &mut rng)?,
    &mut rng,
);
let h = state.hamiltonian_total();

let integrator = SymplecticEulerRayon::default();
for _ in 0..1 {
    // Realistically you would want more steps
    state = integrator.integrate_symplectic(&state, 0.000_001_f64)?;
}
let h2 = state.hamiltonian_total();

println!("The error on the Hamiltonian is {}", h - h2);
Errors

Return an error if the integration encounter a problem

Implementors§