Merge branch 'master' into pair-hybrid-scaled

This commit is contained in:
Axel Kohlmeyer
2021-04-09 22:21:16 -04:00
30 changed files with 335 additions and 347 deletions

View File

@ -46,13 +46,14 @@ system volume (or area in 2d). The second term is the virial, equal to
-dU/dV, computed for all pairwise as well as 2-body, 3-body, 4-body, -dU/dV, computed for all pairwise as well as 2-body, 3-body, 4-body,
many-body, and long-range interactions, where :math:`r_i` and many-body, and long-range interactions, where :math:`r_i` and
:math:`f_i` are the position and force vector of atom *i*, and the black :math:`f_i` are the position and force vector of atom *i*, and the black
dot indicates a dot product. When periodic boundary conditions are dot indicates a dot product. This is computed in parallel for each
used, N' necessarily includes periodic image (ghost) atoms outside the sub-domain and then summed over all parallel processes. Thus N'
central box, and the position and force vectors of ghost atoms are thus necessarily includes atoms from neighboring sub-domains (so-called ghost
included in the summation. When periodic boundary conditions are not atoms) and the position and force vectors of ghost atoms are thus
used, N' = N = the number of atoms in the system. :doc:`Fixes <fix>` included in the summation. Only when running in serial and without
that impose constraints (e.g. the :doc:`fix shake <fix_shake>` command) periodic boundary conditions is N' = N = the number of atoms in the
also contribute to the virial term. system. :doc:`Fixes <fix>` that impose constraints (e.g. the :doc:`fix
shake <fix_shake>` command) may also contribute to the virial term.
A symmetric pressure tensor, stored as a 6-element vector, is also A symmetric pressure tensor, stored as a 6-element vector, is also
calculated by this compute. The 6 components of the vector are calculated by this compute. The 6 components of the vector are

View File

@ -9,7 +9,7 @@ create_box 1 box
create_atoms 1 box create_atoms 1 box
mass 1 1.0 mass 1 1.0
velocity all create 3.0 87287 velocity all create 3.0 87287 loop geom
pair_style lj/cut 2.5 pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 1 1 1.0 1.0 2.5

View File

@ -1,85 +0,0 @@
LAMMPS (27 Nov 2018)
using 1 OpenMP thread(s) per MPI task
# 3d Lennard-Jones melt
units lj
atom_style atomic
lattice fcc 0.8442
Lattice spacing in x,y,z = 1.6796 1.6796 1.6796
region box block 0 10 0 10 0 10
create_box 1 box
Created orthogonal box = (0 0 0) to (16.796 16.796 16.796)
1 by 2 by 2 MPI processor grid
create_atoms 1 box
Created 4000 atoms
Time spent = 0.00041604 secs
mass 1 1.0
velocity all create 3.0 87287
pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5
neighbor 0.3 bin
neigh_modify every 20 delay 0 check no
fix 1 all nve
#dump id all atom 50 dump.melt
#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30
#dump_modify 2 pad 3
#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30
#dump_modify 3 pad 3
thermo 50
run 250
Neighbor list info ...
update every 20 steps, delay 0 steps, check no
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 2.8
ghost atom cutoff = 2.8
binsize = 1.4, bins = 12 12 12
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair lj/cut, perpetual
attributes: half, newton on
pair build: half/bin/atomonly/newton
stencil: half/bin/3d/newton
bin: standard
Per MPI rank memory allocation (min/avg/max) = 2.705 | 2.705 | 2.705 Mbytes
Step Temp E_pair E_mol TotEng Press
0 3 -6.7733681 0 -2.2744931 -3.7033504
50 1.6754119 -4.7947589 0 -2.2822693 5.6615925
100 1.6503357 -4.756014 0 -2.2811293 5.8050524
150 1.6596605 -4.7699432 0 -2.2810749 5.7830138
200 1.6371874 -4.7365462 0 -2.2813789 5.9246674
250 1.6323462 -4.7292021 0 -2.2812949 5.9762238
Loop time of 0.223329 on 4 procs for 250 steps with 4000 atoms
Performance: 483592.231 tau/day, 1119.426 timesteps/s
97.3% CPU use with 4 MPI tasks x 1 OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 0.15881 | 0.16314 | 0.16859 | 0.9 | 73.05
Neigh | 0.02472 | 0.025218 | 0.025828 | 0.3 | 11.29
Comm | 0.025185 | 0.030091 | 0.034351 | 1.9 | 13.47
Output | 0.00015163 | 0.00019169 | 0.00030899 | 0.0 | 0.09
Modify | 0.0037532 | 0.0038366 | 0.0040054 | 0.2 | 1.72
Other | | 0.00085 | | | 0.38
Nlocal: 1000 ave 1010 max 982 min
Histogram: 1 0 0 0 0 0 1 0 0 2
Nghost: 2703.75 ave 2713 max 2689 min
Histogram: 1 0 0 0 0 0 0 2 0 1
Neighs: 37915.5 ave 39239 max 36193 min
Histogram: 1 0 0 0 0 1 1 0 0 1
Total # of neighbors = 151662
Ave neighs/atom = 37.9155
Neighbor list builds = 12
Dangerous builds not checked
Total wall time: 0:00:00

View File

@ -1,4 +1,4 @@
LAMMPS (27 Nov 2018) LAMMPS (8 Apr 2021)
using 1 OpenMP thread(s) per MPI task using 1 OpenMP thread(s) per MPI task
# 3d Lennard-Jones melt # 3d Lennard-Jones melt
@ -6,17 +6,17 @@ units lj
atom_style atomic atom_style atomic
lattice fcc 0.8442 lattice fcc 0.8442
Lattice spacing in x,y,z = 1.6796 1.6796 1.6796 Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962
region box block 0 10 0 10 0 10 region box block 0 10 0 10 0 10
create_box 1 box create_box 1 box
Created orthogonal box = (0 0 0) to (16.796 16.796 16.796) Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (16.795962 16.795962 16.795962)
1 by 1 by 1 MPI processor grid 1 by 1 by 1 MPI processor grid
create_atoms 1 box create_atoms 1 box
Created 4000 atoms Created 4000 atoms
Time spent = 0.000645638 secs create_atoms CPU = 0.002 seconds
mass 1 1.0 mass 1 1.0
velocity all create 3.0 87287 velocity all create 3.0 87287 loop geom
pair_style lj/cut 2.5 pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 1 1 1.0 1.0 2.5
@ -48,38 +48,38 @@ Neighbor list info ...
pair build: half/bin/atomonly/newton pair build: half/bin/atomonly/newton
stencil: half/bin/3d/newton stencil: half/bin/3d/newton
bin: standard bin: standard
Per MPI rank memory allocation (min/avg/max) = 3.221 | 3.221 | 3.221 Mbytes Per MPI rank memory allocation (min/avg/max) = 3.222 | 3.222 | 3.222 Mbytes
Step Temp E_pair E_mol TotEng Press Step Temp E_pair E_mol TotEng Press
0 3 -6.7733681 0 -2.2744931 -3.7033504 0 3 -6.7733681 0 -2.2744931 -3.7033504
50 1.6758903 -4.7955425 0 -2.2823355 5.670064 50 1.6842865 -4.8082494 0 -2.2824513 5.5666131
100 1.6458363 -4.7492704 0 -2.2811332 5.8691042 100 1.6712577 -4.7875609 0 -2.281301 5.6613913
150 1.6324555 -4.7286791 0 -2.280608 5.9589514 150 1.6444751 -4.7471034 0 -2.2810074 5.8614211
200 1.6630725 -4.7750988 0 -2.2811136 5.7364886 200 1.6471542 -4.7509053 0 -2.2807916 5.8805431
250 1.6275257 -4.7224992 0 -2.281821 5.9567365 250 1.6645597 -4.7774327 0 -2.2812174 5.7526089
Loop time of 0.729809 on 1 procs for 250 steps with 4000 atoms Loop time of 1.61045 on 1 procs for 250 steps with 4000 atoms
Performance: 147983.915 tau/day, 342.555 timesteps/s Performance: 67062.020 tau/day, 155.236 timesteps/s
99.9% CPU use with 1 MPI tasks x 1 OpenMP threads 99.9% CPU use with 1 MPI tasks x 1 OpenMP threads
MPI task timing breakdown: MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total Section | min time | avg time | max time |%varavg| %total
--------------------------------------------------------------- ---------------------------------------------------------------
Pair | 0.60661 | 0.60661 | 0.60661 | 0.0 | 83.12 Pair | 1.3961 | 1.3961 | 1.3961 | 0.0 | 86.69
Neigh | 0.092198 | 0.092198 | 0.092198 | 0.0 | 12.63 Neigh | 0.13555 | 0.13555 | 0.13555 | 0.0 | 8.42
Comm | 0.013581 | 0.013581 | 0.013581 | 0.0 | 1.86 Comm | 0.037732 | 0.037732 | 0.037732 | 0.0 | 2.34
Output | 0.0001452 | 0.0001452 | 0.0001452 | 0.0 | 0.02 Output | 0.0003345 | 0.0003345 | 0.0003345 | 0.0 | 0.02
Modify | 0.014395 | 0.014395 | 0.014395 | 0.0 | 1.97 Modify | 0.038016 | 0.038016 | 0.038016 | 0.0 | 2.36
Other | | 0.002878 | | | 0.39 Other | | 0.002731 | | | 0.17
Nlocal: 4000 ave 4000 max 4000 min Nlocal: 4000.00 ave 4000 max 4000 min
Histogram: 1 0 0 0 0 0 0 0 0 0 Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 5499 ave 5499 max 5499 min Nghost: 5506.00 ave 5506 max 5506 min
Histogram: 1 0 0 0 0 0 0 0 0 0 Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 151513 ave 151513 max 151513 min Neighs: 151788.0 ave 151788 max 151788 min
Histogram: 1 0 0 0 0 0 0 0 0 0 Histogram: 1 0 0 0 0 0 0 0 0 0
Total # of neighbors = 151513 Total # of neighbors = 151788
Ave neighs/atom = 37.8783 Ave neighs/atom = 37.947000
Neighbor list builds = 12 Neighbor list builds = 12
Dangerous builds not checked Dangerous builds not checked
Total wall time: 0:00:00 Total wall time: 0:00:01

View File

@ -0,0 +1,85 @@
LAMMPS (8 Apr 2021)
using 1 OpenMP thread(s) per MPI task
# 3d Lennard-Jones melt
units lj
atom_style atomic
lattice fcc 0.8442
Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962
region box block 0 10 0 10 0 10
create_box 1 box
Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (16.795962 16.795962 16.795962)
1 by 2 by 2 MPI processor grid
create_atoms 1 box
Created 4000 atoms
create_atoms CPU = 0.001 seconds
mass 1 1.0
velocity all create 3.0 87287 loop geom
pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5
neighbor 0.3 bin
neigh_modify every 20 delay 0 check no
fix 1 all nve
#dump id all atom 50 dump.melt
#dump 2 all image 25 image.*.jpg type type # axes yes 0.8 0.02 view 60 -30
#dump_modify 2 pad 3
#dump 3 all movie 25 movie.mpg type type # axes yes 0.8 0.02 view 60 -30
#dump_modify 3 pad 3
thermo 50
run 250
Neighbor list info ...
update every 20 steps, delay 0 steps, check no
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 2.8
ghost atom cutoff = 2.8
binsize = 1.4, bins = 12 12 12
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair lj/cut, perpetual
attributes: half, newton on
pair build: half/bin/atomonly/newton
stencil: half/bin/3d/newton
bin: standard
Per MPI rank memory allocation (min/avg/max) = 2.706 | 2.706 | 2.706 Mbytes
Step Temp E_pair E_mol TotEng Press
0 3 -6.7733681 0 -2.2744931 -3.7033504
50 1.6842865 -4.8082494 0 -2.2824513 5.5666131
100 1.6712577 -4.7875609 0 -2.281301 5.6613913
150 1.6444751 -4.7471034 0 -2.2810074 5.8614211
200 1.6471542 -4.7509053 0 -2.2807916 5.8805431
250 1.6645597 -4.7774327 0 -2.2812174 5.7526089
Loop time of 0.490832 on 4 procs for 250 steps with 4000 atoms
Performance: 220034.754 tau/day, 509.340 timesteps/s
96.7% CPU use with 4 MPI tasks x 1 OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 0.35932 | 0.37256 | 0.38746 | 1.9 | 75.90
Neigh | 0.035928 | 0.038449 | 0.042344 | 1.3 | 7.83
Comm | 0.053452 | 0.068917 | 0.08485 | 5.3 | 14.04
Output | 0.00015545 | 0.00023746 | 0.00047684 | 0.0 | 0.05
Modify | 0.0096958 | 0.0097951 | 0.0098989 | 0.1 | 2.00
Other | | 0.0008721 | | | 0.18
Nlocal: 1000.00 ave 1008 max 987 min
Histogram: 1 0 0 0 0 0 1 0 1 1
Nghost: 2711.25 ave 2728 max 2693 min
Histogram: 1 0 0 0 0 2 0 0 0 1
Neighs: 37947.0 ave 38966 max 37338 min
Histogram: 1 1 0 1 0 0 0 0 0 1
Total # of neighbors = 151788
Ave neighs/atom = 37.947000
Neighbor list builds = 12
Dangerous builds not checked
Total wall time: 0:00:00

View File

@ -1261,6 +1261,7 @@ void FixWallGran::granular(double rsq, double dx, double dy, double dz,
k_tangential = tangential_coeffs[0]; k_tangential = tangential_coeffs[0];
damp_tangential = tangential_coeffs[1]*damp_normal_prefactor; damp_tangential = tangential_coeffs[1]*damp_normal_prefactor;
Fscrit = tangential_coeffs[2] * Fncrit;
int thist0 = tangential_history_index; int thist0 = tangential_history_index;
int thist1 = thist0 + 1; int thist1 = thist0 + 1;
@ -1346,7 +1347,6 @@ void FixWallGran::granular(double rsq, double dx, double dy, double dz,
} }
// rescale frictional displacements and forces if needed // rescale frictional displacements and forces if needed
Fscrit = tangential_coeffs[2] * Fncrit;
fs = sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3); fs = sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3);
if (fs > Fscrit) { if (fs > Fscrit) {
shrmag = sqrt(history[thist0]*history[thist0] + shrmag = sqrt(history[thist0]*history[thist0] +

View File

@ -17,17 +17,17 @@
#include "angle_cosine_periodic.h" #include "angle_cosine_periodic.h"
#include <cmath>
#include "atom.h" #include "atom.h"
#include "neighbor.h"
#include "domain.h"
#include "comm.h" #include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h" #include "force.h"
#include "math_const.h" #include "math_const.h"
#include "math_special.h" #include "math_special.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "neighbor.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace MathConst; using namespace MathConst;
@ -224,7 +224,7 @@ void AngleCosinePeriodic::coeff(int narg, char **arg)
double AngleCosinePeriodic::equilibrium_angle(int i) double AngleCosinePeriodic::equilibrium_angle(int i)
{ {
return MY_PI*(1.0 - (b[i]>0)?0.0:1.0/static_cast<double>(multiplicity[i])); return MY_PI*(1.0 - ((b[i]>0) ? 0.0 : (1.0/static_cast<double>(multiplicity[i]))));
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -17,17 +17,18 @@
#include "fix_rattle.h" #include "fix_rattle.h"
#include <cmath>
#include <cstring>
#include "atom.h" #include "atom.h"
#include "update.h"
#include "modify.h"
#include "domain.h"
#include "force.h"
#include "comm.h" #include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "math_extra.h" #include "math_extra.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "modify.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;

View File

@ -13,29 +13,29 @@
#include "fix_rigid.h" #include "fix_rigid.h"
#include <cmath>
#include <cstring>
#include "math_extra.h"
#include "math_eigen.h"
#include "atom.h" #include "atom.h"
#include "atom_vec_ellipsoid.h" #include "atom_vec_ellipsoid.h"
#include "atom_vec_line.h" #include "atom_vec_line.h"
#include "atom_vec_tri.h" #include "atom_vec_tri.h"
#include "domain.h"
#include "update.h"
#include "respa.h"
#include "modify.h"
#include "group.h"
#include "comm.h" #include "comm.h"
#include "random_mars.h" #include "domain.h"
#include "force.h"
#include "input.h"
#include "variable.h"
#include "math_const.h"
#include "memory.h"
#include "error.h" #include "error.h"
#include "force.h"
#include "group.h"
#include "input.h"
#include "math_const.h"
#include "math_eigen.h"
#include "math_extra.h"
#include "memory.h"
#include "modify.h"
#include "random_mars.h"
#include "respa.h"
#include "rigid_const.h" #include "rigid_const.h"
#include "update.h"
#include "variable.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;

View File

@ -18,22 +18,24 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_rigid_nh.h" #include "fix_rigid_nh.h"
#include <cmath>
#include <cstring>
#include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "compute.h" #include "compute.h"
#include "domain.h" #include "domain.h"
#include "update.h"
#include "modify.h"
#include "fix_deform.h"
#include "group.h"
#include "comm.h"
#include "force.h"
#include "kspace.h"
#include "memory.h"
#include "error.h" #include "error.h"
#include "fix_deform.h"
#include "force.h"
#include "group.h"
#include "kspace.h"
#include "math_extra.h"
#include "memory.h"
#include "modify.h"
#include "rigid_const.h" #include "rigid_const.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;

View File

@ -18,6 +18,7 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_rigid_nvt_small.h" #include "fix_rigid_nvt_small.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;

View File

@ -13,25 +13,26 @@
#include "fix_shake.h" #include "fix_shake.h"
#include "angle.h"
#include "atom.h"
#include "atom_vec.h"
#include "bond.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "fix_respa.h"
#include "force.h"
#include "group.h"
#include "math_const.h"
#include "memory.h"
#include "modify.h"
#include "molecule.h"
#include "respa.h"
#include "update.h"
#include <cmath> #include <cmath>
#include <cctype> #include <cctype>
#include <cstring> #include <cstring>
#include "atom.h"
#include "atom_vec.h"
#include "molecule.h"
#include "update.h"
#include "respa.h"
#include "modify.h"
#include "domain.h"
#include "force.h"
#include "bond.h"
#include "angle.h"
#include "comm.h"
#include "group.h"
#include "fix_respa.h"
#include "math_const.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;

View File

@ -581,14 +581,14 @@ double PairLJSwitch3CoulGaussLong::single(int i, int j, int itype, int jtype,
{ {
double r2inv,r6inv,r,grij,expm2,t,erfc1,prefactor,prefactor2; double r2inv,r6inv,r,grij,expm2,t,erfc1,prefactor,prefactor2;
double fraction,table,forcecoul,forcecoul2,forcelj; double fraction,table,forcecoul,forcecoul2,forcelj;
double rrij,expn2,erfc2,expb,ecoul,evdwl,trx,tr,ftr; double rrij,expn2,erfc2,ecoul,evdwl,trx,tr,ftr;
int itable; int itable;
r2inv = 1.0/rsq; r2inv = 1.0/rsq;
r = sqrt(rsq);
if (rsq < cut_coulsq) { if (rsq < cut_coulsq) {
if (!ncoultablebits || rsq <= tabinnersq) { if (!ncoultablebits || rsq <= tabinnersq) {
r = sqrt(rsq);
grij = g_ewald * r; grij = g_ewald * r;
expm2 = exp(-grij*grij); expm2 = exp(-grij*grij);
t = 1.0 / (1.0 + EWALD_P*grij); t = 1.0 / (1.0 + EWALD_P*grij);
@ -621,7 +621,6 @@ double PairLJSwitch3CoulGaussLong::single(int i, int j, int itype, int jtype,
forcecoul2 = 0.0; forcecoul2 = 0.0;
prefactor2 = 0.0; prefactor2 = 0.0;
} else { } else {
r = sqrt(rsq);
rrij = lj2[itype][jtype]*r; rrij = lj2[itype][jtype]*r;
expn2 = exp(-rrij*rrij); expn2 = exp(-rrij*rrij);
erfc2 = erfc(rrij); erfc2 = erfc(rrij);

View File

@ -586,9 +586,9 @@ double PairMM3Switch3CoulGaussLong::single(int i, int j, int itype, int jtype,
int itable; int itable;
r2inv = 1.0/rsq; r2inv = 1.0/rsq;
r = sqrt(rsq);
if (rsq < cut_coulsq) { if (rsq < cut_coulsq) {
if (!ncoultablebits || rsq <= tabinnersq) { if (!ncoultablebits || rsq <= tabinnersq) {
r = sqrt(rsq);
grij = g_ewald * r; grij = g_ewald * r;
expm2 = exp(-grij*grij); expm2 = exp(-grij*grij);
t = 1.0 / (1.0 + EWALD_P*grij); t = 1.0 / (1.0 + EWALD_P*grij);
@ -613,7 +613,6 @@ double PairMM3Switch3CoulGaussLong::single(int i, int j, int itype, int jtype,
} else forcecoul = 0.0; } else forcecoul = 0.0;
if (rsq < cut_ljsq[itype][jtype]) { if (rsq < cut_ljsq[itype][jtype]) {
r = sqrt(rsq);
expb = lj3[itype][jtype]*exp(-lj1[itype][jtype]*r); expb = lj3[itype][jtype]*exp(-lj1[itype][jtype]*r);
forcelj = expb*lj1[itype][jtype]*r; forcelj = expb*lj1[itype][jtype]*r;
r6inv = r2inv*r2inv*r2inv; r6inv = r2inv*r2inv*r2inv;

View File

@ -14,16 +14,16 @@
#include "dump.h" #include "dump.h"
#include "atom.h" #include "atom.h"
#include "irregular.h"
#include "update.h"
#include "domain.h"
#include "group.h"
#include "output.h"
#include "modify.h"
#include "fix.h"
#include "compute.h" #include "compute.h"
#include "memory.h" #include "domain.h"
#include "error.h" #include "error.h"
#include "fix.h"
#include "group.h"
#include "irregular.h"
#include "memory.h"
#include "modify.h"
#include "output.h"
#include "update.h"
#include <cstring> #include <cstring>
@ -141,12 +141,9 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp)
if (strchr(filename,'*')) multifile = 1; if (strchr(filename,'*')) multifile = 1;
char *suffix = filename + strlen(filename) - strlen(".bin"); if (utils::strmatch(filename, "\\.bin$")) binary = 1;
if (suffix > filename && strcmp(suffix,".bin") == 0) binary = 1; if (utils::strmatch(filename, "\\.gz$")
suffix = filename + strlen(filename) - strlen(".gz"); || utils::strmatch(filename, "\\.zst$")) compressed = 1;
if (suffix > filename && strcmp(suffix,".gz") == 0) compressed = 1;
suffix = filename + strlen(filename) - strlen(".zst");
if (suffix > filename && strcmp(suffix,".zst") == 0) compressed = 1;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -582,12 +579,11 @@ void Dump::openfile()
if (filewriter) { if (filewriter) {
if (compressed) { if (compressed) {
#ifdef LAMMPS_GZIP #ifdef LAMMPS_GZIP
char gzip[128]; auto gzip = fmt::format("gzip -6 > {}",filecurrent);
sprintf(gzip,"gzip -6 > %s",filecurrent);
#ifdef _WIN32 #ifdef _WIN32
fp = _popen(gzip,"wb"); fp = _popen(gzip.c_str(),"wb");
#else #else
fp = popen(gzip,"w"); fp = popen(gzip.c_str(),"w");
#endif #endif
#else #else
error->one(FLERR,"Cannot open gzipped file"); error->one(FLERR,"Cannot open gzipped file");

View File

@ -401,7 +401,7 @@ void Finish::end(int flag)
} }
#endif #endif
if (lmp->kokkos && lmp->kokkos->ngpus > 0) if ((comm->me == 0) && lmp->kokkos && (lmp->kokkos->ngpus > 0))
if (const char* env_clb = getenv("CUDA_LAUNCH_BLOCKING")) if (const char* env_clb = getenv("CUDA_LAUNCH_BLOCKING"))
if (!(strcmp(env_clb,"1") == 0)) { if (!(strcmp(env_clb,"1") == 0)) {
error->warning(FLERR,"Timing breakdown may not be accurate " error->warning(FLERR,"Timing breakdown may not be accurate "

View File

@ -18,19 +18,18 @@
#include "fix_tmd.h" #include "fix_tmd.h"
#include "atom.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "group.h"
#include "memory.h"
#include "modify.h"
#include "respa.h"
#include "update.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include "atom.h"
#include "update.h"
#include "modify.h"
#include "domain.h"
#include "group.h"
#include "respa.h"
#include "force.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -520,31 +519,29 @@ void FixTMD::readfile(char *file)
void FixTMD::open(char *file) void FixTMD::open(char *file)
{ {
compressed = 0; if (utils::strmatch(file,"\\.gz$")) {
char *suffix = file + strlen(file) - 3; compressed = 1;
if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1;
if (!compressed) fp = fopen(file,"r");
else {
#ifdef LAMMPS_GZIP #ifdef LAMMPS_GZIP
char gunzip[128]; auto gunzip = fmt::format("gzip -c -d {}",file);
snprintf(gunzip,128,"gzip -c -d %s",file);
#ifdef _WIN32 #ifdef _WIN32
fp = _popen(gunzip,"rb"); fp = _popen(gunzip.c_str(),"rb");
#else #else
fp = popen(gunzip,"r"); fp = popen(gunzip.c_str(),"r");
#endif #endif
#else #else
error->one(FLERR,"Cannot open gzipped file"); error->one(FLERR,"Cannot open gzipped file without gzip support");
#endif #endif
} else {
compressed = 0;
fp = fopen(file,"r");
} }
if (fp == nullptr) { if (fp == nullptr)
char str[128]; error->one(FLERR,fmt::format("Cannot open file {}: {}",
snprintf(str,128,"Cannot open file %s",file); file, utils::getsyserror()));
error->one(FLERR,str);
}
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -1250,9 +1250,18 @@ void Input::shell()
for (int i = 1; i < narg; i++) { for (int i = 1; i < narg; i++) {
rv = 0; rv = 0;
#ifdef _WIN32 #ifdef _WIN32
if (arg[i]) rv = _putenv(arg[i]); if (arg[i]) rv = _putenv(utils::strdup(arg[i]));
#else #else
if (arg[i]) rv = putenv(arg[i]); if (arg[i]) {
std::string vardef(arg[i]);
auto found = vardef.find_first_of("=");
if (found == std::string::npos) {
rv = setenv(vardef.c_str(),"",1);
} else {
rv = setenv(vardef.substr(0,found).c_str(),
vardef.substr(found+1).c_str(),1);
}
}
#endif #endif
rv = (rv < 0) ? errno : 0; rv = (rv < 0) ? errno : 0;
MPI_Reduce(&rv,&err,1,MPI_INT,MPI_MAX,0,world); MPI_Reduce(&rv,&err,1,MPI_INT,MPI_MAX,0,world);

View File

@ -4734,19 +4734,14 @@ void lammps_set_fix_external_callback(void *handle, char *id, FixExternalFnPtr c
BEGIN_CAPTURE BEGIN_CAPTURE
{ {
int ifix = lmp->modify->find_fix(id); int ifix = lmp->modify->find_fix(id);
if (ifix < 0) { if (ifix < 0)
char str[128]; lmp->error->all(FLERR,fmt::format("Cannot find fix with ID '{}'!", id));
snprintf(str, 128, "Can not find fix with ID '%s'!", id);
lmp->error->all(FLERR,str);
}
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (strcmp("external",fix->style) != 0) { if (strcmp("external",fix->style) != 0)
char str[128]; lmp->error->all(FLERR,fmt::format("Fix '{}' is not of style "
snprintf(str, 128, "Fix '%s' is not of style external!", id); "external!", id));
lmp->error->all(FLERR,str);
}
FixExternal * fext = (FixExternal*) fix; FixExternal * fext = (FixExternal*) fix;
fext->set_callback(callback, caller); fext->set_callback(callback, caller);

View File

@ -204,7 +204,6 @@ void Pair::modify_params(int narg, char **arg)
else error->all(FLERR,"Illegal pair_modify command"); else error->all(FLERR,"Illegal pair_modify command");
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"nofdotr") == 0) { } else if (strcmp(arg[iarg],"nofdotr") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command");
no_virial_fdotr_compute = 1; no_virial_fdotr_compute = 1;
++iarg; ++iarg;
} else error->all(FLERR,"Illegal pair_modify command"); } else error->all(FLERR,"Illegal pair_modify command");

View File

@ -468,10 +468,7 @@ void PairHybrid::coeff(int narg, char **arg)
if (multiple[m]) { if (multiple[m]) {
multflag = 1; multflag = 1;
if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients");
if (!isdigit(arg[3][0])) if (multiple[m] == utils::inumeric(FLERR,arg[3],false,lmp)) break;
error->all(FLERR,"Incorrect args for pair coefficients");
int index = utils::inumeric(FLERR,arg[3],false,lmp);
if (index == multiple[m]) break;
else continue; else continue;
} else break; } else break;
} }
@ -492,7 +489,7 @@ void PairHybrid::coeff(int narg, char **arg)
// invoke sub-style coeff() starting with 1st remaining arg // invoke sub-style coeff() starting with 1st remaining arg
if (!none) styles[m]->coeff(narg-1-multflag,&arg[1+multflag]); if (!none) styles[m]->coeff(narg-1-multflag,arg+1+multflag);
// if sub-style only allows one pair coeff call (with * * and type mapping) // if sub-style only allows one pair coeff call (with * * and type mapping)
// then unset setflag/map assigned to that style before setting it below // then unset setflag/map assigned to that style before setting it below

View File

@ -17,7 +17,6 @@
#include "error.h" #include "error.h"
#include <cstring> #include <cstring>
#include <cctype>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -51,10 +50,7 @@ void PairHybridOverlay::coeff(int narg, char **arg)
if (multiple[m]) { if (multiple[m]) {
multflag = 1; multflag = 1;
if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients"); if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients");
if (!isdigit(arg[3][0])) if (multiple[m] == utils::inumeric(FLERR,arg[3],false,lmp)) break;
error->all(FLERR,"Incorrect args for pair coefficients");
int index = utils::inumeric(FLERR,arg[3],false,lmp);
if (index == multiple[m]) break;
else continue; else continue;
} else break; } else break;
} }
@ -75,7 +71,7 @@ void PairHybridOverlay::coeff(int narg, char **arg)
// invoke sub-style coeff() starting with 1st remaining arg // invoke sub-style coeff() starting with 1st remaining arg
if (!none) styles[m]->coeff(narg-1-multflag,&arg[1+multflag]); if (!none) styles[m]->coeff(narg-1-multflag,arg+1+multflag);
// set setflag and which type pairs map to which sub-style // set setflag and which type pairs map to which sub-style
// if sub-style is none: set hybrid subflag, wipe out map // if sub-style is none: set hybrid subflag, wipe out map

View File

@ -1954,13 +1954,12 @@ int ReadData::reallocate(int **pcount, int cmax, int amax)
void ReadData::open(char *file) void ReadData::open(char *file)
{ {
compressed = 0; if (utils::strmatch(file,"\\.gz$")) {
char *suffix = file + strlen(file) - 3; compressed = 1;
if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1;
if (!compressed) fp = fopen(file,"r");
else {
#ifdef LAMMPS_GZIP #ifdef LAMMPS_GZIP
std::string gunzip = fmt::format("gzip -c -d {}",file); auto gunzip = fmt::format("gzip -c -d {}",file);
#ifdef _WIN32 #ifdef _WIN32
fp = _popen(gunzip.c_str(),"rb"); fp = _popen(gunzip.c_str(),"rb");
#else #else
@ -1968,8 +1967,11 @@ void ReadData::open(char *file)
#endif #endif
#else #else
error->one(FLERR,"Cannot open gzipped file: " + utils::getsyserror()); error->one(FLERR,"Cannot open gzipped file without gzip support");
#endif #endif
} else {
compressed = 0;
fp = fopen(file,"r");
} }
if (fp == nullptr) if (fp == nullptr)

View File

@ -37,13 +37,12 @@ void Reader::open_file(const char *file)
{ {
if (fp != nullptr) close_file(); if (fp != nullptr) close_file();
compressed = 0; if (utils::strmatch(file,"\\.gz$")) {
const char *suffix = file + strlen(file) - 3; compressed = 1;
if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1;
if (!compressed) fp = fopen(file,"r");
else {
#ifdef LAMMPS_GZIP #ifdef LAMMPS_GZIP
std::string gunzip = fmt::format("gzip -c -d {}",file); auto gunzip = fmt::format("gzip -c -d {}",file);
#ifdef _WIN32 #ifdef _WIN32
fp = _popen(gunzip.c_str(),"rb"); fp = _popen(gunzip.c_str(),"rb");
#else #else
@ -51,8 +50,11 @@ void Reader::open_file(const char *file)
#endif #endif
#else #else
error->one(FLERR,"Cannot open gzipped file: " + utils::getsyserror()); error->one(FLERR,"Cannot open gzipped file without gzip support");
#endif #endif
} else {
compressed = 0;
fp = fopen(file,"r");
} }
if (fp == nullptr) if (fp == nullptr)

View File

@ -337,11 +337,11 @@ void Variable::set(int narg, char **arg)
} }
if (nvar == maxvar) grow(); if (nvar == maxvar) grow();
style[nvar] = GETENV; style[nvar] = GETENV;
num[nvar] = 1; num[nvar] = 2;
which[nvar] = 0; which[nvar] = 0;
pad[nvar] = 0; pad[nvar] = 0;
data[nvar] = new char*[num[nvar]]; data[nvar] = new char*[num[nvar]];
copy(1,&arg[2],data[nvar]); data[nvar][0] = utils::strdup(arg[2]);
data[nvar][1] = utils::strdup("(undefined)"); data[nvar][1] = utils::strdup("(undefined)");
// SCALARFILE for strings or numbers // SCALARFILE for strings or numbers
@ -1252,7 +1252,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
print_var_error(FLERR,"Invalid syntax in variable formula",ivar); print_var_error(FLERR,"Invalid syntax in variable formula",ivar);
expect = OP; expect = OP;
char *contents; char *contents = nullptr;
i = find_matching_paren(str,i,contents,ivar); i = find_matching_paren(str,i,contents,ivar);
i++; i++;
@ -2068,7 +2068,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
// ---------------- // ----------------
if (str[i] == '(') { if (str[i] == '(') {
char *contents; char *contents = nullptr;
i = find_matching_paren(str,i,contents,ivar); i = find_matching_paren(str,i,contents,ivar);
i++; i++;
@ -3286,6 +3286,7 @@ int Variable::find_matching_paren(char *str, int i, char *&contents, int ivar)
int istop = i; int istop = i;
int n = istop - istart - 1; int n = istop - istart - 1;
delete[] contents;
contents = new char[n+1]; contents = new char[n+1];
strncpy(contents,&str[istart+1],n); strncpy(contents,&str[istart+1],n);
contents[n] = '\0'; contents[n] = '\0';
@ -4827,7 +4828,7 @@ double Variable::evaluate_boolean(char *str)
error->all(FLERR,"Invalid Boolean syntax in if command"); error->all(FLERR,"Invalid Boolean syntax in if command");
expect = OP; expect = OP;
char *contents; char *contents = nullptr;
i = find_matching_paren(str,i,contents,-1); i = find_matching_paren(str,i,contents,-1);
i++; i++;

View File

@ -20,8 +20,8 @@
#include "output.h" #include "output.h"
#include "update.h" #include "update.h"
#include "utils.h" #include "utils.h"
#include "variable.h"
#include "fmt/format.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "../testing/core.h" #include "../testing/core.h"
@ -400,23 +400,26 @@ TEST_F(SimpleCommandsTest, Shell)
command("shell putenv TEST_VARIABLE=simpletest"); command("shell putenv TEST_VARIABLE=simpletest");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
char *test_var = getenv("TEST_VARIABLE"); const char *test_var = getenv("TEST_VARIABLE");
ASSERT_NE(test_var, nullptr); ASSERT_NE(test_var, nullptr);
ASSERT_THAT(test_var, StrEq("simpletest")); ASSERT_THAT(test_var, StrEq("simpletest"));
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("shell putenv TEST_VARIABLE=simpletest"); command("shell putenv TEST_VARIABLE");
command("shell putenv TEST_VARIABLE2=simpletest2 OTHER_VARIABLE=2"); command("shell putenv TEST_VARIABLE2=simpletest OTHER_VARIABLE=2");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
char *test_var2 = getenv("TEST_VARIABLE2"); test_var = getenv("TEST_VARIABLE2");
char *other_var = getenv("OTHER_VARIABLE"); ASSERT_NE(test_var, nullptr);
ASSERT_THAT(test_var, StrEq("simpletest"));
ASSERT_NE(test_var2, nullptr); test_var = getenv("OTHER_VARIABLE");
ASSERT_THAT(test_var2, StrEq("simpletest2")); ASSERT_NE(test_var, nullptr);
ASSERT_THAT(test_var, StrEq("2"));
ASSERT_NE(other_var, nullptr); test_var = getenv("TEST_VARIABLE");
ASSERT_THAT(other_var, StrEq("2")); ASSERT_NE(test_var, nullptr);
ASSERT_THAT(test_var, StrEq(""));
} }
TEST_F(SimpleCommandsTest, CiteMe) TEST_F(SimpleCommandsTest, CiteMe)

View File

@ -122,6 +122,8 @@ TEST_F(VariableTest, CreateDelete)
file_vars(); file_vars();
ASSERT_EQ(variable->nvar, 1); ASSERT_EQ(variable->nvar, 1);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("shell putenv TEST_VARIABLE=simpletest2");
command("shell putenv TEST_VARIABLE2=simpletest OTHER_VARIABLE=2");
command("variable one index 1 2 3 4"); command("variable one index 1 2 3 4");
command("variable two equal 1"); command("variable two equal 1");
command("variable two equal 2"); command("variable two equal 2");
@ -133,8 +135,8 @@ TEST_F(VariableTest, CreateDelete)
command("variable five2 loop 10 200 pad"); command("variable five2 loop 10 200 pad");
command("variable six world one"); command("variable six world one");
command("variable seven format two \"%5.2f\""); command("variable seven format two \"%5.2f\"");
command("variable eight getenv PWD"); command("variable eight getenv TEST_VARIABLE2");
command("variable eight getenv XXXXX"); command("variable eight getenv XXX");
command("variable nine file test_variable.file"); command("variable nine file test_variable.file");
command("variable ten internal 1.0"); command("variable ten internal 1.0");
command("variable ten internal 10.0"); command("variable ten internal 10.0");
@ -167,6 +169,14 @@ TEST_F(VariableTest, CreateDelete)
unlink("MYFILE"); unlink("MYFILE");
ASSERT_THAT(variable->retrieve("file"), StrEq("0")); ASSERT_THAT(variable->retrieve("file"), StrEq("0"));
BEGIN_HIDE_OUTPUT();
command("variable seven delete");
command("variable seven getenv TEST_VARIABLE");
command("variable eight getenv OTHER_VARIABLE");
END_HIDE_OUTPUT();
ASSERT_THAT(variable->retrieve("seven"), StrEq("simpletest2"));
ASSERT_THAT(variable->retrieve("eight"), StrEq("2"));
ASSERT_EQ(variable->equalstyle(variable->find("one")), 0); ASSERT_EQ(variable->equalstyle(variable->find("one")), 0);
ASSERT_EQ(variable->equalstyle(variable->find("two")), 1); ASSERT_EQ(variable->equalstyle(variable->find("two")), 1);
ASSERT_EQ(variable->equalstyle(variable->find("ten")), 1); ASSERT_EQ(variable->equalstyle(variable->find("ten")), 1);

View File

@ -1,6 +1,6 @@
--- ---
lammps_version: 10 Mar 2021 lammps_version: 8 Apr 2021
date_generated: Tue Apr 6 18:38:56 2021 date_generated: Thu Apr 8 09:28:11 2021
epsilon: 2.5e-13 epsilon: 2.5e-13
prerequisites: ! | prerequisites: ! |
atom full atom full
@ -11,32 +11,32 @@ input_file: in.fourmol
angle_style: cosine/periodic angle_style: cosine/periodic
angle_coeff: ! | angle_coeff: ! |
1 75.0 1 2 1 75.0 1 2
2 45.0 1 2 2 45.0 -1 2
3 50.0 -1 3 3 50.0 -1 3
4 100.0 -1 4 4 100.0 -1 4
equilibrium: 4 1.5707963267948966 1.5707963267948966 0 0 equilibrium: 4 3.141592653589793 1.5707963267948966 2.0943951023931957 2.356194490192345
extract: ! "" extract: ! ""
natoms: 29 natoms: 29
init_energy: 946.676664091363 init_energy: 605.3643061001458
init_stress: ! |2- init_stress: ! |-
3.8581448829084906e+00 -6.3926599144452858e+01 6.0068454261544439e+01 1.4347370855129017e+02 1.0109551149053127e+02 4.9470344115369670e+01 -1.7082420754402889e+01 -7.3281097507808681e+00 2.4410530505183818e+01 8.5827033671406951e+01 1.4260977966148616e+02 4.1579557432232576e+01
init_forces: ! |2 init_forces: ! |2
1 7.9609486050127529e+00 -3.9274211736421961e+01 -3.8917410871887981e+01 1 7.9609486050127529e+00 -3.9274211736421961e+01 -3.8917410871887981e+01
2 4.6997439470662350e+00 3.8052682089524090e+01 3.0599010994189470e+01 2 4.6997439470662350e+00 3.8052682089524090e+01 3.0599010994189470e+01
3 -4.4330179925982058e+01 -1.6514501437366098e+00 1.9894582317318523e+01 3 -7.1532072701475698e+01 9.6873528247272844e+01 7.3410935137796983e+01
4 1.1465928779203908e+01 -7.1462736556935234e+00 -1.8983545733370338e+01 4 3.1784763224659116e+01 -4.4133218046130608e+01 -6.2234613362865147e+01
5 2.7634466780141157e+01 1.5504150132065057e+01 1.0078115065618357e+01 5 5.8817481848549889e+01 -2.5112568523390145e+01 3.9611729278121981e+00
6 2.2512674572611367e+01 -5.4260358088923418e+01 -6.0646506351853276e+01 6 -8.7258065964885336e+00 -4.2663580774228997e+01 -1.6819642012415606e+01
7 -1.5578858996464229e+01 1.3895348629116569e+01 -3.3939856789628062e+00 7 -1.5578858996464229e+01 1.3895348629116569e+01 -3.3939856789628062e+00
8 -2.6028225001107934e+00 4.7418887884887312e+01 1.2659217319984802e+02 8 -1.6678237064738614e+01 -2.6557373913973738e+01 8.7708427797183326e+00
9 9.4419020144376677e+00 -1.3812152922900303e+01 1.2280697239365450e+00 9 -9.4419020144376677e+00 1.3812152922900303e+01 -1.2280697239365450e+00
10 3.7181742871134183e+01 -2.6592777970320334e+01 -1.0034832175946605e+02 10 1.0844630504236606e+02 1.9274264686364820e+01 1.2594098114786526e+01
11 1.1888648487599809e+01 -1.7288532453781471e+00 -1.8714004234488471e+00 11 -1.1888648487599809e+01 1.7288532453781471e+00 1.8714004234488471e+00
12 1.3452345752647041e+01 3.9195153629390539e+01 -3.9429673136141247e+01 12 9.7432958614920665e+01 1.1284647087939499e+02 -1.3445218835244805e+02
13 -4.6656310032990458e+00 -1.2502935413462930e+01 1.4918864440944628e+01 13 -2.2887258478933525e+01 -5.9815335453575649e+01 4.1237962971772127e+01
14 -2.1383527724886850e+01 -9.3422692044635554e+00 7.5125645645164223e+00 14 -4.6498844054867675e+01 -3.0251289808967520e+01 1.5556535565006259e+01
15 -8.0644375221897171e+00 -2.6783296801963008e+00 6.9267625241565547e+00 15 -5.3477741242848616e+01 -1.7885978453267143e+01 4.6284681424489207e+01
16 -7.0395776185793807e+01 4.3227686209287491e+01 3.0567216126495769e+01 16 -7.3215663693592745e+01 1.7514552522777997e+01 7.4857846653898914e+00
17 2.0782832048872386e+01 -2.8304296512773977e+01 1.5273484998106287e+01 17 2.0782832048872386e+01 -2.8304296512773977e+01 1.5273484998106287e+01
18 1.6481336531704756e+00 1.7222946144801426e+01 -6.9896289164966490e+01 18 1.6481336531704756e+00 1.7222946144801426e+01 -6.9896289164966490e+01
19 -2.0180190840279820e+01 -2.5140421523544326e+01 2.9933594625645306e+01 19 -2.0180190840279820e+01 -2.5140421523544326e+01 2.9933594625645306e+01
@ -50,27 +50,27 @@ init_forces: ! |2
27 -8.7971258084923178e+00 7.2217511410368814e+01 -2.4599681382405976e+01 27 -8.7971258084923178e+00 7.2217511410368814e+01 -2.4599681382405976e+01
28 -1.9235439225569891e+01 -4.3179911322776611e+01 1.0030656861974458e+00 28 -1.9235439225569891e+01 -4.3179911322776611e+01 1.0030656861974458e+00
29 2.8032565034062209e+01 -2.9037600087592210e+01 2.3596615696208531e+01 29 2.8032565034062209e+01 -2.9037600087592210e+01 2.3596615696208531e+01
run_energy: 945.667120914027 run_energy: 603.8182365368202
run_stress: ! |2- run_stress: ! |-
4.9007195370705645e+00 -6.4584848054201885e+01 5.9684128517131313e+01 1.4440631784196160e+02 1.0147779649040916e+02 5.0605123164347972e+01 -1.6098625319219664e+01 -7.7961962067566510e+00 2.3894821525976329e+01 8.7036156470651477e+01 1.4262918929621054e+02 4.2523803236880880e+01
run_forces: ! |2 run_forces: ! |2
1 8.0595707378962782e+00 -3.9275884216073550e+01 -3.8921834622274609e+01 1 8.1036664069391833e+00 -3.9279459516104339e+01 -3.8959949625007155e+01
2 4.6450877231394490e+00 3.7989319504376653e+01 3.0709930231636147e+01 2 4.6488532958171156e+00 3.7987813821226069e+01 3.0712083303318757e+01
3 -4.4174062041610540e+01 -1.3116774304574319e+00 1.9852389406583850e+01 3 -7.1419656269516480e+01 9.7015207052323333e+01 7.3123837986656483e+01
4 1.1432955350908090e+01 -7.3978491536336328e+00 -1.8963452260213845e+01 4 3.1774739774255771e+01 -4.4324760214341296e+01 -6.1918121921961003e+01
5 2.7565769765719310e+01 1.5533965769082254e+01 1.0064393083030197e+01 5 5.8630133295649813e+01 -2.5003101567718115e+01 3.8957656941403842e+00
6 2.2437947870916961e+01 -5.4321180615060769e+01 -6.0748488446866872e+01 6 -8.6686835699933500e+00 -4.2717543793109854e+01 -1.6944132920021204e+01
7 -1.5585343433722571e+01 1.3904433399215314e+01 -3.4020204287915634e+00 7 -1.5605967450730276e+01 1.3924972058096937e+01 -3.4081311693274161e+00
8 -2.7173598979194153e+00 4.7428178462168347e+01 1.2654691883960646e+02 8 -1.6735469954990947e+01 -2.6654949908594496e+01 8.9412902423392993e+00
9 9.4915406599908749e+00 -1.3885257714808199e+01 1.2160209239091246e+00 9 -9.4705763934675620e+00 1.3861186924074314e+01 -1.2218212802251793e+00
10 3.7036130179485966e+01 -2.6384482125884212e+01 -1.0013051660330657e+02 10 1.0864309846473817e+02 1.9311615651482960e+01 1.2534898619395602e+01
11 1.1913327728618880e+01 -1.7105485662994653e+00 -1.8898750666441195e+00 11 -1.1889594908454491e+01 1.6849924892427488e+00 1.9039966312260486e+00
12 1.3449580650332301e+01 3.9344535800585398e+01 -3.9552691785632291e+01 12 9.6643785665770423e+01 1.1329932305772147e+02 -1.3435213826206018e+02
13 -4.6002052262583266e+00 -1.2370495939576998e+01 1.4765847794019894e+01 13 -2.2815824864999897e+01 -5.9701629573330088e+01 4.1148977584672039e+01
14 -2.1313398317698834e+01 -9.6666833306404527e+00 7.4826992840481967e+00 14 -4.6226658006998740e+01 -3.0469540424436548e+01 1.5534272011399247e+01
15 -8.0459573339780484e+00 -2.8098768831377434e+00 7.2021609989661499e+00 15 -5.3141801628038777e+01 -1.8156497866651446e+01 4.6272398149175629e+01
16 -7.0394187900784956e+01 4.3284348202675552e+01 3.0478355256814506e+01 16 -7.3254211788300807e+01 1.7569251761827239e+01 7.4522974142679850e+00
17 2.0798603484964556e+01 -2.8350845162531051e+01 1.5290163395115368e+01 17 2.0784167932320894e+01 -2.8346879951708846e+01 1.5284477542010659e+01
18 1.7456021018344252e+00 1.7528557172698406e+01 -7.0852460721917453e+01 18 1.7456021018344252e+00 1.7528557172698406e+01 -7.0852460721917453e+01
19 -2.0389936120749365e+01 -2.5462340563923114e+01 3.0421727677614534e+01 19 -2.0389936120749365e+01 -2.5462340563923114e+01 3.0421727677614534e+01
20 1.8644334018914940e+01 7.9337833912247095e+00 4.0430733044302912e+01 20 1.8644334018914940e+01 7.9337833912247095e+00 4.0430733044302912e+01

View File

@ -13,6 +13,7 @@
#include "yaml_writer.h" #include "yaml_writer.h"
#include "yaml.h" #include "yaml.h"
#include "fmt/format.h"
#include <cstdio> #include <cstdio>
#include <string> #include <string>
@ -51,41 +52,17 @@ YamlWriter::~YamlWriter()
void YamlWriter::emit(const std::string &key, const double value) void YamlWriter::emit(const std::string &key, const double value)
{ {
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, emit(key,fmt::format("{}",value));
(yaml_char_t *)key.c_str(), key.size(), 1, 0,
YAML_PLAIN_SCALAR_STYLE);
yaml_emitter_emit(&emitter, &event);
char buf[256];
snprintf(buf, 256, "%.15g", value);
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)buf,
strlen(buf), 1, 0, YAML_PLAIN_SCALAR_STYLE);
yaml_emitter_emit(&emitter, &event);
} }
void YamlWriter::emit(const std::string &key, const long value) void YamlWriter::emit(const std::string &key, const long value)
{ {
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, emit(key,fmt::format("{}",value));
(yaml_char_t *)key.c_str(), key.size(), 1, 0,
YAML_PLAIN_SCALAR_STYLE);
yaml_emitter_emit(&emitter, &event);
char buf[256];
snprintf(buf, 256, "%ld", value);
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)buf,
strlen(buf), 1, 0, YAML_PLAIN_SCALAR_STYLE);
yaml_emitter_emit(&emitter, &event);
} }
void YamlWriter::emit(const std::string &key, const int value) void YamlWriter::emit(const std::string &key, const int value)
{ {
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, emit(key,fmt::format("{}",value));
(yaml_char_t *)key.c_str(), key.size(), 1, 0,
YAML_PLAIN_SCALAR_STYLE);
yaml_emitter_emit(&emitter, &event);
char buf[256];
snprintf(buf, 256, "%d", value);
yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)buf,
strlen(buf), 1, 0, YAML_PLAIN_SCALAR_STYLE);
yaml_emitter_emit(&emitter, &event);
} }
void YamlWriter::emit(const std::string &key, const std::string &value) void YamlWriter::emit(const std::string &key, const std::string &value)

View File

@ -4,7 +4,7 @@ from lammps.formats import LogFile, AvgChunkFile
EXAMPLES_DIR=os.path.abspath(os.path.join(__file__, '..', '..', '..', 'examples')) EXAMPLES_DIR=os.path.abspath(os.path.join(__file__, '..', '..', '..', 'examples'))
DEFAULT_STYLE_EXAMPLE_LOG="melt/log.27Nov18.melt.g++.1" DEFAULT_STYLE_EXAMPLE_LOG="melt/log.8Apr21.melt.g++.1"
MULTI_STYLE_EXAMPLE_LOG="peptide/log.27Nov18.peptide.g++.1" MULTI_STYLE_EXAMPLE_LOG="peptide/log.27Nov18.peptide.g++.1"
AVG_CHUNK_FILE="VISCOSITY/profile.13Oct16.nemd.2d.g++.1" AVG_CHUNK_FILE="VISCOSITY/profile.13Oct16.nemd.2d.g++.1"