Example usage
Contents
Example usage¶
Running the FRAGMENT-MNP model is a two-step process. First, the model must be initialised by passing it config and input data. Example config and data is given in the fragmentmnp.examples
module, which is used here. Then the FragmentMNP.run()
method runs the model and returns a FMNPOutput
object with the output data.
from fragmentmnp import FragmentMNP
from fragmentmnp.examples import minimal_config, minimal_data
import matplotlib.pyplot as plt
import numpy as np
# Create the model and pass it config and data. minimal_config and
# minimal_data are an examples of a dicts with only required values.
# full_{config|data} are examples of a dicts with all values given
fmnp = FragmentMNP(minimal_config, minimal_data)
# Run the model
output = fmnp.run()
The returned FMNPOutput
object contains a timeseries t
, particle mass and number concentrations for each size class, c
and n
, particle number concentration lost from each size class due to dissolution n_diss
, and corresponding concentration of dissolved organics from each size class c_diss
. See the API reference for full details. A convenient plotting function can be used to quickly plot model output (see Plotting):
# Plot the time evolution of mass concentrations
_ = output.plot()
We can also plot the particle number concentrations n
. Note the logged y-axis:
_ = output.plot(type='particle_number_conc', log_yaxis=True)
Dissolution¶
The example data has a dissolution rate k_diss
of 0. Let’s simulate dissolution by setting this to an average (median) of 0.001, and use the k_diss_scaling_method
config parameter set to surface_area
to scale this by the surface area to volume ratio (the default is constant
). We will keep k_diss_gamma
set to the default of 1, such that k_diss
is directly proportional to surface area to volume ratio.
# Change the dissolution parameters
minimal_data['k_diss'] = 0.0005
minimal_config['k_diss_scaling_method'] = 'surface_area'
# Rerun the model
fmnp = FragmentMNP(minimal_config, minimal_data)
output = fmnp.run()
Dissolution data is included in the FMNPOutput
class: n_diss
is a timeseries of particle number concentrations lost from each size class, and c_diss
is corresponding mass concentration assuming spherical particles. We can use the FMNPOutput.plot()
method again to plot the time evolution graph with dissolution mass concentrations:
# Plot the model outputs with dissolution included
_ = output.plot(plot_dissolution=True)