Skip to main content

Reduced order modeling for the masses

Project description

Rombus: Helps you qucikly and easily compute slow and complex models

Rombus is a tool for building reduced order models (ROMs): matrix representations of arbitrary models which can be rapidly and easily computed for arbitrary parameter sets.

Building a ROM with Rombus is easy. All you need to do is install it like so:

$ pip install rombus

define your model like this (in this trivial case, a file named my_model.py specifying a simple second-order polynomial):

from numpy import ndarray, polyval, linspace
from rombus.model import RombusModel
from typing import NamedTuple


class Model(RombusModel):
    """Class for creating a ROM for the function y(x)=a2*x^2+a1*x+a0"""

    coordinate.set("x", 0.0, 10.0, 11, label="$x$")

    ordinate.set("y", label="$y(x)$")

    params.add("a0", -10, 10)
    params.add("a1", -10, 10)
    params.add("a2", -10, 10)

    def compute(self, p: NamedTuple, x: ndarray) -> ndarray:
        """Compute the model for a given parameter set."""
        return polyval([p.a2, p.a1, p.a0], x)

and specify a set of points (in this case, the file my_model_samples.py) to build your ROM from:

-10, -10,-10
-10,  10,-10
-10, -10, 10
-10,  10, 10
 10, -10,-10
 10,  10,-10
 10, -10, 10
 10,  10, 10

You build your ROM like this:

$ rombus build my_model:Model my_model_samples.csv

This produces an HDF5 file named my_model.hdf5. You can then use your new ROM in your Python projects like this:

from rombus.rom import ReducedOrderModel

ROM = ReducedOrderModel.from_file('my_model.hdf5')
sample = ROM.model.sample({"a0":0,"a1":0,"a2":1})
model_ROM = ROM.evaluate(sample)
for x, y in zip(ROM.model.domain,model_ROM):
    print(f"{x:5.2f} {y:6.2f}")

which generates the output:

 0.00   0.00
 1.00   1.00
 2.00   4.00
 3.00   9.00
 4.00  16.00
 5.00  25.00
 6.00  36.00
 7.00  49.00
 8.00  64.00
 9.00  81.00
10.00 100.00

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

rombus-1.2.1.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

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

rombus-1.2.1-py3-none-any.whl (45.3 kB view details)

Uploaded Python 3

File details

Details for the file rombus-1.2.1.tar.gz.

File metadata

  • Download URL: rombus-1.2.1.tar.gz
  • Upload date:
  • Size: 38.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/6.8.0-1021-azure

File hashes

Hashes for rombus-1.2.1.tar.gz
Algorithm Hash digest
SHA256 c0f6a9eebd70a717ae638363b51595baadc63555422d908cd31c768f8b5c0630
MD5 101dcd664bf48d5de6dbe5dae39932b9
BLAKE2b-256 36fbc2ba74ebad130cd9dd6e62d6e7de4f4b2fa84acf4a2a1492f2a41e6a38fa

See more details on using hashes here.

File details

Details for the file rombus-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: rombus-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 45.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/6.8.0-1021-azure

File hashes

Hashes for rombus-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4188a835a1000a11a0b6295a3b6a6b98fdbd2b942de60b7c10229305f28a4fd2
MD5 80828046862ec785bcb03d13dfdd6999
BLAKE2b-256 d6b67b5a2b5d55c97f32863b792ccf689c288896fcecec5a287c061b3f15e32f

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