add cores args

This commit is contained in:
2024-01-09 10:10:10 +08:00
parent 27084ba28d
commit baaf63f83a

View File

@@ -14,6 +14,8 @@ WATERMODEL=${WATERMODEL:-"tip3p"}
WATERTOPFILE=${WATERTOPFILE:-"spc216.gro"} WATERTOPFILE=${WATERTOPFILE:-"spc216.gro"}
BOXTYPE=${BOXTYPE:-"tric"} BOXTYPE=${BOXTYPE:-"tric"}
BOXORIENTATION=${BOXORIENTATION:-"1.0"} BOXORIENTATION=${BOXORIENTATION:-"1.0"}
NUM_CORES=${NUM_CORES:-$(($(nproc) - 2))} # 默认使用 CPU 核心数减去 2如果外部有设置则使用外部值
NUM_CORES=$((NUM_CORES > 0 ? NUM_CORES : 1)) # 确保 NUM_CORES 至少为 1
NSTEPS=${NSTEPS:-500000} # 50,000 steps for 1 ns NSTEPS=${NSTEPS:-500000} # 50,000 steps for 1 ns
DT=${DT:-0.002} # 2 fs DT=${DT:-0.002} # 2 fs
#BOXSIZE="5.0" #BOXSIZE="5.0"
@@ -48,13 +50,14 @@ echo "XTC_FILE: $XTC_FILE"
echo "NO_PBC_XTC_FILE: $NO_PBC_XTC_FILE" echo "NO_PBC_XTC_FILE: $NO_PBC_XTC_FILE"
echo "OUTPUT_FOLDER: $OUTPUT_FOLDER" echo "OUTPUT_FOLDER: $OUTPUT_FOLDER"
echo "EXTRACT_EVERY_PS: $EXTRACT_EVERY_PS" echo "EXTRACT_EVERY_PS: $EXTRACT_EVERY_PS"
echo "NUM_CORES: $NUM_CORES"
# generate GROMACS .gro file # generate GROMACS .gro file
gmx_mpi pdb2gmx -f $NAME.pdb -o $NAME.gro -ff $FORCEFIELD -water $WATERMODEL -ignh -p topol.top mpirun -np $NUM_CORES gmx_mpi pdb2gmx -f $NAME.pdb -o $NAME.gro -ff $FORCEFIELD -water $WATERMODEL -ignh -p topol.top
# define the box # define the box
gmx_mpi editconf -f $NAME.gro -o $NAME-box.gro -bt $BOXTYPE -c -d $BOXORIENTATION mpirun -np $NUM_CORES gmx_mpi editconf -f $NAME.gro -o $NAME-box.gro -bt $BOXTYPE -c -d $BOXORIENTATION
# add solvate # add solvate
gmx_mpi solvate -cp $NAME-box.gro -cs $WATERTOPFILE -o $NAME-solv.gro -p topol.top mpirun -np $NUM_CORES gmx_mpi solvate -cp $NAME-box.gro -cs $WATERTOPFILE -o $NAME-solv.gro -p topol.top
# add icons # ! ions.mdp add by manual # add icons # ! ions.mdp add by manual
# --- ions.mdp file content --- # # --- ions.mdp file content --- #
cat << EOF > ions.mdp cat << EOF > ions.mdp
@@ -73,8 +76,9 @@ rcoulomb = 1.0 ; Short-range electrostatic cut-off
rvdw = 1.0 ; Short-range Van der Waals cut-off rvdw = 1.0 ; Short-range Van der Waals cut-off
pbc = xyz ; Periodic Boundary Conditions in all 3 dimensions pbc = xyz ; Periodic Boundary Conditions in all 3 dimensions
EOF EOF
gmx_mpi grompp -f ions.mdp -c $NAME-solv.gro -p topol.top -o ions.tpr -maxwarn 1 mpirun -np $NUM_CORES gmx_mpi grompp -f ions.mdp -c $NAME-solv.gro -p topol.top -o ions.tpr -maxwarn 1
echo SOL | gmx_mpi genion -s ions.tpr -o $NAME-solv-ions.gro -p topol.top -pname NA -nname CL -conc 0.125 -neutral echo "SOL" > ions_input.txt
mpirun -np $NUM_CORES gmx_mpi genion -s ions.tpr -o $NAME-solv-ions.gro -p topol.top -pname NA -nname CL -conc 0.125 -neutral < ions_input.txt
# energy minimization of the structure in solvate # ! minim.mdp add by manual # energy minimization of the structure in solvate # ! minim.mdp add by manual
# --- minim.mdp file content --- # # --- minim.mdp file content --- #
cat << EOF > minim.mdp cat << EOF > minim.mdp
@@ -93,8 +97,8 @@ rcoulomb = 1.0 ; Short-range electrostatic cut-off
rvdw = 1.0 ; Short-range Van der Waals cut-off rvdw = 1.0 ; Short-range Van der Waals cut-off
pbc = xyz ; Periodic Boundary Conditions in all 3 dimensions pbc = xyz ; Periodic Boundary Conditions in all 3 dimensions
EOF EOF
gmx_mpi grompp -f minim.mdp -c $NAME-solv-ions.gro -p topol.top -o em.tpr mpirun -np $NUM_CORES gmx_mpi grompp -f minim.mdp -c $NAME-solv-ions.gro -p topol.top -o em.tpr
gmx_mpi mdrun -v -deffnm em mpirun -np $NUM_CORES gmx_mpi mdrun -v -deffnm em
# optional em, you will need the Xmgrace plotting too # optional em, you will need the Xmgrace plotting too
#gmx_mpi energy -f em.edr -o potential.xvg #gmx_mpi energy -f em.edr -o potential.xvg
#position restrain #position restrain
@@ -146,8 +150,8 @@ gen_vel = yes ; assign velocities from Maxwell distributio
gen_temp = 300 ; temperature for Maxwell distribution gen_temp = 300 ; temperature for Maxwell distribution
gen_seed = -1 ; generate a random seed gen_seed = -1 ; generate a random seed
EOF EOF
gmx_mpi grompp -f nvt.mdp -c em.gro -r em.gro -p topol.top -o nvt.tpr mpirun -np $NUM_CORES gmx_mpi grompp -f nvt.mdp -c em.gro -r em.gro -p topol.top -o nvt.tpr
gmx_mpi mdrun -v -deffnm nvt mpirun -np $NUM_CORES gmx_mpi mdrun -v -deffnm nvt
# optional : Let's analyze the temperature progression, again using energy: # optional : Let's analyze the temperature progression, again using energy:
# gmx_mpi energy -f nvt.edr -o temperature.xvg # gmx_mpi energy -f nvt.edr -o temperature.xvg
# npt # npt
@@ -199,8 +203,8 @@ pbc = xyz ; 3-D PBC
; Velocity generation ; Velocity generation
gen_vel = no ; Velocity generation is off gen_vel = no ; Velocity generation is off
EOF EOF
gmx_mpi grompp -f npt.mdp -c nvt.gro -r nvt.gro -t nvt.cpt -p topol.top -o npt.tpr mpirun -np $NUM_CORES gmx_mpi grompp -f npt.mdp -c nvt.gro -r nvt.gro -t nvt.cpt -p topol.top -o npt.tpr
gmx_mpi mdrun -v -deffnm npt mpirun -np $NUM_CORES gmx_mpi mdrun -v -deffnm npt
# Optional: Let's analyze the pressure progression, again using energy: type 18 0 # Optional: Let's analyze the pressure progression, again using energy: type 18 0
# gmx energy -f npt.edr -o pressure.xvg # gmx energy -f npt.edr -o pressure.xvg
# Optional: Let's take a look at density as well, this time using energy and entering "24 0" at the prompt. # Optional: Let's take a look at density as well, this time using energy and entering "24 0" at the prompt.
@@ -257,10 +261,10 @@ gen_vel = no ; Velocity generation is off
EOF EOF
# Generate GROMACS .tpr file for the simulation # Generate GROMACS .tpr file for the simulation
gmx_mpi grompp -f ${MDRUN_NAME}.mdp -c npt.gro -t npt.cpt -p topol.top -o ${TPR_FILE} mpirun -np $NUM_CORES gmx_mpi grompp -f ${MDRUN_NAME}.mdp -c npt.gro -t npt.cpt -p topol.top -o ${TPR_FILE}
# Run the simulation # Run the simulation
gmx_mpi mdrun -deffnm ${MDRUN_NAME} mpirun -np $NUM_CORES gmx_mpi mdrun -deffnm ${MDRUN_NAME}
# mpirun -np $(ls | egrep "Scaled[0-9]+$" | wc -l) gmx_mpi mdrun -v --deffnm md -cpi Scaled.cpt -multidir $(ls -v | egrep "Scaled[0-9]+$") -plumed plumed.dat -hrex -replex 1000 >& run_$(date "+%H%M%S_%d%m%Y").log || { echo "mdrun failed at line ${LINENO} "; exit -1; } # mpirun -np $(ls | egrep "Scaled[0-9]+$" | wc -l) gmx_mpi mdrun -v --deffnm md -cpi Scaled.cpt -multidir $(ls -v | egrep "Scaled[0-9]+$") -plumed plumed.dat -hrex -replex 1000 >& run_$(date "+%H%M%S_%d%m%Y").log || { echo "mdrun failed at line ${LINENO} "; exit -1; }
# extra ndx file , select protein # extra ndx file , select protein
echo -e "1\nq" | gmx_mpi make_ndx -f ${MDRUN_NAME}.gro -o ${NDX_FILE} echo -e "1\nq" | gmx_mpi make_ndx -f ${MDRUN_NAME}.gro -o ${NDX_FILE}