Integrator Superclass¶
-
class QDynamics::Integrator¶
A superclass from which all individual integrators will inherit. Handles the mundane stuff such as the progress tracking and saving. Importantly, it provides virtual overload methods for Gradu() and U() which allows external definition of the dynamics, and of UpdatePosition() which allows specific subclasses of this object choose how they want to move from q_i -> q_i+1.
Subclassed by QDynamics::BruteInt, QDynamics::Magi< order, step >
Public Functions
-
inline Integrator(double T, double deltaT)¶
Constructor function.
- Parameters
T – The total duration of the integration
deltaT – the width of timesteps used
-
inline Integrator(double T, double deltaT, int skipper)¶
Constructor function.
- Parameters
T – The total duration of the integration
deltaT – the width of timesteps used
skipper – The number of epochs which pass in between updates to the progess Integrator::Buffer
-
inline void Evolve(Quaternion q0, Quaternion p0, JSL::Vector J, std::string saveFolder)¶
The main computation loop. Calls UpdatePosition() at each timestep until the TotalTime is reached.
- Parameters
q0 – The initial position Quaternion
p0 – The initial momentum Quaternion
J – The diagonals of the moment of inertia vector (we have implicitly assumed the system triaxial is such that J is diagonal)
saveFolder – The location into which the Integrator::Buffer output is saved.
-
inline virtual void UpdatePosition(double t)¶
In the Integrator base class, this is an empty function. Child members will mainly focus on overloading this function to their own update formula.
- Parameters
t – The current time of the integrator
Protected Functions
-
virtual Quaternion GradU(double t)¶
Returns the quaternionic derivative of the neo-potential V (equal to the derivative of the rotation potential U), given the current value of Integrator::q and the current time.
- Parameters
t – The current time
- Returns
The value of the quaternionic gradient
-
virtual double U(double t)¶
Returns the current value of the rotation potential U, given the current value of Integrator::q and the current time. Unlike GradU(), it is not critical that this function be 100% correct, as it is only used by the Integrator::Hamiltonian function as bookkeeping for the current energy. If you do not wish to track the current energy, you may neglect this function.
- Parameters
t – The current time
- Returns
The current potential energy of the system
Protected Attributes
-
Quaternion q¶
The current position variable.
-
Quaternion p¶
The current momentum variable.
-
Quaternion w¶
The current body-fixed angular speed.
-
Quaternion L¶
The current body-fixed Angular momentum.
-
double TimeStep¶
The timestep taken by the integrator.
-
double TotalTime¶
The total length of time that the integrator will search for.
-
std::string Name¶
The assigned name of the integrator. This is set to “Unassigned” by default: child classes should modify this name.
-
std::string FileName¶
The location written to by CreateFullName(). A file location which will be used to write the output buffer to.
Private Functions
-
inline void UpdateBuffer(double t)¶
Called during every loop of Evolve(), saves some values of interest to the Integrator::Buffer.
- Parameters
t – The current time, needed as part of the buffer input
-
inline void FlushBuffer()¶
Called when the Integrator::Buffer is full, writes the contents of the buffer to the file determined by Integrator::FileName, and resets the buffer.
-
inline void UpdateProgressBar(double t)¶
Writes a series of # to the screen to act as a progress bar: [##### ].
- Parameters
t – The current time, so that the current progress can be computed.
-
inline void Initialise(Quaternion q0, Quaternion p0, JSL::Vector Jin, std::string saveFolder)¶
Prepares the Integrator for a new computation loop. Called at the start of an Evolve() process, it wipes the buffer and prepares the output file. The inputs are simply those passed to Evolve()
- Parameters
q0 – The initial position Quaternion
p0 – The initial momentum Quaternion
Jin – The diagonals of the moment of inertia vector (we have implicitly assumed the system triaxial is such that J is diagonal)
saveFolder – The location into which the Integrator::Buffer output is saved.
-
inline void CreateFullName(std::string saveFolder)¶
Computes the Integrator::FileName including the filepath from from the Integrator::Name and the provided directory.
- Parameters
saveFolder – The corresponding value passed to Intitialise()
Private Members
-
int BufferPos¶
The current write-index of Integrator::Buffer.
-
int BufferSize¶
The length of the Integrator::Buffer.
-
int NHashes¶
The number of hashes a full progress bar is made up of.
-
bool FinalHash¶
A simple lock tracking if the final hash has been written, preventing multiple termination characters being printed.
-
int CurrentHashes¶
The current number of progress hashes which have been written to the terminal.
-
std::vector<std::string> Buffer¶
A string-buffer containing the save-values of several past values of the integrator. Once full, the buffer is written to file.
-
int SkipID¶
The current number of files that the buffer has skipped (as per the skipper variable in Integrator(double,double,int))
-
int Skips¶
The maximum value of SkipID before the buffer saves a value.
-
inline Integrator(double T, double deltaT)¶