
#### PARAMS ####
replicas={replicas}
min_wqb={wqb_threshold}
    
#### Runing Duck ####
# Minimization&Equilibration
pmemd.cuda -O -i 1_min.in -o min.out -p {top} -c system_complex.inpcrd -r min.rst -ref system_complex.inpcrd
pmemd.cuda -O -i 2_heating150.in -o 2_heating150.out -p {top} -c min.rst -r  2_heating150.rst -x 2_heating150.nc -ref system_complex.inpcrd
pmemd.cuda -O -i 2_heating200.in -o 2_heating200.out -p {top} -c 2_heating150.rst -r 2_heating200.rst -x 2_heating200.nc -ref 2_heating150.rst
pmemd.cuda -O -i 2_heating250.in -o 2_heating250.out -p {top} -c 2_heating200.rst -r 2_heating250.rst -x 2_heating250.nc -ref 2_heating200.rst
pmemd.cuda -O -i 2_heating300.in -o 2_heating300.out -p {top} -c 2_heating250.rst -r 2_heating300.rst -x 2_heating300.nc -ref 2_heating250.rst
pmemd.cuda -O -i 3_eq.in -o 3_eq.out -p {top} -c 2_heating300.rst -r 3_eq.rst -x 3_eq.nc -ref 2_heating300.rst -e 3_eq.ene

#Launch DUck 0 and check wqb
prepare_duck_and_launch 0 0 300K
check_WQB $min_wqb

#Launch DUck_325K 0 and check wqb
prepare_duck_and_launch 0 0 325K
check_WQB $min_wqb

#For each replica wanted do: MD, prepare SMD & launch SMD
for ((i=1;i<=$replicas;++i)); do
   if [ "$i" == "1" ]; then
      pmemd.cuda -O -i md.in -o md1.out -p {top} -c 3_eq.rst -r md1.rst -x md1.nc -ref 3_eq.rst
   else
      pmemd.cuda -O -i md.in -o md${i}.out -p {top} -c md$((i-1)).rst -r md${i}.rst -x md${i}.nc -ref 3_eq.rst
   fi

   prepare_duck_and_launch $i $i 300K
   prepare_duck_and_launch $i $i 325K
   check_WQB $min_wqb

done
    