Source code for libs.test_case_0dparcel.run_0dparcel
"""Copyright (c) 2024 MPI-M, Clara Bayley----- Microphysics Test Cases -----File: run_0dparcel.pyProject: test_case_0dparcelCreated Date: Thursday 29th February 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 0-D parcel model by timestepping and outputting data"""from.adiabatic_motionimportAdiabaticMotionfromlibs.thermo.output_thermodynamicsimportOutputThermodynamics
[docs]defrun_0dparcel(time,time_end,timestep,thermo,microphys_scheme):"""Run a 0-D parcel model with a specified microphysics scheme and parcel dynamics. This function runs a 0-D parcel model with the given initial thermodynamic conditions, and microphysics scheme from time to time_end with a constant timestep using an instance of AdiabaticMotion for the parcel dynamics. Parameters: time (float): Initial time for the simulation (s). 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. """### data to output during model runntime=int(time_end/timestep)+1out=OutputThermodynamics([ntime,1])### type of dynamics parcel will undergoamp=11325# amplitude of pressure sinusoid [Pa]tau=120# time period of pressure sinusiod [s]parcel_dynamics=AdiabaticMotion(amp,tau)### run dynamics + microphysics from time to time_endmicrophys_scheme.initialize()out.output_thermodynamics(time,thermo)whiletime<time_end:thermo=parcel_dynamics.run(time,timestep,thermo)# thermo.print_state()thermo=microphys_scheme.run(timestep,thermo)# thermo.print_state()time+=timestepout.output_thermodynamics(time,thermo)microphys_scheme.finalize()out.finalize()returnout