- rename pair_style pace/al to pace/extrapolation

- PairPACEExtrapolation do not instantiate special compute and dump pace/extrapolation classes. This is user responsibility now.
- add is_set_energies_forces option to control updating Pair::evdwl and Pair::f
- add dump_pace_extrapolation.h/cpp
- DumpPACEExtrapolation::write()   dump only if
 1) extrapolation grades were computed on current timestep AND
 2) max extrapolation grade > gamma_lower_bound
 - ComputePACEExtrapolation::invoke_compute_extrapolation_grades: does not update energies/forces/stresses, called when compute and pair_style pace/extrapolation not syncronize
This commit is contained in:
Yury Lysogorskiy
2022-07-07 23:35:27 +02:00
parent 3b41ec7d9b
commit d21c933ae0
7 changed files with 263 additions and 260 deletions

View File

@ -1,88 +0,0 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
//
// Created by Yury Lysogorskiy on 23.06.22.
//
#include "compute_pace.h"
#include "pair_pace_al.h"
#include "atom.h"
#include "comm.h"
#include "error.h"
#include "force.h"
#include "math_extra.h"
#include "memory.h"
#include "modify.h"
#include "neigh_list.h"
#include "neighbor.h"
#include "pair.h"
#include "update.h"
using namespace LAMMPS_NS;
ComputePaceAtom::ComputePaceAtom(class LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg) {
if (narg < 3) error->all(FLERR, "Illegal compute pace/atom command");
peratom_flag = 1;
size_peratom_cols = 0;
scalar_flag = 1; // compute max of gamma
}
ComputePaceAtom::~ComputePaceAtom() {
}
void ComputePaceAtom::init() {
if (force->pair == nullptr)
error->all(FLERR, "Compute pace/atom requires a pair style pace/al be defined");
int count = 0;
for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style, "pace/atom") == 0) count++;
if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute pace/atom");
pair_pace_al = force->pair_match("pace/al", 1);
if (!pair_pace_al)
error->all(FLERR, "Compute pace/atom requires a `pace/al` pair style");
}
double ComputePaceAtom::compute_scalar() {
invoked_scalar = update->ntimestep;
auto pair = (PairPACEActiveLearning *) pair_pace_al;
if (invoked_scalar != pair->bevaluator_timestep) {
//TODO: somehow control the frequency of extra computation and warn user about adjusting gamma_freq?
// utils::logmesg(lmp,"[ComputePaceAtom::compute_scalar] Reseting timestep shift to {} (pace timestep={}) and recomputing\n",invoked_scalar,pair->bevaluator_timestep);
pair->bevaluator_timestep_shift = invoked_scalar;
//TODO: is that right calling of pair pace compute?
pair->compute(1, 1);
}
scalar = pair->max_gamma_grade_per_structure;
return scalar;
}
void ComputePaceAtom::compute_peratom() {
invoked_peratom = update->ntimestep;
auto pair = (PairPACEActiveLearning *) pair_pace_al;
if (invoked_peratom != pair->bevaluator_timestep) {
//TODO: somehow control the frequency of extra computation and warn user about adjusting gamma_freq?
// utils::logmesg(lmp,"[ComputePaceAtom::compute_peratom] Reseting timestep shift to {} (pace timestep={}) and recomputing\n",invoked_peratom,pair->bevaluator_timestep);
pair->bevaluator_timestep_shift = invoked_peratom;
//TODO: is that right calling of pair pace compute?
pair->compute(1, 1);
}
vector_atom = pair->extrapolation_grade_gamma;
}

View File

@ -0,0 +1,93 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
//
// Created by Yury Lysogorskiy on 23.06.22.
//
#include "compute_pace_extrapolation.h"
#include "pair_pace_extrapolation.h"
#include "comm.h"
#include "error.h"
#include "force.h"
#include "modify.h"
#include "update.h"
using namespace LAMMPS_NS;
ComputePACEExtrapolation::ComputePACEExtrapolation(class LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg) {
if (narg < 3) error->all(FLERR, "Illegal compute pace/extrapolation command");
peratom_flag = 1;
size_peratom_cols = 0;
scalar_flag = 1; // compute max of gamma
}
ComputePACEExtrapolation::~ComputePACEExtrapolation() {
}
void ComputePACEExtrapolation::init() {
if (force->pair == nullptr)
error->all(FLERR, "Compute pace/extrapolation requires a pair style pace/extrapolation be defined");
if ((modify->get_compute_by_style("pace/extrapolation").size() > 1) && (comm->me == 0))
error->warning(FLERR, "More than one instance of compute pace/atom");
pair_pace_extrapolation = (PairPACEExtrapolation *) force->pair_match("pace/extrapolation", 1);
if (!pair_pace_extrapolation)
error->all(FLERR, "Compute pace/extrapolation requires a `pace/extrapolation` pair style");
}
void ComputePACEExtrapolation::invoke_compute_extrapolation_grades() {
bigint current_timestep = update->ntimestep;
pair_pace_extrapolation->bevaluator_timestep_shift = current_timestep;
int old_vflag_fdotr = pair_pace_extrapolation->vflag_fdotr;
pair_pace_extrapolation->vflag_fdotr = 0;
pair_pace_extrapolation->is_set_energies_forces = false;
pair_pace_extrapolation->compute(0, 0);
pair_pace_extrapolation->is_set_energies_forces = true;
pair_pace_extrapolation->vflag_fdotr = old_vflag_fdotr;
}
double ComputePACEExtrapolation::compute_scalar() {
invoked_scalar = update->ntimestep;
// check the coherence of bevaluator_timestep (when extrapolation grades are computed) and actual timestep
// if not coherent, change pair->bevaluator_timestep_shift to current timestep
// and call invoke_compute_extrapolation_grades without updating energies and forces
if (invoked_scalar != pair_pace_extrapolation->bevaluator_timestep) {
//utils::logmesg(lmp,"[ComputePaceAtom::compute_scalar] Reseting timestep shift to {} (pace timestep={}) and recomputing\n",invoked_scalar,pair->bevaluator_timestep);
invoke_compute_extrapolation_grades();
}
scalar = pair_pace_extrapolation->max_gamma_grade_per_structure;
return scalar;
}
void ComputePACEExtrapolation::compute_peratom() {
invoked_peratom = update->ntimestep;
// check the coherence of bevaluator_timestep (when extrapolation grades are computed) and actual timestep
// if not coherent, change pair->bevaluator_timestep_shift to current timestep
// and call invoke_compute_extrapolation_grades without updating energies and forces
if (invoked_peratom != pair_pace_extrapolation->bevaluator_timestep) {
//utils::logmesg(lmp,"[ComputePaceAtom::compute_peratom] Reseting timestep shift to {} (pace timestep={}) and recomputing\n",invoked_peratom,pair->bevaluator_timestep);
invoke_compute_extrapolation_grades();
}
vector_atom = pair_pace_extrapolation->extrapolation_grade_gamma;
}

View File

@ -17,7 +17,7 @@
#ifdef COMPUTE_CLASS
// clang-format off
ComputeStyle(pace/atom,ComputePaceAtom);
ComputeStyle(pace/extrapolation,ComputePACEExtrapolation);
// clang-format on
#else
@ -26,20 +26,21 @@ ComputeStyle(pace/atom,ComputePaceAtom);
#include "compute.h"
#include "pair_pace_al.h"
#include "pair_pace_extrapolation.h"
namespace LAMMPS_NS {
class PairPACEExtrapolation;
class ComputePaceAtom : public Compute {
class ComputePACEExtrapolation : public Compute {
public:
ComputePaceAtom(class LAMMPS *, int, char **);
~ComputePaceAtom() override;
ComputePACEExtrapolation(class LAMMPS *, int, char **);
~ComputePACEExtrapolation() override;
void init() override;
double compute_scalar() override;
void compute_peratom() override;
private:
int nmax;
Pair *pair_pace_al;
PairPACEExtrapolation *pair_pace_extrapolation;
void invoke_compute_extrapolation_grades();
};
} // namespace LAMMPS_NS

View File

@ -0,0 +1,56 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "dump_pace_extrapolation.h"
#include "atom.h"
#include "force.h"
#include "comm.h"
#include "memory.h"
#include "error.h"
#include "update.h"
#include "modify.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
DumpPACEExtrapolation::DumpPACEExtrapolation(struct LAMMPS *lmp, int nargs, char **argv) : DumpCustom(lmp, nargs,
argv) {
pairPaceExtrapolation = (PairPACEExtrapolation *) force->pair_match("pace/extrapolation", 1);
if (!pairPaceExtrapolation)
error->all(FLERR, "Dump pace/extrapolation requires a `pace/extrapolation` pair style");
// Save atomtypes to elements mapping into SPECIES_TYPE_FNAME to be used later in Python for loading extrapolative structures
FILE *species_type_file = fopen(SPECIES_TYPE_FNAME.c_str(), "w");
const int n = atom->ntypes;
for (int i = 0; i < n; i++) {
auto elemname = pairPaceExtrapolation->element_names[i].c_str();
fprintf(species_type_file, "%s ", elemname);
}
fclose(species_type_file);
}
void DumpPACEExtrapolation::write() {
int current_time_step = update->ntimestep;
// dump only if
// 1) extrapolation grades were computed on current timestep AND
// 2) max extrapolation grade > gamma_lower_bound
if (current_time_step == pairPaceExtrapolation->bevaluator_timestep) {
if (pairPaceExtrapolation->max_gamma_grade_per_structure > pairPaceExtrapolation->gamma_lower_bound) {
DumpCustom::write();
MPI_Barrier(world);
}
}
}

View File

@ -0,0 +1,43 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef DUMP_CLASS
// clang-format off
DumpStyle(pace/extrapolation,DumpPACEExtrapolation);
// clang-format on
#else
#ifndef LMP_DUMP_PACE_AL_H
#define LMP_DUMP_PACE_AL_H
#include "pair.h"
#include "dump_custom.h"
#include "pair_pace_extrapolation.h"
namespace LAMMPS_NS {
// forward declaration
class PairPACEExtrapolation;
class DumpPACEExtrapolation : public DumpCustom {
const std::string SPECIES_TYPE_FNAME = "species_types.dat";
PairPACEExtrapolation *pairPaceExtrapolation;
public:
DumpPACEExtrapolation(class LAMMPS *lmp, int nargs, char **argv);
void write() override;
};
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -27,7 +27,7 @@ Copyright 2022 Yury Lysogorskiy^1, Anton Bochkarev^1, Matous Mrovec^1, Ralf Drau
#include <cstdlib>
#include <cstring>
#include <mpi.h>
#include "pair_pace_al.h"
#include "pair_pace_extrapolation.h"
#include "atom.h"
#include "dump_custom.h"
#include "neighbor.h"
@ -47,7 +47,7 @@ Copyright 2022 Yury Lysogorskiy^1, Anton Bochkarev^1, Matous Mrovec^1, Ralf Drau
#include "ace_b_basis.h"
#include "ace_recursive.h"
#include "ace_version.h"
#include "compute_pace.h"
#include "compute_pace_extrapolation.h"
namespace LAMMPS_NS {
struct ACEALImpl {
@ -70,9 +70,7 @@ using namespace MathConst;
#define MAXLINE 1024
#define DELTA 4
#define PACE_AL_EXTRAPOLATION_GRADE_FNAME "grade.dat"
#define EXTRAPOLATIVE_STRUCTURES_FNAME "extrapolative_structures.dat"
#define SPECIES_TYPE_FNAME "species_types.dat"
//added YL
@ -96,27 +94,9 @@ int AtomicNumberByName_pace_al(char *elname) {
return -1;
}
/* ----------------------------------------------------------------------
* Append extrapolation grade to file
---------------------------------------------------------------------- */
void dump_extrapolation_grade_header() {
FILE *gamma_file = fopen(PACE_AL_EXTRAPOLATION_GRADE_FNAME, "w");
fprintf(gamma_file, "Step\tgamma\n");
fclose(gamma_file);
}
/* ----------------------------------------------------------------------
* Append extrapolation grade to file
---------------------------------------------------------------------- */
void dump_extrapolation_grade(int timestep, double gamma) {
FILE *gamma_file = fopen(PACE_AL_EXTRAPOLATION_GRADE_FNAME, "a");
fprintf(gamma_file, "%d\t%f\n", timestep, gamma);
fclose(gamma_file);
}
/* ---------------------------------------------------------------------- */
PairPACEActiveLearning::PairPACEActiveLearning(LAMMPS *lmp) : Pair(lmp) {
PairPACEExtrapolation::PairPACEExtrapolation(LAMMPS *lmp) : Pair(lmp) {
single_enable = 0;
restartinfo = 0;
one_coeff = 1;
@ -133,7 +113,7 @@ PairPACEActiveLearning::PairPACEActiveLearning(LAMMPS *lmp) : Pair(lmp) {
check if allocated, since class can be destructed when incomplete
------------------------------------------------------------------------- */
PairPACEActiveLearning::~PairPACEActiveLearning() {
PairPACEExtrapolation::~PairPACEExtrapolation() {
if (copymode) return;
delete aceimpl;
@ -145,18 +125,11 @@ PairPACEActiveLearning::~PairPACEActiveLearning() {
memory->destroy(map);
memory->destroy(extrapolation_grade_gamma);
}
if (dump) {
delete dump;
dump = nullptr;
}
//computePaceAtom will be deleted by lmp->modify, as it was registered there
}
/* ---------------------------------------------------------------------- */
void PairPACEActiveLearning::compute(int eflag, int vflag) {
void PairPACEExtrapolation::compute(int eflag, int vflag) {
int i, j, ii, jj, inum, jnum;
double delx, dely, delz, evdwl;
double fij[3];
@ -192,9 +165,7 @@ void PairPACEActiveLearning::compute(int eflag, int vflag) {
firstneigh = list->firstneigh;
if (inum != nlocal) {
char str[128];
snprintf(str, 128, "inum: %d nlocal: %d are different", inum, nlocal);
error->all(FLERR, str);
error->all(FLERR, "inum: %d nlocal: %d are different", inum, nlocal);
}
//grow extrapolation_grade_gamma array, that store per-atom extrapolation grades
@ -270,6 +241,8 @@ void PairPACEActiveLearning::compute(int eflag, int vflag) {
Array2D<DOUBLE_TYPE> &neighbours_forces = (is_bevaluator ? aceimpl->ace->neighbours_forces
: aceimpl->rec_ace->neighbours_forces);
//optionally assign global forces arrays
if (is_set_energies_forces) {
for (jj = 0; jj < jnum; jj++) {
j = jlist[jj];
const int jtype = type[j];
@ -296,9 +269,10 @@ void PairPACEActiveLearning::compute(int eflag, int vflag) {
fij[0], fij[1], fij[2],
-delx, -dely, -delz);
}
}
// tally energy contribution
if (eflag) {
if (eflag && is_set_energies_forces) {
// evdwl = energy of atom I
DOUBLE_TYPE e_atom;
if (is_bevaluator)
@ -313,17 +287,12 @@ void PairPACEActiveLearning::compute(int eflag, int vflag) {
if (vflag_fdotr) virial_fdotr_compute();
//TODO: check correctness of MPI usage
if (is_bevaluator) {
//gather together max_gamma_grade_per_structure
MPI_Allreduce(&max_gamma_grade, &max_gamma_grade_per_structure, 1, MPI_DOUBLE, MPI_MAX, world);
// check if gamma_upper_bound is exceeded
if (max_gamma_grade_per_structure > gamma_upper_bound) {
if (comm->me == 0)
dump_extrapolation_grade(update->ntimestep, max_gamma_grade_per_structure);
if (is_dump_extrapolative_structures) dump->write();
MPI_Barrier(world);
if (comm->me == 0)
error->all(FLERR,
"Extrapolation grade is too large (gamma={:.3f} > gamma_upper_bound={:.3f}, timestep={}), stopping...\n",
@ -332,11 +301,6 @@ void PairPACEActiveLearning::compute(int eflag, int vflag) {
MPI_Barrier(world);
MPI_Abort(world, 1); //abort properly with error code '1' if not using many processes
exit(EXIT_FAILURE);
} else if (max_gamma_grade_per_structure > gamma_lower_bound) {
if (comm->me == 0)
dump_extrapolation_grade(update->ntimestep, max_gamma_grade_per_structure);
if (is_dump_extrapolative_structures)
dump->write();
}
}
@ -345,7 +309,7 @@ void PairPACEActiveLearning::compute(int eflag, int vflag) {
/* ---------------------------------------------------------------------- */
void PairPACEActiveLearning::allocate() {
void PairPACEExtrapolation::allocate() {
allocated = 1;
int n = atom->ntypes;
@ -359,11 +323,10 @@ void PairPACEActiveLearning::allocate() {
global settings
------------------------------------------------------------------------- */
void PairPACEActiveLearning::settings(int narg, char **arg) {
//TODO: make keyword base interface: pair_style pace/al freq 100 gamma_lo 1.5 gamma_hi 10 dump yes
if (narg > 4) {
void PairPACEExtrapolation::settings(int narg, char **arg) {
if (narg > 3) {
error->all(FLERR,
"Illegal pair_style command. Correct form:\n\tpair_style pace/al [gamma_lower_bound] [gamma_upper_bound] [freq] [nodump]");
"Illegal pair_style command. Correct form:\n\tpair_style pace/al [gamma_lower_bound] [gamma_upper_bound] [freq]");
}
if (narg > 0) {
@ -391,25 +354,11 @@ void PairPACEActiveLearning::settings(int narg, char **arg) {
"Illegal gamma_grade_eval_freq value: it should be integer number >= 1");
}
if (narg > 3) {
//default value is_dump_extrapolative_structures = false
if (strcmp(arg[3], "nodump") == 0) is_dump_extrapolative_structures = false;
if (strcmp(arg[3], "dump") == 0) is_dump_extrapolative_structures = true;
}
if (comm->me == 0) {
if (screen) {
utils::logmesg(lmp, "ACE/AL version: {}.{}.{}\n", VERSION_YEAR, VERSION_MONTH, VERSION_DAY);
utils::logmesg(lmp, "Extrapolation grade thresholds (lower/upper): {}/{}\n", gamma_lower_bound,
gamma_upper_bound);
utils::logmesg(lmp, "Extrapolation grade evaluation frequency: {}\n", gamma_grade_eval_freq);
if (is_dump_extrapolative_structures)
utils::logmesg(lmp, "Extrapolative structures will be dumped into {}\n",
EXTRAPOLATIVE_STRUCTURES_FNAME);
else
utils::logmesg(lmp, "No extrapolative structures will be dumped\n");
}
}
}
@ -417,7 +366,7 @@ void PairPACEActiveLearning::settings(int narg, char **arg) {
set coeffs for one or more type pairs
------------------------------------------------------------------------- */
void PairPACEActiveLearning::coeff(int narg, char **arg) {
void PairPACEExtrapolation::coeff(int narg, char **arg) {
if (narg < 5)
error->all(FLERR,
@ -471,12 +420,12 @@ void PairPACEActiveLearning::coeff(int narg, char **arg) {
aceimpl->rec_ace->element_type_mapping.fill(-1); //-1 means atom not included into potential
FILE *species_type_file = nullptr;
if (is_dump_extrapolative_structures)
species_type_file = fopen(SPECIES_TYPE_FNAME, "w");
const int n = atom->ntypes;
element_names.resize(n);
for (int i = 1; i <= n; i++) {
char *elemname = elemtypes[i - 1];
element_names[i - 1] = elemname;
if (strcmp(elemname, "NULL") == 0) {
// species_type=-1 value will not reach ACE Evaluator::compute_atom,
// but if it will ,then error will be thrown there
@ -485,7 +434,6 @@ void PairPACEActiveLearning::coeff(int narg, char **arg) {
if (comm->me == 0) utils::logmesg(lmp, "Skipping LAMMPS atom type #{}(NULL)\n", i);
} else {
// dump species types for reconstruction of atomic configurations
if (is_dump_extrapolative_structures) fprintf(species_type_file, "%s ", elemname);
int atomic_number = AtomicNumberByName_pace_al(elemname);
if (atomic_number == -1) error->all(FLERR, "'{}' is not a valid element\n", elemname);
SPECIES_TYPE mu = aceimpl->basis_set->get_species_index_by_name(elemname);
@ -503,7 +451,7 @@ void PairPACEActiveLearning::coeff(int narg, char **arg) {
}
}
}
if (is_dump_extrapolative_structures) fclose(species_type_file);
aceimpl->ace->set_basis(*aceimpl->basis_set);
aceimpl->rec_ace->set_basis(*aceimpl->ctilde_basis_set);
@ -515,59 +463,13 @@ void PairPACEActiveLearning::coeff(int narg, char **arg) {
for (int j = i; j <= n; j++)
scale[i][j] = 1.0;
// prepare compute gamma
if (!computePaceAtom) {
// compute pace all pace/atom
char **computeargs = new char *[3];
computeargs[0] = (char *) "pace_gamma"; //name
computeargs[1] = (char *) "all"; // atoms group
computeargs[2] = (char *) "pace/atom"; //compute style
computePaceAtom = new ComputePaceAtom(lmp, 3, computeargs);
computePaceAtom->init();
// mimic behaviour from Modify::add_compute
modify->compute[modify->ncompute] = computePaceAtom;
//TODO: modify->compute_list is protected!!!
// modify->compute_list = std::vector<Compute *>(modify->compute, modify->compute + modify->ncompute + 1);
modify->ncompute++;
}
// prepare dump class
if (is_dump_extrapolative_structures && !dump) {
// dump pace all custom freq extrapolation.dat id type mass x y z
char **dumpargs = new char *[12];
dumpargs[0] = (char *) "pace"; // dump id
dumpargs[1] = (char *) "all"; // group
dumpargs[2] = (char *) "custom"; // dump style
dumpargs[3] = (char *) "1"; // dump frequency
dumpargs[4] = (char *) EXTRAPOLATIVE_STRUCTURES_FNAME; // fname
dumpargs[5] = (char *) "id";
dumpargs[6] = (char *) "type";
dumpargs[7] = (char *) "mass";
dumpargs[8] = (char *) "x";
dumpargs[9] = (char *) "y";
dumpargs[10] = (char *) "z";
dumpargs[11] = (char *) "c_pace_gamma";
dump = new DumpCustom(lmp, 12, dumpargs);
dump->init();
// dump_modify WRITE_DUMP element X Y Z
char **dumpargs3 = new char *[atom->ntypes + 1];
dumpargs3[0] = (char *) "element";
for (int k = 0; k < atom->ntypes; k++)
dumpargs3[k + 1] = elemtypes[k];
dump->modify_params(atom->ntypes + 1, dumpargs3);
}
// write extrapolation_grade.dat file header
if (comm->me == 0)
dump_extrapolation_grade_header();
}
/* ----------------------------------------------------------------------
init specific to this pair style
------------------------------------------------------------------------- */
void PairPACEActiveLearning::init_style() {
void PairPACEExtrapolation::init_style() {
if (atom->tag_enable == 0)
error->all(FLERR, "Pair style PACE requires atom IDs");
if (force->newton_pair == 0)
@ -581,7 +483,7 @@ void PairPACEActiveLearning::init_style() {
init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */
double PairPACEActiveLearning::init_one(int i, int j) {
double PairPACEExtrapolation::init_one(int i, int j) {
if (setflag[i][j] == 0) error->all(FLERR, "All pair coeffs are not set");
//cutoff from the basis set's radial functions settings
scale[j][i] = scale[i][j];
@ -591,7 +493,7 @@ double PairPACEActiveLearning::init_one(int i, int j) {
/* ----------------------------------------------------------------------
extract method for extracting value of scale variable
---------------------------------------------------------------------- */
void *PairPACEActiveLearning::extract(const char *str, int &dim) {
void *PairPACEExtrapolation::extract(const char *str, int &dim) {
dim = 2;
if (strcmp(str, "scale") == 0) return (void *) scale;
return nullptr;

View File

@ -9,8 +9,7 @@
------------------------------------------------------------------------- */
/*
Copyright 2022 Yury Lysogorskiy^1, Anton Bochkarev^1,
Matous Mrovec^1, Ralf Drautz^1
Copyright 2022 Yury Lysogorskiy^1, Anton Bochkarev^1, Matous Mrovec^1, Ralf Drautz^1
^1: Ruhr-University Bochum, Bochum, Germany
*/
@ -22,7 +21,7 @@ Copyright 2022 Yury Lysogorskiy^1, Anton Bochkarev^1,
#ifdef PAIR_CLASS
// clang-format off
PairStyle(pace/al,PairPACEActiveLearning)
PairStyle(pace/extrapolation,PairPACEExtrapolation)
// clang-format on
#else
@ -30,18 +29,22 @@ PairStyle(pace/al,PairPACEActiveLearning)
#define LMP_PAIR_PACE_AL_H
#include "pair.h"
#include "dump_custom.h"
#include "compute_pace.h"
#include <vector>
namespace LAMMPS_NS {
class PairPACEActiveLearning : public Pair {
friend class ComputePaceAtom;
//forward declaration
class ComputePACEExtrapolation;
class DumpPACEExtrapolation;
class PairPACEExtrapolation : public Pair {
friend class ComputePACEExtrapolation;
friend class DumpPACEExtrapolation;
public:
PairPACEActiveLearning(class LAMMPS *);
PairPACEExtrapolation(class LAMMPS *);
~PairPACEActiveLearning() override;
~PairPACEExtrapolation() override;
void compute(int, int) override;
@ -57,23 +60,16 @@ namespace LAMMPS_NS {
protected:
struct ACEALImpl *aceimpl;
int gamma_grade_eval_freq = 1;
bool is_dump_extrapolative_structures = false;
DumpCustom *dump = nullptr;
Compute *computePaceAtom = nullptr;
bool is_set_energies_forces = true; // if set, then update forces and energies
int natoms; //total number of atoms
double gamma_lower_bound = 1.5;
double gamma_upper_bound = 10;
double max_gamma_grade_per_structure = 0;
virtual void allocate();
void read_files(char *, char *);
inline int equal(double *x, double *y);
void allocate();
std::vector<std::string> element_names; // list of elements (used by dump pace/extrapolation)
double rcutmax; // max cutoff for all elements
int nelements; // # of unique elements
int bevaluator_timestep; // timestep, on which gamma grade were computed