********> bugfix.61 Correction Author: David A. Pearlman Correction Date: 03/24/94 Programs: GIBBS Severity: Serious Problem: A free energy calculation restart can result in erroneous results if ALL the following conditions are met: 1) The free energy calculation is run in more than one piece, resulting in a "restart" run (IREST=1). 2) Dynamically Modified Windows are being used where the the width of each window can vary (if DMW is requested, but the ability to change width at each window is defeated by setting DLMIN=DLMAX, no problem will occur). 3) Double-wide sampling is being used (IDWIDE=0). 4) The calculation is a "windows" type simulation, NOT a Thermodynamic Integration calculation. In any case, this bug will only affect the energy calculated in the direction OPPOSITE to the direction in which the simulation was run (see "Affects" below). Affects: If all the above conditions are met, then the free energy calculated in the direction OPPOSITE to that in which the simulation is run may be incorrect. That is, if the simulation is run 0->1, the total energy reported as "reverse" may be incorrect. If the simulation is run 1->0, the total energy reported as "forward" may be incorrect. In either case, the energy reported for the same direction as the simulation ("forward" for 0->1 or "reverse" for 1->0) will be CORRECT. The degree of error in the reported free energy in the opposite direction will depend on the difference in d_lambda in the direction of the simulation over the last window before the restart and the first window after the restart. If these two values of d_lambda are close, the error in the reported free energy will probably be small (and if they are equal, it will be zero). Cause: The value of delta_lambda over the window just calculated was being incorrectly written to the restart file. Instead of using the true value, the value of delta_lambda over the subsequent window was being written. Fix: Make the following changes to slwadj.f ---To routine WRTDYS in file slwadj.f ----------------------------------------- *** OLD slwadj.f --- NEW slwadj.f *************** *** 785,790 **** --- 785,803 ---- DATA FLAG/'SLOWDYN'/ VERSON = 4.001D0 C + C Bugfix.61: + C Following fixes bug in value of "DLOLD" written. The value written + C should reflect d_lambda in the direction opposite to that of the + C simulation. Previously, it was generally the same as lambda in the + C forward direction -- dap (3/94). + C + IF (IFTIME.GT.0) THEN + DLOLD2 = ALM(1)-ALM(5) + ELSE + DLOLD2 = ALM(3)-ALM(1) + END IF + + C C ----------------- C UNFORMATTED WRITES C ----------------- *************** *** 802,808 **** C Write variables for the SLWLOC block: C WRITE(NF) IONCE1,INRG,IDEL,IAVSL1,IAVDL1,IPTSSL, ! * IPTSDL,IENUF,DLOLD,ALMDEL,IONCE5 WRITE(NF) DELDS,DAFOLD,DAROLD,ETOT,CTIME WRITE(NF) ((DELA(I,J),I=1,2),J=1,IPTSSL) WRITE(NF) ((DELDA(I,J),I=1,2),J=1,IPTSDL) --- 815,821 ---- C Write variables for the SLWLOC block: C WRITE(NF) IONCE1,INRG,IDEL,IAVSL1,IAVDL1,IPTSSL, ! * IPTSDL,IENUF,DLOLD2,ALMDEL,IONCE5 WRITE(NF) DELDS,DAFOLD,DAROLD,ETOT,CTIME WRITE(NF) ((DELA(I,J),I=1,2),J=1,IPTSSL) WRITE(NF) ((DELDA(I,J),I=1,2),J=1,IPTSDL) *************** *** 834,840 **** C Read variables for the SLWLOC block: C WRITE(NF,9100) IONCE1,INRG,IDEL,IAVSL1,IAVDL1,IPTSSL, ! * IPTSDL,IENUF,DLOLD,ALMDEL,IONCE5 WRITE(NF,9110) DELDS,DAFOLD,DAROLD,ETOT,CTIME WRITE(NF,9110) ((DELA(I,J),I=1,2),J=1,IPTSSL) WRITE(NF,9110) ((DELDA(I,J),I=1,2),J=1,IPTSDL) --- 847,853 ---- C Read variables for the SLWLOC block: C WRITE(NF,9100) IONCE1,INRG,IDEL,IAVSL1,IAVDL1,IPTSSL, ! * IPTSDL,IENUF,DLOLD2,ALMDEL,IONCE5 WRITE(NF,9110) DELDS,DAFOLD,DAROLD,ETOT,CTIME WRITE(NF,9110) ((DELA(I,J),I=1,2),J=1,IPTSSL) WRITE(NF,9110) ((DELDA(I,J),I=1,2),J=1,IPTSDL) ------------------------------------------------------------------------------ Temporary workarounds: The results reported in the first section of the simulation (pre-restart) will be entirely correct. If you wish to use these results as input to a restart with corrected code, you must edit the restart file created by the first simulation. Search for the line starting with the keyword "SLOWDYN" in this file. The NEXT line will look something like: 1 2 0 2 0 8 0 1 0.3267250E-01 0.3267250E-01 9899 ^^^^^^^^^^^^^ where the two real values will be the same. Change the underlined value to the actual value of delta_lambda(old) over the last COMPLETED window in the first simulation. This can be ascertained by examination of the output file from the simulation. Find the LAST point at which the free energy was updated (lambda changed). Then, if the simulation was run 0->1, delta_lambda(old) = Lam+d_lam - Lambda. If the simulation was run 1->0, delta_lambda(old) = Lambda - Lam-d_lam. (The values of Lambda, Lam+d_lam & Lam-d_lam are clearly given in the output file). After making this change, the first restart leg of the simulation can be run. Remember that in any case, this bug does not affect free energy results reported for the direction of the simulation--these will be correct even in old code. (See "Affects" above). Routines affected: GIBBS Routine WRTDYS in file ...amber4/src/gibbs/slwadj.f ----