CellGPU
0.8.0
GPU-accelerated simulations of cells
|
Implement energy minimization via the FIRE algorithm. More...
#include <EnergyMinimizerFIRE2D.h>
Public Member Functions | |
EnergyMinimizerFIRE () | |
The basic constructor. | |
EnergyMinimizerFIRE (shared_ptr< Simple2DModel > system) | |
The basic constructor that feeds in a target system to minimize. More... | |
void | initializeParameters () |
Sets a bunch of default parameters that do not depend on the number of degrees of freedom. More... | |
void | initializeFromModel () |
Set a bunch of default initialization parameters (if the State is available to determine the size of vectors) More... | |
virtual void | set2DModel (shared_ptr< Simple2DModel > _model) |
set the internal State to the given model | |
void | setMaximumIterations (int maxIt) |
Set the maximum number of iterations before terminating (or set to -1 to ignore) | |
void | setForceCutoff (Dscalar fc) |
Set the force cutoff. | |
void | setDeltaT (Dscalar dt) |
set the initial value of deltaT | |
void | setAlphaStart (Dscalar as) |
set the initial value of alpha and alphaStart | |
void | setDeltaTMax (Dscalar tmax) |
Set the maximum deltaT. | |
void | setDeltaTInc (Dscalar dti) |
Set the fraction by which delta increments. | |
void | setDeltaTDec (Dscalar dtc) |
Set the fraction by which delta decrements. | |
void | setAlphaDec (Dscalar ad) |
Set the fraction by which alpha decrements. | |
void | setNMin (int nm) |
Set the number of consecutive steps P must be non-negative before increasing delatT. | |
void | velocityVerlet () |
an interface to call either the CPU or GPU velocity Verlet algorithm More... | |
void | velocityVerletCPU () |
Perform a velocity Verlet step on the CPU. More... | |
void | velocityVerletGPU () |
Perform a velocity Verlet step on the GPU. More... | |
void | fireStep () |
an interface to call either the CPU or GPU FIRE algorithm More... | |
void | fireStepCPU () |
Perform a velocity Verlet step on the CPU. More... | |
void | fireStepGPU () |
Perform a velocity Verlet step on the GPU. More... | |
void | minimize () |
Minimize to either the force tolerance or the maximum number of iterations. More... | |
virtual void | integrateEquationsOfMotion () |
The "intergate equatios of motion just calls minimize. | |
void | parallelReduce (GPUArray< Dscalar > &vec) |
Test the parallel reduction routines by passing in a known vector. More... | |
Dscalar | getMaxForce () |
Return the maximum force. | |
int | getTimestep () |
get the number of timesteps run | |
Dscalar | getTime () |
get the current simulation time | |
virtual void | performUpdate () |
performUpdate just maps to integrateEquationsOfMotion | |
virtual void | setReproducible (bool rep) |
Set whether the source of noise should always use the same random numbers. | |
void | reIndexRNG (GPUArray< curandState > &array) |
re-index the any RNGs associated with the e.o.m. | |
virtual void | Update (int timestep) |
The fundamental function that a controlling Simulation can call. | |
void | setPeriod (int _p) |
set the period | |
void | setPhase (int _p) |
set the phase | |
virtual void | spatialSorting () |
allow for spatial sorting to be called if necessary... | |
virtual void | setGPU () |
Enforce GPU-only operation. This is the default mode, so this method need not be called most of the time. | |
virtual void | setCPU () |
Enforce CPU-only operation. Derived classes might have to do more work when the CPU mode is invoked. | |
int | getNdof () |
Get the number of degrees of freedom of the equation of motion. | |
void | setNdof (int _n) |
Set the number of degrees of freedom of the equation of motion. | |
Public Attributes | |
shared_ptr< Simple2DModel > | State |
The system that can compute forces, move degrees of freedom, etc. | |
shared_ptr< Simple2DModel > | model |
A pointer to a Simple2DModel that the updater acts on. | |
Protected Member Functions | |
void | reIndexArray (GPUArray< int > &array) |
Re-index cell arrays after a spatial sorting has occured. | |
void | reIndexArray (GPUArray< Dscalar > &array) |
why use templates when you can type more? | |
void | reIndexArray (GPUArray< Dscalar2 > &array) |
why use templates when you can type more? | |
Protected Attributes | |
int | iterations |
The number of iterations performed. | |
int | maxIterations |
The maximum number of iterations allowed. | |
Dscalar | forceMax |
The cutoff value of the maximum force. | |
Dscalar | forceCutoff |
The cutoff value of the maximum force. | |
int | N |
The number of points, or cells, or particles. | |
int | NMin |
The numer of consecutive time steps the power must be positive before increasing deltaT. | |
int | NSinceNegativePower |
The numer of consecutive time since the power has be negative. | |
Dscalar | deltaT |
The internal time step size. | |
Dscalar | deltaTMin |
The minimum time step size. | |
Dscalar | deltaTMax |
The maximum time step size. | |
Dscalar | deltaTInc |
The fraction by which deltaT can get bigger. | |
Dscalar | deltaTDec |
The fraction by which deltaT can get smaller. | |
Dscalar | Power |
The internal value of the "power". | |
Dscalar | alpha |
The alpha parameter of the minimization routine. | |
Dscalar | alphaStart |
The initial value of the alpha parameter. | |
Dscalar | alphaDec |
The fraction by which alpha can decrease. | |
GPUArray< Dscalar2 > | force |
The GPUArray containing the force. | |
GPUArray< Dscalar2 > | velocity |
The GPUArray containing the velocity. | |
GPUArray< Dscalar2 > | displacement |
an array of displacements | |
GPUArray< Dscalar > | forceDotVelocity |
Utility array for computing force.velocity. | |
GPUArray< Dscalar > | forceDotForce |
Utility array for computing force.force. | |
GPUArray< Dscalar > | velocityDotVelocity |
Utility array for computing velocity.velocity. | |
GPUArray< Dscalar > | sumReductionIntermediate |
Utility array for simple reductions. | |
GPUArray< Dscalar > | sumReductions |
Utility array for simple reductions. | |
int | Timestep |
Count the number of integration timesteps. | |
GPUArray< Dscalar2 > | displacements |
an internal GPUArray for holding displacements | |
noiseSource | noise |
A source of noise for the equation of motion. | |
int | Period |
The period of the updater... the updater will work every Period timesteps. | |
int | Phase |
The phase of the updater... the updater will work every Period timesteps offset by a phase. | |
bool | GPUcompute |
whether the updater does its work on the GPU or not | |
int | Ndof |
The number of degrees of freedom the equations of motion need to know about. | |
vector< int > | reIndexing |
a vector of the re-indexing information | |
Implement energy minimization via the FIRE algorithm.
This class uses the "FIRE" algorithm to perform an energy minimization. The class is in the same framework as the simpleEquationOfMotion class, so it is called by calling performTimestep on a Simulation object that has been given the FIRE minimizer and the configuration to minimize. Each timestep, though, is a complete minimization (i.e. will run for the maximum number of iterations, or until a target tolerance has been acheived, or whatever stopping condition the user sets.
EnergyMinimizerFIRE::EnergyMinimizerFIRE | ( | shared_ptr< Simple2DModel > | system | ) |
The basic constructor that feeds in a target system to minimize.
Initialize the minimizer with a reference to a target system, set a bunch of default parameters. Of note, the current default is CPU operation
References initializeFromModel(), initializeParameters(), and set2DModel().
void EnergyMinimizerFIRE::initializeParameters | ( | ) |
Sets a bunch of default parameters that do not depend on the number of degrees of freedom.
Initialize the minimizer with some default parameters. that do not depend on N
References forceMax, iterations, NSinceNegativePower, Power, GPUArray< T >::resize(), setAlphaDec(), setAlphaStart(), setDeltaT(), setDeltaTDec(), setDeltaTInc(), setDeltaTMax(), setForceCutoff(), updater::setGPU(), setMaximumIterations(), setNMin(), and sumReductions.
Referenced by EnergyMinimizerFIRE().
void EnergyMinimizerFIRE::initializeFromModel | ( | ) |
Set a bunch of default initialization parameters (if the State is available to determine the size of vectors)
Initialize the minimizer with some default parameters.
References displacement, force, forceDotForce, forceDotVelocity, N, GPUArray< T >::resize(), State, sumReductionIntermediate, velocity, and velocityDotVelocity.
Referenced by EnergyMinimizerFIRE(), and minimize().
void EnergyMinimizerFIRE::velocityVerlet | ( | ) |
an interface to call either the CPU or GPU velocity Verlet algorithm
Call the correct velocity Verlet routine
References updater::GPUcompute, velocityVerletCPU(), and velocityVerletGPU().
Referenced by minimize(), and setNMin().
void EnergyMinimizerFIRE::velocityVerletCPU | ( | ) |
Perform a velocity Verlet step on the CPU.
Perform a velocity verlet integration step on the CPU
References ArrayHandle< T >::data, deltaT, displacement, force, N, State, and velocity.
Referenced by setNMin(), and velocityVerlet().
void EnergyMinimizerFIRE::velocityVerletGPU | ( | ) |
Perform a velocity Verlet step on the GPU.
Perform a velocity verlet integration step on the GPU
References ArrayHandle< T >::data, deltaT, access_location::device, displacement, force, gpu_displacement_velocity_verlet(), gpu_update_velocity(), N, access_mode::overwrite, access_mode::read, access_mode::readwrite, State, and velocity.
Referenced by setNMin(), and velocityVerlet().
void EnergyMinimizerFIRE::fireStep | ( | ) |
an interface to call either the CPU or GPU FIRE algorithm
Call the correct FIRE step routine
References fireStepCPU(), fireStepGPU(), and updater::GPUcompute.
Referenced by minimize(), and setNMin().
void EnergyMinimizerFIRE::fireStepCPU | ( | ) |
void EnergyMinimizerFIRE::fireStepGPU | ( | ) |
Perform a velocity Verlet step on the GPU.
Perform a FIRE minimization step on the GPU
References ArrayHandle< T >::data, access_location::device, forceDotForce, forceDotVelocity, forceMax, gpu_dot_Dscalar2_vectors(), gpu_parallel_reduction(), access_location::host, N, access_mode::overwrite, Power, access_mode::read, access_mode::readwrite, State, sumReductionIntermediate, sumReductions, velocity, and velocityDotVelocity.
Referenced by fireStep(), and setNMin().
void EnergyMinimizerFIRE::minimize | ( | ) |
Minimize to either the force tolerance or the maximum number of iterations.
Perform a FIRE minimization step on the CPU
References alpha, deltaT, fireStep(), force, forceCutoff, forceMax, initializeFromModel(), iterations, maxIterations, N, Power, State, and velocityVerlet().
Referenced by integrateEquationsOfMotion(), and setNMin().
void EnergyMinimizerFIRE::parallelReduce | ( | GPUArray< Dscalar > & | vec | ) |
Test the parallel reduction routines by passing in a known vector.
A utility function to help test the parallel reduction routines
Referenced by integrateEquationsOfMotion().