Simulation
#include "Spirit/Simulation.h"
This API of Spirit is used to run and monitor iterative calculation methods.
If many iterations are called individually, one should use the single shot simulation functionality. It avoids the allocations etc. involved when a simulation is started and ended and behaves like a regular simulation, except that the iterations have to be triggered manually.
Definition of solvers
Note that the VP and LBFGS Solvers only do direct minimization and not suitable for dynamics.
-
Solver_VP 0
VP: Verlet-like velocity projection
-
Solver_SIB 1
SIB: Semi-implicit midpoint method B
-
Solver_Depondt 2
Depondt: Heun method using rotations
-
Solver_Heun 3
Heun: second-order midpoint
-
Solver_RungeKutta4 4
RK4: 4th order Runge-Kutta
-
Solver_LBFGS_OSO 5
LBFGS_OSO: Limited memory Broyden-Fletcher-Goldfarb-Shanno, exponential transform
-
Solver_LBFGS_Atlas 6
LBFGS_Atlas: Limited memory Broyden-Fletcher-Goldfarb-Shannon, stereographic projection
-
Solver_VP_OSO 7
Solver_VP_OSO: Verlet-like velocity projection, exponential transform
Definition of Monte Carlo Algorithms
-
MC_Algorithm_Metropolis 0
Metropolis: Metropolis algorithm
-
MC_Algorithm_Metropolis_MDC 1
Metropolis_MDC: Magnetization Direction Constrained Metropolis algorithm
Run info
-
struct Simulation_Run_Info
A struct that can be passed as an additional argument to the
Simulation_XXX_Startmethods to gather some basic information about the simulation runPublic Members
-
int total_iterations = 0
total number of iterations
-
int total_walltime = 0
total walltime passed in miliseconds
-
scalar total_ips = 0
total iterations per second
-
scalar max_torque = 0
maximum torque at the end of the simulation
-
int n_history_iteration = 0
number of iteration entries in history
-
int *history_iteration = nullptr
history of iteration counts
-
int n_history_max_torque = 0
number of max torque entries in history
-
scalar *history_max_torque = nullptr
history of max torque values
-
int n_history_energy = 0
number of energy entries in history
-
scalar *history_energy = nullptr
history of total energy values
-
int total_iterations = 0
-
void free_run_info(Simulation_Run_Info info)
Free the memory of an acquired
Simulation_Run_Infostruct. This struct is allocated when a legal address is passed to the simulation on start for theinfoparameter.
Start or stop a simulation
-
void Simulation_MC_Start(State *state, int mc_algorithm = MC_Algorithm_Metropolis, int n_iterations = -1, int n_iterations_log = -1, bool singleshot = false, Simulation_Run_Info *info = nullptr, int idx_image = -1, int idx_chain = -1)
Monte Carlo.
-
void Simulation_LLG_Start(State *state, int solver_type, int n_iterations = -1, int n_iterations_log = -1, bool singleshot = false, Simulation_Run_Info *info = nullptr, int idx_image = -1, int idx_chain = -1)
Landau-Lifshitz-Gilbert dynamics and energy minimisation.
-
void Simulation_GNEB_Start(State *state, int solver_type, int n_iterations = -1, int n_iterations_log = -1, bool singleshot = false, Simulation_Run_Info *info = nullptr, int idx_chain = -1)
Geodesic nudged elastic band method.
-
void Simulation_MMF_Start(State *state, int solver_type, int n_iterations = -1, int n_iterations_log = -1, bool singleshot = false, Simulation_Run_Info *info = nullptr, int idx_image = -1, int idx_chain = -1)
Minimum mode following method.
-
void Simulation_EMA_Start(State *state, int n_iterations = -1, int n_iterations_log = -1, bool singleshot = false, Simulation_Run_Info *info = nullptr, int idx_image = -1, int idx_chain = -1)
Eigenmode analysis.
-
void Simulation_SingleShot(State *state, int idx_image = -1, int idx_chain = -1)
Single iteration of a Method
If
singleshot=truewas passed toSimulation_..._Startbefore, this will perform one iteration. Otherwise, nothing will happen.
-
void Simulation_N_Shot(State *state, int N, int idx_image = -1, int idx_chain = -1)
N iterations of a Method
If
singleshot=truewas passed toSimulation_..._Startbefore, this will perform N iterations. Otherwise, nothing will happen.
Get information
-
scalar Simulation_Get_MaxTorqueNorm(State *state, int idx_image = -1, int idx_chain = -1)
Get maximum torque norm.
If a MC, LLG, MMF or EMA simulation is running this returns the max. torque on the current image.
If a GNEB simulation is running this returns the max. torque on the current chain.
-
void Simulation_Get_Chain_MaxTorqueNorms(State *state, scalar *torques, int idx_chain = -1)
Get maximum torque norms on the images of a chain.
Will only work if a GNEB simulation is running.
-
scalar Simulation_Get_IterationsPerSecond(State *state, int idx_image = -1, int idx_chain = -1)
If a MC, LLG, MMF or EMA simulation is running this returns the IPS on the current image.
If a GNEB simulation is running this returns the IPS on the current chain.
- Returns:
the iterations per second (IPS).
Whether a simulation is running
-
bool Simulation_Running_On_Image(State *state, int idx_image = -1, int idx_chain = -1)
Check if a simulation is running on specific image of specific chain.