Skip to content
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

YAML configuration #44

Merged
merged 45 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d4b66c0
refactor(config): convert config.txt into config.yaml
yoctoyotta1024 Apr 17, 2024
3ccc4a7
refactor(config): rename params
yoctoyotta1024 Apr 17, 2024
664e5be
feat(yaml-cpp): build yaml-cpp external library with cmake
yoctoyotta1024 Apr 17, 2024
b0104dc
docs for external packages CLEO requires
yoctoyotta1024 Apr 17, 2024
6f5ef59
feat(config): include yaml-cpp in cmake and config
yoctoyotta1024 Apr 17, 2024
6583b1c
fix(docs): minor bug fixes to doc paths
yoctoyotta1024 Apr 17, 2024
f493ac4
fix(docs): minor bug fixes to formatting
yoctoyotta1024 Apr 17, 2024
065ba20
fix: 3.12.2 Python version in cienv
yoctoyotta1024 Apr 17, 2024
ade55c0
Revert "fix: 3.12.2 Python version in cienv"
yoctoyotta1024 Apr 17, 2024
83426b1
feat(config): clear old config files
yoctoyotta1024 Apr 17, 2024
40026be
chore(config): rename variable
yoctoyotta1024 Apr 17, 2024
5922146
refactor(config): clearer argument passing
yoctoyotta1024 Apr 17, 2024
0cfd1cc
feat(config): use getters and setters WIP
yoctoyotta1024 Apr 17, 2024
0dbe3fe
feat(config): use getters and setters for config
yoctoyotta1024 Apr 17, 2024
daba1cb
feat(config): use getters and setters for config nspacedims
yoctoyotta1024 Apr 17, 2024
ce116b8
chore: clang formatting for Google style
yoctoyotta1024 Apr 17, 2024
d9f2057
feat(config): config has optional and required configuraiton parameters
yoctoyotta1024 Apr 17, 2024
dcddfa0
feat(config): cvode params optional
yoctoyotta1024 Apr 17, 2024
a2370a7
refactor(config): split config params into two files
yoctoyotta1024 Apr 17, 2024
5fa82c8
refactor(config): add better comments
yoctoyotta1024 Apr 17, 2024
1f28cb0
refactor(confid): tidier intialisation with functions
yoctoyotta1024 Apr 17, 2024
e1b83d7
refactor(config): use lambda instead of function
yoctoyotta1024 Apr 17, 2024
59916fb
refactor: use filesystem::path not strings
yoctoyotta1024 Apr 17, 2024
79d3fa0
feat(config): config constructors for optional and required input par…
yoctoyotta1024 Apr 17, 2024
ecd8f7e
refactor(config): rename configuration parameters and re-style constr…
yoctoyotta1024 Apr 17, 2024
fe8a64d
feat(config): new optional params for initialisation of super-droplets
yoctoyotta1024 Apr 17, 2024
f00acc8
chore: delete completed TODO
yoctoyotta1024 Apr 17, 2024
479d6b3
refactor(config): reorder print statement
yoctoyotta1024 Apr 17, 2024
11b6157
refactor(config): reorganise config yaml
yoctoyotta1024 Apr 17, 2024
1242e4f
refactor(config): seperate set_params for different sections of optio…
yoctoyotta1024 Apr 17, 2024
7295bd0
feat(config): executables for examples compatible with new config struct
yoctoyotta1024 Apr 17, 2024
63fec0c
feat(config): yaml config files for adiabatic examples
yoctoyotta1024 Apr 17, 2024
118ab64
refactor(config): config.txt files now yaml in bash scripts
yoctoyotta1024 Apr 17, 2024
09c0c21
feat(pySD): edit config file compatible with yaml configs instead of txt
yoctoyotta1024 Apr 17, 2024
2be8cf4
feat(pySD): error is edit of param fails
yoctoyotta1024 Apr 17, 2024
8ff0c9d
feat(pySD): seperate reading of config file from cxx2py
yoctoyotta1024 Apr 17, 2024
3c56d80
feat(pySD): function for text file replaced by yaml version for readi…
yoctoyotta1024 Apr 17, 2024
32dfbe5
fix: adia0D example can run
yoctoyotta1024 Apr 17, 2024
b9f6f43
feat(config): new yaml files for more examples
yoctoyotta1024 Apr 17, 2024
94a1ad9
feat(config): new yaml files for more examples
yoctoyotta1024 Apr 17, 2024
ee57948
fix: typo
yoctoyotta1024 Apr 17, 2024
b2aa300
fix: missing get function readded
yoctoyotta1024 Apr 17, 2024
7b37b53
feat(config): new yaml config files for all examples
yoctoyotta1024 Apr 17, 2024
dbf72d0
fix(config): missing file name in config for 3D example. all validati…
yoctoyotta1024 Apr 18, 2024
5b94dd1
refactor: ensure types are size_t
yoctoyotta1024 Apr 18, 2024
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
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CXX_EXTENSIONS ON)

# install Kokkos for project
message(STATUS "Using Kokkos installation from: ${CMAKE_SOURCE_DIR}/extern/kokkos")
add_subdirectory(${CMAKE_SOURCE_DIR}/extern/kokkos)
set(kokkospath ${CMAKE_SOURCE_DIR}/extern/kokkos)
message(STATUS "Using Kokkos installation from: ${kokkospath}")
add_subdirectory(${kokkospath})

# install yaml-cpp for project
set(yamlcpppath ${CMAKE_SOURCE_DIR}/extern/yaml-cpp)
message(STATUS "Using yaml-cpp installation from: ${yamlcpppath}")
add_subdirectory(${yamlcpppath})

# print default compiler flags
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Time to get involved! Start by :doc:`installing CLEO<usage/installation>` and ex

intro/intro
usage/requirements
usage/extern
usage/installation
usage/examples
usage/quickstart
Expand Down
1 change: 1 addition & 0 deletions docs/source/pySD/pySD.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ input files and processing the Zarr output from CLEO.
thermobinary_src/thermobinary_src
sdmout_src/sdmout_src
cxx2py
readconfigfile
editconfigfile
readbinary
writebinary
Expand Down
5 changes: 5 additions & 0 deletions docs/source/pySD/readconfigfile.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
READCONFIGFILE
==============

.. automodule:: pySD.readconfigfile
:members:
31 changes: 31 additions & 0 deletions docs/source/usage/extern.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
External Libraries
==================

CLEO depends upon Kokkos and may depend upon some additional external libraries such as YAC and
``yaml-cpp`` depending on your setup. These are automatically built using CMAKE and compiled if
required.

.. note::
The installation of YAC for CLEO is currently in development and may require some manual installation.

Kokkos
------
All builds of CLEO require Kokkos in order to implement thread parallelism. You can read more about
how we use Kokkos on :doc:`our page about Kokkos<../intro/kokkos>`.

YAC
---
YAC is required if CLEO couples to dynamics using YAC and/or uses MPI domain decompoisiton. You can
find more information about it from `its documentation: <https://dkrz-sw.gitlab-pages.dkrz.de/yac>`_.

TODO(all): Detail how to install YAC for CLEO.

yaml-cpp
--------
CLEO's ``initialise`` library depends on the ```yaml-cpp``` package to read and write YAML files. You
can find more information about it from `its repository: <https://github.com/jbeder/yaml-cpp>`_.

CVODE
-----
CLEO's ``coupldyn_cvode`` library requires the SUNDIALS CVODE package. You can find more information
about it from `its webpage: <https://computing.llnl.gov/projects/sundials/cvode>`_.
9 changes: 7 additions & 2 deletions docs/source/usage/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ You can install Python packages to an existing Conda (or Mamba) environment via:
YAC
---

To use YAC some additional MPI, NetCDF and yaml libraries are required alongside the gcc compiler.
.. note::
The installation of YAC for CLEO is currently in development and may require some manual installation.

You can load them on Levante via:
YAC is one of the :doc:`external libraries<extern>` which CLEO may require in order to
couple to dynamics and/or have MPI domain decomposition.

YAC requires some additional MPI, NetCDF and yaml libraries alongside the gcc compiler. You can
load them on Levante via:

.. code-block:: console
Expand Down
30 changes: 14 additions & 16 deletions examples/adiabaticparcel/as2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Author: Clara Bayley (CB)
Additional Contributors:
-----
Last Modified: Friday 12th April 2024
Last Modified: Thursday 18th April 2024
Modified By: CB
-----
License: BSD 3-Clause "New" or "Revised" License
Expand Down Expand Up @@ -80,30 +80,28 @@

# parameters to edit in model configuration and plotting
params1 = {
"W_AVG": 1,
"T_HALF": 150,
"W_avg": 1,
"TAU_half": 150,
"T_END": 300,
"COUPLTSTEP": 1,
"OBSTSTEP": 2,
"lwdth": 2,
}
params2 = {
"W_AVG": 0.5,
"T_HALF": 300,
"W_avg": 0.5,
"TAU_half": 300,
"T_END": 600,
"COUPLTSTEP": 1,
"OBSTSTEP": 2,
"lwdth": 1,
}
params3 = {
"W_AVG": 0.002,
"T_HALF": 75000,
"W_avg": 0.002,
"TAU_half": 75000,
"T_END": 150000,
"COUPLTSTEP": 3,
"OBSTSTEP": 750,
"lwdth": 0.5,
}
paramslist = [params1, params2, params3]
lwdths = [2, 1, 0.5]

def displacement(time, w_avg, thalf):
'''displacement z given velocity, w, is sinusoidal
Expand Down Expand Up @@ -163,16 +161,16 @@ def displacement(time, w_avg, thalf):
plt.close()

fig, axs = plt.subplots(nrows=3, ncols=1, figsize=(5, 16))
for params in paramslist:
for params, lwdth in zip(paramslist, lwdths):

### edit relevant setup file parameters
params["zarrbasedir"] = binpath+"as2017_sol"+str(runnum)+".zarr"
params["setuptxt"] = binpath+"as2017_setup.txt"
params["setup_filename"] = binpath+"as2017_setup.txt"
editconfigfile.edit_config_params(configfile, params)

### delete any existing dataset
os.system("rm -rf "+params["zarrbasedir"])
os.system("rm "+params["setuptxt"])
os.system("rm "+params["setup_filename"])

### run model
os.chdir(path2build)
Expand All @@ -197,18 +195,18 @@ def displacement(time, w_avg, thalf):
supersat = thermo.supersaturation()
time = pyzarr.get_time(dataset).secs
sddata = pyzarr.get_supers(dataset, consts)
zprof = displacement(time, config["W_AVG"], config["T_HALF"])
zprof = displacement(time, config["W_avg"], config["TAU_half"])

attrs = ["radius", "xi", "msol"]
sd0 = sdtracing.attributes_for1superdroplet(sddata, 0, attrs)
numconc = np.sum(sddata["xi"][0])/gbxs["domainvol"]/1e6 # [/cm^3]

### plot results
wlab = "<w> = {:.1f}".format(config["W_AVG"]*100)+"cm s$^{-1}$"
wlab = "<w> = {:.1f}".format(config["W_avg"]*100)+"cm s$^{-1}$"
axs = as2017fig.condensation_validation_subplots(axs, time, sd0["radius"],
supersat[:, 0, 0, 0],
zprof,
lwdth=params["lwdth"],
lwdth=lwdth,
lab=wlab)

runnum += 1
Expand Down
2 changes: 1 addition & 1 deletion examples/adiabaticparcel/as2017.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ path2build=${HOME}/CLEO/build_adia0D/
executables="adia0D"

pythonscript=${path2CLEO}/examples/adiabaticparcel/as2017.py
configfile=${path2CLEO}/examples/adiabaticparcel/src/config/as2017_config.txt
configfile=${path2CLEO}/examples/adiabaticparcel/src/config/as2017_config.yaml
script_args="${configfile}"
### ---------------------------------------------------- ###
### ---------------------------------------------------- ###
Expand Down
6 changes: 3 additions & 3 deletions examples/adiabaticparcel/cuspbifurc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Author: Clara Bayley (CB)
Additional Contributors:
-----
Last Modified: Friday 12th April 2024
Last Modified: Thursday 18th April 2024
Modified By: CB
-----
License: BSD 3-Clause "New" or "Revised" License
Expand Down Expand Up @@ -149,7 +149,7 @@ def displacement(time, w_avg, thalf):
supersat = thermo.supersaturation()
time = pyzarr.get_time(dataset).secs
sddata = pyzarr.get_supers(dataset, consts)
zprof = displacement(time, config["W_AVG"], config["T_HALF"])
zprof = displacement(time, config["W_avg"], config["TAU_half"])

### plot results
# sample drops to plot from whole range of SD ids
Expand All @@ -169,5 +169,5 @@ def displacement(time, w_avg, thalf):
thermo.temp[:, 0, 0, 0],
supersat[:, 0, 0, 0],
sddata.IONIC, sddata.MR_SOL,
config["W_AVG"], numconc,
config["W_avg"], numconc,
savename2)
2 changes: 1 addition & 1 deletion examples/adiabaticparcel/cuspbifurc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ path2build=${HOME}/CLEO/build_adia0D/
executables="adia0D"

pythonscript=${path2CLEO}/examples/adiabaticparcel/cuspbifurc.py
configfile=${path2CLEO}/examples/adiabaticparcel/src/config/cuspbifurc_config.txt
configfile=${path2CLEO}/examples/adiabaticparcel/src/config/cuspbifurc_config.yaml
script_args="${configfile}"
### ---------------------------------------------------- ###
### ---------------------------------------------------- ###
Expand Down
70 changes: 0 additions & 70 deletions examples/adiabaticparcel/src/config/as2017_config.txt

This file was deleted.

74 changes: 74 additions & 0 deletions examples/adiabaticparcel/src/config/as2017_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# ----- CLEO -----
# File: as2017_config.yaml
# Project: config
# Created Date: Wednesday 17th April 2024
# Author: Clara Bayley (CB)
# Additional Contributors:
# -----
# Last Modified: Wednesday 17th April 2024
# Modified By: CB
# -----
# License: BSD 3-Clause "New" or "Revised" License
# https://opensource.org/licenses/BSD-3-Clause
# -----
# Copyright (c) 2023 MPI-M, Clara Bayley
# -----
# File Description:
# Configuration file for CLEO SDM coupled to a CVODE dynamics solver for an adiabatic parcel example
# Note: The inital superdroplets data read from file "initsupers_filename" can be made with
# CLEO's pySD module (see Python script "create_initsuperdropsbinary_script.py" for usage).
# Likewise the "grid_filename" can be made using pySD (see "create_gbxboundariesbinary_script.py"),
# and so can the thermodynamics files when using coupled thermodynamics "fromfile".
#

### Initialisation Parameters ###
inputfiles:
constants_filename: ../libs/cleoconstants.hpp # name of file for values of physical constants
grid_filename: ./share/as2017_dimlessGBxboundaries.dat # binary filename for initialisation of GBxs / GbxMaps

initsupers:
type: frombinary # type of initialisation of super-droplets
initsupers_filename: ./share/as2017_dimlessSDsinit.dat # binary filename for initialisation of SDs
totnsupers: 64 # initial total no. of SDs

### Output Parameters ###
outputdata:
setup_filename: /home/m/m300950/CLEO/build_adia0D//bin/as2017_setup.txt # .txt filename to copy configuration to
stats_filename: /home/m/m300950/CLEO/build_adia0D//bin/as2017_stats.txt # .txt file to output runtime statistics to
zarrbasedir: /home/m/m300950/CLEO/build_adia0D//bin/as2017_sol8.zarr # zarr store base directory
maxchunk: 2500000 # maximum no. of elements in chunks of zarr store array

### SDM Runtime Parameters ###
domain:
nspacedims: 0 # no. of spatial dimensions to model
ngbxs: 1 # total number of Gbxs

timesteps:
CONDTSTEP: 1 # time between SD condensation [s]
COLLTSTEP: 1 # time between SD collision [s]
MOTIONTSTEP: 1 # time between SDM motion [s]
COUPLTSTEP: 3 # time between dynamic couplings [s]
OBSTSTEP: 750 # time between SDM observations [s]
T_END: 150000 # time span of integration from 0s to T_END [s]

### Microphysics Parameters ###
microphysics:
condensation:
do_alter_thermo: true # true = cond/evap alters the thermodynamic state
niters: 2 # no. iterations of Newton Raphson Method before testing for convergence
SUBTSTEP: 0.1 # smallest subtimestep in cases of substepping [s]
rtol: 0.0 # relative tolerance for implicit Euler integration
atol: 0.01 # abolute tolerance for implicit Euler integration

### Coupled Dynamics Parameters ###
coupled_dynamics:
type: cvode # type of coupled dynamics to configure
# initial (uniform) thermodynamic conditions #
P_init: 100000.0 # initial pressure [Pa]
TEMP_init: 273.15 # initial temperature [T]
relh_init: 98.0 # initial relative humidity (%)
# ODE solver parameters #
W_avg: 0.002 # average amplitude of sinusoidal w [m/s] (dP/dt ~ w*dP/dz)
TAU_half: 75000 # timescale for w sinusoid, tau_half = TAU_half/pi [s]
rtol: 1e-6 # relative tolerance for integration of [P, T, qv, qc] ODEs
atol: 1e-6 # relative tolerance for integration of [P, T, qv, qc] ODEs
Loading
Loading