|
SimSystem class performs Molecular Dynamic simulation. It manages the simulation systems. This class must be inherited by the main class in the main simulation program. This class is the container for simulation system atoms. Any other classes will reffer and use atom data from this class. The main simulation class must implements at least two functions, CreateSystem() and InitSystem(). CreateSystem() function is used to create the simulation system by adding atoms, crystals, conditioners, detectors and setting integrator. InitSystem is used to do initialization before running the simulation, such as setting the boundary defining boundary condition, and other needed initialization. Another important functions are BeforeRun() and AfterRun(). These functions are called exactly before and and after running simulation. Header file: simsystem.h Variables:All the variables, if not stated explicitly, are public. - IsReady |bool, private|, indicates that the system is ready.
- Restored |bool, private|, indicates that the system is restored from a restore/restart file.
- TimeStepAdaptionPeriod |integer, private|, the period to adapt time step. SimSystem will adjust TimeStep according to the maximum velocity of the atoms every this period.
- ExternalInterupt |pointer to integer, private|. This variable points to an integer variable outside the class. A non-zero value of that variable will be consider as an interrupt to the system. When the system recieves interrupt, it will quit the main loop and call Interruption() function.
- DynamicTimeStep |bool, protected|, indicates that the simulation uses dynamic time step. If this variable is false, then SimSystem will not adjust TimeStep every TimeStepAdaptionPeriod.
- HasInline |bool, protected|, indicates that the simulation has an inline function. When it is true, then the InlineFunction() will be called in every step.
- Forces |pointer to Integrator|, keeps the force kernels and do integration using those forces.
- Conditioners |vector of Conditioner|, keeps the Conditioners used by simulation. A Conditioner can be accesed using its index, as Conditionersindex. The index is the sequence of conditioner insertion to the system, starting with 0.
- Detectors |vector of Detector|, keeps the Detectors used by simulation. Accesing a detector is the same like conditioner.
- AtomContainers |vector od AtomContainer|, keeps the AtomContainers in the simulations. Accesing atom container is the same like conditioner.
- SimBeginTime, SimEndTime |time_t|, keeps the information about starting and ending of simulation, in real time.
- Step |integer|, the simulation step counter.
- PBoundary |integer|, keeps the boundary conditions of the simulation. The predifined conditions are: PERIODIC_X, PERIODIC_Y, PERIODIC_Z, PERIODIC, and NOPERIODIC.
- Energy |double|, systems total energy.
- Kinetic |double|, systems kinetic energy.
- Virial |double|, systems virial.
- Potential |double|, system potential energy.
- BasePotential |double|, the base potential of the system, calculated before running simulation. At runtime, the potential shown is after subtraction by this value.
- TimeStep |double|, the time step.
- ElapsedTime |double|, simulations elapsed time.
- MaxTime |double|, maximum simulation time. The simulation stops after ElapsedTime reaches this time.
- MaxPath |double|, maximum path distance of the atoms in every step. For platinum crystal is 0.0981.
- SqrMaxVelocity, the square of maximum atom velocity.
- Box |structure of 9 doubles|. This structure keeps the boundary box of the simulation system. Fields: x0, x1, y0, y1, z0, z1, are the vertices of the box, and lx, ly, lz are the length of the sides.
Functions:All the functions, if not stated explicitly, are public functions and does not return anything. - CreateSystem() |void, abstract|, this function must be implemented by the child class, to create and add atoms, conditioners, and detectors.
- InitSystem() |void, abstract|, this function must be implemented by the child class, to do initializations.
- BeforeRun() |void, private|, this function will be called before running simulation. By default does nothing.
- Interruption() |void, private|, this function is the interuption handler, when the simulation recieves interruption signals from the integer variable pointed by ExternalInterupt.
- AfterRun() |void, private|, this function will be called after running simulation. By default does nothing.
- Scheduller() |void, private|, this function is called in every loop. (delete candidate, job can be replaced by InlineFunction)
- InlineFunction() |void, private|, this function is called in every loop when HasInline is true. The difference with Scheduller: this function is called after the integration and all detectors are executed, while Scheduller before. Scheduller is called right on the top of the loop.
- AdaptTimeStep() |void, protected|, adapts time step every period defined by AdaptTimeStepPeriod.
- UnificateAtoms() |void, protected|, puts the atoms in atom containers, into a single array.
- BoundaryBox() |void, protected|, calculates the boundary box of the simulation system. The atom containers which have OUTSIDEBOX flag, will be excluded from the calculation.
- SaveSimulation(const char* fname, void* par=NULL, int n), saves the everything from the simulation to a binary file.
- RestoreSimulation(const char* fname, void* par=NULL), load a saved binary file and restore the simulaition to the status where it was before.
- SetForce(Integrator* Forc) |pointer to Integrator|, set an integrator to the system.
- AddDetector(Detector* Detc) |pointer to Detector|, add a detector to the system.
- AddConditioner(Conditioner* Cond) |pointer to Conditioner|, add a conditioner to the system.
- AddAtom(AtomContainer* Atm) |pointer to AtomContainer|, add an atom container (crystal, atoms) to the system.
- SetExternalInterrupt(int* intflag), sets external interrupt to an external integer variable.
- PrintTime(), prints simulation's running time in real time.
- ChangeAtomID(int idx, short NewID), ChangeAtomID(int start, int end, int NewID), changes the id of atoms identified by idx, or starting from start to end parameter to a new id NewID (Buggy).
- PrintInfo(), prints all informations abount the simulation by calling all PrintInfo functions of the gadgets.
- Measure() does measurement. This function runs once the integrator and measures the energies.
- Initiate() does basic system initialization.
- Run(), runs the simulation. This function is the main loop of Object Molecular Dynamics.
|