Metadata-Version: 2.3
Name: trano-simulate
Version: 0.2.0
Summary: Simulate Modelica models with OpenModelica (in Docker or locally) and report their results.
Keywords: modelica,openmodelica,simulation,building energy simulation
Author: Ando Andriamamonjy
Author-email: Ando Andriamamonjy <andoludovic.andriamamonjy@gmail.com>
License: LGPL-3.0-or-later
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python
Classifier: Typing :: Typed
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: pydantic>=2.13.4,<3
Requires-Dist: docker>=7.1.0,<8
Requires-Dist: jinja2>=3.1.6,<4
Requires-Dist: pandas>=2.2.2,<3
Requires-Dist: buildingspy>=5.2.0,<6
Requires-Dist: matplotlib>=3.10.9,<4
Requires-Dist: plotly>=6.8.0,<7
Requires-Dist: python-docx>=1.2.0,<2
Requires-Dist: yattag>=1.16.1,<2
Requires-Python: >=3.11, <4.0
Project-URL: Repository, https://github.com/andoludo/trano-simulate
Description-Content-Type: text/markdown

# trano-simulate

Simulate Modelica models with [OpenModelica](https://openmodelica.org), in a Docker container of the
OpenModelica image or with the `omc` of your machine, and report their results.

It is the simulation backend of [trano](https://github.com/andoludo/trano), and does not depend on it:
a model is the name and the Modelica text of a package whose top model is `building`.

```python
from pathlib import Path

from trano_simulate import ModelPackage, SimulationOptions, run_simulation

package = ModelPackage(name="Decay", source=Path("decay.mo").read_text())
result = run_simulation(Path("run"), package, options=SimulationOptions(end_time=3600), runtime="docker")
result.success, result.result_path, result.error_kind, result.error_message
```

`runtime="docker"` needs Docker; `runtime="local"` needs OpenModelica's `omc` on the PATH, with the Modelica
libraries installed (`trano-install-libraries`).

## Reports

A report needs two files: the description of the model, which trano writes next to the model it generates
(`<name>.description.json`: its spaces, constructions and systems, and the result variables to plot), and the result
file of the simulation.

```python
from trano_simulate.reporting import ModelDocumentation, to_docx, to_html_reporting

documentation = ModelDocumentation.from_files(Path("house.description.json"), Path("run/results/house.building_res.mat"))
Path("house.html").write_text(to_html_reporting(documentation))
to_docx(documentation, Path("house.docx"))
```

## Development

```bash
uv sync
make linting
make tests      # unit tests
make simulate   # simulations in Docker
```
