# Standard library logic error when restarting colvars run

**URL:** <https://gromacs.bioexcel.eu/t/standard-library-logic-error-when-restarting-colvars-run/7747>\
**Category:** User discussions\
**Tags:** mdrun, colvars\
**Created:** [November 29, 2023, 2:28pm UTC](https://gromacs.bioexcel.eu/t/standard-library-logic-error-when-restarting-colvars-run/7747 "2023-11-29T14:28:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattiafelicepalermo](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@mattiafelicepalermo](https://gromacs.bioexcel.eu/u/mattiafelicepalermo)\
**Post date:** [November 29, 2023, 2:28pm UTC](https://gromacs.bioexcel.eu/t/standard-library-logic-error-when-restarting-colvars-run/7747/1 "2023-11-29T14:28:28Z")

</div>

GROMACS version: 2023.3  
GROMACS modification: No

Dear GROMACS forum,

I’m running an MD simulation of ethane in argon gas, where I use the colvars module to explore energy profile of the H-C-C-H dihedral. This are the ABFsettings:

```auto
colvar {
  name phi
  width 2.
  lowerBoundary 0.
  upperBoundary +360.
  # H C C H
  dihedral {
    group1 { atomNumbers 3}
    group2 { atomNumbers 1}
    group3 { atomNumbers 2}
    group4 { atomNumbers 6}
  }
  extendedLagrangian on
  extendedFluctuation 0.1
}
abf {
 colvars phi
 fullSamples 200
}

```

Launching the MD run works fine, but once it finished I noticed that, during the simulation time, half of the range of the dihedral angle has not been explored.

Therefore, I tried to extend the simulation as follows:

`gmx mdrun -s abf_dihedral.tpr -cpi abf_dihedral.cpt -deffnm abf_dihedral -colvars abf_dihedral.dat -colvars_restart abf_dihedral_state.dat`

This is the error I get, which happens right after the program version is stated in the output:

```auto
Standard library logic error (bug):
(exception type: St12out_of_range)
basic_string::erase: __pos (which is 18446744073709551615) > this->size()
(which is 18)

```

Am I making any mistake in my workflow or is this a bug? I would appreciate your input in troubleshooting this.

Thank you in advance for your help and let me know if further details or files are needed.

Mattia

---

<div class="post-metadata">

**Author:** ![giacomo.fiorin](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/giacomo.fiorin/32/2862_2.png) [@giacomo.fiorin](https://gromacs.bioexcel.eu/u/giacomo.fiorin)\
**Post date:** [November 29, 2023, 2:54pm UTC](https://gromacs.bioexcel.eu/t/standard-library-logic-error-when-restarting-colvars-run/7747/2 "2023-11-29T14:54:50Z")

</div>

Hi Mattia, there is certainly a bug in that the code should be able to handle a potential error in the config without crashing. We’ll take a look.

Please also note that the `dihedral` function has by default a range of -180° to 180°.  
[https://colvars.github.io/gromacs-2023/colvars-refman-gromacs.html#sec:cvc\_dihedral](https://colvars.github.io/gromacs-2023/colvars-refman-gromacs.html#sec:cvc_dihedral)  
If you want to use 0-360 try the `wrapAround` keyword inside `dihedral`, with a value of 180.0:  
[https://colvars.github.io/gromacs-2023/colvars-refman-gromacs.html#sec:cvc\_periodic](https://colvars.github.io/gromacs-2023/colvars-refman-gromacs.html#sec:cvc_periodic)

Lastly, GROMACS 2024 beta now supports Colvars natively:  
[https://colvars.github.io/gromacs-2024/colvars-refman-gromacs.html#sec:colvars\_mdengine\_parameters](https://colvars.github.io/gromacs-2024/colvars-refman-gromacs.html#sec:colvars_mdengine_parameters)  
You may want to give it a try.

Giacomo

---

<div class="post-metadata">

**Author:** ![Hub](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hub/32/634_2.png) [@Hub](https://gromacs.bioexcel.eu/u/Hub)\
**Post date:** [November 30, 2023, 8:15am UTC](https://gromacs.bioexcel.eu/t/standard-library-logic-error-when-restarting-colvars-run/7747/3 "2023-11-30T08:15:12Z")

</div>

Hi Mattia,

Thanks for reporting the issue, this looks indeed like a bug.  
Could you share the tpr file so we could try to reproduce the error ?

Thanks,  
Hubert

---

<div class="post-metadata">

**Author:** ![mattiafelicepalermo](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@mattiafelicepalermo](https://gromacs.bioexcel.eu/u/mattiafelicepalermo)\
**Post date:** [December 1, 2023, 7:02am UTC](https://gromacs.bioexcel.eu/t/standard-library-logic-error-when-restarting-colvars-run/7747/4 "2023-12-01T07:02:15Z")

</div>

Hello everyone,

thank you for your kind responses and useful inputs.

@giacomo.fiorin thank you for the suggestion of the wrapAround command. I’m trying to compare the PES from QM calculations, and unfortunately in ORCA the dihedral range can be only between 0 and 360.

@Hub I am attaching the tpr file as required, plus the colvars input and state file. Let me know if you need anything else for debugging purposes.  
[abf\_dihedral.dat](https://gromacs.bioexcel.eu/uploads/short-url/74WnZMEIFJQf6Wj9JpHgqlhoCEI.dat) (326 Bytes)  
[abf\_dihedral\_state.dat](https://gromacs.bioexcel.eu/uploads/short-url/z64uUuIJuDG0W8cLsoPbIo1EAg2.dat) (9.4 KB)

Mattia

---

<div class="post-metadata">

**Author:** ![mattiafelicepalermo](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@mattiafelicepalermo](https://gromacs.bioexcel.eu/u/mattiafelicepalermo)\
**Post date:** [December 1, 2023, 7:04am UTC](https://gromacs.bioexcel.eu/t/standard-library-logic-error-when-restarting-colvars-run/7747/5 "2023-12-01T07:04:15Z")

</div>

This is the tpr file (renamed with .dat extension due to the forum extension limitation).  
[abf\_dihedral.tpr.dat](https://gromacs.bioexcel.eu/uploads/short-url/jTmSE96kCPBsIfewdIpjbhQ9Dm7.dat) (5.9 KB)

---

<div class="post-metadata">

**Author:** ![Hub](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hub/32/634_2.png) [@Hub](https://gromacs.bioexcel.eu/u/Hub)\
**Post date:** [December 8, 2023, 2:02pm UTC](https://gromacs.bioexcel.eu/t/standard-library-logic-error-when-restarting-colvars-run/7747/6 "2023-12-08T14:02:27Z")

</div>

Hi Mattia,

Thanks for the file. I’m able to reproduce the error.  
The reason is the name of the colvars restart file : `-colvars_restart abf_dihedral_state.dat`.

In the colvars/gromacs code, we assume the name of this restart file is always in the form of **X.colvars.state.dat** so in your case `abf_dihedral.colvars.state.dat`.  
[Edit: you need in fact to have this file copied twice : one with the name `abf_dihedral.colvars.state.dat` to be read by mdrun and one with the name `abf_dihedral.colvars.state` to be parsed by colvars]

It will not happen in GMX 2024 because we handle the restart information differently.

Anyway, I will report the issue for GROMACS 2023 and below to have a more meaningful error message and remove the need to have 2 copies of the same file
