update kim_style command semantics as discussed in PR #1440

this also adds documentation of error messages in the kim_style header
This commit is contained in:
Axel Kohlmeyer 2019-05-30 21:51:13 -04:00
parent b3a01694b7
commit 24a63f0f31
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
7 changed files with 79 additions and 117 deletions

View File

@ -10,17 +10,18 @@ kim_style command :h3
[Syntax:]
kim_style mode model args :pre
kim_style mode args :pre
mode = {init} or {define}
model = name of the KIM model (potential or simulator model) or NULL
args = atom type to species mapping ({define} option only, one entry per atom type) :ul
mode = {init model} or {define typeargs}
model = name of the KIM model (KIM potential or KIM simulator model)
typeargs = atom type to species mapping (one entry per atom type) :ul
[Examples:]
kim_style init ex_sim_model_Si_mod_tersoff
kim_style define NULL Si Si
kim_style define LennardJones_Ar Ar :pre
kim_style define Si Si
kim_style init LennardJones_Ar
kim_style define Ar :pre
[Description:]
@ -29,27 +30,34 @@ The kim_style command is a high-level wrapper around the
repository of interatomic potentials, so that they can be used by
LAMMPS scripts. It does not implement any computations directly, but
rather will generate LAMMPS input commands based on the information
retrieved from the OpenKIM repository. It is primarily meant to realize
so-called "KIM Simulator Models", which are OpenKIM repository entries
of models using native features of the simulation engine, i.e. LAMMPS
retrieved from the OpenKIM repository. It is able to realize so-called
"KIM Simulator Models", which are OpenKIM repository entries of models
using native features of the simulation engine in use, i.e. LAMMPS
in this case, but it also supports realizing conventional KIM models
via the "pair_style kim"_pair_kim.html command.
implicitly via generating a "pair_style kim"_pair_kim.html command
followed by a suitable "pair_coeff"_pair_coeff.html command.
The kim_style command has two modes, {init} and {define}, indicated by
the first argument to the kim_style command. An {init} mode command
must be issued [before] the simulation box is created, while the {define}
mode version may only be used [after] the simulation box exists. The
{init} mode version is only required, if the KIM model requires it.
The second argument to the kim_style command is the KIM model ID. It
can be set to NULL in the kim_style define command, if it was already
set in a kim_style init command. Otherwise, the two model IDs must match.
mode version may only be used [after] the simulation box exists. Both
are required. The {init} mode version sets the model name and may issue
additional commands changing LAMMPS default settings that are required
for using a selected simulator model. If needed, those settings can be
overridden. The second argument to the {kim_style init} command is the
KIM model ID.
Only the kim_style define command allows additional arguments. Those
are used to map the atom types in LAMMPS to the available species in
the KIM model. This is equivalent to the arguments following
"pair_coeff * *" in a "kim"_pair_kim.html pair style. Thus the command
The {kim_style define} command will issue commands that will realize
the selected model (through generating pair_style and pair_coeff commands,
but also other commands, as required). It has to be issued [after] the
the simulation box is defined. The {kim_style define} command allows a
varying numbver of additional arguments. Those are used to map the atom
types in LAMMPS to the available species in the KIM model. This is
equivalent to the arguments following "pair_coeff * *" in a
"kim"_pair_kim.html pair style. Thus the commands:
kim_style define LennardJones_Ar Ar :pre
kim_style init LennardJones_Ar
kim_style define Ar :pre
will generate the LAMMPS input commands:
@ -60,7 +68,7 @@ For simulator models, the generated input commands may be more complex
and require that LAMMPS is built with the required packages included.
The commands generated by the kim_style command, can be copied to the
screen or log file, through the "echo"_echo.html command.
The kim_style command will also validate, that the selected simulator
The kim_style command will also validate, that a selected simulator
model was generated for the LAMMPS MD code and not some other software.
In addition, the version strings for LAMMPS version used for defining
the simulator model and the LAMMPS version being currently run are

View File

@ -8,7 +8,7 @@ kim_style init Sim_LAMMPS_ReaxFF_ChenowethVanDuinPersson_2008_CHOV__SM_429148913
read_data data.VOH
kim_style define NULL H C O V
kim_style define H C O V
neighbor 2 bin
neigh_modify every 10 delay 0 check no

View File

@ -54,7 +54,7 @@ velocity all create ${thi} 5287286 mom yes rot yes dist gaussian
group del id 300
delete_atoms group del
kim_style define NULL Si
kim_style define Si
thermo 10

View File

@ -1,69 +0,0 @@
units metal
kim_style init ex_sim_model_Si_mod_tersoff
atom_style atomic
atom_modify map array
boundary p p p
# temperatures
variable tlo equal 1800.0
variable thi equal 2400.0
# coordination number cutoff
variable r equal 2.835
# minimization parameters
variable etol equal 1.0e-5
variable ftol equal 1.0e-5
variable maxiter equal 100
variable maxeval equal 100
variable dmax equal 1.0e-1
# diamond unit cell
variable a equal 5.431
lattice custom $a &
a1 1.0 0.0 0.0 &
a2 0.0 1.0 0.0 &
a3 0.0 0.0 1.0 &
basis 0.0 0.0 0.0 &
basis 0.0 0.5 0.5 &
basis 0.5 0.0 0.5 &
basis 0.5 0.5 0.0 &
basis 0.25 0.25 0.25 &
basis 0.25 0.75 0.75 &
basis 0.75 0.25 0.75 &
basis 0.75 0.75 0.25
region myreg block 0 4 &
0 4 &
0 4
create_box 1 myreg
create_atoms 1 region myreg
mass 1 28.06
group Si type 1
velocity all create ${thi} 5287286 mom yes rot yes dist gaussian
# make a vacancy
group del id 300
delete_atoms group del
kim_style define ex_sim_model_Si_mod_tersoff Si
thermo 10
fix 1 all nve
fix 2 all langevin ${thi} ${thi} 0.1 48278
timestep 1.0e-3
neighbor 1.0 bin
neigh_modify every 1 delay 10 check yes
run 100

View File

@ -18,6 +18,8 @@ units metal
atom_style atomic
newton on
kim_style init LennardJones_Ar
lattice fcc 4.4300
region box block 0 ${xx} 0 ${yy} 0 ${zz}
create_box 1 box
@ -26,7 +28,7 @@ create_atoms 1 box
#pair_style lj/cut 8.1500
#pair_coeff 1 1 0.0104 3.4000
kim_style define LennardJones_Ar Ar
kim_style define Ar
mass 1 39.95
velocity all create 200.0 232345 loop geom

View File

@ -79,7 +79,7 @@ void KimStyle::command(int narg, char **arg)
if (narg < 2) error->all(FLERR,"Illegal kim_style command");
if (strcmp(arg[0],"init") == 0) {
if (narg > 2) error->all(FLERR,"Illegal kim_style init command");
if (narg > 2) error->all(FLERR,"Illegal kim_style command");
if (domain->box_exist)
error->all(FLERR,"Must use 'kim_style init' command before "
"simulation box is defined");
@ -167,10 +167,10 @@ void KimStyle::do_init(char *model)
void KimStyle::do_defn(int narg, char **arg)
{
if (narg != atom->ntypes + 1)
error->all(FLERR,"Incorrect number of arguments for kim_style define command");
if (narg != atom->ntypes)
error->all(FLERR,"Illegal kim_style command");
char *model = arg[0];
char *model = NULL;
KIM::SimulatorModel *simulatorModel(NULL);
int kimerror;
@ -182,17 +182,9 @@ void KimStyle::do_defn(int narg, char **arg)
int ifix = modify->find_fix("KIM_MODEL_STORE");
if (ifix >= 0) {
FixStoreKIM *fix_store = (FixStoreKIM *) modify->fix[ifix];
if (strcmp(model,"NULL") == 0)
model = (char *)fix_store->getptr("model_name");
else if (strcmp(model,(const char*)fix_store->getptr("model_name")) != 0)
error->all(FLERR,"Inconsistent KIM model name");
model = (char *)fix_store->getptr("model_name");
simulatorModel = (KIM::SimulatorModel *)fix_store->getptr("simulator_model");
} else {
kimerror = KIM::SimulatorModel::Create(model,&simulatorModel);
if (kimerror) simulatorModel = NULL;
}
} else error->all(FLERR,"Must use 'kim_style init' before 'kim_style define'");
if (simulatorModel) {
@ -219,7 +211,7 @@ void KimStyle::do_defn(int narg, char **arg)
if (*sim_name != "LAMMPS")
error->all(FLERR,"Incompatible KIM Simulator Model");
for (int i = 1; i < narg; i++)
for (int i = 0; i < narg; i++)
atom_type_sym_list += std::string(" ") + arg[i];
simulatorModel->AddTemplateMap("atom-type-sym-list",atom_type_sym_list);
@ -268,14 +260,6 @@ void KimStyle::do_defn(int narg, char **arg)
if (*sim_value != update->unit_style)
error->all(FLERR,"Incompatible units for KIM Simulator Model");
}
if ((ifix < 0) && ( *sim_field == "model-init")) {
for (int j=0; j < sim_lines; ++j) {
simulatorModel->GetSimulatorFieldLine(i,j,&sim_value);
if (*sim_value != "")
error->all(FLERR,"Must use 'kim_style init' with this model");
}
}
}
int sim_model_idx=-1;
@ -294,6 +278,7 @@ void KimStyle::do_defn(int narg, char **arg)
error->all(FLERR,"KIM Simulator Model has no Model definition");
simulatorModel->ClearTemplateMap();
} else {
// not a simulator model. issue pair_style and pair_coeff commands.
@ -304,7 +289,7 @@ void KimStyle::do_defn(int narg, char **arg)
cmd1 += model;
std::string cmd2("pair_coeff * * ");
for (int i=1; i < narg; ++i) {
for (int i=0; i < narg; ++i) {
cmd2 += arg[i];
cmd2 += " ";
}

View File

@ -83,5 +83,41 @@ class KimStyle : protected Pointers {
/* ERROR/WARNING messages:
E: Illegal kim_style command
Incorrect number or kind of arguments to kim_style
E: Must use 'kim_style init' command before simulation box is defined
Self-explanatory
E: Must use 'kim_style define' command after simulation box is defined
Self-explanatory
E: Must use 'kim_style init' command before 'kim_style define'
Self-explanatory
E: Incompatible KIM Simulator Model
The requested KIM Simulator Model was defined for a different MD code
and thus is not compatible with LAMMPS
E: Species XXX is not supported by this KIM Simulator Model
The kim_style define command was referencing a species that is not
present in the requested KIM Simulator Model
E: Incompatible units for KIM Simulator Model
The selected unit style is not compatible with the requested KIM
Simulator Model
E: KIM Simulator Model has no Model definition
There is no model definition (key: model-defn) in the KIM Simulator
Model. Please contact the OpenKIM database maintainers to verify
and potentially correct this.
*/