update gromacs/wham2d example for dialanine

This commit is contained in:
Daniel Bauer
2018-06-17 10:55:28 +02:00
parent e298515a63
commit 0cce09b213
6 changed files with 48 additions and 12 deletions

13
examples/data/plumed.dat Normal file
View File

@@ -0,0 +1,13 @@
# set up two variables for Phi and Psi dihedral angles
phi: TORSION ATOMS=5,7,9,15
psi: TORSION ATOMS=7,9,15,17
#
# Impose an umbrella potential on CV 1 and CV 2
# with a spring constant of 500 kjoule/mol
# at fixed points on the Ramachandran plot
#
restraint-phi: RESTRAINT ARG=phi KAPPA=100 AT=LAMBDA1
restraint-psi: RESTRAINT ARG=psi KAPPA=100 AT=LAMBDA2
# monitor the two variables and the bias potential from the two restraints
PRINT STRIDE=10 ARG=phi,psi,restraint-phi.bias,restraint-psi.bias FILE=COLVAR UPDATE_FROM=50

23
examples/data/sim.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
lambda1=$1
lambda2=$2
FOLDER="./tmp/simulations/sim_${lambda1}_${lambda2}"
if [ -f $FOLDER/topol.gro ]; then
echo "$FOLDER exists"
exit 0
fi
mkdir -p $FOLDER
cp data/plumed.dat $FOLDER
cp data/topol.tpr $FOLDER
sed -i -e "s/LAMBDA1/${lambda1}/g" $FOLDER/plumed.dat
sed -i -e "s/LAMBDA2/${lambda2}/g" $FOLDER/plumed.dat
cd $FOLDER
source /usr/local/gromacs/bin/GMXRC
gmx --quiet mdrun -deffnm topol -plumed plumed.dat -nsteps 100000 2>&1
cd ../..

BIN
examples/data/topol.edr Normal file

Binary file not shown.

BIN
examples/data/topol.tpr Normal file

Binary file not shown.

View File

@@ -24,11 +24,11 @@ class WHAM2DRunner(UmbrellaRunner):
import os
from shutil import copyfile
simulation_dir = "simulations"
simulation_dir = "tmp/simulations"
print("Collecting sampling data from simulations folder")
# collect COLVARs
wham_dir = "WHAM/"
wham_dir = "tmp/WHAM/"
if not os.path.exists(wham_dir):
os.makedirs(wham_dir)
@@ -44,7 +44,7 @@ class WHAM2DRunner(UmbrellaRunner):
with open(metadata_file, 'w') as out:
for f in os.listdir(simulation_dir):
prefix, x, y = f.split("_")
out.write("WHAM/{}.xvg {} {} {} {}\n".format(f, x, y, fc_x, fc_y))
out.write("{}/{}.xvg {} {} {} {}\n".format(wham_dir, f, x, y, fc_x, fc_y))
# run WHAM2d
print("Running WHAM-2d")
@@ -101,7 +101,7 @@ class WHAM2DRunner(UmbrellaRunner):
class MyUmbrellaRunner(WHAM2DRunner):
def after_run_hook(self):
filename = "pmf_{}.pdf".format(self.num_iterations)
filename = "tmp/pmf_{}.pdf".format(self.num_iterations)
print("Writing new pmf to {}".format(filename))
pmf_to_plot = deepcopy(self.pmf.T)
pmf_to_plot[pmf_to_plot < 0] = None
@@ -118,22 +118,21 @@ class MyUmbrellaRunner(WHAM2DRunner):
cb = plt.colorbar(pad=0.1)
cb.set_label("kJ/mol")
plt.savefig(filename)
os.system("cp {} {}".format(filename, "pmf_current.pdf"))
os.system("cp {} {}".format(filename, "tmp/pmf_current.pdf"))
def simulate_frames(self, lambdas, frames):
print("{} new simulations:".format(len(lambdas)))
counter = 0
if not os.path.exists("tmp"):
os.mkdir('tmp')
threads = []
for f in lambdas:
counter += 1
if os.path.exists("sim/sim_{}_{}/COLVAR".format(*f)):
print("{}) Skipping lambdas={}/{}: COLVAR exists".format(counter, *f))
continue
print("{}) Simulate lambda1={}, lambda2={}".format(counter, *f))
command = "bash sim.sh {} {} 2>&1 > run.log".format(*f)
command = "bash data/sim.sh {} {} 2>&1 > tmp/run.log".format(*f)
# print("Running {}".format(command))
os.system(command)
@@ -147,6 +146,6 @@ runner.cvs_init = (1.4, -1.4)
runner.E_min = 10
runner.E_max = 100
runner.E_incr = 10
runner.max_iterations = 100
runner.max_iterations = 30
runner.run()