Skip to content

New Slurm Job Scripts densmap-z_*.sh to Run the MDTools Script densmap.py #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions analysis/lintf2_ether/gmx/.cleanup_gmx_analyses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,51 @@ gather() {
fi
}

gather_cmps() {
# Gather output of similar analyses scripts ordered by compounds
# into sub-directories.
local root="${1}"
local cmps="${2}"

# Create "root" directory.
if [[ -d ${root} ]]; then
echo "WARNING: Directory already exists: '${root}'"
return 0
else
mkdir "${root}/" || exit
fi

# Move all "compound" directories to the root directory.
for cmp in ${cmps}; do
if [[ -n $(find . -maxdepth 1 -type d -name "${root}_${cmp}*_slurm-[0-9]*" -print -quit) ]]; then
mv "${root}_${cmp}"*_slurm-[0-9]*/ "${root}/" || exit
fi
done

# Check if the root directory is empty.
if [[ -n $(find "${root}/" -prune -empty) ]]; then
echo "WARNING: No directory matching pattern '${root}_<compound>*_slurm-[0-9]*'"
rm -r "${root:?}/" || exit
return 0
fi

# Gather all compound analyses.
cd "${root}/" || exit
for cmp in ${cmps}; do
gather "${root}_${cmp}"
done
cd ../ || exit
}

gather "density-z"
gather "densmap-z"
gather "energy"
gather "make_ndx"
gather "msd"
gather "polystat"
gather "potential-z"
gather "rdf_slab-z"
gather "rdf"
gather "trjconv"

gather_cmps "densmap-z" "gra Li NBT OBT OE"

gather_cmps "rdf_slab-z" "Li-com NTf2-com ether-com Li NBT OE"
gather "rdf"
18 changes: 16 additions & 2 deletions analysis/lintf2_ether/gmx/submit_gmx_analyses_lintf2_ether.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,14 @@ def _assemble_submit_cmd(sbatch_opts, job_script):
if "output" not in sbatch_opts and "o" not in sbatch_opts:
sbatch_output = " --output " + gmx_infile_pattern + "_"
submit += sbatch_output + job_script + "_slurm-%j.out"
submit += " " + job_script + ".sh " + posargs[job_script]
job_script_path = os.path.abspath(os.path.join(FILE_ROOT, job_script))
job_script_path += ".sh"
if not os.path.isfile(job_script_path):
raise FileNotFoundError(
"No such file: '{}'. This might happen if you change the"
" directory structure of this project".format(job_script_path)
)
submit += " " + job_script_path + posargs[job_script]
return submit


Expand Down Expand Up @@ -348,7 +355,14 @@ def _submit_discretized(sbatch_opts, job_script, bins):
posargs_tmp = opthandler.posargs2str(
posargs[job_script] + slab, prec=ARG_PREC
)
submit += " " + job_script + ".sh " + posargs_tmp
job_script_path = os.path.abspath(os.path.join(FILE_ROOT, job_script))
job_script_path += ".sh "
if not os.path.isfile(job_script_path):
raise FileNotFoundError(
"No such file: '{}'. This might happen if you change the"
" directory structure of this project".format(job_script_path)
)
submit += " " + job_script_path + posargs_tmp
subproc.check_output(shlex.split(submit))
n_jobs_submitted += 1
return n_jobs_submitted
Expand Down
1 change: 1 addition & 0 deletions analysis/lintf2_ether/mdt/.cleanup_mdt_analyses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ gather "subvolume_charge"

gather_cmps "attribute_hist" "Li NBT OBT OE NTf2 ether"
gather_cmps "axial_hex_dist" "1nn 2nn"
gather_cmps "densmap-z" "Li NBT OBT OE NTf2 ether"
gather_cmps "renewal_events" "Li-ether Li-NTf2"
gather_cmps "topo_map" "Li-OBT Li-OE"

Expand Down
126 changes: 126 additions & 0 deletions analysis/lintf2_ether/mdt/densmap-z_Li.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/bin/bash

#SBATCH --time=0-02:00:00
#SBATCH --job-name="mdt_densmap-z_Li"
#SBATCH --output="mdt_densmap-z_Li_slurm-%j.out"
#SBATCH --nodes=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=512M
# The above options are only default values that can be overwritten by
# command-line arguments

# MIT License
# Copyright (c) 2021-2023 All authors listed in the file AUTHORS.rst

# This script is meant to be submitted by
# submit_mdt_analyses_lintf2_ether.py

analysis="densmap-z_Li"
thisfile=$(basename "${BASH_SOURCE[0]}")
echo "${thisfile}"
start_time=$(date --rfc-3339=seconds || exit)
echo "Start time = ${start_time}"

########################################################################
# Argument Parsing #
########################################################################

bash_dir=${1} # Directory containing bash scripts used by this script
py_lmod=${2} # File containing the modules to load Python
py_exe=${3} # Name of the Python executable
mdt_path=${4} # Path to the MDTools installation
system=${5} # The name of the system to analyze
settings=${6} # The used simulation settings
begin=${7} # First frame to read. Frame numbering starts at 0
end=${8} # Last frame to read (exclusive)
every=${9} # Read every n-th frame
bin_width=${10} # Grid size in the investigated plane in Angstrom
zmin=${11} # Only atoms in a slab in the xy-plane between zmin
zmax=${12} # and zmax are considered (in Angstrom)

echo -e "\n"
echo "Parsed arguments:"
echo "bash_dir = ${bash_dir}"
echo "py_lmod = ${py_lmod}"
echo "py_exe = ${py_exe}"
echo "mdt_path = ${mdt_path}"
echo "system = ${system}"
echo "settings = ${settings}"
echo "begin = ${begin}"
echo "end = ${end}"
echo "every = ${every}"
echo "bin_width = ${bin_width}"
echo "zmin = ${zmin}"
echo "zmax = ${zmax}"

if [[ ! -d ${bash_dir} ]]; then
echo
echo "ERROR: No such directory: '${bash_dir}'"
exit 1
fi

echo -e "\n"
bash "${bash_dir}/echo_slurm_output_environment_variables.sh"

########################################################################
# Load required executable(s) #
########################################################################

# shellcheck source=/dev/null
source "${bash_dir}/load_python.sh" "${py_lmod}" "${py_exe}" || exit

########################################################################
# Start the Analysis #
########################################################################

echo -e "\n"
echo "================================================================="
${py_exe} -u \
"${mdt_path}/scripts/structure/densmap.py" \
-f "${settings}_out_${system}_pbc_whole_mol.xtc" \
-s "${settings}_${system}.tpr" \
-o "${settings}_${system}_${analysis}_${zmin}-${zmax}A.txt.gz" \
-b "${begin}" \
-e "${end}" \
--every "${every}" \
--sel "type Li" \
--direction "z" \
--min "${zmin}" \
--max "${zmax}" \
--grid-spacing "${bin_width}" ||
exit
echo "================================================================="

########################################################################
# Cleanup #
########################################################################

echo -e "\n"
mv -v \
"${settings}_${system}_${analysis}_slurm-${SLURM_JOB_ID}.out" \
"${settings}_${system}_${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}.out"

save_dir="${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}"
if [[ ! -d ${save_dir} ]]; then
echo -e "\n"
mkdir -v "${save_dir}" || exit
mv -v \
"${settings}_${system}_${analysis}_${zmin}-${zmax}A.txt.gz" \
"${settings}_${system}_${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}.out" \
"${save_dir}"
bash "${bash_dir}/cleanup_analysis.sh" \
"${system}" \
"${settings}" \
"${save_dir}" \
"mdt"
fi

end_time=$(date --rfc-3339=seconds)
elapsed_time=$(bash \
"${bash_dir}/date_time_diff.sh" \
-s "${start_time}" \
-e "${end_time}")
echo -e "\n"
echo "End time = ${end_time}"
echo "Elapsed time = ${elapsed_time}"
echo "${thisfile} done"
126 changes: 126 additions & 0 deletions analysis/lintf2_ether/mdt/densmap-z_NBT.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/bin/bash

#SBATCH --time=0-02:00:00
#SBATCH --job-name="mdt_densmap-z_NBT"
#SBATCH --output="mdt_densmap-z_NBT_slurm-%j.out"
#SBATCH --nodes=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=512M
# The above options are only default values that can be overwritten by
# command-line arguments

# MIT License
# Copyright (c) 2021-2023 All authors listed in the file AUTHORS.rst

# This script is meant to be submitted by
# submit_mdt_analyses_lintf2_ether.py

analysis="densmap-z_NBT"
thisfile=$(basename "${BASH_SOURCE[0]}")
echo "${thisfile}"
start_time=$(date --rfc-3339=seconds || exit)
echo "Start time = ${start_time}"

########################################################################
# Argument Parsing #
########################################################################

bash_dir=${1} # Directory containing bash scripts used by this script
py_lmod=${2} # File containing the modules to load Python
py_exe=${3} # Name of the Python executable
mdt_path=${4} # Path to the MDTools installation
system=${5} # The name of the system to analyze
settings=${6} # The used simulation settings
begin=${7} # First frame to read. Frame numbering starts at 0
end=${8} # Last frame to read (exclusive)
every=${9} # Read every n-th frame
bin_width=${10} # Grid size in the investigated plane in Angstrom
zmin=${11} # Only atoms in a slab in the xy-plane between zmin
zmax=${12} # and zmax are considered (in Angstrom)

echo -e "\n"
echo "Parsed arguments:"
echo "bash_dir = ${bash_dir}"
echo "py_lmod = ${py_lmod}"
echo "py_exe = ${py_exe}"
echo "mdt_path = ${mdt_path}"
echo "system = ${system}"
echo "settings = ${settings}"
echo "begin = ${begin}"
echo "end = ${end}"
echo "every = ${every}"
echo "bin_width = ${bin_width}"
echo "zmin = ${zmin}"
echo "zmax = ${zmax}"

if [[ ! -d ${bash_dir} ]]; then
echo
echo "ERROR: No such directory: '${bash_dir}'"
exit 1
fi

echo -e "\n"
bash "${bash_dir}/echo_slurm_output_environment_variables.sh"

########################################################################
# Load required executable(s) #
########################################################################

# shellcheck source=/dev/null
source "${bash_dir}/load_python.sh" "${py_lmod}" "${py_exe}" || exit

########################################################################
# Start the Analysis #
########################################################################

echo -e "\n"
echo "================================================================="
${py_exe} -u \
"${mdt_path}/scripts/structure/densmap.py" \
-f "${settings}_out_${system}_pbc_whole_mol.xtc" \
-s "${settings}_${system}.tpr" \
-o "${settings}_${system}_${analysis}_${zmin}-${zmax}A.txt.gz" \
-b "${begin}" \
-e "${end}" \
--every "${every}" \
--sel "type NBT" \
--direction "z" \
--min "${zmin}" \
--max "${zmax}" \
--grid-spacing "${bin_width}" ||
exit
echo "================================================================="

########################################################################
# Cleanup #
########################################################################

echo -e "\n"
mv -v \
"${settings}_${system}_${analysis}_slurm-${SLURM_JOB_ID}.out" \
"${settings}_${system}_${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}.out"

save_dir="${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}"
if [[ ! -d ${save_dir} ]]; then
echo -e "\n"
mkdir -v "${save_dir}" || exit
mv -v \
"${settings}_${system}_${analysis}_${zmin}-${zmax}A.txt.gz" \
"${settings}_${system}_${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}.out" \
"${save_dir}"
bash "${bash_dir}/cleanup_analysis.sh" \
"${system}" \
"${settings}" \
"${save_dir}" \
"mdt"
fi

end_time=$(date --rfc-3339=seconds)
elapsed_time=$(bash \
"${bash_dir}/date_time_diff.sh" \
-s "${start_time}" \
-e "${end_time}")
echo -e "\n"
echo "End time = ${end_time}"
echo "Elapsed time = ${elapsed_time}"
echo "${thisfile} done"
Loading