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 (
NeuralNetworkclass). - 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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 pinnfactory-0.1.0.tar.gz.
File metadata
- Download URL: pinnfactory-0.1.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e339fdc954417fde68e2393d97a3fcfc1db545e6cb7161e40f970c0bc2d911a0
|
|
| MD5 |
cc58ae8334913a3d5b870393c339154a
|
|
| BLAKE2b-256 |
dee0fa8ba4b10c598d667644249b4bac8a750ea59f3460c3060fcb5c8016df01
|
File details
Details for the file pinnfactory-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pinnfactory-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be762d3013a3021d93dda3bc9bf9745399c7b93cf6430eee61501e0aeb54191f
|
|
| MD5 |
864b84bde4a2a792eeba18ec8db93145
|
|
| BLAKE2b-256 |
30c5c35ba9936e68c3c8a9d28c00d6dc5193051b598052038a41d9f64d2bf299
|