The sodym package provides key functionality for material flow analysis, including
MFASystem
acting as a template (parent class) for users to create their own material flow modelsNamedDimArray
handling mathematical operations between multi-dimensional arraysDynamicStockModel
representing stocks accumulation, in- and outflows based on age cohort tracking and lifetime distributions. Those can be integrated in the MFASystem
.sodym is an adaptation of:
ODYM
Copyright (c) 2018 Industrial Ecology
author: Stefan Pauliuk, Uni Freiburg, Germany
https://github.com/IndEcol/ODYM
sodym dependencies are managed with pip.
To install as a user: run python -m pip install sodym@git+https://github.com/pik-piam/sodym.git
To install as a developer:
pip install -e ".[test,docs,examples]"
to obtain all the necessary
dependencies, including those for running the tests, making the documentation, and running the examples.Note that it is advisable to do this within a virtual environment.
The notebooks in the examples folder provide usage examples of the code.
MFA models mainly consist on mathematical operations on different multi-dimensional arrays.
For example, the generation of different waste types waste
might be a 3D-array defined over the dimensions time $t$, region $r$ and waste type $w$, and might be calculated from multiplying end_of_life_products
(defined over time, region, and product type $p$) with a waste_share
mapping from product type to waste type.
In numpy, the according matrix multiplication can be carried out nicely with the einsum
function, were an index string indicates the involved dimensions:
waste = np.einsum('trw,pw->trp', end_of_life_products, waste_share)
sodym uses this function under the hood, but wraps it in a data type NamedDimArray
, which stores the dimensions of the array and internally manages the dimensions of different arrays involved in mathematical operations.
With this, the above example reduces to
waste[...] = end_of_life_products * waste_share
This gives a sodym-based MFA models the following properties:
NamedDimArray
, and custom methods for the rest.