|
| 1 | +""" |
| 2 | +Copyright (c) 2025 MPI-M, Clara Bayley |
| 3 | +
|
| 4 | +----- Microphysics Test Cases ----- |
| 5 | +File: run_cleo_1dkid_condevap_only.py |
| 6 | +Project: scripts |
| 7 | +Created Date: Monday 14th July 2025 |
| 8 | +Author: Clara Bayley (CB) |
| 9 | +Additional Contributors: |
| 10 | +----- |
| 11 | +Last Modified: Monday 14th July 2025 |
| 12 | +Modified By: CB |
| 13 | +----- |
| 14 | +License: BSD 3-Clause "New" or "Revised" License |
| 15 | +https://opensource.org/licenses/BSD-3-Clause |
| 16 | +----- |
| 17 | +File Description: |
| 18 | +Run 1-D kid test case for CLEO SDM with only condensation/evaporation enabled. |
| 19 | +
|
| 20 | +NOTE: script assumes CLEO's initial condition binary files already exist |
| 21 | +(i.e. 'dimlessGBxboundaries.dat' and 'dimlessSDsinit.dat' files, whose |
| 22 | +locations are given in CLEO's config file ('config_filename') |
| 23 | +""" |
| 24 | + |
| 25 | +import argparse |
| 26 | +import numpy as np |
| 27 | +import os |
| 28 | +import sys |
| 29 | +from pathlib import Path |
| 30 | +from PyMPDATA_examples.Shipway_and_Hill_2012 import si |
| 31 | + |
| 32 | +parser = argparse.ArgumentParser() |
| 33 | +parser.add_argument( |
| 34 | + "--run_name", |
| 35 | + type=str, |
| 36 | + default="run_cleo_condevap_only", |
| 37 | + help="path to pycleo python module", |
| 38 | +) |
| 39 | +parser.add_argument( |
| 40 | + "--config_filename", |
| 41 | + type=Path, |
| 42 | + default="/home/m/m300950/superdrops-in-action/cleo_1dkid/share/cleo_initial_conditions/1dkid/condevap_only/config.yaml", |
| 43 | + help="path to pycleo python module", |
| 44 | +) |
| 45 | +parser.add_argument( |
| 46 | + "--binpath", |
| 47 | + type=Path, |
| 48 | + default="/home/m/m300950/superdrops-in-action/build/bin/condevap", |
| 49 | + help="path to CLEO run output files", |
| 50 | +) |
| 51 | +parser.add_argument( |
| 52 | + "--figpath", |
| 53 | + type=Path, |
| 54 | + default="/home/m/m300950/superdrops-in-action/build/bin/condevap", |
| 55 | + help="path to save figures in", |
| 56 | +) |
| 57 | +parser.add_argument( |
| 58 | + "--path2pycleo", |
| 59 | + type=Path, |
| 60 | + default="/home/m/m300950/superdrops-in-action/build/pycleo", |
| 61 | + help="path to pycleo python module", |
| 62 | +) |
| 63 | +args = parser.parse_args() |
| 64 | + |
| 65 | +os.environ["PYCLEO_DIR"] = str(args.path2pycleo) |
| 66 | +sys.path.append("/home/m/m300950/superdrops-in-action/cleo_1dkid/") |
| 67 | +from libs.test_case_1dkid.perform_1dkid_test_case import perform_1dkid_test_case |
| 68 | +from libs.thermo.thermodynamics import Thermodynamics |
| 69 | +from libs.cleo_sdm.microphysics_scheme_wrapper import MicrophysicsSchemeWrapper |
| 70 | + |
| 71 | +### label for test case to name data/plots with |
| 72 | +run_name = args.run_name |
| 73 | +config_filename = args.config_filename |
| 74 | +binpath = args.binpath |
| 75 | +figpath = args.figpath |
| 76 | + |
| 77 | +### path to directory to save data/plots in after model run |
| 78 | +Path(figpath).mkdir(parents=False, exist_ok=True) |
| 79 | + |
| 80 | +### time and grid parameters |
| 81 | +# NOTE: these must be consistent with CLEO initial condition binary files(!) |
| 82 | +z_delta = 25 * si.m # (!) must be consistent with CLEO |
| 83 | +z_max = 3200 * si.m # (!) must be consistent with CLEO |
| 84 | +timestep = 1.25 * si.s |
| 85 | +time_end = 15 * si.minutes |
| 86 | + |
| 87 | +### initial thermodynamic conditions |
| 88 | +assert z_max % z_delta == 0, "z limit is not a multiple of the grid spacing." |
| 89 | +ngbxs = int(z_max / z_delta) |
| 90 | +zeros = np.zeros(ngbxs) |
| 91 | +zeros2 = np.tile(zeros, 2) |
| 92 | +thermo_init = Thermodynamics( |
| 93 | + zeros, |
| 94 | + zeros, |
| 95 | + zeros, |
| 96 | + zeros, |
| 97 | + zeros, |
| 98 | + zeros, |
| 99 | + zeros, |
| 100 | + zeros, |
| 101 | + zeros, |
| 102 | + zeros2, |
| 103 | + zeros2, |
| 104 | + zeros2, |
| 105 | +) |
| 106 | + |
| 107 | +### microphysics scheme to use (within a wrapper) |
| 108 | +is_motion = True |
| 109 | +microphys_scheme = MicrophysicsSchemeWrapper( |
| 110 | + config_filename, |
| 111 | + is_motion, |
| 112 | + 0.0, |
| 113 | + timestep, |
| 114 | + thermo_init.press, |
| 115 | + thermo_init.temp, |
| 116 | + thermo_init.massmix_ratios["qvap"], |
| 117 | + thermo_init.massmix_ratios["qcond"], |
| 118 | + thermo_init.wvel, |
| 119 | + thermo_init.uvel, |
| 120 | + thermo_init.vvel, |
| 121 | +) |
| 122 | + |
| 123 | +### Perform test of 1-D KiD rainshaft model using chosen setup |
| 124 | +advect_hydrometeors = False |
| 125 | +perform_1dkid_test_case( |
| 126 | + z_delta, |
| 127 | + z_max, |
| 128 | + time_end, |
| 129 | + timestep, |
| 130 | + thermo_init, |
| 131 | + microphys_scheme, |
| 132 | + advect_hydrometeors, |
| 133 | + figpath, |
| 134 | + run_name, |
| 135 | +) |
0 commit comments