simplify more code for creating fix instances using the improved APIs
This commit is contained in:
@ -309,113 +309,16 @@ void FixReaxFFSpecies::init()
|
|||||||
|
|
||||||
if (!setupflag) {
|
if (!setupflag) {
|
||||||
// create a compute to store properties
|
// create a compute to store properties
|
||||||
create_compute();
|
modify->add_compute("SPECATOM all SPEC/ATOM q x y z vx vy vz abo01 abo02 abo03 abo04 "
|
||||||
|
"abo05 abo06 abo07 abo08 abo09 abo10 abo11 abo12 abo13 abo14 "
|
||||||
|
"abo15 abo16 abo17 abo18 abo19 abo20 abo21 abo22 abo23 abo24");
|
||||||
|
|
||||||
// create a fix to point to fix_ave_atom for averaging stored properties
|
// create a fix to point to fix_ave_atom for averaging stored properties
|
||||||
create_fix();
|
auto fixcmd = fmt::format("SPECBOND all ave/atom {} {} {}",tmparg[0],tmparg[1],tmparg[2]);
|
||||||
|
for (int i = 1; i < 32; ++i) fixcmd += " c_SPECATOM[" + std::to_string(i) + "]";
|
||||||
|
f_SPECBOND = (FixAveAtom *) modify->add_fix(fixcmd);
|
||||||
setupflag = 1;
|
setupflag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void FixReaxFFSpecies::create_compute()
|
|
||||||
{
|
|
||||||
int narg;
|
|
||||||
char **args;
|
|
||||||
|
|
||||||
narg = 34;
|
|
||||||
args = new char*[narg];
|
|
||||||
args[0] = (char *) "SPECATOM";
|
|
||||||
args[1] = (char *) "all";
|
|
||||||
args[2] = (char *) "SPEC/ATOM";
|
|
||||||
args[3] = (char *) "q";
|
|
||||||
args[4] = (char *) "x";
|
|
||||||
args[5] = (char *) "y";
|
|
||||||
args[6] = (char *) "z";
|
|
||||||
args[7] = (char *) "vx";
|
|
||||||
args[8] = (char *) "vy";
|
|
||||||
args[9] = (char *) "vz";
|
|
||||||
args[10] = (char *) "abo01";
|
|
||||||
args[11] = (char *) "abo02";
|
|
||||||
args[12] = (char *) "abo03";
|
|
||||||
args[13] = (char *) "abo04";
|
|
||||||
args[14] = (char *) "abo05";
|
|
||||||
args[15] = (char *) "abo06";
|
|
||||||
args[16] = (char *) "abo07";
|
|
||||||
args[17] = (char *) "abo08";
|
|
||||||
args[18] = (char *) "abo09";
|
|
||||||
args[19] = (char *) "abo10";
|
|
||||||
args[20] = (char *) "abo11";
|
|
||||||
args[21] = (char *) "abo12";
|
|
||||||
args[22] = (char *) "abo13";
|
|
||||||
args[23] = (char *) "abo14";
|
|
||||||
args[24] = (char *) "abo15";
|
|
||||||
args[25] = (char *) "abo16";
|
|
||||||
args[26] = (char *) "abo17";
|
|
||||||
args[27] = (char *) "abo18";
|
|
||||||
args[28] = (char *) "abo19";
|
|
||||||
args[29] = (char *) "abo20";
|
|
||||||
args[30] = (char *) "abo21";
|
|
||||||
args[31] = (char *) "abo22";
|
|
||||||
args[32] = (char *) "abo23";
|
|
||||||
args[33] = (char *) "abo24";
|
|
||||||
modify->add_compute(narg,args);
|
|
||||||
delete [] args;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void FixReaxFFSpecies::create_fix()
|
|
||||||
{
|
|
||||||
int narg;
|
|
||||||
char **args;
|
|
||||||
|
|
||||||
narg = 37;
|
|
||||||
args = new char*[narg];
|
|
||||||
args[0] = (char *) "SPECBOND";
|
|
||||||
args[1] = (char *) "all";
|
|
||||||
args[2] = (char *) "ave/atom";
|
|
||||||
args[3] = tmparg[0];
|
|
||||||
args[4] = tmparg[1];
|
|
||||||
args[5] = tmparg[2];
|
|
||||||
args[6] = (char *) "c_SPECATOM[1]"; // q, array_atoms[i][0]
|
|
||||||
args[7] = (char *) "c_SPECATOM[2]"; // x, 1
|
|
||||||
args[8] = (char *) "c_SPECATOM[3]"; // y, 2
|
|
||||||
args[9] = (char *) "c_SPECATOM[4]"; // z, 3
|
|
||||||
args[10] = (char *) "c_SPECATOM[5]"; // vx, 4
|
|
||||||
args[11] = (char *) "c_SPECATOM[6]"; // vy, 5
|
|
||||||
args[12] = (char *) "c_SPECATOM[7]"; // vz, 6
|
|
||||||
args[13] = (char *) "c_SPECATOM[8]"; // abo01, 7
|
|
||||||
args[14] = (char *) "c_SPECATOM[9]";
|
|
||||||
args[15] = (char *) "c_SPECATOM[10]";
|
|
||||||
args[16] = (char *) "c_SPECATOM[11]";
|
|
||||||
args[17] = (char *) "c_SPECATOM[12]";
|
|
||||||
args[18] = (char *) "c_SPECATOM[13]";
|
|
||||||
args[19] = (char *) "c_SPECATOM[14]";
|
|
||||||
args[20] = (char *) "c_SPECATOM[15]";
|
|
||||||
args[21] = (char *) "c_SPECATOM[16]";
|
|
||||||
args[22] = (char *) "c_SPECATOM[17]";
|
|
||||||
args[23] = (char *) "c_SPECATOM[18]";
|
|
||||||
args[24] = (char *) "c_SPECATOM[19]"; // abo12, 18
|
|
||||||
args[25] = (char *) "c_SPECATOM[20]";
|
|
||||||
args[26] = (char *) "c_SPECATOM[21]";
|
|
||||||
args[27] = (char *) "c_SPECATOM[22]";
|
|
||||||
args[28] = (char *) "c_SPECATOM[23]";
|
|
||||||
args[29] = (char *) "c_SPECATOM[24]";
|
|
||||||
args[30] = (char *) "c_SPECATOM[25]";
|
|
||||||
args[31] = (char *) "c_SPECATOM[26]";
|
|
||||||
args[32] = (char *) "c_SPECATOM[27]";
|
|
||||||
args[33] = (char *) "c_SPECATOM[28]";
|
|
||||||
args[34] = (char *) "c_SPECATOM[29]";
|
|
||||||
args[35] = (char *) "c_SPECATOM[30]";
|
|
||||||
args[36] = (char *) "c_SPECATOM[31]";
|
|
||||||
modify->add_fix(narg,args);
|
|
||||||
f_SPECBOND = (FixAveAtom *) modify->fix[modify->nfix-1];
|
|
||||||
delete [] args;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -61,8 +61,6 @@ class FixReaxFFSpecies : public Fix {
|
|||||||
char *ele, **eletype, *filepos;
|
char *ele, **eletype, *filepos;
|
||||||
|
|
||||||
void Output_ReaxFF_Bonds(bigint, FILE *);
|
void Output_ReaxFF_Bonds(bigint, FILE *);
|
||||||
void create_compute();
|
|
||||||
void create_fix();
|
|
||||||
AtomCoord chAnchor(AtomCoord, AtomCoord);
|
AtomCoord chAnchor(AtomCoord, AtomCoord);
|
||||||
virtual void FindMolecule();
|
virtual void FindMolecule();
|
||||||
void SortMolecule(int &);
|
void SortMolecule(int &);
|
||||||
@ -82,7 +80,6 @@ class FixReaxFFSpecies : public Fix {
|
|||||||
class NeighList *list;
|
class NeighList *list;
|
||||||
class FixAveAtom *f_SPECBOND;
|
class FixAveAtom *f_SPECBOND;
|
||||||
class PairReaxFF *reaxff;
|
class PairReaxFF *reaxff;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -368,10 +368,8 @@ void PairReaxFF::init_style()
|
|||||||
error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an "
|
error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an "
|
||||||
"increased neighbor list skin.");
|
"increased neighbor list skin.");
|
||||||
|
|
||||||
if (fix_reaxff == nullptr) {
|
if (fix_reaxff == nullptr)
|
||||||
modify->add_fix(fmt::format("{} all REAXFF",fix_id));
|
fix_reaxff = (FixReaxFF *) modify->add_fix(fmt::format("{} all REAXFF",fix_id));
|
||||||
fix_reaxff = (FixReaxFF *) modify->fix[modify->nfix-1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -101,8 +101,7 @@ void Hyper::command(int narg, char **arg)
|
|||||||
|
|
||||||
// create FixEventHyper class to store event and pre-quench states
|
// create FixEventHyper class to store event and pre-quench states
|
||||||
|
|
||||||
modify->add_fix("hyper_event all EVENT/HYPER");
|
fix_event = (FixEventHyper *) modify->add_fix("hyper_event all EVENT/HYPER");
|
||||||
fix_event = (FixEventHyper *) modify->fix[modify->nfix-1];
|
|
||||||
|
|
||||||
// create Finish for timing output
|
// create Finish for timing output
|
||||||
|
|
||||||
|
|||||||
@ -145,8 +145,7 @@ void PRD::command(int narg, char **arg)
|
|||||||
|
|
||||||
// create ComputeTemp class to monitor temperature
|
// create ComputeTemp class to monitor temperature
|
||||||
|
|
||||||
modify->add_compute("prd_temp all temp");
|
temperature = modify->add_compute("prd_temp all temp");
|
||||||
temperature = modify->compute[modify->ncompute-1];
|
|
||||||
|
|
||||||
// create Velocity class for velocity creation in dephasing
|
// create Velocity class for velocity creation in dephasing
|
||||||
// pass it temperature compute, loop_setting, dist_setting settings
|
// pass it temperature compute, loop_setting, dist_setting settings
|
||||||
@ -168,8 +167,7 @@ void PRD::command(int narg, char **arg)
|
|||||||
|
|
||||||
// create FixEventPRD class to store event and pre-quench states
|
// create FixEventPRD class to store event and pre-quench states
|
||||||
|
|
||||||
modify->add_fix("prd_event all EVENT/PRD");
|
fix_event = (FixEventPRD *) modify->add_fix("prd_event all EVENT/PRD");
|
||||||
fix_event = (FixEventPRD *) modify->fix[modify->nfix-1];
|
|
||||||
|
|
||||||
// create Finish for timing output
|
// create Finish for timing output
|
||||||
|
|
||||||
|
|||||||
@ -131,28 +131,11 @@ void TAD::command(int narg, char **arg)
|
|||||||
|
|
||||||
// create FixEventTAD object to store last event
|
// create FixEventTAD object to store last event
|
||||||
|
|
||||||
int narg2 = 3;
|
fix_event = (FixEventTAD *) modify->add_fix("tad_event all EVENT/TAD");
|
||||||
char **args = new char*[narg2];
|
|
||||||
args[0] = (char *) "tad_event";
|
|
||||||
args[1] = (char *) "all";
|
|
||||||
args[2] = (char *) "EVENT/TAD";
|
|
||||||
modify->add_fix(narg2,args);
|
|
||||||
fix_event = (FixEventTAD *) modify->fix[modify->nfix-1];
|
|
||||||
delete [] args;
|
|
||||||
|
|
||||||
// create FixStore object to store revert state
|
// create FixStore object to store revert state
|
||||||
|
|
||||||
narg2 = 6;
|
fix_revert = (FixStore *) modify->add_fix("tad_revert all STORE peratom 0 7");
|
||||||
args = new char*[narg2];
|
|
||||||
args[0] = (char *) "tad_revert";
|
|
||||||
args[1] = (char *) "all";
|
|
||||||
args[2] = (char *) "STORE";
|
|
||||||
args[3] = (char *) "peratom";
|
|
||||||
args[4] = (char *) "0";
|
|
||||||
args[5] = (char *) "7";
|
|
||||||
modify->add_fix(narg2,args);
|
|
||||||
fix_revert = (FixStore *) modify->fix[modify->nfix-1];
|
|
||||||
delete [] args;
|
|
||||||
|
|
||||||
// create Finish for timing output
|
// create Finish for timing output
|
||||||
|
|
||||||
@ -195,13 +178,10 @@ void TAD::command(int narg, char **arg)
|
|||||||
|
|
||||||
// set minimize style for quench
|
// set minimize style for quench
|
||||||
|
|
||||||
narg2 = 1;
|
char *args[1];
|
||||||
args = new char*[narg2];
|
|
||||||
args[0] = min_style;
|
args[0] = min_style;
|
||||||
|
|
||||||
update->create_minimize(narg2,args,1);
|
update->create_minimize(1,args,1);
|
||||||
|
|
||||||
delete [] args;
|
|
||||||
|
|
||||||
// init minimizer settings and minimizer itself
|
// init minimizer settings and minimizer itself
|
||||||
|
|
||||||
@ -691,25 +671,13 @@ void TAD::perform_neb(int ievent)
|
|||||||
|
|
||||||
// create FixNEB object to support NEB
|
// create FixNEB object to support NEB
|
||||||
|
|
||||||
int narg2 = 4;
|
fix_neb = (Fix *) modify->add_fix("neb all neb 1.0");
|
||||||
char **args = new char*[narg2];
|
|
||||||
args[0] = (char *) "neb";
|
|
||||||
args[1] = (char *) "all";
|
|
||||||
args[2] = (char *) "neb";
|
|
||||||
args[3] = (char *) "1.0";
|
|
||||||
modify->add_fix(narg2,args);
|
|
||||||
fix_neb = (Fix *) modify->fix[modify->nfix-1];
|
|
||||||
delete [] args;
|
|
||||||
|
|
||||||
// switch minimize style to quickmin for NEB
|
// switch minimize style to quickmin for NEB
|
||||||
|
|
||||||
narg2 = 1;
|
char *args[1];
|
||||||
args = new char*[narg2];
|
|
||||||
args[0] = min_style_neb;
|
args[0] = min_style_neb;
|
||||||
|
update->create_minimize(1,args,1);
|
||||||
update->create_minimize(narg2,args,1);
|
|
||||||
|
|
||||||
delete [] args;
|
|
||||||
|
|
||||||
// create NEB object
|
// create NEB object
|
||||||
|
|
||||||
@ -769,17 +737,12 @@ void TAD::perform_neb(int ievent)
|
|||||||
|
|
||||||
// switch minimize style back for quench
|
// switch minimize style back for quench
|
||||||
|
|
||||||
narg2 = 1;
|
|
||||||
args = new char*[narg2];
|
|
||||||
args[0] = min_style;
|
args[0] = min_style;
|
||||||
|
update->create_minimize(1,args,1);
|
||||||
update->create_minimize(narg2,args,1);
|
|
||||||
|
|
||||||
update->etol = etol;
|
update->etol = etol;
|
||||||
update->ftol = ftol;
|
update->ftol = ftol;
|
||||||
|
|
||||||
delete [] args;
|
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
|
|
||||||
modify->delete_fix("neb");
|
modify->delete_fix("neb");
|
||||||
@ -895,25 +858,14 @@ void TAD::delete_event_list() {
|
|||||||
|
|
||||||
void TAD::add_event()
|
void TAD::add_event()
|
||||||
{
|
{
|
||||||
|
if (n_event_list == nmax_event_list)
|
||||||
|
grow_event_list(nmax_event_list+nmin_event_list);
|
||||||
|
|
||||||
// create FixEventTAD object to store possible event
|
// create FixEventTAD object to store possible event
|
||||||
|
|
||||||
int narg = 3;
|
int ievent = n_event_list++;
|
||||||
char **args = new char*[narg];
|
fix_event_list[ievent]
|
||||||
|
= (FixEventTAD *) modify->add_fix(fmt::format("tad_event_{} all EVENT/TAD", ievent));
|
||||||
char str[128];
|
|
||||||
sprintf(str,"tad_event_%d",n_event_list);
|
|
||||||
|
|
||||||
args[0] = str;
|
|
||||||
args[1] = (char *) "all";
|
|
||||||
args[2] = (char *) "EVENT/TAD";
|
|
||||||
modify->add_fix(narg,args);
|
|
||||||
|
|
||||||
if (n_event_list == nmax_event_list)
|
|
||||||
grow_event_list(nmax_event_list+nmin_event_list);
|
|
||||||
n_event_list += 1;
|
|
||||||
int ievent = n_event_list-1;
|
|
||||||
fix_event_list[ievent] = (FixEventTAD *) modify->fix[modify->nfix-1];
|
|
||||||
|
|
||||||
// store quenched state for new event
|
// store quenched state for new event
|
||||||
|
|
||||||
@ -923,11 +875,6 @@ void TAD::add_event()
|
|||||||
|
|
||||||
fix_event->restore_state_quench();
|
fix_event->restore_state_quench();
|
||||||
fix_event_list[ievent]->store_state_quench();
|
fix_event_list[ievent]->store_state_quench();
|
||||||
|
|
||||||
// string clean-up
|
|
||||||
|
|
||||||
delete [] args;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user