Skip to content

Commit

Permalink
lb no longer touches resort_particles
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Arnold committed Apr 23, 2014
1 parent 3c72b60 commit d19bf34
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
23 changes: 22 additions & 1 deletion doc/ug/run.tex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ \section{\texttt{integrate}: Running the simulation}
\newescommand{integrate}

\begin{essyntax}
\variant{1} integrate \var{steps}
\variant{1} integrate \opt{reuse_forces} \var{steps}
\variant{2} integrate set \opt{nvt}
\variant{3} integrate set npt_isotropic \var{p_{ext}} \var{piston} \opt{\var{x\: y\: z}} \opt{-cubic_box}
\end{essyntax}
Expand All @@ -34,6 +34,27 @@ \section{\texttt{integrate}: Running the simulation}
\texttt{steps} as parameter integrates the system for \texttt{steps}
time steps.

Note that this implementation of the Velocity Verlet algorithm reuses forces,
that is, they are computed once in the middle of the time step, but used twice,
at the beginning and end. However, in the first time step after setting up,
there are no forces present yet. Therefore, \es{} has to compute them before the
first time step. That has two consequences: first, random forces are redrawn,
resulting in a narrower distribution of the random forces, which we compensate
by stretching. Second, coupling forces of e.\,g. the Lattice Boltzmann fluid cannot
be computed and are therefore lacking in the first half time step. In order to
minimize these effects, \es{} has a quite conservative heuristics to decide whether
a change makes it necessary to recompute forces before the first time step. Therefore,
calling hundred times \texttt{integrate 1} does the same as \textt{integrate 100},
apart from some small calling overhead.

However, for checkpointing, there is no way for \es{} to tell that the forces that you
read back in actually match the parameters that are set. Therefore, \es{} would recompute
the forces before the first time step, which makes it essentially impossible to checkpoint
LB simulations, where it is vital to keep the coupling forces. Therefore, \texttt{integrate}
has an additional parameter \opt{reuse_forces}, which tells integrate to not recalculate
the forces for the first time step, but use that the values still stored with the particles.
Use this only if you are absolutely sure that the forces stored match your current setup!

Two methods for the integration can be set: For an NVT ensemble
(thermostat) and for an NPT isotropic ensemble (barostat). The current
method can be detected with the command \texttt{integrate set} without
Expand Down
19 changes: 5 additions & 14 deletions src/lb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,20 +880,6 @@ int lb_lbfluid_save_checkpoint(char* filename, int binary) {
return ES_OK;
}
int lb_lbfluid_load_checkpoint(char* filename, int binary) {
if (lattice_switch & LATTICE_LB) {
fprintf (stderr, "Loading an LB checkpoint requires first that all particles and forces are loaded into the system and then an integrate 0, this is required for the reformation of the the neighbor lists. After this integration the particle data must then be reloaded just prior to loading the LB checkpoint file. This is a rather inelegant hack to make the checkpointing work correctly.\n");
recalc_forces = 0; //Indicates the forces need not be recalculated
resort_particles = 0; //Prevents a call of on_resort_particles which gets called when the particle data is reset and then set recalc_forces = 1
}
else if (lattice_switch & LATTICE_LB_GPU) {
fprintf (stderr, "Loading an LB GPU checkpoint requires first that all particles and forces are loaded into the system and then an integrate 0, this is required for the reformation of the neighbor lists. After this integration the particle data must then be reloaded just prior to loading the LB GPU checkpoint file. This is a rather inelegant hack to make the checkpointing work correctly.\n");
recalc_forces = 0; //Indicates the forces need not be recalculated
resort_particles = 0; //Prevents a call of on_resort_particles which gets called when the particle data is reset and then set recalc_forces = 1
}
else {
fprintf (stderr, "To load an LB checkpoint one needs to have already initialized the LB fluid with the same grid size.\n");
return ES_ERROR;
}
if(lattice_switch & LATTICE_LB_GPU) {
#ifdef LB_GPU
FILE* cpfile;
Expand Down Expand Up @@ -969,6 +955,11 @@ int lb_lbfluid_load_checkpoint(char* filename, int binary) {
// mpi_bcast_lb_params(0);
#endif
}
else {
char *errtext = runtime_error(128);
ERROR_SPRINTF(errtext,"{To load an LB checkpoint one needs to have already initialized the LB fluid with the same grid size.}");
return ES_ERROR;
}
return ES_OK;
}

Expand Down

0 comments on commit d19bf34

Please sign in to comment.