Skip to content
Snippets Groups Projects
Unverified Commit 6027de53 authored by Steve Plimpton's avatar Steve Plimpton Committed by GitHub
Browse files

Merge pull request #870 from lammps/doc-tweak

add info to compute heat/flux doc page and a small update to the developer's guide
parents 43002746 398f3173
No related branches found
No related tags found
No related merge requests found
......@@ -449,15 +449,15 @@ Writing fixes is a flexible way of extending LAMMPS. Users can
implement many things using fixes:
\begin{itemize}
\item changing particles attributes (positions, velocities, forces, etc.).
\item changing particles attributes (positions, velocities, forces, etc.).
Example: FixFreeze.
\item reading/writing data. Example: FixRestart.
\item implementing boundary conditions. Example: FixWall.
\item saving information about particles for future use (previous positions,
\item saving information about particles for future use (previous positions,
for instance). Example: FixStoreState.
\end{itemize}
All fixes are derived from class Fix and must have constructor with the
All fixes are derived from class Fix and must have constructor with the
signature: FixMine(class LAMMPS *, int, char **).
Every fix must be registered in LAMMPS by writing the following lines
......@@ -478,7 +478,7 @@ included in the file "style\_fix.h". In case if you use LAMMPS make,
this file is generated automatically - all files starting with prefix
fix\_ are included, so call your header the same way. Otherwise, donÕt
forget to add your include into "style\_fix.h".
Let's write a simple fix which will print average velocity at the end
of each timestep. First of all, implement a constructor:
......@@ -487,11 +487,11 @@ of each timestep. First of all, implement a constructor:
FixPrintVel::FixPrintVel(LAMMPS *lmp, int narg, char **arg)
: Fix(lmp, narg, arg)
{
if (narg < 4)
if (narg < 4)
error->all(FLERR,"Illegal fix print command");
nevery = atoi(arg[3]);
if (nevery <= 0)
if (nevery <= 0)
error->all(FLERR,"Illegal fix print command");
}
\end{verbatim}
......@@ -545,7 +545,7 @@ void FixPrintVel::end_of_step()
{
// for add3, scale3
using namespace MathExtra;
double** v = atom->v;
int nlocal = atom->nlocal;
double localAvgVel[4]; // 4th element for particles count
......@@ -559,7 +559,7 @@ void FixPrintVel::end_of_step()
MPI_Allreduce(localAvgVel, globalAvgVel, 4, MPI_DOUBLE, MPI_SUM, world);
scale3(1.0 / globalAvgVel[3], globalAvgVel);
if (comm->me == 0) {
printf("\%e, \%e, \%e\n",
printf("\%e, \%e, \%e\n",
globalAvgVel[0], globalAvgVel[1], globalAvgVel[2]);
}
}
......@@ -607,14 +607,15 @@ this situation there are several methods which should be implemented:
\begin{itemize}
\item \verb|double memory_usage| - return how much memory fix uses
\item \verb|void grow_arrays(int)| - do reallocation of the per particle arrays
\item \verb|void grow_arrays(int)| - do reallocation of the per particle arrays
in your fix
\item \verb|void copy_arrays(int i, int j)| - copy i-th per-particle information
to j-th. Used when atoms sorting is performed
\item \verb|void copy_arrays(int i, int j, int delflag)| - copy i-th per-particle
information to j-th. Used when atoms sorting is performed. if delflag is set
and atom j owns a body, move the body information to atom i.
\item \verb|void set_arrays(int i)| - sets i-th particle related information to zero
\end{itemize}
Note, that if your class implements these methods, it must call add calls of
Note, that if your class implements these methods, it must call add calls of
add\_callback and delete\_callback to constructor and destructor:
\begin{center}
......@@ -654,7 +655,7 @@ void FixSavePos::grow_arrays(int nmax)
memory->grow(this->x, nmax, 3, "FixSavePos:x");
}
void FixSavePos::copy_arrays(int i, int j)
void FixSavePos::copy_arrays(int i, int j, int delflag)
{
memcpy(this->x[j], this->x[i], sizeof(double) * 3);
}
......@@ -670,7 +671,7 @@ int FixSavePos::pack_exchange(int i, double *buf)
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
return m;
}
......
......@@ -26,14 +26,16 @@ compute myFlux all heat/flux myKE myPE myStress :pre
Define a computation that calculates the heat flux vector based on
contributions from atoms in the specified group. This can be used by
itself to measure the heat flux into or out of a reservoir of atoms,
or to calculate a thermal conductivity using the Green-Kubo formalism.
See the "fix thermal/conductivity"_fix_thermal_conductivity.html
command for details on how to compute thermal conductivity in an
alternate way, via the Muller-Plathe method. See the "fix
heat"_fix_heat.html command for a way to control the heat added or
subtracted to a group of atoms.
itself to measure the heat flux through a set of atoms (e.g. a region
between two thermostatted reservoirs held at different temperatures),
or to calculate a thermal conductivity using the equilibrium
Green-Kubo formalism.
For other non-equilibrium ways to compute a thermal conductivity, see
"this section"_Section_howto.html#howto_20. These include use of the
"fix thermal/conductivity"_fix_thermal_conductivity.html command for
the Muller-Plathe method. Or the "fix heat"_fix_heat.html command
which can add or subtract heat from groups of atoms.
The compute takes three arguments which are IDs of other
"computes"_compute.html. One calculates per-atom kinetic energy
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment