"""Copyright (c) 2024 MPI-M, Clara Bayley----- Microphysics Test Cases -----File: run_1dkid.pyProject: test_case_1dkidCreated Date: Monday 2nd September 2024Author: Clara Bayley (CB)Additional Contributors:-----Last Modified: Wednesday 4th June 2025Modified By: CB-----License: BSD 3-Clause "New" or "Revised" Licensehttps://opensource.org/licenses/BSD-3-Clause-----File Description:run 1-D KiD rainshaft model by timestepping and outputting data"""from.kid_dynamicsimportKiDDynamicsfromlibs.thermo.output_thermodynamicsimportOutputThermodynamics
[docs]defrun_1dkid(z_delta,z_max,time_end,timestep,thermo,microphys_scheme):"""Run 1-D KiD rainshaft model with a specified microphysics scheme and KiD dynamics. This function runs a 1-D KiD rainshaft model with the given initial thermodynamic conditions, and microphysics scheme from time to time_end with a constant timestep based on the Shipway and Hill (2012) setup. Parameters: z_delta (float): Grid spacing od 1-D column (m). z_max (float): Upper limit of 1-D column (m). time_end (float): End time for the simulation (s). timestep (float): Timestep for the simulation (s). thermo (Thermodynamics): Initial thermodynamic conditions. microphys_scheme: Microphysics scheme to use. Returns: OutputThermodynamics: Output containing thermodynamic data from the model run. """### type of dynamics rainshaft will undergokid_dynamics=KiDDynamics(z_delta,z_max,timestep,time_end)### run dynamics + microphysics from time to time_endmicrophys_scheme.initialize()### data to output during model runntime=int(time_end/timestep)+1nz=len(kid_dynamics.zhalf)-1shape=(ntime,nz)out=OutputThermodynamics(shape,zhalf=kid_dynamics.zhalf)time=0.0thermo=kid_dynamics.set_thermo(thermo)out.output_thermodynamics(time,thermo)whiletime<time_end:thermo=kid_dynamics.run(time,timestep,thermo)thermo=microphys_scheme.run(timestep,thermo)time+=timestepout.output_thermodynamics(time,thermo)microphys_scheme.finalize()out.finalize()returnout