Added unit-test for orientation restraints output.
authorDavid van der Spoel <spoel@xray.bmc.uu.se>
Thu, 27 Jul 2017 07:16:51 +0000 (09:16 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 28 Jul 2017 15:30:10 +0000 (17:30 +0200)
In order to allow splitting of the gmx energy functionality
into an NMR and an energy part additional tests are needed.
The regression test tests the content of the edr file but
not the extraction to xvg files, which is what this test
contributes.

The test is complicated by intricate differences between single-
and double precision files, which was cleaned up.

Had to add memory cleanups in multiple locations as well, e.g.
for cleaning cmap data structures. Never touch untouched code.
Change-Id: I0a6ee05f38bd198c9a3c37f7f837a28ce77b74e0

src/gromacs/energyanalysis/tests/legacyenergy.cpp
src/gromacs/energyanalysis/tests/orires.edr [new file with mode: 0644]
src/gromacs/energyanalysis/tests/orires.tpr [new file with mode: 0644]
src/gromacs/energyanalysis/tests/refdata/OriresTest_ExtractOrires.xml [new file with mode: 0644]
src/gromacs/gmxana/gmx_energy.cpp
src/gromacs/mdtypes/inputrec.cpp
src/gromacs/topology/topology.cpp

index e906db1bb693774b05cfe979325ee6d6e5ee1a62..d64d70662971d1fab69e895aa5b034b365604809 100644 (file)
@@ -86,6 +86,38 @@ TEST_F(DhdlTest, ExtractDhdl)
     runTest();
 }
 
+class OriresTest : public CommandLineTestBase
+{
+    public:
+        void runTest(const char *stringForStdin)
+        {
+            auto &cmdline = commandLine();
+            cmdline.append("energy");
+
+            setInputFile("-s", "orires.tpr");
+            setInputFile("-f", "orires.edr");
+            test::XvgMatch    xvg;
+            test::XvgMatch   &toler     = xvg.tolerance(gmx::test::relativeToleranceAsFloatingPoint(1, 1e-4));
+
+            setOutputFile("-oten", ".xvg", toler);
+            setOutputFile("-ora", ".xvg", toler);
+            setOutputFile("-ort", ".xvg", toler);
+            setOutputFile("-oda", ".xvg", toler);
+            setOutputFile("-odr", ".xvg", toler);
+
+            StdioTestHelper stdioHelper(&fileManager());
+            stdioHelper.redirectStringToStdin(stringForStdin);
+            ASSERT_EQ(0, gmx_energy(cmdline.argc(), cmdline.argv()));
+
+            checkOutputFiles();
+        }
+};
+
+TEST_F(OriresTest, ExtractOrires)
+{
+    runTest("Orient.-Rest.\nOri.-R.-RMSD\n0\n-1\n");
+}
+
 class EnergyTest : public CommandLineTestBase
 {
     public:
diff --git a/src/gromacs/energyanalysis/tests/orires.edr b/src/gromacs/energyanalysis/tests/orires.edr
new file mode 100644 (file)
index 0000000..5517334
Binary files /dev/null and b/src/gromacs/energyanalysis/tests/orires.edr differ
diff --git a/src/gromacs/energyanalysis/tests/orires.tpr b/src/gromacs/energyanalysis/tests/orires.tpr
new file mode 100644 (file)
index 0000000..b8fa860
Binary files /dev/null and b/src/gromacs/energyanalysis/tests/orires.tpr differ
diff --git a/src/gromacs/energyanalysis/tests/refdata/OriresTest_ExtractOrires.xml b/src/gromacs/energyanalysis/tests/refdata/OriresTest_ExtractOrires.xml
new file mode 100644 (file)
index 0000000..432e4e0
--- /dev/null
@@ -0,0 +1,379 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+  <OutputFiles Name="Files">
+    <File Name="-oten">
+      <XvgLegend Name="Legend">
+        <String Name="XvgLegend"><![CDATA[
+title "Order tensor"
+xaxis  label "Time (ps)"
+yaxis  label ""
+TYPE xy
+s0 legend "eig1"
+s1 legend "eig2"
+s2 legend "eig3"
+]]></String>
+      </XvgLegend>
+      <XvgData Name="Data">
+        <Sequence Name="Row0">
+          <Int Name="Length">4</Int>
+          <Real>0.000000</Real>
+          <Real>0.000874024</Real>
+          <Real>-0.000514914</Real>
+          <Real>-0.00035911</Real>
+        </Sequence>
+        <Sequence Name="Row1">
+          <Int Name="Length">4</Int>
+          <Real>0.002000</Real>
+          <Real>0.000957853</Real>
+          <Real>-0.000568174</Real>
+          <Real>-0.00038968</Real>
+        </Sequence>
+        <Sequence Name="Row2">
+          <Int Name="Length">4</Int>
+          <Real>0.004000</Real>
+          <Real>0.0010501</Real>
+          <Real>-0.000591766</Real>
+          <Real>-0.000458333</Real>
+        </Sequence>
+        <Sequence Name="Row3">
+          <Int Name="Length">4</Int>
+          <Real>0.006000</Real>
+          <Real>0.00109263</Real>
+          <Real>-0.000597102</Real>
+          <Real>-0.000495525</Real>
+        </Sequence>
+        <Sequence Name="Row4">
+          <Int Name="Length">4</Int>
+          <Real>0.008000</Real>
+          <Real>0.00110458</Real>
+          <Real>-0.000597999</Real>
+          <Real>-0.000506579</Real>
+        </Sequence>
+        <Sequence Name="Row5">
+          <Int Name="Length">4</Int>
+          <Real>0.010000</Real>
+          <Real>0.00110374</Real>
+          <Real>-0.000602079</Real>
+          <Real>-0.000501658</Real>
+        </Sequence>
+        <Sequence Name="Row6">
+          <Int Name="Length">4</Int>
+          <Real>0.012000</Real>
+          <Real>0.00109991</Real>
+          <Real>-0.000609947</Real>
+          <Real>-0.00048996</Real>
+        </Sequence>
+        <Sequence Name="Row7">
+          <Int Name="Length">4</Int>
+          <Real>0.014000</Real>
+          <Real>0.00109939</Real>
+          <Real>-0.000620441</Real>
+          <Real>-0.000478945</Real>
+        </Sequence>
+        <Sequence Name="Row8">
+          <Int Name="Length">4</Int>
+          <Real>0.016000</Real>
+          <Real>0.00110964</Real>
+          <Real>-0.00063242</Real>
+          <Real>-0.000477215</Real>
+        </Sequence>
+        <Sequence Name="Row9">
+          <Int Name="Length">4</Int>
+          <Real>0.018000</Real>
+          <Real>0.00114132</Real>
+          <Real>-0.000644279</Real>
+          <Real>-0.000497043</Real>
+        </Sequence>
+        <Sequence Name="Row10">
+          <Int Name="Length">4</Int>
+          <Real>0.020000</Real>
+          <Real>0.00120594</Real>
+          <Real>-0.000654815</Real>
+          <Real>-0.000551126</Real>
+        </Sequence>
+      </XvgData>
+    </File>
+    <File Name="-ora">
+      <XvgLegend Name="Legend">
+        <String Name="XvgLegend"><![CDATA[
+title "Average calculated orientations"
+xaxis  label "Restraint label"
+yaxis  label ""
+TYPE xy
+]]></String>
+      </XvgLegend>
+      <XvgData Name="Data">
+        <Sequence Name="Row0">
+          <Int Name="Length">2</Int>
+          <Real>3</Real>
+          <Real>-5.65282</Real>
+        </Sequence>
+        <Sequence Name="Row1">
+          <Int Name="Length">2</Int>
+          <Real>4</Real>
+          <Real>-6.6605</Real>
+        </Sequence>
+        <Sequence Name="Row2">
+          <Int Name="Length">2</Int>
+          <Real>5</Real>
+          <Real>-5.05241</Real>
+        </Sequence>
+        <Sequence Name="Row3">
+          <Int Name="Length">2</Int>
+          <Real>6</Real>
+          <Real>-4.79816</Real>
+        </Sequence>
+        <Sequence Name="Row4">
+          <Int Name="Length">2</Int>
+          <Real>7</Real>
+          <Real>-1.77661</Real>
+        </Sequence>
+        <Sequence Name="Row5">
+          <Int Name="Length">2</Int>
+          <Real>8</Real>
+          <Real>-5.81927</Real>
+        </Sequence>
+        <Sequence Name="Row6">
+          <Int Name="Length">2</Int>
+          <Real>9</Real>
+          <Real>-3.85166</Real>
+        </Sequence>
+      </XvgData>
+    </File>
+    <File Name="-ort">
+      <XvgLegend Name="Legend">
+        <String Name="XvgLegend"><![CDATA[
+title "Calculated orientations"
+xaxis  label "Time (ps)"
+yaxis  label ""
+TYPE xy
+s0 legend "3"
+s1 legend "4"
+s2 legend "5"
+s3 legend "6"
+s4 legend "7"
+s5 legend "8"
+s6 legend "9"
+]]></String>
+      </XvgLegend>
+      <XvgData Name="Data">
+        <Sequence Name="Row0">
+          <Int Name="Length">8</Int>
+          <Real>0.000000</Real>
+          <Real>-4.89452</Real>
+          <Real>-5.87842</Real>
+          <Real>-5.30698</Real>
+          <Real>-5.01504</Real>
+          <Real>-0.544227</Real>
+          <Real>-4.75521</Real>
+          <Real>-5.82053</Real>
+        </Sequence>
+        <Sequence Name="Row1">
+          <Int Name="Length">8</Int>
+          <Real>0.002000</Real>
+          <Real>-5.15825</Real>
+          <Real>-6.3131</Real>
+          <Real>-4.82974</Real>
+          <Real>-5.30595</Real>
+          <Real>-0.699448</Real>
+          <Real>-5.26383</Real>
+          <Real>-4.98295</Real>
+        </Sequence>
+        <Sequence Name="Row2">
+          <Int Name="Length">8</Int>
+          <Real>0.004000</Real>
+          <Real>-5.50881</Real>
+          <Real>-6.5012</Real>
+          <Real>-4.6769</Real>
+          <Real>-5.30756</Real>
+          <Real>-1.18245</Real>
+          <Real>-5.6455</Real>
+          <Real>-4.25769</Real>
+        </Sequence>
+        <Sequence Name="Row3">
+          <Int Name="Length">8</Int>
+          <Real>0.006000</Real>
+          <Real>-5.78819</Real>
+          <Real>-6.57865</Real>
+          <Real>-4.73666</Real>
+          <Real>-5.14671</Real>
+          <Real>-1.67991</Real>
+          <Real>-5.82657</Real>
+          <Real>-3.80163</Real>
+        </Sequence>
+        <Sequence Name="Row4">
+          <Int Name="Length">8</Int>
+          <Real>0.008000</Real>
+          <Real>-5.94801</Real>
+          <Real>-6.63582</Real>
+          <Real>-4.8771</Real>
+          <Real>-4.94553</Real>
+          <Real>-2.03635</Real>
+          <Real>-5.89558</Real>
+          <Real>-3.55664</Real>
+        </Sequence>
+        <Sequence Name="Row5">
+          <Int Name="Length">8</Int>
+          <Real>0.010000</Real>
+          <Real>-5.99537</Real>
+          <Real>-6.69487</Real>
+          <Real>-5.0156</Real>
+          <Real>-4.77013</Real>
+          <Real>-2.23404</Real>
+          <Real>-5.93982</Real>
+          <Real>-3.4359</Real>
+        </Sequence>
+        <Sequence Name="Row6">
+          <Int Name="Length">8</Int>
+          <Real>0.012000</Real>
+          <Real>-5.95561</Real>
+          <Real>-6.75984</Real>
+          <Real>-5.1177</Real>
+          <Real>-4.63846</Real>
+          <Real>-2.30732</Real>
+          <Real>-6.0011</Real>
+          <Real>-3.37638</Real>
+        </Sequence>
+        <Sequence Name="Row7">
+          <Int Name="Length">8</Int>
+          <Real>0.014000</Real>
+          <Real>-5.86272</Real>
+          <Real>-6.83544</Real>
+          <Real>-5.18525</Real>
+          <Real>-4.53827</Real>
+          <Real>-2.29768</Real>
+          <Real>-6.08155</Real>
+          <Real>-3.3403</Real>
+        </Sequence>
+        <Sequence Name="Row8">
+          <Int Name="Length">8</Int>
+          <Real>0.016000</Real>
+          <Real>-5.75713</Real>
+          <Real>-6.9238</Real>
+          <Real>-5.23559</Real>
+          <Real>-4.45047</Real>
+          <Real>-2.24405</Real>
+          <Real>-6.16018</Real>
+          <Real>-3.3078</Real>
+        </Sequence>
+        <Sequence Name="Row9">
+          <Int Name="Length">8</Int>
+          <Real>0.018000</Real>
+          <Real>-5.67512</Real>
+          <Real>-7.02144</Real>
+          <Real>-5.27937</Real>
+          <Real>-4.36782</Real>
+          <Real>-2.18139</Real>
+          <Real>-6.21335</Real>
+          <Real>-3.26937</Real>
+        </Sequence>
+        <Sequence Name="Row10">
+          <Int Name="Length">8</Int>
+          <Real>0.020000</Real>
+          <Real>-5.63729</Real>
+          <Real>-7.12295</Real>
+          <Real>-5.31557</Real>
+          <Real>-4.29384</Real>
+          <Real>-2.1358</Real>
+          <Real>-6.22931</Real>
+          <Real>-3.21908</Real>
+        </Sequence>
+      </XvgData>
+    </File>
+    <File Name="-oda">
+      <XvgLegend Name="Legend">
+        <String Name="XvgLegend"><![CDATA[
+title "Average restraint deviation"
+xaxis  label "Restraint label"
+yaxis  label ""
+TYPE xy
+]]></String>
+      </XvgLegend>
+      <XvgData Name="Data">
+        <Sequence Name="Row0">
+          <Int Name="Length">2</Int>
+          <Real>3</Real>
+          <Real>1.07718</Real>
+        </Sequence>
+        <Sequence Name="Row1">
+          <Int Name="Length">2</Int>
+          <Real>4</Real>
+          <Real>1.2095</Real>
+        </Sequence>
+        <Sequence Name="Row2">
+          <Int Name="Length">2</Int>
+          <Real>5</Real>
+          <Real>2.07759</Real>
+        </Sequence>
+        <Sequence Name="Row3">
+          <Int Name="Length">2</Int>
+          <Real>6</Real>
+          <Real>-2.22816</Real>
+        </Sequence>
+        <Sequence Name="Row4">
+          <Int Name="Length">2</Int>
+          <Real>7</Real>
+          <Real>0.323394</Real>
+        </Sequence>
+        <Sequence Name="Row5">
+          <Int Name="Length">2</Int>
+          <Real>8</Real>
+          <Real>-1.71927</Real>
+        </Sequence>
+        <Sequence Name="Row6">
+          <Int Name="Length">2</Int>
+          <Real>9</Real>
+          <Real>-0.751661</Real>
+        </Sequence>
+      </XvgData>
+    </File>
+    <File Name="-odr">
+      <XvgLegend Name="Legend">
+        <String Name="XvgLegend"><![CDATA[
+title "RMS orientation restraint deviations"
+xaxis  label "Restraint label"
+yaxis  label ""
+TYPE xy
+]]></String>
+      </XvgLegend>
+      <XvgData Name="Data">
+        <Sequence Name="Row0">
+          <Int Name="Length">2</Int>
+          <Real>3</Real>
+          <Real>1.1271</Real>
+        </Sequence>
+        <Sequence Name="Row1">
+          <Int Name="Length">2</Int>
+          <Real>4</Real>
+          <Real>1.25451</Real>
+        </Sequence>
+        <Sequence Name="Row2">
+          <Int Name="Length">2</Int>
+          <Real>5</Real>
+          <Real>2.08989</Real>
+        </Sequence>
+        <Sequence Name="Row3">
+          <Int Name="Length">2</Int>
+          <Real>6</Real>
+          <Real>2.25577</Real>
+        </Sequence>
+        <Sequence Name="Row4">
+          <Int Name="Length">2</Int>
+          <Real>7</Real>
+          <Real>0.70923</Real>
+        </Sequence>
+        <Sequence Name="Row5">
+          <Int Name="Length">2</Int>
+          <Real>8</Real>
+          <Real>1.7722</Real>
+        </Sequence>
+        <Sequence Name="Row6">
+          <Int Name="Length">2</Int>
+          <Real>9</Real>
+          <Real>1.10045</Real>
+        </Sequence>
+      </XvgData>
+    </File>
+  </OutputFiles>
+</ReferenceData>
index 0b69c9dbba852044d807f74ecf1e658660d74934..7c9f28e0e1577a100f5ea5e479e93950f60aecb0 100644 (file)
@@ -124,6 +124,24 @@ static double mypow(double x, double y)
     }
 }
 
+static real blk_value(t_enxblock *blk, int sub, int index)
+{
+    range_check(index, 0, blk->sub[sub].nr);
+    if (blk->sub[sub].type == xdr_datatype_float)
+    {
+        return blk->sub[sub].fval[index];
+    }
+    else if (blk->sub[sub].type == xdr_datatype_double)
+    {
+        return blk->sub[sub].dval[index];
+    }
+    else
+    {
+        gmx_incons("Unknown datatype in t_enxblock");
+    }
+    return 0.0;
+}
+
 static int *select_it(int nre, char *nm[], int *nset)
 {
     gmx_bool *bE;
@@ -387,7 +405,7 @@ static void get_orires_parms(const char *topnm, t_inputrec *ir,
                              int *nor, int *nex, int **label, real **obs)
 {
     gmx_mtop_t      mtop;
-    gmx_localtop_t *top;
+    t_topology      top;
     t_iparams      *ip;
     int             natoms, i;
     t_iatom        *iatom;
@@ -395,13 +413,13 @@ static void get_orires_parms(const char *topnm, t_inputrec *ir,
     matrix          box;
 
     read_tpx(topnm, ir, box, &natoms, nullptr, nullptr, &mtop);
-    top = gmx_mtop_generate_local_top(&mtop, ir->efep != efepNO);
+    top = gmx_mtop_t_to_t_topology(&mtop, FALSE);
 
-    ip       = top->idef.iparams;
-    iatom    = top->idef.il[F_ORIRES].iatoms;
+    ip       = top.idef.iparams;
+    iatom    = top.idef.il[F_ORIRES].iatoms;
 
     /* Count how many distance restraint there are... */
-    nb = top->idef.il[F_ORIRES].nr;
+    nb = top.idef.il[F_ORIRES].nr;
     if (nb == 0)
     {
         gmx_fatal(FARGS, "No orientation restraints in topology!\n");
@@ -422,6 +440,7 @@ static void get_orires_parms(const char *topnm, t_inputrec *ir,
     }
     fprintf(stderr, "Found %d orientation restraints with %d experiments",
             *nor, *nex);
+    done_top_mtop(&top, &mtop);
 }
 
 static int get_bounds(const char *topnm,
@@ -2031,7 +2050,6 @@ int gmx_energy(int argc, char *argv[])
     const char        *orinst_sub = "@ subtitle \"instantaneous\"\n";
     char               buf[256];
     gmx_output_env_t  *oenv;
-    t_enxblock        *blk       = nullptr;
     t_enxblock        *blk_disre = nullptr;
     int                ndisre    = 0;
     int                dh_blocks = 0, dh_hists = 0, dh_samples = 0, dh_lambdas = 0;
@@ -2287,6 +2305,10 @@ int gmx_energy(int argc, char *argv[])
                     }
                     xvgr_legend(fodt, norsel, (const char**)odtleg, oenv);
                 }
+                for (i = 0; i < norsel; i++)
+                {
+                    sfree(odtleg[i]);
+                }
                 sfree(odtleg);
             }
         }
@@ -2312,6 +2334,11 @@ int gmx_energy(int argc, char *argv[])
                 }
             }
             xvgr_legend(foten, bOvec ? nex*12 : nex*3, (const char**)otenleg, oenv);
+            for (j = 0; j < 3; j++)
+            {
+                sfree(otenleg[j]);
+            }
+            sfree(otenleg);
         }
     }
     else if (bDisRe)
@@ -2628,25 +2655,13 @@ int gmx_energy(int argc, char *argv[])
                             fprintf(out, "\n");
                         }
                     }
-                    blk = find_block_id_enxframe(fr, enx_i, nullptr);
+                    t_enxblock *blk = find_block_id_enxframe(fr, enx_i, nullptr);
                     if (bORIRE && blk)
                     {
-#if !GMX_DOUBLE
-                        xdr_datatype dt = xdr_datatype_float;
-#else
-                        xdr_datatype dt = xdr_datatype_double;
-#endif
-                        real        *vals;
-
-                        if ( (blk->nsub != 1) || (blk->sub[0].type != dt) )
+                        if (blk->nsub != 1)
                         {
-                            gmx_fatal(FARGS, "Orientational restraints read in incorrectly");
+                            gmx_fatal(FARGS, "Orientational restraints read in incorrectly.");
                         }
-#if !GMX_DOUBLE
-                        vals = blk->sub[0].fval;
-#else
-                        vals = blk->sub[0].dval;
-#endif
 
                         if (blk->sub[0].nr != nor)
                         {
@@ -2656,14 +2671,15 @@ int gmx_energy(int argc, char *argv[])
                         {
                             for (i = 0; i < nor; i++)
                             {
-                                orient[i] += vals[i];
+                                orient[i] += blk_value(blk, 0, i);
                             }
                         }
                         if (bODR)
                         {
                             for (i = 0; i < nor; i++)
                             {
-                                odrms[i] += gmx::square(vals[i]-oobs[i]);
+                                real v = blk_value(blk, 0, i);
+                                odrms[i] += gmx::square(v - oobs[i]);
                             }
                         }
                         if (bORT)
@@ -2671,7 +2687,7 @@ int gmx_energy(int argc, char *argv[])
                             fprintf(fort, "  %10f", fr->t);
                             for (i = 0; i < norsel; i++)
                             {
-                                fprintf(fort, " %g", vals[orsel[i]]);
+                                fprintf(fort, " %g", blk_value(blk, 0, orsel[i]));
                             }
                             fprintf(fort, "\n");
                         }
@@ -2680,7 +2696,7 @@ int gmx_energy(int argc, char *argv[])
                             fprintf(fodt, "  %10f", fr->t);
                             for (i = 0; i < norsel; i++)
                             {
-                                fprintf(fodt, " %g", vals[orsel[i]]-oobs[orsel[i]]);
+                                fprintf(fodt, " %g", blk_value(blk, 0, orsel[i])-oobs[orsel[i]]);
                             }
                             fprintf(fodt, "\n");
                         }
@@ -2689,22 +2705,10 @@ int gmx_energy(int argc, char *argv[])
                     blk = find_block_id_enxframe(fr, enxORT, nullptr);
                     if (bOTEN && blk)
                     {
-#if !GMX_DOUBLE
-                        xdr_datatype dt = xdr_datatype_float;
-#else
-                        xdr_datatype dt = xdr_datatype_double;
-#endif
-                        real        *vals;
-
-                        if ( (blk->nsub != 1) || (blk->sub[0].type != dt) )
+                        if (blk->nsub != 1)
                         {
                             gmx_fatal(FARGS, "Orientational restraints read in incorrectly");
                         }
-#if !GMX_DOUBLE
-                        vals = blk->sub[0].fval;
-#else
-                        vals = blk->sub[0].dval;
-#endif
 
                         if (blk->sub[0].nr != nex*12)
                         {
@@ -2716,7 +2720,7 @@ int gmx_energy(int argc, char *argv[])
                         {
                             for (j = 0; j < (bOvec ? 12 : 3); j++)
                             {
-                                fprintf(foten, " %g", vals[i*12+j]);
+                                fprintf(foten, " %g", blk_value(blk, 0, i*12+j));
                             }
                         }
                         fprintf(foten, "\n");
@@ -2793,6 +2797,12 @@ int gmx_energy(int argc, char *argv[])
         }
         xvgrclose(out);
     }
+    // Clean up orires variables.
+    sfree(or_label);
+    sfree(oobs);
+    sfree(orient);
+    sfree(odrms);
+    sfree(orsel);
     if (bOTEN)
     {
         xvgrclose(foten);
index dac1821dfb91bd5b97d33d199f21441f0237ec55..6391a8a663e473931040473e0f0fe844f61cb2c6 100644 (file)
@@ -299,8 +299,8 @@ static void done_lambdas(t_lambda *fep)
         {
             sfree(fep->all_lambda[i]);
         }
-        sfree(fep->all_lambda);
     }
+    sfree(fep->all_lambda);
 }
 
 void done_inputrec(t_inputrec *ir)
index f194f23af7b13c95a605a101126dab0e879ae84b..ac9ec0d9bb6f0bf7e3d01588e2dfd69225f0918b 100644 (file)
@@ -150,6 +150,11 @@ void done_mtop(gmx_mtop_t *mtop)
 
     sfree(mtop->ffparams.functype);
     sfree(mtop->ffparams.iparams);
+    for (int i = 0; i < mtop->ffparams.cmap_grid.ngrid; i++)
+    {
+        sfree(mtop->ffparams.cmap_grid.cmapdata[i].cmap);
+    }
+    sfree(mtop->ffparams.cmap_grid.cmapdata);
 
     for (int i = 0; i < mtop->nmoltype; i++)
     {