Skip to main content

Equation oriented process modelling library

Project description

What is SigmaMu?

SigmaMu is a python library for first principle steady-state modelling of chemical processes.

SigmaMu logo

Links:

With focus on rigorous thermodynamic models, the first layer provides functionality to flexibly define, combine thermodynamic and parameterize model contributions into accurate descriptions of the processed materials. One can use pre-defined model structures, exchange single contributions, such as the α-function in equations of states, or implement entirely new contributions and model structures.

The second layer provides a framework for steady-state process modelling in a fully hierarchical context. Concepts such as material and energy balances can be defined and reused without code duplication. Models define a self-documenting interface of interacting materials, parameters and properties.

As the toplevel model is used to generate a numeric handler, it is fed to the third layer of functionality, represented by the numerical solvers. These are tailor-made for process models built on thermodynamic models, characterized by restricted domains and solutions close to the domain limits, badly scaled variables, and strong non-linearity.

SigmaMu is heavily based on CasADi for the mathematical representation and differentiation of the models, and Pint for flexible and consistent handling of physical dimensions and units of measurements.

Being a python library built on well establish dependencies only, SigmaMu is platform independent and moderate regarding its own footprint. In summary, the focus points are

  • Scalable process modelling environment, suitable for modelling industrial production processes with high accuracy and in detail, utilising available CPUs.
  • Covering standard process simulation, but also for instance optimization, data reconciliation, data fit of process and/or thermodynamic parameters.
  • Extensible environment, enabling encapsulation and protection of intellectual property on repository level
    • in-house development and efficient reuse of thermodynamic models and process model parts.
    • The LGPL license allows use of SigmaMu even in commercial settings and without forcing GPL-type licenses onto the derived software, as long as SigmaMu itself (the core) is kept as is.
  • Compatibility to other operative systems, for instance to run models in cloud-deployed Linux docker containers.
  • Enabling model development with elements of modern software development, including
    • concurrent development by utilising version control systems
    • standard ways of code/model testing using standard frameworks, such as pytest
    • in-code documentation of models using sphinx with for instance autodoc and mathjax.
  • Maximising model reliability and reducing modelling errors through
    • hierarchical modelling, enabling efficient independent testing of minor sub-model parts
    • forcing consistent modelling with respect to physical dimensions by using Pint for all exchange of physical quantities.
  • Extensive documentation, use of doctest and unit tests, and examples to make the software most accessible for new users.

... and what not?

  • SigmaMu makes no attempt to provide a graphical user interface to make its functionality easier accessible and increase usability. This can surely be done and might be a good idea for some use-cases, but is not the primary goal of this project.

  • SigmaMu is not a general purpose modelling tool, such as for instance Modelica. While it is to some degree possible to model non-chemical systems, one is surely better off by using such generic tools.

  • While the modelling approach of SigmaMu strongly promotes better understanding of thermodynamics and chemical process modelling, it is not removing the necessity to define the model on equation level. However, some models are readily available for reuse, and experts might develop further in-house model parts that need not be understood by downstream developers.

  • Physical property data is less public domain than you might think, and while it is perfectly legal to use numerous online databases and textbooks as free sources in academic and cooperate work, extracting compiled data and republishing them open source is not generally admitted. Therefore, SigmaMu cannot contain significant physical property data by itself.

    The idea is that physical data for the particular application is gathered legally in derived projects under much less strict conditions. However, we might seek permission and be granted to provide data for a subset of common species, not least for demonstration purposes.

Example

Below code imports a material definition for methane as an ideal gas and then defines a simple process model that simply specifies a methane flow by temperature, pressure and volume flow.

from simu import Model
from .material_factory import ch4_ideal_gas

class Source(Model):
    """A model of a methane source"""

    def interface(self):
        self.parameters.define("T", 25, "degC")
        self.parameters.define("p", 1, "bar")
        self.parameters.define("V", 10, "m^3/hr")

    def define(self):
        src = self.materials.create_flow("source", ch4_ideal_gas)
        self.residuals.add( "T", self.parameters["T"] - src["T"], "K")
        self.residuals.add( "p", self.parameters["p"] - src["p"], "bar")
        self.residuals.add( "V", self.parameters["V"] - src["V"], "m^3/h")


This model can be solved as follows:

from simu import NumericHandler, SimulationSolver
from simu.examples.material_model import Source

numeric = NumericHandler(Source.top())
solver = SimulationSolver(numeric)
solver.solve()

The solver applies the Newton-Raphson method, whereas the system matrix (here pathetically 3x3) is obtained using CasADi. The linearized systems are solved using the multicore Intel oneAPI solver provided by the PyPardiso package:

Iter   LMET   Alpha   Time   Limit on bound Max residual
----- ----- ------- ------ ---------------- ------------
    0   9.0    0.83   0.07 source/n/Methane            T
    1   8.2       1   0.07                             T
    2   6.4       1   0.07                             V
    3  -7.3       1   0.07                             V

Here, the relaxation factor α is limited in the first iteration for the quantity of methane to remain positive. The LMET column shows the maximum logarithmic (base 10) residual error to tolerance ratio. The model is converged when LMET < 0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sigmamu-1.0b1.tar.gz (133.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sigmamu-1.0b1-py3-none-any.whl (171.0 kB view details)

Uploaded Python 3

File details

Details for the file sigmamu-1.0b1.tar.gz.

File metadata

  • Download URL: sigmamu-1.0b1.tar.gz
  • Upload date:
  • Size: 133.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for sigmamu-1.0b1.tar.gz
Algorithm Hash digest
SHA256 f165211925a06f37e88dfd9096e7eabe6774e8d1f7ec5d7487f3097300b625f9
MD5 336f8f01072f658a11a8b060a69491cd
BLAKE2b-256 7c8f74697b4c44c70f383beecbb2658348b8c552e01d00f06702e266808e79c3

See more details on using hashes here.

File details

Details for the file sigmamu-1.0b1-py3-none-any.whl.

File metadata

  • Download URL: sigmamu-1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 171.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for sigmamu-1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 257319b56dc2cf7ccc931788fc231fdea2d3af746ecd8233dd33c6643c4d7cc5
MD5 b4ca1f84b5b55c4ed00f148f9b6dd07b
BLAKE2b-256 8241c70b97b7fb639102a52a86f822abed93c22aad533cb4b19e445c11dc0585

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page