Physics-informed.
Project description
PINNx: Physics-Informed Neural Networks for Scientific Machine Learning in JAX
PINNx is a library for scientific machine learning and physics-informed learning in JAX.
It is inspired from DeepXDE but is enhanced by our
Brain Dynamics Programming (BDP) ecosystem.
For example, it leverages
- brainstate for just-in-time compilation,
- brainunit for dimensional analysis,
- braintools for checkpointing, loss functions, and other utilities.
Quickstart
Define a PINN with explicit variables and physical units.
import brainstate as bst
import brainunit as u
import pinnx
# geometry
geometry = pinnx.geometry.GeometryXTime(
geometry=pinnx.geometry.Interval(-1, 1.),
timedomain=pinnx.geometry.TimeDomain(0, 0.99)
).to_dict_point(x=u.meter, t=u.second)
uy = u.meter / u.second
v = 0.01 / u.math.pi * u.meter ** 2 / u.second
# boundary conditions
bc = pinnx.icbc.DirichletBC(lambda x: {'y': 0. * uy})
ic = pinnx.icbc.IC(lambda x: {'y': -u.math.sin(u.math.pi * x['x'] / u.meter) * uy})
# PDE equation
def pde(x, y):
jacobian = approximator.jacobian(x)
hessian = approximator.hessian(x)
dy_x = jacobian['y']['x']
dy_t = jacobian['y']['t']
dy_xx = hessian['y']['x']['x']
residual = dy_t + y['y'] * dy_x - v * dy_xx
return residual
# neural network
approximator = pinnx.nn.Model(
pinnx.nn.DictToArray(x=u.meter, t=u.second),
pinnx.nn.FNN(
[geometry.dim] + [20] * 3 + [1],
"tanh",
bst.init.KaimingUniform()
),
pinnx.nn.ArrayToDict(y=uy)
)
# problem
problem = pinnx.problem.TimePDE(
geometry,
pde,
[bc, ic],
approximator,
num_domain=2540,
num_boundary=80,
num_initial=160,
)
# training
trainer = pinnx.Trainer(problem)
trainer.compile(bst.optim.Adam(1e-3)).train(iterations=15000)
trainer.compile(bst.optim.LBFGS(1e-3)).train(2000, display_every=500)
trainer.saveplot(issave=True, isplot=True)
Installation
- Install the stable version with
pip:
pip install pinnx --upgrade
Documentation
The official documentation is hosted on Read the Docs: https://pinnx.readthedocs.io/
See also the BDP ecosystem
We are building the Brain Dynamics Programming ecosystem: https://ecosystem-for-brain-dynamics.readthedocs.io/
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
Built Distribution
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 pinnx-0.0.2.post20241220-py2.py3-none-any.whl.
File metadata
- Download URL: pinnx-0.0.2.post20241220-py2.py3-none-any.whl
- Upload date:
- Size: 124.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c813301ca3319273ca9ae0c88724f564a1e13111b3a554c3d053d97299ac4d2c
|
|
| MD5 |
f45b5e168d5c631cb1400739157538bf
|
|
| BLAKE2b-256 |
74686c6787ad3d6a01772d59fe905aa2a73441679bb817e25f937d92ae1202f6
|