Skip to content
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
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ rst-substitutions =
Lmod,
rsync,
Gromacs,
edr_file,
gro_file,
log_file,
mdp_file,
Expand Down
160 changes: 160 additions & 0 deletions analysis/lintf2_ether/mdt/energy_dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#!/bin/bash

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

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

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

analysis="energy_dist"
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

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}"

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

########################################################################
# Decompress input file(s) if necessary #
########################################################################

echo -e "\n"
echo "Decompressing input file(s) if necessary..."
infile="${settings}_out_${system}.edr"
decompressed=$(bash \
"${bash_dir}/decompress.sh" \
"${infile}" \
--keep \
--verbose)

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

echo -e "\n"
echo "================================================================="
${py_exe} -u \
"${mdt_path}/scripts/gmx/plot_energy_dist.py" \
-f "${infile}" \
--plot-out "${settings}_${system}_${analysis}_${begin}-${end}frame.pdf" \
--stats-out "${settings}_${system}_${analysis}_${begin}-${end}frame.txt" \
-b "${begin}" \
-e "${end}" \
--every "${every}" \
--observables \
"Potential" \
"Kinetic En." \
"Total Energy" \
"Temperature" \
"Pressure" \
--num-points 1000 ||
exit
echo "================================================================="

echo -e "\n"
echo "================================================================="
${py_exe} -u \
"${mdt_path}/scripts/gmx/plot_energy_dist.py" \
-f "${infile}" \
--plot-out "${settings}_${system}_${analysis}_diff_${begin}-${end}frame.pdf" \
--stats-out "${settings}_${system}_${analysis}_diff_${begin}-${end}frame.txt" \
-b "${begin}" \
-e "${end}" \
--every "${every}" \
--observables \
"Potential" \
"Kinetic En." \
"Total Energy" \
"Temperature" \
"Pressure" \
--diff \
--num-points 1000 ||
exit
echo "================================================================="

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

if [[ ${decompressed} -eq 1 ]]; then
echo -e "\n"
echo "Removing decompressed input file(s)..."
rm -v "${infile}"
fi

save_dir="${analysis}_slurm-${SLURM_JOB_ID}"
if [[ ! -d ${save_dir} ]]; then
echo -e "\n"
mkdir -v "${save_dir}" || exit
mv -v \
"${settings}_${system}_${analysis}_${begin}-${end}frame.pdf" \
"${settings}_${system}_${analysis}_${begin}-${end}frame.txt" \
"${settings}_${system}_${analysis}_diff_${begin}-${end}frame.pdf" \
"${settings}_${system}_${analysis}_diff_${begin}-${end}frame.txt" \
"${settings}_${system}_${analysis}_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"
18 changes: 17 additions & 1 deletion analysis/lintf2_ether/mdt/submit_mdt_analyses_lintf2_ether.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
space-separated as one enquoted string. To list all possible script
names type
:bash:`ls path/to/hpc_submit_scripts/analysis/lintf2_ether/mdt/`.
Note that scripts that take an |edr_file| as input are excluded from
the number options unless they are explicitily mentioned to be
included.

:0: All scripts. Note that all lig_change_at_pos_change*
scripts are excluded.
Expand All @@ -45,7 +48,8 @@
excluded, because msd_layer_serial.py (and
msd_layer_parallel.py) must first be fixed for
simulations with periodc boundary conditions in the
discretized direction.
discretized direction (see MDTools Issue
`#98 <https://github.com/andthum/mdtools/issues/98>`_).
:2: All scripts analyzing a slab in xy plane.

:3: discrete-z_Li and discrete-z_Li_state_lifetime_discrete.
Expand Down Expand Up @@ -297,6 +301,10 @@
"topo_map_Li-OBT",
"topo_map_Li-OE",
)
REQUIRE_EDR = (
# `${settings}_out_${system}.edr`
"energy_dist",
)
REQUIRE_XTC_WRAPPED = (
# `${settings}_out_${system}_pbc_whole_mol.xtc`
"axial_hex_dist_1nn_Li",
Expand Down Expand Up @@ -579,6 +587,7 @@ def _submit(sbatch_opts, job_script):
required=True,
help=(
"The analysis script(s) to submit."
""
" 0 = All scripts. Note that all lig_change_at_pos_change*"
" scripts are excluded."
" 1 = All scripts analyzing the bulk system (i.e. exclude scripts"
Expand Down Expand Up @@ -858,6 +867,7 @@ def _submit(sbatch_opts, job_script):
gmx_infile_pattern = args["settings"] + "_" + args["system"]
gmx_outfile_pattern = args["settings"] + "_out_" + args["system"]
TPR_FILE = gmx_infile_pattern + ".tpr"
EDR_FILE = gmx_outfile_pattern + ".edr"
GRO_FILE = gmx_outfile_pattern + ".gro"
XTC_FILE_WRAPPED = gmx_outfile_pattern + "_pbc_whole_mol.xtc"
XTC_FILE_UNWRAPPED = gmx_outfile_pattern + "_pbc_whole_mol_nojump.xtc"
Expand Down Expand Up @@ -937,6 +947,8 @@ def _submit(sbatch_opts, job_script):
for script in args["scripts"].split():
if script in REQUIRE_TPR:
files.setdefault("run input", TPR_FILE)
if script in REQUIRE_EDR:
files.setdefault("energy", gmx.get_compressed_file(EDR_FILE))
if script in REQUIRE_XTC_WRAPPED:
files.setdefault("wrapped compressed trajectory", XTC_FILE_WRAPPED)
if script in REQUIRE_XTC_UNWRAPPED:
Expand Down Expand Up @@ -1158,6 +1170,7 @@ def _submit(sbatch_opts, job_script):
"discrete-z_Li_state_lifetime_discrete": (
posargs_general + [posargs_trj[4]]
),
"energy_dist": posargs_general + posargs_trj[:3],
"lifetime_autocorr_Li-ether": (
posargs_general
+ posargs_trj
Expand Down Expand Up @@ -1356,6 +1369,9 @@ def _submit(sbatch_opts, job_script):
"renewal_events_Li-NTf2",
):
continue
if batch_script == "energy_dist":
# Exlcude all scripts that take an .edr file as input.
continue
if "lig_change_at_pos_change" in batch_script:
# Exclude all lig_change_at_pos_change* scripts.
continue
Expand Down
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@
:raw-html:`<a href="https://rsync.samba.org/">rsync</a>`
.. |Gromacs| replace::
:raw-html:`<a href="https://manual.gromacs.org/">Gromacs</a>`
.. |edr_file| replace::
:raw-html:`<a href="https://manual.gromacs.org/documentation/current/reference-manual/file-formats.html#edr">.edr file</a>`
.. |gro_file| replace::
:raw-html:`<a href="https://manual.gromacs.org/documentation/current/reference-manual/file-formats.html#gro">.gro file</a>`
.. |log_file| replace::
Expand Down
2 changes: 1 addition & 1 deletion python/gmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_box_from_gro(fname):

def get_compressed_file(fname):
"""
Check if the input file or a compressed version it exsists.
Check if the input file or a compressed version of it exsists.

Check if the input file exsists. If it does not exist, check
whether a file with the same name but with one of the following
Expand Down
4 changes: 3 additions & 1 deletion simulation/gmx/submit_gmx_mdrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@
" directory structure of this project".format(PYTHON_DIR)
)
sys.path.insert(1, PYTHON_DIR)
# Third-party libraries


# First-party libraries
import gmx # noqa: E402
import opthandler # noqa: E402
import strng # noqa: E402
Expand Down