Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several issues preventing reading state from LAMMPS restart file #579

Merged
merged 9 commits into from
Sep 7, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonic1
firstStep 0
centers 2.00000000000000e-02
accumulatedWork -5.11227629613763e-03
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonic1
firstStep 0
centers 2.00000000000000e-02
accumulatedWork -5.11227629613763e-03
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonic1
firstStep 0
forceConstant 1.00000000000000e-04
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonic1
firstStep 0
forceConstant 1.00000000000000e-04
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonic1
firstStep 0
centers 2.00000000000000e-02
accumulatedWork -5.12652207647146e-03
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonic1
firstStep 0
centers 2.00000000000000e-02
accumulatedWork -5.12652207647146e-03
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonic1
firstStep 0
stage 3
centers 1.50000000000000e-02
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonic1
firstStep 0
stage 5
centers 2.00000000000000e-02
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonic1
firstStep 0
centers 2.00000000000000e-02
accumulatedWork -5.11227629613763e-03
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonic1
firstStep 0
centers 2.00000000000000e-02
accumulatedWork -5.11227629613763e-03
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonic1
firstStep 0
forceConstant 1.00000000000000e-04
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonic1
firstStep 0
forceConstant 1.00000000000000e-04
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonicwalls1
firstStep 0
forceConstant 4.18400000000000e-04
accumulatedWork -1.41440677278924e-01
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonicwalls1
firstStep 0
forceConstant 4.18400000000000e-04
accumulatedWork -1.41440677278924e-01
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonicwalls1
firstStep 0
forceConstant 4.18400000000000e-04
accumulatedWork -1.36982738418544e-01
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonicwalls1
firstStep 0
forceConstant 4.18400000000000e-04
accumulatedWork -1.36982738418544e-01
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonicwalls1
firstStep 0
forceConstant 4.18400000000000e-04
accumulatedWork -1.36982738418544e-01
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonicwalls1
firstStep 0
forceConstant 4.18400000000000e-04
accumulatedWork -1.36982738418544e-01
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name linear1
firstStep 0
forceConstant -4.18400000000000e-01
accumulatedWork -5.26670061742242e+00
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name linear1
firstStep 0
forceConstant -4.18400000000000e-01
accumulatedWork -5.26670061742242e+00
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonic1
firstStep 0
centers ( 0.00000000000000e+00 , 0.00000000000000e+00 , 1.00000000000000e+00 , 0.00000000000000e+00 )
accumulatedWork 9.54354372629752e-01
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonic1
firstStep 0
centers ( 0.00000000000000e+00 , 0.00000000000000e+00 , 1.00000000000000e+00 , 0.00000000000000e+00 )
accumulatedWork 9.54354372629752e-01
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 20
name harmonic1
firstStep 0
centers ( 0.00000000000000e+00 , 0.00000000000000e+00 , 1.00000000000000e+00 , 0.00000000000000e+00 )
accumulatedWork 9.46575449173417e-01
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ restraint {
configuration {
step 40
name harmonic1
firstStep 0
centers ( 0.00000000000000e+00 , 0.00000000000000e+00 , 1.00000000000000e+00 , 0.00000000000000e+00 )
accumulatedWork 9.46575449173417e-01
}
Expand Down
5 changes: 1 addition & 4 deletions lammps/src/COLVARS/colvarproxy_lammps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,7 @@ void colvarproxy_lammps::serialize_status(std::string &rst)
// set status from string
bool colvarproxy_lammps::deserialize_status(std::string &rst)
{
std::istringstream is;
is.str(rst);

if (!colvars->read_restart(is)) {
if (! colvarproxy_io::input_stream_from_string("input state string", rst)) {
return false;
} else {
return true;
Expand Down
5 changes: 3 additions & 2 deletions lammps/src/COLVARS/fix_colvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ void FixColvars::setup(int vflag)
if (me == 0) {
setup_io();
proxy->parse_module_config();
proxy->setup();
}

init_taglist();
Expand Down Expand Up @@ -905,7 +904,9 @@ void FixColvars::restart(char *buf)
{
if (me == 0) {
std::string rest_text(buf);
proxy->deserialize_status(rest_text);
if (!proxy->deserialize_status(rest_text)) {
error->all(FLERR, "Failed to set the Colvars input state from string buffer");
}
}
}

Expand Down
132 changes: 132 additions & 0 deletions lammps/tests/interface/003_binary_restart/AutoDiff/test.colvars.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
colvars: Creating proxy instance
colvars: ----------------------------------------------------------------------
colvars: Please cite Fiorin et al, Mol Phys 2013:
colvars: https://dx.doi.org/10.1080/00268976.2013.813594
colvars: in any publication based on this calculation.
colvars: This version was built with the C++11 standard or higher.
colvars: Using LAMMPS interface, version "2019-08-17".
colvars: ----------------------------------------------------------------------
colvars: Reading new configuration from file "test.in":
colvars: # indexFile = "index.ndx"
colvars: The following index groups were read from the index file "index.ndx":
colvars: Protein (104 atoms).
colvars: Protein_noH (51 atoms).
colvars: Protein_Backbone (40 atoms).
colvars: Protein_C-alpha (10 atoms).
colvars: RMSD_atoms (10 atoms).
colvars: Protein_C-alpha_1_2 (2 atoms).
colvars: Protein_C-alpha_9_10 (2 atoms).
colvars: Protein_C-alpha_1 (1 atoms).
colvars: group1 (4 atoms).
colvars: Protein_C-alpha_2 (1 atoms).
colvars: group2 (4 atoms).
colvars: Protein_C-alpha_3 (1 atoms).
colvars: group3 (4 atoms).
colvars: Protein_C-alpha_4 (1 atoms).
colvars: group4 (4 atoms).
colvars: Protein_C-alpha_5 (1 atoms).
colvars: group5 (4 atoms).
colvars: Protein_C-alpha_6 (1 atoms).
colvars: group6 (4 atoms).
colvars: Protein_C-alpha_7 (1 atoms).
colvars: group7 (4 atoms).
colvars: Protein_C-alpha_8 (1 atoms).
colvars: group8 (4 atoms).
colvars: Protein_C-alpha_9 (1 atoms).
colvars: group9 (4 atoms).
colvars: Protein_C-alpha_10 (1 atoms).
colvars: group10 (4 atoms).
colvars: heavy_atoms (51 atoms).
colvars: # smp = on [default]
colvars: # colvarsTrajFrequency = 1
colvars: # colvarsRestartFrequency = 10
colvars: # scriptedColvarForces = off [default]
colvars: # scriptingAfterBiases = off [default]
colvars: ----------------------------------------------------------------------
colvars: Initializing a new collective variable.
colvars: # name = "one"
colvars: Initializing a new "distance" component.
colvars: # name = "" [default]
colvars: # componentCoeff = 1 [default]
colvars: # componentExp = 1 [default]
colvars: # period = 0 [default]
colvars: # wrapAround = 0 [default]
colvars: # forceNoPBC = off [default]
colvars: # scalable = on [default]
colvars: Initializing atom group "group1".
colvars: # name = "" [default]
colvars: # centerReference = off [default]
colvars: # rotateReference = off [default]
colvars: # atomsOfGroup = "" [default]
colvars: # indexGroup = "group1"
colvars: # psfSegID = [default]
colvars: # atomsFile = "" [default]
colvars: # dummyAtom = ( 0 , 0 , 0 ) [default]
colvars: # enableForces = on [default]
colvars: # enableFitGradients = on [default]
colvars: # printAtomIDs = off [default]
colvars: Atom group "group1" defined with 4 atoms requested.
colvars: Initializing atom group "group2".
colvars: # name = "" [default]
colvars: # centerReference = off [default]
colvars: # rotateReference = off [default]
colvars: # atomsOfGroup = "" [default]
colvars: # indexGroup = "group2"
colvars: # psfSegID = [default]
colvars: # atomsFile = "" [default]
colvars: # dummyAtom = ( 0 , 0 , 0 ) [default]
colvars: # enableForces = on [default]
colvars: # enableFitGradients = on [default]
colvars: # printAtomIDs = off [default]
colvars: Atom group "group2" defined with 4 atoms requested.
colvars: # oneSiteSystemForce = off [default]
colvars: # oneSiteTotalForce = off [default]
colvars: All components initialized.
colvars: # timeStepFactor = 1 [default]
colvars: # width = 0.5
colvars: # lowerBoundary = 0 [default]
colvars: # upperBoundary = 0 [default]
colvars: # expandBoundaries = off [default]
colvars: # extendedLagrangian = off [default]
colvars: # outputValue = on [default]
colvars: # outputVelocity = off [default]
colvars: # outputTotalForce = off [default]
colvars: # outputAppliedForce = on
colvars: # subtractAppliedForce = off [default]
colvars: # runAve = off [default]
colvars: # corrFunc = off [default]
colvars: ----------------------------------------------------------------------
colvars: Collective variables initialized, 1 in total.
colvars: ----------------------------------------------------------------------
colvars: Initializing a new "harmonic" instance.
colvars: # name = "harmonic1" [default]
colvars: # colvars = { one }
colvars: # outputEnergy = on
colvars: # timeStepFactor = 1 [default]
colvars: # writeTISamples = off [default]
colvars: # writeTIPMF = off [default]
colvars: # centers = { 0.1 }
colvars: # targetCenters = { 0.2 }
colvars: # targetNumSteps = 10
colvars: # targetNumStages = 0 [default]
colvars: # outputAccumulatedWork = on
colvars: # outputCenters = on
colvars: # forceConstant = 0.001
colvars: # targetForceConstant = -1 [default]
colvars: The force constant for colvar "one" will be rescaled to 0.004 according to the specified width (0.5).
colvars: ----------------------------------------------------------------------
colvars: Collective variables biases initialized, 1 in total.
colvars: ----------------------------------------------------------------------
colvars: Collective variables module (re)initialized.
colvars: ----------------------------------------------------------------------
colvars: The restart output state file will be "rest.colvars.state".
colvars: The final output state file will be "test.colvars.state".
colvars: Writing to colvar trajectory file "test.colvars.traj".
colvars: Re-initialized atom group for variable "one":0/0. 4 atoms: total mass = 54.028, total charge = -0.72.
colvars: Re-initialized atom group for variable "one":0/1. 4 atoms: total mass = 54.028, total charge = -0.4.
colvars: Synchronizing (emptying the buffer of) trajectory file "test.colvars.traj".
colvars: Saving collective variables state to "rest.colvars.state".
colvars: Synchronizing (emptying the buffer of) trajectory file "test.colvars.traj".
colvars: Saving collective variables state to "rest.colvars.state".
colvars: Saving collective variables state to "test.colvars.state".
colvars: Resetting the Collective Variables module.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
configuration {
step 20
dt 1.000000e+00
}

colvar {
name one
x 3.21927610288861e+00
}

restraint {
configuration {
step 20
name harmonic1
firstStep 0
centers 2.00000000000000e-01
accumulatedWork -1.22156562115015e-03
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# step one fa_one E_harmonic1 x0_one W_harmonic1
0 3.20554673729024e+00 -1.24221869491610e-02 1.92888410749882e-02 1.00000000000000e-01 0.00000000000000e+00
1 3.20438161758906e+00 -1.23775264703562e-02 1.91503951905462e-02 1.10000000000000e-01 -1.23775264703563e-04
2 3.20388055819324e+00 -1.23355222327730e-02 1.90206385944045e-02 1.20000000000000e-01 -2.47130487031292e-04
3 3.20405695050090e+00 -1.22962278020036e-02 1.88996522698458e-02 1.30000000000000e-01 -3.70092765051328e-04
4 3.20488566343521e+00 -1.22595426537408e-02 1.87870482598613e-02 1.40000000000000e-01 -4.92688191588736e-04
5 3.20630523013386e+00 -1.22252209205354e-02 1.86820033194872e-02 1.50000000000000e-01 -6.14940400794091e-04
6 3.20822193294306e+00 -1.21928877317723e-02 1.85833139049503e-02 1.60000000000000e-01 -7.36869278111813e-04
7 3.21051524726036e+00 -1.21620609890414e-02 1.84894659376454e-02 1.70000000000000e-01 -8.58489888002227e-04
8 3.21304438443477e+00 -1.21321775377391e-02 1.83987164759025e-02 1.80000000000000e-01 -9.79811663379618e-04
9 3.21565597399793e+00 -1.21026238959917e-02 1.83091881459787e-02 1.90000000000000e-01 -1.10083790233954e-03
10 3.21819297026538e+00 -1.20727718810615e-02 1.82189776115188e-02 2.00000000000000e-01 -1.22156562115015e-03
11 3.22050455244023e+00 -1.20820182097609e-02 1.82468955026243e-02 2.00000000000000e-01 -1.22156562115015e-03
12 3.22245626645718e+00 -1.20898250658287e-02 1.82704837652926e-02 2.00000000000000e-01 -1.22156562115015e-03
13 3.22393923848317e+00 -1.20957569539327e-02 1.82884170360763e-02 2.00000000000000e-01 -1.22156562115015e-03
14 3.22487721259280e+00 -1.20995088503712e-02 1.82997643025264e-02 2.00000000000000e-01 -1.22156562115015e-03
15 3.22523054868521e+00 -1.21009221947408e-02 1.83040397453964e-02 2.00000000000000e-01 -1.22156562115015e-03
16 3.22499693749777e+00 -1.20999877499911e-02 1.83012129437417e-02 2.00000000000000e-01 -1.22156562115015e-03
17 3.22420921060027e+00 -1.20968368424011e-02 1.82916826989590e-02 2.00000000000000e-01 -1.22156562115015e-03
18 3.22293098631693e+00 -1.20917239452677e-02 1.82762234960701e-02 2.00000000000000e-01 -1.22156562115015e-03
19 3.22125091863508e+00 -1.20850036745403e-02 1.82559142267067e-02 2.00000000000000e-01 -1.22156562115015e-03
20 3.21927610288861e+00 -1.20771044115544e-02 1.82320563709485e-02 2.00000000000000e-01 -1.22156562115015e-03
Loading