Automatic simulation system powered by neural networks
Project description
Automatic simulation system powered by neural networks
Installation
pip install asim
What is asim
- Physical field modeling with automatic constraint enforcement
- Flexible data grouping and normalization
- Built-in support for recurrent architectures
- Export/import of trained models
Using asim
import matplotlib.pyplot as plt
import pandas as pd
from asim.dataset import PhysicalDataManage, Vt, Vu, Vx, DummyDatasets
from asim.model import PhysicalFieldModel
from asim.optimizer import ContinuousOptimizer
from asim.simulator import PhysicalSimulator
# 1. Define data and structure
df = DummyDatasets.boiler_minimum(size=2000) # pd.read_csv("demo.csv")
cols = [
Vt(label="ts"),
Vx(group="boiler", label="heat_temp", minmax=(0.0, None), unit="kj", enable=True),
Vu(group="boiler", label="heat_power1", minmax=(0.0, None), unit="kw", enable=True),
Vu(group="boiler", label="heat_power2", minmax=(0.0, None), unit="kw", enable=True),
]
dm = PhysicalDataManage(df, columns=cols, batch_size=64)
# 2A. Select the model, define the parameters, train and save
fm = PhysicalFieldModel(dm, lr=0.003)
fm.fit(epochs=100)
fm.export("demo.sim.onnx")
# 2B. Use a simulator to simulate the operation
sim = PhysicalSimulator("demo.sim.onnx", dm=dm)
sim_df = df[0:1440].copy()
sim_df.index = pd.to_datetime(sim_df["ts"], unit="s", utc=True).dt.tz_convert("Etc/GMT-8")
sim_df = sim.steps(sim_df, x0={"heat_temp": 150.0})
sim.plots(sim_df)
plt.show()
# 3A. Build the optimizer
lTerm = lambda x, u, p: (x - p) ** 2 + 0.5 * (u[0] ** 2 + u[1] ** 2)
mTerm = lambda x, u, p: (x - p) ** 2
opt = ContinuousOptimizer("demo.sim.onnx", dm=dm, lTerm=lTerm, mTerm=mTerm)
opt.fit(epochs=100)
opt.export("demo.opt.onnx")
# 3B. Use the optimizer
opt_df = opt.steps(df[0:360].copy())
opt.plots(opt_df)
plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asim-26.1.6-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: asim-26.1.6-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 282.8 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
806dac274e6c38691323d99616466cb403be0de6108e5a96ed4094694c274bd7
|
|
| MD5 |
9cf0032e15a4486b35f46f89729f4420
|
|
| BLAKE2b-256 |
163b15af7bb2a79409de44a11d7203a538528c6d70440afeefb711d26d2edcae
|
File details
Details for the file asim-26.1.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: asim-26.1.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81d081b85b7f4efb4218b5b61dfd522b959e1772a754424fc5a803fc1440bba6
|
|
| MD5 |
55893a31c51c604b5a998a83cf1599dd
|
|
| BLAKE2b-256 |
0b443bc47efb4a788209d3e2fe2f5d44ed054bfeb3b70663f9117a8a138f3d04
|
File details
Details for the file asim-26.1.6-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: asim-26.1.6-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 285.0 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed75d3431a67d43c328f89984508f7c0b682426093bbe2c1bc4b8077033abb99
|
|
| MD5 |
08fd89c5271761201e0b479f305da348
|
|
| BLAKE2b-256 |
bfa1f46c903bfdd58667db92bfff4b8223a1fbfaecef64d26ef6f5b3d4a50544
|
File details
Details for the file asim-26.1.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: asim-26.1.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d080c79c955e38d8bc5d79d31e045f053e8850b6663f8d068e7e927833acf811
|
|
| MD5 |
9890f71983f892a220d609b60bba1255
|
|
| BLAKE2b-256 |
e93b75e0121583168f25354487dc3e07645ee8711dffd6daf00be3549b634fea
|