Metadata-Version: 2.4
Name: physai
Version: 2.5.8
Summary: Physics-Informed Neural Network (PINN) library for solving and animating ODEs/PDEs with visualization and training tools
Author-email: Mankrit Singh <whataninfinity@gmail.com>
License: # Modified Apache License, Version 2.0
        # Copyright 2025 Mankrit Singh (MS-AGI)
        # Email: whataninfinity@gmail.com
        # GitHub: https://github.com/MS-AGI
        
        This is a modified version of the Apache License, Version 2.0.
        Modifications include:
        - Mandatory citation for academic or official use.
        - Ethical use clause prohibiting malicious or illegal use.
        
        All other terms follow the standard Apache License 2.0.
        
        ---
        
        Apache License
        Version 2.0, January 2004
        http://www.apache.org/licenses/
        
        TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
        1. Definitions.
           "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
           "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
        
        2. Grant of Copyright License.
           Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
        
        3. Grant of Patent License.
           Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted.
        
        4. Redistribution.
           You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
           a) You must provide a copy of this License in every copy of the Work or Derivative Works that You distribute.
           b) You must cause any modified files to carry prominent notices stating that You changed the files.
           c) You must retain, in the NOTICE file provided with the Work, if any, a prominent attribution to the original authors, including any changes made.
        
        5. Submission of Contributions.
           Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions.
        
        6. Trademarks.
           This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
        
        7. Disclaimer of Warranty.
           Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
        
        8. Limitation of Liability.
           In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
        
        9. Accepting the License.
           By using, reproducing, or distributing the Work (or any work based on the Work) in any medium, you indicate your acceptance of this License and agree to be bound by its terms.
        
        END OF LICENSE
        
        NOTICE:
        By using this software, you agree to:
        - Cite the work in any academic, government, or commercial publication where it is used.
        - Avoid malicious, illegal, or unethical applications.
        - Acknowledge the original author and contributors in derivative works.
        
Project-URL: homepage, https://github.com/MS-AGI/PhysAI
Project-URL: documentation, https://github.com/MS-AGI/PhysAI
Project-URL: source, https://github.com/MS-AGI/PhysAI
Project-URL: doi, https://doi.org/10.5281/zenodo.17214725
Keywords: PINN,Physics-Informed Neural Network,ODE,PDE,Deep Learning,Modular Library,Built-in PDE support,Efficient and Fast Training for Great PDE Solving and visualization,Built-in Partial Differential Equations using pre-made PINN
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.8.0
Requires-Dist: matplotlib
Requires-Dist: numpy
Dynamic: license-file

# PhysAI: Modular PyTorch Library with Built-In Residual PDEs, Automatic PINN Losses, and Visualization Tools for Complex ODE/PDE Solving

[![PyPI version](https://img.shields.io/pypi/v/physai.svg)](https://pypi.org/project/physai/)
[![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-indigo.svg)](https://opensource.org/licenses/MIT)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/physai.svg)](https://pypi.org/project/physai/)
[![Socket Badge](https://badge.socket.dev/pypi/package/physai/2.5.7?artifact_id=tar-gz)](https://badge.socket.dev/pypi/package/physai/2.5.7?artifact_id=tar-gz)
[![DOI](https://zenodo.org/badge/1064030431.svg)](https://doi.org/10.5281/zenodo.17214724)

---

## **Overview**

**PhysAI** is a Python package for solving **ordinary differential equations (ODEs) and partial differential equations (PDEs)** using **Physics-Informed Neural Networks (PINNs)**. It integrates physics directly into neural network training, allowing the solution of classic physics problems without relying on traditional numerical solvers.

PhysAI supports a wide range of physics problems including:

* **ODEs:** Logistic growth, Newton’s law of cooling, damped/simple harmonic oscillators, Markov processes.
* **PDEs:** Heat equation, wave equation, Burgers' equation, KdV equation, convection-diffusion.
* **Quantum Mechanics:** Schrödinger equation.
* **Electromagnetism & Quantum Phenomena:** Planck’s law, photoelectric effect.
* **Fluid Dynamics:** 2D incompressible Navier-Stokes.
* **Static Problems:** Laplace and Poisson equations (2D/3D).

Key features:

* Flexible **PDE/ODE residual computation** for various physics laws.
* **Mixed-precision training** for faster computation on GPUs.
* Gradient clipping and learning rate schedulers supported.
* **Visualization and animations** of solutions using matplotlib.
* Weighted loss functions combining residual and boundary conditions.

---

## **Installation**

Clone the repository and install dependencies:

```bash
git clone https://github.com/yourusername/physai.git
cd physai
pip install -r requirements.txt
```

Python >= 3.10 recommended.

---

## **Repository Structure**

```
physai/
├── __init__.py
├── models.py          # PINN neural network class
├── trainer.py         # trainer cls for PINNs
├── visualization.py
├── pde_residual.py    # residuals for ODEs/PDEs
├── losses.py
├── utils.py 
examples/              
├── example_schrodinger.py
├── example_newton_cooling.py
├── example_markov.py
├── example_photoelectric.py
├── example_planck.py
README.md             
requirements.txt      
.gitignore             
```

---

## **Quick Start Example**

```python
import torch
from physai.models import PINN
from physai.pde_residual import pde_residual
from physai.losses import pinn_loss
from physai.visualization import plot_1d_solution

# Define a 1D logistic growth ODE
def logistic(x, y):
    r, K = 1.0, 1.0
    return torch.autograd.grad(y, x, grad_outputs=torch.ones_like(y), create_graph=True)[0] - r*y*(1 - y/K)

# Create a PINN model
model = PINN(layers=[1, 20, 20, 1], activation='tanh')

# Training points
x_train = torch.linspace(0, 5, 100).reshape(-1,1)

# Train the model
from physai.trainer import Trainer
trainer = Trainer(model, collocation_points=x_train, pde_type='logistic')
history = trainer.train(epochs=500, lr=1e-3)

# Plot solution
plot_1d_solution(model, x_train, title='Logistic Growth')
```

---

## **Training a PDE Example: 1D Heat Equation**

```python
import torch
from physai.models import PINN
from physai.trainer import Trainer
from physai.visualization import animate_2d

# PINN model
model = PINN(layers=[2, 50, 50, 1], activation='tanh')

# Collocation points
x = torch.linspace(0, 1, 50).reshape(-1,1)
t = torch.linspace(0, 2, 50).reshape(-1,1)
inputs = torch.cartesian_prod(x.squeeze(), t.squeeze())
inputs = inputs.float()

# Trainer
trainer = Trainer(model, collocation_points=inputs, pde_type='heat')
history = trainer.train(epochs=1000, lr=1e-3)

# Animate solution
animate_2d(model, x, t, title='Heat Equation Evolution')
```

---

## **Physics Problems Supported**

| Type               | Equations / Laws                                                                           |
| ------------------ | ------------------------------------------------------------------------------------------ |
| ODE                | Logistic Growth, Simple/Damped Harmonic Oscillator, Newton's Law of Cooling, Markov Chains |
| PDE                | Heat Equation, Wave Equation, Burgers', KdV, Convection-Diffusion, Laplace, Poisson        |
| Quantum            | Schrödinger Equation, Planck's Law                                                         |
| Quantum/Electromag | Photoelectric Effect                                                                       |
| Fluid Dynamics     | 2D Incompressible Navier-Stokes                                                            |
| 3D PDEs            | Laplace 3D, Poisson 3D                                                                     |

---

## **Visualization**

* **1D plots:** `plot_1d_solution(model, x)`
* **2D surface plots:** `plot_2d_surface(model, X, Y)`
* **Animation over time:** `animate_2d(model, x, t)`
* **Training loss plots:** `plot_loss(trainer.history)`

---

## **Advanced Features**

* Mixed precision training for faster GPU computation
* Gradient clipping
* Flexible learning rate scheduling
* Weighted PINN loss for custom PDE/BC importance
* Supports custom potentials (`V(x,t)`) for Schrödinger equation

---

## Citation
If you use **PhysAI** in your research, academic publication, or official work, **citation is required**.

Please cite the software as follows:

**APA:**
> Singh, M. (2025). *PhysAI: Physics-Informed Neural Networks in PyTorch* (Version 2.5.7) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.17214725

**BibTeX:**
```bibtex
@software{singh_physai_2025,
  author       = {Mankrit Singh},
  title        = {PhysAI: Physics-Informed Neural Networks in PyTorch},
  month        = sep,
  year         = 2025,
  publisher    = {Zenodo},
  version      = {2.5.7},
  doi          = {10.5281/zenodo.17214725},
  url          = {https://doi.org/10.5281/zenodo.17214725}
}
```

---

## **License**

Apache License. See [LICENSE](LICENSE) file.

---

**Important Notice: Ethical Use Required**  
This software **must not be used for malicious, illegal, or unethical purposes**.  
Misuse of the library voids your license under the Ethical Use Clause.


**Solve physics problems with PINNs and visualize them interactively!**
