Skip to main content

PINNx: Physics-Informed Neural Networks for Scientific Machine Learning in JAX

Header image of pinnx.

Build Status Documentation Status PyPI Version License

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/

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 Distribution

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

pinnx-0.0.2.post20250107-py2.py3-none-any.whl (124.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pinnx-0.0.2.post20250107-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pinnx-0.0.2.post20250107-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c3042bbb21258691b9af0bcffd83fea25bc5d5e56ff65b5003ab669ef52c9c3b
MD5 5871ca4c7e4a8497aace61aa084b0d1c
BLAKE2b-256 dad0ac3593be5084ad90898791b9dbd39e42e8143acb1d01d8de2a3c7584c6f1

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.3

2 files

This release

0.0.2.post20250107 This release

1 file

0.0.2

1 file

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page