Source code for tests.test_case_0dparcel.run_0dparcel_model
"""Copyright (c) 2024 MPI-M, Clara Bayley----- Microphysics Test Cases -----File: run_0dparcel_model.pyProject: test_case_0dparcelCreated Date: Thursday 29th February 2024Author: Clara Bayley (CB)Additional Contributors:-----Last Modified: Sunday 1st September 2024Modified By: CB-----License: BSD 3-Clause "New" or "Revised" Licensehttps://opensource.org/licenses/BSD-3-Clause-----File Description:"""from.adiabatic_motionimportAdiabaticMotionfromlibs.src_mock_py.output_thermodynamicsimportOutputThermodynamics
[docs]defrun_0dparcel_model(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 runout=OutputThermodynamics()### 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=microphys_scheme.run(timestep,thermo)out.output_thermodynamics(time,thermo)time+=timestepmicrophys_scheme.finalize()out.finalize()returnout