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/

Metadata

Release files for pinnx 0.0.2.post20250107

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pinnx 0.0.2.post20250107
File Interpreter ABI Platform
pinnx-0.0.2.post20250107-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / pinnx-0.0.2.post20250107-py2.py3-none-any.whl

Download URL pinnx-0.0.2.post20250107-py2.py3-none-any.whl
Size 124.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c3042bbb21258691b9af0bcffd83fea25bc5d5e56ff65b5003ab669ef52c9c3b
BLAKE2b-256 checksum
How to use checksums
dad0ac3593be5084ad90898791b9dbd39e42e8143acb1d01d8de2a3c7584c6f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for pinnx 0.0.2.post20250107

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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