Skip to content
Snippets Groups Projects
Commit ea4f16bd authored by Steve Plimpton's avatar Steve Plimpton
Browse files

additional fix external hooks for calling programs

parent d0a397d6
No related branches found
No related tags found
No related merge requests found
......@@ -17,19 +17,22 @@ msst = style name of this fix :l
dir = {x} or {y} or {z} :l
shockvel = shock velocity (strictly positive, distance/time units) :l
zero or more keyword value pairs may be appended :l
keyword = {q} or {mu} or {p0} or {v0} or {e0} or {tscale} :l
keyword = {q} or {mu} or {p0} or {v0} or {e0} or {tscale} or {beta} or {dftb} :l
{q} value = cell mass-like parameter (mass^2/distance^4 units)
{mu} value = artificial viscosity (mass/length/time units)
{p0} value = initial pressure in the shock equations (pressure units)
{v0} value = initial simulation cell volume in the shock equations (distance^3 units)
{e0} value = initial total energy (energy units)
{tscale} value = reduction in initial temperature (unitless fraction between 0.0 and 1.0) :pre
{tscale} value = reduction in initial temperature (unitless fraction between 0.0 and 1.0)
{dftb} value = {yes} or {no} for whether using MSST in conjunction with DFTB+
{beta} value = scale factor on energy contribution of DFTB+ :pre
:ule
[Examples:]
fix 1 all msst y 100.0 q 1.0e5 mu 1.0e5
fix 2 all msst z 50.0 q 1.0e4 mu 1.0e4 v0 4.3419e+03 p0 3.7797e+03 e0 -9.72360e+02 tscale 0.01 :pre
fix 2 all msst z 50.0 q 1.0e4 mu 1.0e4 v0 4.3419e+03 p0 3.7797e+03 e0 -9.72360e+02 tscale 0.01
fix 1 all msst y 100.0 q 1.0e5 mu 1.0e5 dftb yes beta 0.5 :pre
[Description:]
......@@ -58,11 +61,11 @@ oscillations have physical significance in some cases. The optional
symmetry to equilibrate to the shock Hugoniot and Rayleigh line more
rapidly in such cases.
{tscale} is a factor between 0 and 1 that determines what fraction of
thermal kinetic energy is converted to compressive strain kinetic
energy at the start of the simulation. Setting this parameter to a
non-zero value may assist in compression at the start of simulations
where it is slow to occur.
The keyword {tscale} is a factor between 0 and 1 that determines what
fraction of thermal kinetic energy is converted to compressive strain
kinetic energy at the start of the simulation. Setting this parameter
to a non-zero value may assist in compression at the start of
simulations where it is slow to occur.
If keywords {e0}, {p0},or {v0} are not supplied, these quantities will
be calculated on the first step, after the energy specified by
......@@ -77,17 +80,40 @@ For all pressure styles, the simulation box stays orthogonal in shape.
Parrinello-Rahman boundary conditions (tilted box) are supported by
LAMMPS, but are not implemented for MSST.
This fix computes a temperature and pressure each timestep. To do
this, the fix creates its own computes of style "temp" and "pressure",
as if these commands had been issued:
This fix computes a temperature and pressure and potential energy each
timestep. To do this, the fix creates its own computes of style "temp"
"pressure", and "pe", as if these commands had been issued:
compute fix-ID_temp group-ID temp
compute fix-ID_press group-ID pressure fix-ID_temp :pre
compute fix-ID_MSST_temp all temp
compute fix-ID_MSST_press all pressure fix-ID_MSST_temp :pre
compute fix-ID_MSST_pe all pe :pre
See the "compute temp"_compute_temp.html and "compute
pressure"_compute_pressure.html commands for details. Note that the
IDs of the new computes are the fix-ID + underscore + "temp" or fix_ID
+ underscore + "press". The group for the new computes is "all".
IDs of the new computes are the fix-ID + "_MSST_temp" or "_MSST_press"
or "_MSST_pe". The group for the new computes is "all".
:line
The {dftb} and {beta} keywords are to allow this fix to be used when
LAMMPS is being driven by DFTB+, a density-functional tight-binding
code.
If the keyword {dftb} is used with a value of {yes}, then the MSST
equations are altered to account for an energy contribution compute by
DFTB+. In this case, you must define a "fix
external"_fix_external.html command in your input script, which is
used to callback to DFTB+ during the LAMMPS timestepping. DFTB+ will
communicate its info to LAMMPS via that fix.
The keyword {beta} is a scale factor on the DFTB+ energy contribution.
The value of {beta} must be between 0.0 and 1.0 inclusive. A value of
0.0 means no contribution, a value of 1.0 means a full contribution.
(July 2017) More information about these keywords and the use of
LAMMPS with DFTB+ will be added to the LAMMMPS documention soon.
:line
[Restart, fix_modify, output, run start/stop, minimize info:]
......@@ -149,8 +175,9 @@ all.
[Default:]
The keyword defaults are q = 10, mu = 0, tscale = 0.01. p0, v0, and e0
are calculated on the first step.
The keyword defaults are q = 10, mu = 0, tscale = 0.01, dftb = no,
beta = 0.0. Note that p0, v0, and e0 are calculated on the first
timestep.
:line
......
This diff is collapsed.
......@@ -10,10 +10,6 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* Implementation of the Multi-Scale Shock Method.
See Reed, Fried, Joannopoulos, Phys. Rev. Lett., 90, 235503(2003).
Implementation by Laurence Fried, LLNL, 4/2007.
*/
#ifdef FIX_CLASS
......@@ -42,55 +38,68 @@ class FixMSST : public Fix {
void write_restart(FILE *);
void restart(char *);
int modify_param(int, char **);
double memory_usage();
private:
double dtv,dtf,dthalf; // Full and half step sizes.
double boltz,nktv2p, mvv2e; // Boltzmann factor and unit conversions.
double total_mass; // Mass of the computational cell.
double dtv,dtf,dthalf; // Full and half step sizes
double boltz,nktv2p, mvv2e; // Boltzmann factor and unit conversions
double total_mass; // Mass of the computational cell
double omega[3]; // Time derivative of the volume.
double omega[3]; // Time derivative of the volume
double p_current[3],dilation[3];
double qmass; // Effective cell mass.
double mu; // Effective cell viscosity.
double qmass; // Effective cell mass
double mu; // Effective cell viscosity
double tscale; // Converts thermal energy to compressive
// strain ke at simulation start
int dftb; // flag for use with DFTB+
double velocity_sum; // Sum of the velocities squared.
double velocity_sum; // Sum of the velocities squared
double damping; // Damping function for TS force term at
// small volume difference (v0 - vol)
double T0S0; // Initial TS term for DFTB+ simulations
double S_elec,S_elec_1,S_elec_2; // time history of electron entropy
// for DFTB+ simulaitons
double TS_dot; // time derivative of TS term for
// DFTB+ simulations
double **old_velocity; // Saved velocities.
double **old_velocity; // Saved velocities
int kspace_flag; // 1 if KSpace invoked, 0 if not
int nrigid; // number of rigid fixes
int *rfix; // indices of rigid fixes
char *id_temp,*id_press; // Strings with identifiers of
char *id_pe; // created computes.
char *id_pe; // created computes
class Compute *temperature; // Computes created to evaluate
class Compute *pressure; // thermodynamic quantities.
class Compute *pressure; // thermodynamic quantities
class Compute *pe;
int tflag,pflag,vsflag,peflag; // Flags to keep track of computes that
// were created.
// were created
// shock initial conditions.
// shock initial conditions
double e0; // Initial energy
double v0; // Initial volume
double p0; // Initial pressure
double velocity; // Velocity of the shock.
double velocity; // Velocity of the shock
double lagrangian_position; // Lagrangian location of computational cell
int direction; // Direction of shock
int p0_set; // Is pressure set.
int v0_set; // Is volume set.
int e0_set; // Is energy set.
int p0_set; // Is pressure set
int v0_set; // Is volume set
int e0_set; // Is energy set
double TS_int; // Needed for conserved quantity
// with thermal electronic excitations
double beta; // Energy conservation scaling factor
int atoms_allocated; // The number of allocated atoms in old_velocity.
int maxold; // allocated size of old_velocity
double TS_dftb; // value needed from DFTB+ via fix external
class FixExternal *fix_external; // ptr to fix external
// functions
void couple();
void remap(int);
void check_alloc(int n);
double compute_etotal();
double compute_vol();
double compute_hugoniot();
......
......@@ -30,7 +30,7 @@ enum{PF_CALLBACK,PF_ARRAY};
FixExternal::FixExternal(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
fexternal(NULL)
fexternal(NULL), caller_vector(NULL)
{
if (narg < 4) error->all(FLERR,"Illegal fix external command");
......@@ -62,6 +62,11 @@ FixExternal::FixExternal(LAMMPS *lmp, int narg, char **arg) :
atom->add_callback(0);
user_energy = 0.0;
// optional vector of values provided by caller
// vector_flag and size_vector are setup via set_vector_length()
caller_vector = NULL;
}
/* ---------------------------------------------------------------------- */
......@@ -73,6 +78,7 @@ FixExternal::~FixExternal()
atom->delete_callback(id,0);
memory->destroy(fexternal);
delete [] caller_vector;
}
/* ---------------------------------------------------------------------- */
......@@ -167,10 +173,15 @@ void FixExternal::min_post_force(int vflag)
post_force(vflag);
}
// ----------------------------------------------------------------------
// "set" methods caller can invoke directly
// ----------------------------------------------------------------------
/* ----------------------------------------------------------------------
caller invokes this method to set its contribution to global energy
do not just return if eflag_global is not set
input script could access this quantity via compute_scalar()
unlike other energy/virial set methods:
do not just return if eflag_global is not set
b/c input script could access this quantity via compute_scalar()
even if eflag is not set on a particular timestep
------------------------------------------------------------------------- */
......@@ -220,6 +231,34 @@ void FixExternal::set_virial_peratom(double **caller_virial)
vatom[i][j] = caller_virial[i][j];
}
/* ----------------------------------------------------------------------
caller invokes this method to set length of vector of values
assume all vector values are extensive, could make this an option
------------------------------------------------------------------------- */
void FixExternal::set_vector_length(int n)
{
delete [] caller_vector;
vector_flag = 1;
size_vector = n;
extvector = 1;
caller_vector = new double[n];
}
/* ----------------------------------------------------------------------
caller invokes this method to set Index value in vector
index ranges from 1 to N inclusive
------------------------------------------------------------------------- */
void FixExternal::set_vector(int index, double value)
{
if (index >= size_vector)
error->all(FLERR,"Invalid set_vector index in fix external");
caller_vector[index-1] = value;
}
/* ----------------------------------------------------------------------
potential energy of added force
up to user to set it via set_energy()
......@@ -230,6 +269,16 @@ double FixExternal::compute_scalar()
return user_energy;
}
/* ----------------------------------------------------------------------
arbitrary value computed by caller
up to user to set it via set_vector()
------------------------------------------------------------------------- */
double FixExternal::compute_vector(int n)
{
return caller_vector[n];
}
/* ----------------------------------------------------------------------
memory usage of local atom-based array
------------------------------------------------------------------------- */
......
......@@ -39,11 +39,14 @@ class FixExternal : public Fix {
void post_force(int);
void min_post_force(int);
double compute_scalar();
double compute_vector(int);
void set_energy_global(double);
void set_virial_global(double *);
void set_energy_peratom(double *);
void set_virial_peratom(double **);
void set_vector_length(int);
void set_vector(int,double);
double memory_usage();
void grow_arrays(int);
......@@ -59,6 +62,7 @@ class FixExternal : public Fix {
FnPtr callback;
void *ptr_caller;
double user_energy;
double *caller_vector;
};
}
......
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