Merge branch 'collected-small-changes' of github.com:akohlmey/lammps into collected-small-changes
This commit is contained in:
@ -499,10 +499,13 @@ void PairEAMCD::read_h_coeff(char *filename)
|
|||||||
// Seek to end of file, read last part into a buffer and
|
// Seek to end of file, read last part into a buffer and
|
||||||
// then skip over lines in buffer until reaching the end.
|
// then skip over lines in buffer until reaching the end.
|
||||||
|
|
||||||
platform::fseek(fptr, platform::END_OF_FILE);
|
if ( (platform::fseek(fptr, platform::END_OF_FILE) < 0)
|
||||||
platform::fseek(fptr, platform::ftell(fptr) - MAXLINE);
|
|| (platform::fseek(fptr, platform::ftell(fptr) - MAXLINE) < 0))
|
||||||
|
error->one(FLERR,"Failure to seek to end-of-file for reading h(x) coeffs: {}",
|
||||||
|
utils::getsyserror());
|
||||||
|
|
||||||
char *buf = new char[MAXLINE+1];
|
char *buf = new char[MAXLINE+1];
|
||||||
fread(buf, 1, MAXLINE, fptr);
|
utils::sfread(FLERR, buf, 1, MAXLINE, fptr, filename, error);
|
||||||
buf[MAXLINE] = '\0'; // must 0-terminate buffer for string processing
|
buf[MAXLINE] = '\0'; // must 0-terminate buffer for string processing
|
||||||
Tokenizer lines(buf, "\n");
|
Tokenizer lines(buf, "\n");
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
|
|||||||
@ -246,8 +246,10 @@ FixReaxFFSpecies::~FixReaxFFSpecies()
|
|||||||
if (posflag && multipos_opened) fclose(pos);
|
if (posflag && multipos_opened) fclose(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
modify->delete_compute(fmt::format("SPECATOM_{}",id));
|
try {
|
||||||
modify->delete_fix(fmt::format("SPECBOND_{}",id));
|
modify->delete_compute(fmt::format("SPECATOM_{}",id));
|
||||||
|
modify->delete_fix(fmt::format("SPECBOND_{}",id));
|
||||||
|
} catch (std::exception &) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -522,7 +522,7 @@ void FixMove::initial_integrate(int /*vflag*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for wiggle: X = X0 + A sin(w*dt)
|
// for wiggle: X = X0 + A sin(w*dt)
|
||||||
|
|
||||||
} else if (mstyle == WIGGLE) {
|
} else if (mstyle == WIGGLE) {
|
||||||
double arg = omega_rotate * delta;
|
double arg = omega_rotate * delta;
|
||||||
@ -578,19 +578,19 @@ void FixMove::initial_integrate(int /*vflag*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for rotate by right-hand rule around omega:
|
// for rotate by right-hand rule around omega:
|
||||||
// P = point = vector = point of rotation
|
// P = point = vector = point of rotation
|
||||||
// R = vector = axis of rotation
|
// R = vector = axis of rotation
|
||||||
// w = omega of rotation (from period)
|
// w = omega of rotation (from period)
|
||||||
// X0 = xoriginal = initial coord of atom
|
// X0 = xoriginal = initial coord of atom
|
||||||
// R0 = runit = unit vector for R
|
// R0 = runit = unit vector for R
|
||||||
// D = X0 - P = vector from P to X0
|
// D = X0 - P = vector from P to X0
|
||||||
// C = (D dot R0) R0 = projection of atom coord onto R line
|
// C = (D dot R0) R0 = projection of atom coord onto R line
|
||||||
// A = D - C = vector from R line to X0
|
// A = D - C = vector from R line to X0
|
||||||
// B = R0 cross A = vector perp to A in plane of rotation
|
// B = R0 cross A = vector perp to A in plane of rotation
|
||||||
// A,B define plane of circular rotation around R line
|
// A,B define plane of circular rotation around R line
|
||||||
// X = P + C + A cos(w*dt) + B sin(w*dt)
|
// X = P + C + A cos(w*dt) + B sin(w*dt)
|
||||||
// V = w R0 cross (A cos(w*dt) + B sin(w*dt))
|
// V = w R0 cross (A cos(w*dt) + B sin(w*dt))
|
||||||
|
|
||||||
} else if (mstyle == ROTATE) {
|
} else if (mstyle == ROTATE) {
|
||||||
double arg = omega_rotate * delta;
|
double arg = omega_rotate * delta;
|
||||||
@ -707,10 +707,10 @@ void FixMove::initial_integrate(int /*vflag*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for variable: compute x,v from variables
|
// for variable: compute x,v from variables
|
||||||
// NOTE: also allow for changes to extra attributes?
|
// NOTE: also allow for changes to extra attributes?
|
||||||
// omega, angmom, theta, quat
|
// omega, angmom, theta, quat
|
||||||
// only necessary if prescribed motion involves rotation
|
// only necessary if prescribed motion involves rotation
|
||||||
|
|
||||||
} else if (mstyle == VARIABLE) {
|
} else if (mstyle == VARIABLE) {
|
||||||
|
|
||||||
@ -778,21 +778,16 @@ void FixMove::initial_integrate(int /*vflag*/)
|
|||||||
} else if (vxvarstr) {
|
} else if (vxvarstr) {
|
||||||
if (vxvarstyle == EQUAL) v[i][0] = vx;
|
if (vxvarstyle == EQUAL) v[i][0] = vx;
|
||||||
else v[i][0] = velocity[i][0];
|
else v[i][0] = velocity[i][0];
|
||||||
if (rmass) {
|
x[i][0] += dtv * v[i][0];
|
||||||
x[i][0] += dtv * v[i][0];
|
|
||||||
} else {
|
|
||||||
x[i][0] += dtv * v[i][0];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (rmass) {
|
if (rmass) {
|
||||||
dtfm = dtf / rmass[i];
|
dtfm = dtf / rmass[i];
|
||||||
v[i][0] += dtfm * f[i][0];
|
v[i][0] += dtfm * f[i][0];
|
||||||
x[i][0] += dtv * v[i][0];
|
|
||||||
} else {
|
} else {
|
||||||
dtfm = dtf / mass[type[i]];
|
dtfm = dtf / mass[type[i]];
|
||||||
v[i][0] += dtfm * f[i][0];
|
v[i][0] += dtfm * f[i][0];
|
||||||
x[i][0] += dtv * v[i][0];
|
|
||||||
}
|
}
|
||||||
|
x[i][0] += dtv * v[i][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yvarstr && vyvarstr) {
|
if (yvarstr && vyvarstr) {
|
||||||
@ -806,21 +801,16 @@ void FixMove::initial_integrate(int /*vflag*/)
|
|||||||
} else if (vyvarstr) {
|
} else if (vyvarstr) {
|
||||||
if (vyvarstyle == EQUAL) v[i][1] = vy;
|
if (vyvarstyle == EQUAL) v[i][1] = vy;
|
||||||
else v[i][1] = velocity[i][1];
|
else v[i][1] = velocity[i][1];
|
||||||
if (rmass) {
|
x[i][1] += dtv * v[i][1];
|
||||||
x[i][1] += dtv * v[i][1];
|
|
||||||
} else {
|
|
||||||
x[i][1] += dtv * v[i][1];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (rmass) {
|
if (rmass) {
|
||||||
dtfm = dtf / rmass[i];
|
dtfm = dtf / rmass[i];
|
||||||
v[i][1] += dtfm * f[i][1];
|
v[i][1] += dtfm * f[i][1];
|
||||||
x[i][1] += dtv * v[i][1];
|
|
||||||
} else {
|
} else {
|
||||||
dtfm = dtf / mass[type[i]];
|
dtfm = dtf / mass[type[i]];
|
||||||
v[i][1] += dtfm * f[i][1];
|
v[i][1] += dtfm * f[i][1];
|
||||||
x[i][1] += dtv * v[i][1];
|
|
||||||
}
|
}
|
||||||
|
x[i][1] += dtv * v[i][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zvarstr && vzvarstr) {
|
if (zvarstr && vzvarstr) {
|
||||||
@ -834,21 +824,16 @@ void FixMove::initial_integrate(int /*vflag*/)
|
|||||||
} else if (vzvarstr) {
|
} else if (vzvarstr) {
|
||||||
if (vzvarstyle == EQUAL) v[i][2] = vz;
|
if (vzvarstyle == EQUAL) v[i][2] = vz;
|
||||||
else v[i][2] = velocity[i][2];
|
else v[i][2] = velocity[i][2];
|
||||||
if (rmass) {
|
x[i][2] += dtv * v[i][2];
|
||||||
x[i][2] += dtv * v[i][2];
|
|
||||||
} else {
|
|
||||||
x[i][2] += dtv * v[i][2];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (rmass) {
|
if (rmass) {
|
||||||
dtfm = dtf / rmass[i];
|
dtfm = dtf / rmass[i];
|
||||||
v[i][2] += dtfm * f[i][2];
|
v[i][2] += dtfm * f[i][2];
|
||||||
x[i][2] += dtv * v[i][2];
|
|
||||||
} else {
|
} else {
|
||||||
dtfm = dtf / mass[type[i]];
|
dtfm = dtf / mass[type[i]];
|
||||||
v[i][2] += dtfm * f[i][2];
|
v[i][2] += dtfm * f[i][2];
|
||||||
x[i][2] += dtv * v[i][2];
|
|
||||||
}
|
}
|
||||||
|
x[i][2] += dtv * v[i][2];
|
||||||
}
|
}
|
||||||
|
|
||||||
domain->remap_near(x[i],xold);
|
domain->remap_near(x[i],xold);
|
||||||
|
|||||||
@ -41,6 +41,8 @@ using namespace LAMMPS_NS;
|
|||||||
#define DELTA 1
|
#define DELTA 1
|
||||||
#define EPSDT 1.0e-6
|
#define EPSDT 1.0e-6
|
||||||
|
|
||||||
|
enum {SETUP, WRITE, RESET_DT};
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
initialize all output
|
initialize all output
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
@ -232,7 +234,7 @@ void Output::setup(int memflag)
|
|||||||
// only do this if dump written or dump has not been written yet
|
// only do this if dump written or dump has not been written yet
|
||||||
|
|
||||||
if (writeflag || last_dump[idump] < 0)
|
if (writeflag || last_dump[idump] < 0)
|
||||||
calculate_next_dump(0,idump,ntimestep);
|
calculate_next_dump(SETUP,idump,ntimestep);
|
||||||
|
|
||||||
// if dump not written now, use addstep_compute_all()
|
// if dump not written now, use addstep_compute_all()
|
||||||
// since don't know what computes the dump will invoke
|
// since don't know what computes the dump will invoke
|
||||||
@ -361,7 +363,7 @@ void Output::setup(int memflag)
|
|||||||
|
|
||||||
dump[idump]->write();
|
dump[idump]->write();
|
||||||
last_dump[idump] = ntimestep;
|
last_dump[idump] = ntimestep;
|
||||||
calculate_next_dump(1,idump,ntimestep);
|
calculate_next_dump(WRITE,idump,ntimestep);
|
||||||
|
|
||||||
if (mode_dump[idump] == 0 &&
|
if (mode_dump[idump] == 0 &&
|
||||||
(dump[idump]->clearstep || var_dump[idump]))
|
(dump[idump]->clearstep || var_dump[idump]))
|
||||||
@ -468,12 +470,12 @@ void Output::setup(int memflag)
|
|||||||
for timestep mode, set next_dump
|
for timestep mode, set next_dump
|
||||||
for simulation time mode, set next_time_dump and next_dump
|
for simulation time mode, set next_time_dump and next_dump
|
||||||
which flag depends on caller
|
which flag depends on caller
|
||||||
0 = from setup() at start of run
|
SETUP = from setup() at start of run
|
||||||
1 = from write() during run each time a dump file is written
|
WRITE = from write() during run each time a dump file is written
|
||||||
2 = from reset_dt() called from fix dt/reset when it changes timestep size
|
RESET_DT = from reset_dt() called from fix dt/reset when it changes timestep size
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Output::calculate_next_dump(int which, int idump, bigint ntimestep)
|
void Output::calculate_next_dump(int which, int idump, bigint ntimestep)
|
||||||
{
|
{
|
||||||
// dump mode is by timestep
|
// dump mode is by timestep
|
||||||
// just set next_dump
|
// just set next_dump
|
||||||
@ -482,13 +484,13 @@ void Output::setup(int memflag)
|
|||||||
|
|
||||||
if (every_dump[idump]) {
|
if (every_dump[idump]) {
|
||||||
|
|
||||||
// which = 0: nextdump = next multiple of every_dump
|
// which = SETUP: nextdump = next multiple of every_dump
|
||||||
// which = 1: increment nextdump by every_dump
|
// which = WRITE: increment nextdump by every_dump
|
||||||
|
|
||||||
if (which == 0)
|
if (which == SETUP)
|
||||||
next_dump[idump] =
|
next_dump[idump] =
|
||||||
(ntimestep/every_dump[idump])*every_dump[idump] + every_dump[idump];
|
(ntimestep/every_dump[idump])*every_dump[idump] + every_dump[idump];
|
||||||
else if (which == 1)
|
else if (which == WRITE)
|
||||||
next_dump[idump] += every_dump[idump];
|
next_dump[idump] += every_dump[idump];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -510,17 +512,28 @@ void Output::setup(int memflag)
|
|||||||
|
|
||||||
if (every_time_dump[idump] > 0.0) {
|
if (every_time_dump[idump] > 0.0) {
|
||||||
|
|
||||||
// which = 0: nexttime = next multiple of every_time_dump
|
// which = SETUP: nexttime = next multiple of every_time_dump
|
||||||
// which = 1: increment nexttime by every_time_dump
|
// which = WRITE: increment nexttime by every_time_dump
|
||||||
// which = 2: no change to previous nexttime (only timestep has changed)
|
// which = RESET_DT: no change to previous nexttime (only timestep has changed)
|
||||||
|
|
||||||
if (which == 0)
|
switch (which) {
|
||||||
|
case SETUP:
|
||||||
nexttime = static_cast<bigint> (tcurrent/every_time_dump[idump]) *
|
nexttime = static_cast<bigint> (tcurrent/every_time_dump[idump]) *
|
||||||
every_time_dump[idump] + every_time_dump[idump];
|
every_time_dump[idump] + every_time_dump[idump];
|
||||||
else if (which == 1)
|
break;
|
||||||
|
|
||||||
|
case WRITE:
|
||||||
nexttime = next_time_dump[idump] + every_time_dump[idump];
|
nexttime = next_time_dump[idump] + every_time_dump[idump];
|
||||||
else if (which == 2)
|
break;
|
||||||
|
|
||||||
|
case RESET_DT:
|
||||||
nexttime = next_time_dump[idump];
|
nexttime = next_time_dump[idump];
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
nexttime = 0;
|
||||||
|
error->all(FLERR,"Unexpected argument to calculate_next_dump");
|
||||||
|
}
|
||||||
|
|
||||||
nextdump = ntimestep +
|
nextdump = ntimestep +
|
||||||
static_cast<bigint> ((nexttime - tcurrent - EPSDT*update->dt) /
|
static_cast<bigint> ((nexttime - tcurrent - EPSDT*update->dt) /
|
||||||
@ -541,10 +554,10 @@ void Output::setup(int memflag)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// do not re-evaulate variable for which = 2, leave nexttime as-is
|
// do not re-evaulate variable for which = RESET_DT, leave nexttime as-is
|
||||||
// unless next_time_dump < 0.0, which means variable never yet evaluated
|
// unless next_time_dump < 0.0, which means variable never yet evaluated
|
||||||
|
|
||||||
if (which < 2 || next_time_dump[idump] < 0.0) {
|
if (which < RESET_DT || next_time_dump[idump] < 0.0) {
|
||||||
nexttime = input->variable->compute_equal(ivar_dump[idump]);
|
nexttime = input->variable->compute_equal(ivar_dump[idump]);
|
||||||
} else
|
} else
|
||||||
nexttime = next_time_dump[idump];
|
nexttime = next_time_dump[idump];
|
||||||
@ -703,7 +716,7 @@ void Output::reset_dt()
|
|||||||
// since timestep change affects next step
|
// since timestep change affects next step
|
||||||
|
|
||||||
if (next_dump[idump] != ntimestep)
|
if (next_dump[idump] != ntimestep)
|
||||||
calculate_next_dump(2,idump,update->ntimestep);
|
calculate_next_dump(RESET_DT,idump,update->ntimestep);
|
||||||
|
|
||||||
if (dump[idump]->clearstep || var_dump[idump])
|
if (dump[idump]->clearstep || var_dump[idump])
|
||||||
next_time_dump_any = MIN(next_time_dump_any,next_dump[idump]);
|
next_time_dump_any = MIN(next_time_dump_any,next_dump[idump]);
|
||||||
|
|||||||
Reference in New Issue
Block a user