pyrcel.ParcelModel

class pyrcel.ParcelModel(aerosols, V, T0, S0, P0, console=False, accom=1.0, truncate_aerosols=False)

Wrapper class for instantiating and running the parcel model.

The parcel model has been implemented in an object-oriented format to facilitate easy extensibility to different aerosol and meteorological conditions. A typical use case would involve specifying the initial conditions such as:

>>> import pyrcel as pm
>>> P0 = 80000.
>>> T0 = 283.15
>>> S0 = 0.0
>>> V = 1.0
>>> aerosol1 = pm.AerosolSpecies('sulfate',
...                              Lognorm(mu=0.025, sigma=1.3, N=2000.),
...                              bins=200, kappa=0.54)
>>> initial_aerosols = [aerosol1, ]
>>> z_top = 50.
>>> dt = 0.01

which initializes the model with typical conditions at the top of the boundary layer (800 hPa, 283.15 K, 100% Relative Humidity, 1 m/s updraft), and a simple sulfate aerosol distribution which will be discretized into 200 size bins to track. Furthermore the model was specified to simulate the updraft for 50 meters (z_top) and use a time-discretization of 0.01 seconds. This timestep is used in the model output – the actual ODE solver will generally calculate the trace of the model at many more times.

Running the model and saving the output can be accomplished by invoking:

>>> model = pm.ParcelModel(initial_aerosols, V, T0, S0, P0)
>>> par_out, aer_out = pm.run(z_top, dt)

This will yield par_out, a pandas.DataFrame containing the meteorological conditions in the parcel, and aerosols, a dictionary of DataFrame objects for each species in initial_aerosols with the appropriately tracked size bins and their evolution over time.

See also

_setup_run

companion routine which computes equilibrium droplet sizes and sets the model’s state vectors.

Attributes:
V, T0, S0, P0, aerosolsfloats

Initial parcel settings (see Parameters).

_r0sarray_like of floats

Initial equilibrium droplet sizes.

_r_drysarray_like of floats

Dry radii of aerosol population.

_kappasarray_like of floats

Hygroscopicity of each aerosol size.

_Nisarray_like of floats

Number concentration of each aerosol size.

_nrint

Number of aerosol sizes tracked in model.

_model_setboolean

Flag indicating whether or not at any given time the model initialization/equilibration routine has been run with the current model settings.

_y0array_like

Initial state vector.

Methods

run(t_end, dt, max_steps=1000, solver=”odeint”, output_fmt=”dataframes”, terminate=False, solver_args={})

Execute model simulation.

set_initial_conditions(V=None, T0=None, S0=None, P0=None, aerosols=None)

Re-initialize a model simulation in order to run it.

__init__(aerosols, V, T0, S0, P0, console=False, accom=1.0, truncate_aerosols=False)

Initialize the parcel model.

Parameters:
aerosolsarray_like sequence of AerosolSpecies

The aerosols contained in the parcel.

V, T0, S0, P0floats

The updraft speed and initial temperature (K), pressure (Pa), supersaturation (percent, with 0.0 = 100% RH).

consoleboolean, optional

Enable some basic debugging output to print to the terminal.

accomfloat, optional (default=:const:constants.ac)

Condensation coefficient

truncate_aerosolsboolean, optional (default=**False**)

Eliminate extremely small aerosol which will cause numerical problems

Methods

__init__(aerosols, V, T0, S0, P0[, console, ...])

Initialize the parcel model.

run(t_end[, output_dt, solver_dt, ...])

Run the parcel model simulation.

save([filename, format, other_dfs])

set_initial_conditions([V, T0, S0, P0, aerosols])

Set the initial conditions and parameters for a new parcel model run without having to create a new ParcelModel instance.

write_csv(parcel_data, aerosol_data[, ...])

Write output to CSV files.

write_summary(parcel_data, aerosol_data, ...)

Write a quick and dirty summary of given parcel model output to the terminal.