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
48 changes: 45 additions & 3 deletions docs/source/testcases/collisions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ and source directory in ``/home/m/m300950/validating_cleo/src/``:
/home/m/m300950/validating_cleo/src/ \
/work/mh0731/m300950/validating_cleo/build

Then compile the example with:
Then compile the example with the ``colls_golovin`` and ``colls_long`` and ``colls_testikstraub``
executables with:

.. code-block:: console

$ ./scripts/compile_only.sh \
colls_golovin \
[colls_golovin or colls_long or colls_testikstraub] \
openmp \
intel \
/home/m/m300950/validating_cleo/src/ \
Expand All @@ -52,7 +53,7 @@ conditions, you would run:
Run Model
---------

Use ``./scripts/run.sh`` to run the executable (or ``./scripts/run_gpu.sh`` for gpu SLURM settings).
Use ``./scripts/run_allcollisions.sh`` to run all the executables.
E.g.

.. code-block:: console
Expand All @@ -74,3 +75,44 @@ E.g.
/work/mh0731/m300950/validating_cleo/build/share/collisions/dimlessGBxboundaries.dat \
/work/mh0731/m300950/validating_cleo/build/bin/collisions \
/work/mh0731/m300950/validating_cleo/build/bin/collisions


Breakup Comparison
------------------

To compare the results of the collision test cases including breakup, first build and compile the
breakup excutables ``colls_testikstraub``, ``colls_straub_schlottke``, ``colls_straub_fixednfrags`` and
``constcoalbu_fixednfrags`` as above, as well as the long executable ``colls_long``.

The generate the initial conditons similarly but with the ``initconds_compare_breakup.py`` script
and ``config_compare_breakup.yaml``.
E.g.

.. code-block:: console

$ python ./scripts/collisions/initconds_compare_breakup.py \
/home/m/m300950/CLEO \
/work/mh0731/m300950/validating_cleo/build \
/home/m/m300950/validating_cleo/src/collisions/config_compare_breakup.yaml \
TRUE TRUE

Similarly use ``./scripts/run_compare_breakup.sh`` to run the executables.
E.g.

.. code-block:: console

$ ./scripts/collisions/run_compare_breakup.sh \
/work/mh0731/m300950/validating_cleo/build \
openmp

Similarly plot the results of the model runs using the python script
``./scripts/collisions/plot_compare_breakup.py``.
E.g.

.. code-block:: console

$ python ./scripts/collisions/plot_compare_breakup.py`` \
/home/m/m300950/CLEO \
/work/mh0731/m300950/validating_cleo/build/share/collisions/dimlessGBxboundaries_bucomp.dat \
/work/mh0731/m300950/validating_cleo/build/bin/collisions \
/work/mh0731/m300950/validating_cleo/build/bin/collisions
4 changes: 2 additions & 2 deletions scripts/collisions/initconds.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
Author: Clara Bayley (CB)
Additional Contributors:
-----
Last Modified: Wednesday 16th April 2025
Last Modified: Monday 9th March 2026
Modified By: CB
-----
License: BSD 3-Clause "New" or "Revised" License
https://opensource.org/licenses/BSD-3-Clause
-----
File Description:
Script generates input files for CLEO 0-D box model with
mono-size droplet distribution as in S. Arabas and S. Shima 2017.
mono-size droplet distribution as S. Shima et al. 2009.
E.g. execute
``
python ./scripts/collisions/initconds.py ~/CLEO/ /work/mh0731/m300950/validating_cleo/build \
Expand Down
96 changes: 96 additions & 0 deletions scripts/collisions/initconds_compare_breakup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""
Copyright (c) 2025 MPI-M, Clara Bayley


----- ValidatingCLEO -----
File: initconds_compare_breakup.py
Project: collisions
Created Date: Wednesday 16th April 2025
Author: Clara Bayley (CB)
Additional Contributors:
-----
Last Modified: Monday 9th March 2026
Modified By: CB
-----
License: BSD 3-Clause "New" or "Revised" License
https://opensource.org/licenses/BSD-3-Clause
-----
File Description:
Script generates input files for CLEO 0-D box model with
droplet distribution as in Shima et al. 2009 for
comparison study with de Jong et al. 2023.
E.g. execute
``
python ./scripts/collisions/initconds_compare_breakup.py ~/CLEO/ /work/mh0731/m300950/validating_cleo/build \
/home/m/m300950/validating_cleo/src/collisions/config.yaml False False
``
"""


import argparse
import sys
from pathlib import Path

# for imports from collisions src module
sys.path.append(str(Path(__file__).resolve().parents[2] / "src"))
import collisions.initconds_compare_breakup as iccb


def main(path2pySD, path2build, original_config, isfigures=[False, False]):
if not (
path2build.is_dir()
and all([(path2build / f"{d}").is_dir() for d in ["tmp", "share", "bin"]])
):
raise OSError(
"Your build directory and bin, tmp, and share subdirectories do not exist"
)
else:
for d in ["tmp", "share", "bin"]:
path2dir = path2build / f"{d}" / "collisions"
path2dir.mkdir(exist_ok=True)

config_filenames = iccb.generate_configurations(
path2pySD, path2build, original_config
)

iccb.gridbox_boundaries(path2pySD, config_filenames[0], isfigures=isfigures)

for cf in config_filenames:
iccb.initial_superdroplet_conditions(path2pySD, cf, isfigures=isfigures)


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"path2pySD", type=Path, help="Absolute path for CLEO (for pySD)"
)
parser.add_argument(
"path2build", type=Path, help="Absolute path for build directory"
)
parser.add_argument(
"original_config", type=Path, help="Absolute path for original config file"
)
parser.add_argument(
"is_plotfigs",
type=str,
choices=["TRUE", "FALSE"],
help="=='TRUE' then make initial condition figures",
)
parser.add_argument(
"is_savefigs",
type=str,
choices=["TRUE", "FALSE"],
help="=='TRUE' then save initial condition figures",
)
args = parser.parse_args()

path2pySD = args.path2pySD
path2build = args.path2build
original_config = args.original_config
isfigures = [False, False]
if args.is_plotfigs == "TRUE":
isfigures[0] = True
if args.is_savefigs == "TRUE":
isfigures[1] = True

main(path2pySD, path2build, original_config, isfigures=isfigures)
71 changes: 71 additions & 0 deletions scripts/collisions/plot_compare_breakup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""
Copyright (c) 2025 MPI-M, Clara Bayley


----- ValidatingCLEO -----
File: plot_compare_breakup.py
Project: collisions
Created Date: Wednesday 16th April 2025
Author: Clara Bayley (CB)
Additional Contributors:
-----
Last Modified: Monday 9th March 2026
Modified By: CB
-----
License: BSD 3-Clause "New" or "Revised" License
https://opensource.org/licenses/BSD-3-Clause
-----
File Description:
Script to plot Figures from de Jong et al. 2023 to compare breakup methods
using results from CLEO 0-D collisions-only box model.
"""


import argparse
import sys
from pathlib import Path

# for imports from collisions src module
sys.path.append(str(Path(__file__).resolve().parents[2] / "src"))
import collisions.plot_compare_breakup as breakupplt


def main(path2CLEO, grid_filename, path2bin, path4figs):
datasets = {}
setups = {}
for r in range(9):
datasets[r] = path2bin / f"sol_bucomp_{r}.zarr"
setups[r] = path2bin / f"setup_bucomp_{r}.txt"

fig1, fig2, fig3 = breakupplt.plot_compare_breakup(
path2CLEO, grid_filename, datasets, setups
)

savename = path4figs / "dejong2023_fig7a_as_timeseries.png"
fig1.savefig(savename, dpi=400, bbox_inches="tight", facecolor="w")
print("Figure .png saved as: " + str(savename))

savename = path4figs / "dejong2023_fig7a.pdf"
fig2.savefig(savename, dpi=400, bbox_inches="tight", facecolor="w")
print("Figure .pdf saved as: " + str(savename))

savename = path4figs / "dejong2023_fig8.pdf"
fig3.savefig(savename, dpi=400, bbox_inches="tight", facecolor="w")
print("Figure .pdf saved as: " + str(savename))


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("path2CLEO", type=Path, help="Absolute path of CLEO (for pySD)")
parser.add_argument(
"grid_filename", type=Path, help="Absolute path of .dat grid file"
)
parser.add_argument(
"path2bin", type=Path, help="Absolute path to dataset and setup files"
)
parser.add_argument(
"path4figs", type=Path, help="Absolute path for directory to save plots in"
)
args = parser.parse_args()

main(args.path2CLEO, args.grid_filename, args.path2bin, args.path4figs)
74 changes: 74 additions & 0 deletions scripts/collisions/run_compare_breakup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
#SBATCH --job-name=compare_breakup
#SBATCH --partition=compute
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=128
#SBATCH --mem=940M
#SBATCH --time=04:00:00
#SBATCH [email protected]
#SBATCH --mail-type=FAIL
#SBATCH --account=mh0731
#SBATCH --output=./compare_breakup_out.%j.out
#SBATCH --error=./compare_breakup_err.%j.out

### ------------------ input parameters ---------------- ###
### ----- You need to edit these lines to specify ------ ###
### ----- your build configuration and executables ----- ###
### ---------------------------------------------------- ###
path2build=${1:-/work/mh0731/m300950/validating_cleo/build} # should be absolute path
buildtype=${2:-openmp} # "serial", "threads", "openmp" or "cuda"

SCRIPT_DIR=/home/m/m300950/validating_cleo/scripts
runscript=${SCRIPT_DIR}/run.sh
### ---------------------------------------------------- ###

### ------------ run long executable ---------- ###
for run in 0; do
runcmd="${runscript} ${path2build} ${buildtype} \
/work/mh0731/m300950/validating_cleo/build/collisions/colls_long \
/work/mh0731/m300950/validating_cleo/build/tmp/collisions/config_bucomp_${run}.yaml"
echo ${runcmd}
eval ${runcmd}
done;
### -------------------------------------------------- ###

### ------------ run tesikstraub executable ---------- ###
for run in 1; do
runcmd="${runscript} ${path2build} ${buildtype} \
/work/mh0731/m300950/validating_cleo/build/collisions/colls_testikstraub \
/work/mh0731/m300950/validating_cleo/build/tmp/collisions/config_bucomp_${run}.yaml"
echo ${runcmd}
eval ${runcmd}
done;
### -------------------------------------------------- ###

### ------------ run straub_schlottke executable ---------- ###
for run in 2; do
runcmd="${runscript} ${path2build} ${buildtype} \
/work/mh0731/m300950/validating_cleo/build/collisions/colls_straub_schlottke \
/work/mh0731/m300950/validating_cleo/build/tmp/collisions/config_bucomp_${run}.yaml"
echo ${runcmd}
eval ${runcmd}
done;
### -------------------------------------------------- ###

### ------------ run straub_fixednfrags executable ---------- ###
for run in 3 4 5; do
runcmd="${runscript} ${path2build} ${buildtype} \
/work/mh0731/m300950/validating_cleo/build/collisions/colls_straub_fixednfrags \
/work/mh0731/m300950/validating_cleo/build/tmp/collisions/config_bucomp_${run}.yaml"
echo ${runcmd}
eval ${runcmd}
done;
### -------------------------------------------------- ###

### ------------ run constcoalbu_fixednfrags executable ---------- ###
for run in 6 7 8; do
runcmd="${runscript} ${path2build} ${buildtype} \
/work/mh0731/m300950/validating_cleo/build/collisions/colls_constcoalbu_fixednfrags \
/work/mh0731/m300950/validating_cleo/build/tmp/collisions/config_bucomp_${run}.yaml"
echo ${runcmd}
eval ${runcmd}
done;
### -------------------------------------------------- ###
54 changes: 54 additions & 0 deletions src/collisions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,57 @@ set_target_properties(${exec} PROPERTIES
CMAKE_CXX_STANDARD_REQUIRED ON
CMAKE_CXX_EXTENSIONS ON
CXX_STANDARD 20)

### create primary executable 3 ###
set(exec colls_straub_schlottke)
add_executable(${exec} EXCLUDE_FROM_ALL "main_straub_schlottke.cpp")

# Add directories and link libraries to target
target_link_libraries(${exec} PRIVATE cartesiandomain "${CLEOLIBS}")
target_link_libraries(${exec} PUBLIC Kokkos::kokkos)
target_include_directories(${exec} PRIVATE "${CLEO_SOURCE_DIR}/libs") # CLEO libs directory

# set specific C++ compiler options for target (optional)
#target_compile_options(${exec} PRIVATE)

# set compiler properties for target(s)
set_target_properties(${exec} PROPERTIES
CMAKE_CXX_STANDARD_REQUIRED ON
CMAKE_CXX_EXTENSIONS ON
CXX_STANDARD 20)

### create primary executable 3 ###
set(exec colls_straub_fixednfrags)
add_executable(${exec} EXCLUDE_FROM_ALL "main_straub_fixednfrags.cpp")

# Add directories and link libraries to target
target_link_libraries(${exec} PRIVATE cartesiandomain "${CLEOLIBS}")
target_link_libraries(${exec} PUBLIC Kokkos::kokkos)
target_include_directories(${exec} PRIVATE "${CLEO_SOURCE_DIR}/libs") # CLEO libs directory

# set specific C++ compiler options for target (optional)
#target_compile_options(${exec} PRIVATE)

# set compiler properties for target(s)
set_target_properties(${exec} PROPERTIES
CMAKE_CXX_STANDARD_REQUIRED ON
CMAKE_CXX_EXTENSIONS ON
CXX_STANDARD 20)

### create primary executable 3 ###
set(exec colls_constcoalbu_fixednfrags)
add_executable(${exec} EXCLUDE_FROM_ALL "main_constcoalbu_fixednfrags.cpp")

# Add directories and link libraries to target
target_link_libraries(${exec} PRIVATE cartesiandomain "${CLEOLIBS}")
target_link_libraries(${exec} PUBLIC Kokkos::kokkos)
target_include_directories(${exec} PRIVATE "${CLEO_SOURCE_DIR}/libs") # CLEO libs directory

# set specific C++ compiler options for target (optional)
#target_compile_options(${exec} PRIVATE)

# set compiler properties for target(s)
set_target_properties(${exec} PROPERTIES
CMAKE_CXX_STANDARD_REQUIRED ON
CMAKE_CXX_EXTENSIONS ON
CXX_STANDARD 20)
5 changes: 5 additions & 0 deletions src/collisions/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ outputdata:
setup_filename: XXX # .txt filename to copy configuration to
zarrbasedir: XXX # zarr store base directory
maxchunk: 2500000 # maximum no. of elements in chunks of zarr store array

microphysics:
coalescence:
constcoaleff:
coaleff: 1.0 # constant coalescence efficiency
Loading
Loading