Skip to main content

PINNeAPPle - PINNFactory

A lightweight framework for building Physics-Informed Neural Networks (PINNs) with symbolic PDE definitions using SymPy and automatic differentiation in PyTorch.

It provides:

  • Flexible neural architectures (NeuralNetwork class).
  • Wrapper for inverse parameter estimation (PINN).
  • Factory for PDE-driven loss generation from symbolic equations (PINNFactory).

Installation

Clone the repository and install the requirements:

git clone https://github.com/barrosyan/pinnfactory.git
cd pinnfactory
pip install -r requirements.txt

Requirements

  • torch
  • numpy
  • matplotlib
  • sympy

Quick Start

1. Define your neural network

from pinn_generator import NeuralNetwork, PINN

# Example: 1 input, 1 output, 3 hidden layers with 20 neurons each
net = NeuralNetwork(num_inputs=1, num_outputs=1, num_layers=3, num_neurons=20)
pinn = PINN(net)

2. Define PDEs and conditions symbolically

from pinn_generator import PINNFactory

# PDE: u_xx + u = 0  (example)
pde_residuals = ["Derivative(u(x), (x,2)) + u(x)"]

# Boundary conditions: u(0) = 0, u(pi) = 0
conditions = [
    {"equation": "u(0)"},
    {"equation": "u(pi)"}
]

factory = PINNFactory(
    pde_residuals=pde_residuals,
    conditions=conditions,
    independent_vars=["x"],
    dependent_vars=["u"]
)

loss_fn = factory.generate_loss_function()

3. Training loop

import torch

optimizer = torch.optim.Adam(pinn.parameters(), lr=1e-3)

# Example training batch
x = torch.linspace(0, 3.14, 100).view(-1, 1).requires_grad_(True)

for epoch in range(1000):
    optimizer.zero_grad()
    loss, loss_components = loss_fn(pinn, {"collocation": (x,)})
    loss.backward()
    optimizer.step()
    if epoch % 100 == 0:
        print(f"Epoch {epoch} - Total Loss: {loss.item():.6f}")

Roadmap

  • Add support for system of PDEs.
  • Implement collocation sampling utilities.
  • Add GPU support for large-scale PDE solving.
  • Integrate with visualization tools for PINN training.
  • Add more NN Architectures.

License

Apache License 2.0.
You may use, modify, and distribute this project under the terms of the Apache License 2.0.

Metadata

Release files for pinnfactory 0.1.0

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

Source distribution (sdist)

Source distribution for pinnfactory 0.1.0
File Size Uploaded Provenance Actions
pinnfactory-0.1.0.tar.gz 9.3 kB Without provenance Details for pinnfactory-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pinnfactory 0.1.0
File Interpreter ABI Platform Actions
pinnfactory-0.1.0-py3-none-any.whl Python 3 none any Details for pinnfactory-0.1.0-py3-none-any.whl

Total release size: 20.3 kB

Release files / pinnfactory-0.1.0.tar.gz

Download URL pinnfactory-0.1.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e339fdc954417fde68e2393d97a3fcfc1db545e6cb7161e40f970c0bc2d911a0
BLAKE2b-256 checksum
How to use checksums
dee0fa8ba4b10c598d667644249b4bac8a750ea59f3460c3060fcb5c8016df01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pinnfactory-0.1.0-py3-none-any.whl

Download URL pinnfactory-0.1.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be762d3013a3021d93dda3bc9bf9745399c7b93cf6430eee61501e0aeb54191f
BLAKE2b-256 checksum
How to use checksums
30c5c35ba9936e68c3c8a9d28c00d6dc5193051b598052038a41d9f64d2bf299
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for pinnfactory 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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