Skip to content

Commit 48aec85

Browse files
authored
Merge pull request #144 from andthum/feat/analysis/lintf2-ether/mdt/densmap-z
New Slurm Job Scripts `densmap-z_*.sh` to Run the MDTools Script `densmap.py`
2 parents 4c2c659 + c8f4f8a commit 48aec85

14 files changed

+902
-13
lines changed

analysis/lintf2_ether/gmx/.cleanup_gmx_analyses.sh

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,51 @@ gather() {
2424
fi
2525
}
2626

27+
gather_cmps() {
28+
# Gather output of similar analyses scripts ordered by compounds
29+
# into sub-directories.
30+
local root="${1}"
31+
local cmps="${2}"
32+
33+
# Create "root" directory.
34+
if [[ -d ${root} ]]; then
35+
echo "WARNING: Directory already exists: '${root}'"
36+
return 0
37+
else
38+
mkdir "${root}/" || exit
39+
fi
40+
41+
# Move all "compound" directories to the root directory.
42+
for cmp in ${cmps}; do
43+
if [[ -n $(find . -maxdepth 1 -type d -name "${root}_${cmp}*_slurm-[0-9]*" -print -quit) ]]; then
44+
mv "${root}_${cmp}"*_slurm-[0-9]*/ "${root}/" || exit
45+
fi
46+
done
47+
48+
# Check if the root directory is empty.
49+
if [[ -n $(find "${root}/" -prune -empty) ]]; then
50+
echo "WARNING: No directory matching pattern '${root}_<compound>*_slurm-[0-9]*'"
51+
rm -r "${root:?}/" || exit
52+
return 0
53+
fi
54+
55+
# Gather all compound analyses.
56+
cd "${root}/" || exit
57+
for cmp in ${cmps}; do
58+
gather "${root}_${cmp}"
59+
done
60+
cd ../ || exit
61+
}
62+
2763
gather "density-z"
28-
gather "densmap-z"
2964
gather "energy"
3065
gather "make_ndx"
3166
gather "msd"
3267
gather "polystat"
3368
gather "potential-z"
34-
gather "rdf_slab-z"
35-
gather "rdf"
3669
gather "trjconv"
70+
71+
gather_cmps "densmap-z" "gra Li NBT OBT OE"
72+
73+
gather_cmps "rdf_slab-z" "Li-com NTf2-com ether-com Li NBT OE"
74+
gather "rdf"

analysis/lintf2_ether/gmx/submit_gmx_analyses_lintf2_ether.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,14 @@ def _assemble_submit_cmd(sbatch_opts, job_script):
281281
if "output" not in sbatch_opts and "o" not in sbatch_opts:
282282
sbatch_output = " --output " + gmx_infile_pattern + "_"
283283
submit += sbatch_output + job_script + "_slurm-%j.out"
284-
submit += " " + job_script + ".sh " + posargs[job_script]
284+
job_script_path = os.path.abspath(os.path.join(FILE_ROOT, job_script))
285+
job_script_path += ".sh"
286+
if not os.path.isfile(job_script_path):
287+
raise FileNotFoundError(
288+
"No such file: '{}'. This might happen if you change the"
289+
" directory structure of this project".format(job_script_path)
290+
)
291+
submit += " " + job_script_path + posargs[job_script]
285292
return submit
286293

287294

@@ -348,7 +355,14 @@ def _submit_discretized(sbatch_opts, job_script, bins):
348355
posargs_tmp = opthandler.posargs2str(
349356
posargs[job_script] + slab, prec=ARG_PREC
350357
)
351-
submit += " " + job_script + ".sh " + posargs_tmp
358+
job_script_path = os.path.abspath(os.path.join(FILE_ROOT, job_script))
359+
job_script_path += ".sh "
360+
if not os.path.isfile(job_script_path):
361+
raise FileNotFoundError(
362+
"No such file: '{}'. This might happen if you change the"
363+
" directory structure of this project".format(job_script_path)
364+
)
365+
submit += " " + job_script_path + posargs_tmp
352366
subproc.check_output(shlex.split(submit))
353367
n_jobs_submitted += 1
354368
return n_jobs_submitted

analysis/lintf2_ether/mdt/.cleanup_mdt_analyses.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ gather "subvolume_charge"
7070

7171
gather_cmps "attribute_hist" "Li NBT OBT OE NTf2 ether"
7272
gather_cmps "axial_hex_dist" "1nn 2nn"
73+
gather_cmps "densmap-z" "Li NBT OBT OE NTf2 ether"
7374
gather_cmps "renewal_events" "Li-ether Li-NTf2"
7475
gather_cmps "topo_map" "Li-OBT Li-OE"
7576

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
3+
#SBATCH --time=0-02:00:00
4+
#SBATCH --job-name="mdt_densmap-z_Li"
5+
#SBATCH --output="mdt_densmap-z_Li_slurm-%j.out"
6+
#SBATCH --nodes=1
7+
#SBATCH --cpus-per-task=1
8+
#SBATCH --mem=512M
9+
# The above options are only default values that can be overwritten by
10+
# command-line arguments
11+
12+
# MIT License
13+
# Copyright (c) 2021-2023 All authors listed in the file AUTHORS.rst
14+
15+
# This script is meant to be submitted by
16+
# submit_mdt_analyses_lintf2_ether.py
17+
18+
analysis="densmap-z_Li"
19+
thisfile=$(basename "${BASH_SOURCE[0]}")
20+
echo "${thisfile}"
21+
start_time=$(date --rfc-3339=seconds || exit)
22+
echo "Start time = ${start_time}"
23+
24+
########################################################################
25+
# Argument Parsing #
26+
########################################################################
27+
28+
bash_dir=${1} # Directory containing bash scripts used by this script
29+
py_lmod=${2} # File containing the modules to load Python
30+
py_exe=${3} # Name of the Python executable
31+
mdt_path=${4} # Path to the MDTools installation
32+
system=${5} # The name of the system to analyze
33+
settings=${6} # The used simulation settings
34+
begin=${7} # First frame to read. Frame numbering starts at 0
35+
end=${8} # Last frame to read (exclusive)
36+
every=${9} # Read every n-th frame
37+
bin_width=${10} # Grid size in the investigated plane in Angstrom
38+
zmin=${11} # Only atoms in a slab in the xy-plane between zmin
39+
zmax=${12} # and zmax are considered (in Angstrom)
40+
41+
echo -e "\n"
42+
echo "Parsed arguments:"
43+
echo "bash_dir = ${bash_dir}"
44+
echo "py_lmod = ${py_lmod}"
45+
echo "py_exe = ${py_exe}"
46+
echo "mdt_path = ${mdt_path}"
47+
echo "system = ${system}"
48+
echo "settings = ${settings}"
49+
echo "begin = ${begin}"
50+
echo "end = ${end}"
51+
echo "every = ${every}"
52+
echo "bin_width = ${bin_width}"
53+
echo "zmin = ${zmin}"
54+
echo "zmax = ${zmax}"
55+
56+
if [[ ! -d ${bash_dir} ]]; then
57+
echo
58+
echo "ERROR: No such directory: '${bash_dir}'"
59+
exit 1
60+
fi
61+
62+
echo -e "\n"
63+
bash "${bash_dir}/echo_slurm_output_environment_variables.sh"
64+
65+
########################################################################
66+
# Load required executable(s) #
67+
########################################################################
68+
69+
# shellcheck source=/dev/null
70+
source "${bash_dir}/load_python.sh" "${py_lmod}" "${py_exe}" || exit
71+
72+
########################################################################
73+
# Start the Analysis #
74+
########################################################################
75+
76+
echo -e "\n"
77+
echo "================================================================="
78+
${py_exe} -u \
79+
"${mdt_path}/scripts/structure/densmap.py" \
80+
-f "${settings}_out_${system}_pbc_whole_mol.xtc" \
81+
-s "${settings}_${system}.tpr" \
82+
-o "${settings}_${system}_${analysis}_${zmin}-${zmax}A.txt.gz" \
83+
-b "${begin}" \
84+
-e "${end}" \
85+
--every "${every}" \
86+
--sel "type Li" \
87+
--direction "z" \
88+
--min "${zmin}" \
89+
--max "${zmax}" \
90+
--grid-spacing "${bin_width}" ||
91+
exit
92+
echo "================================================================="
93+
94+
########################################################################
95+
# Cleanup #
96+
########################################################################
97+
98+
echo -e "\n"
99+
mv -v \
100+
"${settings}_${system}_${analysis}_slurm-${SLURM_JOB_ID}.out" \
101+
"${settings}_${system}_${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}.out"
102+
103+
save_dir="${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}"
104+
if [[ ! -d ${save_dir} ]]; then
105+
echo -e "\n"
106+
mkdir -v "${save_dir}" || exit
107+
mv -v \
108+
"${settings}_${system}_${analysis}_${zmin}-${zmax}A.txt.gz" \
109+
"${settings}_${system}_${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}.out" \
110+
"${save_dir}"
111+
bash "${bash_dir}/cleanup_analysis.sh" \
112+
"${system}" \
113+
"${settings}" \
114+
"${save_dir}" \
115+
"mdt"
116+
fi
117+
118+
end_time=$(date --rfc-3339=seconds)
119+
elapsed_time=$(bash \
120+
"${bash_dir}/date_time_diff.sh" \
121+
-s "${start_time}" \
122+
-e "${end_time}")
123+
echo -e "\n"
124+
echo "End time = ${end_time}"
125+
echo "Elapsed time = ${elapsed_time}"
126+
echo "${thisfile} done"
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
3+
#SBATCH --time=0-02:00:00
4+
#SBATCH --job-name="mdt_densmap-z_NBT"
5+
#SBATCH --output="mdt_densmap-z_NBT_slurm-%j.out"
6+
#SBATCH --nodes=1
7+
#SBATCH --cpus-per-task=1
8+
#SBATCH --mem=512M
9+
# The above options are only default values that can be overwritten by
10+
# command-line arguments
11+
12+
# MIT License
13+
# Copyright (c) 2021-2023 All authors listed in the file AUTHORS.rst
14+
15+
# This script is meant to be submitted by
16+
# submit_mdt_analyses_lintf2_ether.py
17+
18+
analysis="densmap-z_NBT"
19+
thisfile=$(basename "${BASH_SOURCE[0]}")
20+
echo "${thisfile}"
21+
start_time=$(date --rfc-3339=seconds || exit)
22+
echo "Start time = ${start_time}"
23+
24+
########################################################################
25+
# Argument Parsing #
26+
########################################################################
27+
28+
bash_dir=${1} # Directory containing bash scripts used by this script
29+
py_lmod=${2} # File containing the modules to load Python
30+
py_exe=${3} # Name of the Python executable
31+
mdt_path=${4} # Path to the MDTools installation
32+
system=${5} # The name of the system to analyze
33+
settings=${6} # The used simulation settings
34+
begin=${7} # First frame to read. Frame numbering starts at 0
35+
end=${8} # Last frame to read (exclusive)
36+
every=${9} # Read every n-th frame
37+
bin_width=${10} # Grid size in the investigated plane in Angstrom
38+
zmin=${11} # Only atoms in a slab in the xy-plane between zmin
39+
zmax=${12} # and zmax are considered (in Angstrom)
40+
41+
echo -e "\n"
42+
echo "Parsed arguments:"
43+
echo "bash_dir = ${bash_dir}"
44+
echo "py_lmod = ${py_lmod}"
45+
echo "py_exe = ${py_exe}"
46+
echo "mdt_path = ${mdt_path}"
47+
echo "system = ${system}"
48+
echo "settings = ${settings}"
49+
echo "begin = ${begin}"
50+
echo "end = ${end}"
51+
echo "every = ${every}"
52+
echo "bin_width = ${bin_width}"
53+
echo "zmin = ${zmin}"
54+
echo "zmax = ${zmax}"
55+
56+
if [[ ! -d ${bash_dir} ]]; then
57+
echo
58+
echo "ERROR: No such directory: '${bash_dir}'"
59+
exit 1
60+
fi
61+
62+
echo -e "\n"
63+
bash "${bash_dir}/echo_slurm_output_environment_variables.sh"
64+
65+
########################################################################
66+
# Load required executable(s) #
67+
########################################################################
68+
69+
# shellcheck source=/dev/null
70+
source "${bash_dir}/load_python.sh" "${py_lmod}" "${py_exe}" || exit
71+
72+
########################################################################
73+
# Start the Analysis #
74+
########################################################################
75+
76+
echo -e "\n"
77+
echo "================================================================="
78+
${py_exe} -u \
79+
"${mdt_path}/scripts/structure/densmap.py" \
80+
-f "${settings}_out_${system}_pbc_whole_mol.xtc" \
81+
-s "${settings}_${system}.tpr" \
82+
-o "${settings}_${system}_${analysis}_${zmin}-${zmax}A.txt.gz" \
83+
-b "${begin}" \
84+
-e "${end}" \
85+
--every "${every}" \
86+
--sel "type NBT" \
87+
--direction "z" \
88+
--min "${zmin}" \
89+
--max "${zmax}" \
90+
--grid-spacing "${bin_width}" ||
91+
exit
92+
echo "================================================================="
93+
94+
########################################################################
95+
# Cleanup #
96+
########################################################################
97+
98+
echo -e "\n"
99+
mv -v \
100+
"${settings}_${system}_${analysis}_slurm-${SLURM_JOB_ID}.out" \
101+
"${settings}_${system}_${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}.out"
102+
103+
save_dir="${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}"
104+
if [[ ! -d ${save_dir} ]]; then
105+
echo -e "\n"
106+
mkdir -v "${save_dir}" || exit
107+
mv -v \
108+
"${settings}_${system}_${analysis}_${zmin}-${zmax}A.txt.gz" \
109+
"${settings}_${system}_${analysis}_${zmin}-${zmax}A_slurm-${SLURM_JOB_ID}.out" \
110+
"${save_dir}"
111+
bash "${bash_dir}/cleanup_analysis.sh" \
112+
"${system}" \
113+
"${settings}" \
114+
"${save_dir}" \
115+
"mdt"
116+
fi
117+
118+
end_time=$(date --rfc-3339=seconds)
119+
elapsed_time=$(bash \
120+
"${bash_dir}/date_time_diff.sh" \
121+
-s "${start_time}" \
122+
-e "${end_time}")
123+
echo -e "\n"
124+
echo "End time = ${end_time}"
125+
echo "Elapsed time = ${elapsed_time}"
126+
echo "${thisfile} done"

0 commit comments

Comments
 (0)