Source Code
Note
This section needs cleaning up at the end. Ignore from the point
where it becomes illegible.
-
class BETRS.Model(chemical, run='default', chemdb='chemicals_default.txt', seasonalparfile='seasonal_parameters_default.txt', constantparfile='const_parameters_default.txt', compartmentfile='compartments_default.txt', flowdir='default', processfile='processes_default.txt', controlfile='control_default.txt')[source]
The class Model is the user’s interface to BETR-Research.
Parameters: |
- chemical (int) – The ID of the chemical to be modelled (according to Chemicals/chemdb)
- run (string) – String describing a particular model run. Used for the construction of output file paths.
- chemdb (string) – Filename of the chemicals database.
- seasonalparfile (string) – Filename of the parameter-file for seasonally changing values.
- constantparfile (string) – Filename of parameter-file for time-constant parameters.
- compartmentfile (string) – Filename of file describing the compartment.
- flowdir (string) – Name of the directory containing the convective flow descriptions.
- processfile (string) – Filename of the list of processes to be considered.
- controlfile (string) – Filename of the file containing options for this model run.
|
-
get_avgMatrix()[source]
Returns the averages system matrix of mass rate constants used
for the steady-state solution.
-
get_ssEmission()[source]
Returns the full emission vector used for steady-state
calculation in Compressed Sparse Column format.
-
output_dyn(filename='dyn', units=['mol'], netcdf=False)[source]
Parameters: |
- filename (string) – Prefix of the output file(s). The output files
will be written to Output/<run>/<filename>_x.
- units (list) – A list of strings to indicate the unit(s) of the
output. Possible list elements are ‘mol’, ‘mol_per_m3’, ‘kg’,
‘kg_per_m3’ and ‘Pa’.
- netcdf (bool) – Indicates whether netCDF-files are written or not.
|
-
output_ss(filename='ss', units=['mol'], netcdf=False)[source]
Parameters: |
- filename (string) – Prefix of the output file(s). The output files
will be written to Output/<run>/<filename>_x.
- units (list) – A list of strings to indicate the unit(s) of the
output. Possible list elements are ‘mol’, ‘mol_per_m3’, ‘kg’,
‘kg_per_m3’ and ‘Pa’.
- netcdf (bool) – Indicates whether netCDF-files are written or not.
|
-
solve_dyn(no_periods)[source]
Solves the dynamic model for no_periods (years).
-
solve_ss()[source]
Averages the all mass rate matrices for each season (month) to
get a time invariant system. Solves for the steady-state.
-
update_bigDlist()[source]
Make system matrices ready for solving
-
update_chemical(chemno, chemdb)[source]
reads the chemical to be modelled from the database of chemicals and updates Model.chemdict.
Parameters: |
- chemno – ID of the chemical in chemdb.
- chemdb – path to the database of chemicals.
|
-
update_emissions(emfile)[source]
Constructs emission object from emissions-input-file
-
update_solver(stepfile='stepping_default.txt', solvparamfile='solvparams_default.txt', initfile='initial_default.txt')[source]
Updates or initializes the solver.
Parameters: |
- stepfile (string) – File describing the mapping
between timesteps and actual time
- solvparamfile (string) – File containing the parameters
for the solver
- initfile (string) – File containing the initial
contamination of the environments.
|
-
update_zvinvlist()[source]
Make list of 1/ZV diagonal matrices (matdim,matdim)
in sparse csr-format
Module “modifyparameters”, July 2010, is part of
BETR-Research by Harald von Waldow <hvwaldow@chem.ethz.ch>, which is
based on BETR-Global by Matt MacLeod <matthew.macleod@chem.ethz.ch>
This module calculates derived parameters, changes units etc.
-
modifyparams.modparams(model)[source]
Derive new parameters from original ones. Here, the scavenging
ratio is selected with respect to snow / rain
Module “volumes”, July 2010, is part of
BETR-Research by Harald von Waldow <hvwaldow@chem.ethz.ch>, which is
based on BETR-Global by Matt MacLeod <matthew.macleod@chem.ethz.ch>
This module calculates compartments volumes
-
class volumes.Volumes(par, compdict)[source]
This class constructs a dictionary with compartment-IDs as keys and
dictionaries with bulk- and sub-compartment volumes as values.
It calls all a method V<compartment_ID> for each compartment in compdict.
This method has to exist, and must return a dictionary with keys “bulk” and
optionally sub-compartment names.
In case no volumes are necessary to calculate processes for a particular
compartment with ID <x>, or volumes are directly read from an input-file,
define a function V<x> that returns an empty dictionary.
Module “zvalues”, July 2010, is part of
BETR-Research by Harald von Waldow <hvwaldow@chem.ethz.ch>, which is
based on BETR-Global by Matt MacLeod <matthew.macleod@chem.ethz.ch>
This module calculates Z-values
-
class zvalues.Zvalues(par, compdict, chempardict)[source]
This class constructs a dictionary with compartment-IDs as keys and
dictionaries with bulk- and sub-compartment Z-values (mol/Pa/m^3) as values.
It calls all a method Z<compartment_ID> for each compartment in compdict.
This method has to exist, and must return a dictionary with keys “bulk” and
optionally sub-compartment names.
In case no Z-values are necessary to calculate processes for a particular
compartment with ID <x>, define a function Z<x> that returns an empty
dictionary.
-
Z1()[source]
Z-values for upper air
-
Z2()[source]
Z-values for lower air
-
Z3()[source]
Z-values for vegetation
-
Z4()[source]
Z-values for freshwater
-
Z5()[source]
Z-values for ocean water
-
Z6()[source]
Z-values for soil
-
Z7()[source]
Z-values for sediment
-
helpers.cell2regcomp(cell, m)[source]
translates cell index into region-number and compartment ID
Parameters: |
- cell – index of cell (0–2015 in BETR-Global)
- m – BETRS.Model object
|
Return type: | (regionNumber <int>, compartmentID <int>)
|
-
helpers.tocell(reg, comp, m)[source]
translates region number and compartment ID into cell-index
Parameters: |
- reg – region number (1–288 in BETR-Global)
- comp – compartment ID (1–7 in BETR Global)
- m – BETRS.Model object
|
Return type: | cellIndex (0–2015 in BETR-Global)
|