nnde

nnde: A Python package for solving differential equations using neural networks - Published in JOSS (2022)

https://github.com/elwinter/nnde

Science Score: 95.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README and JOSS metadata
  • Academic publication links
  • Committers with academic emails
    3 of 7 committers (42.9%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Scientific Fields

Artificial Intelligence and Machine Learning Computer Science - 40% confidence
Last synced: 4 months ago · JSON representation

Repository

nnde is a package of Python modules which implement a set of neural networks which solve ordinary and partial differential equations. This code is based on the previous package, nnode.

Basic Info
  • Host: GitHub
  • Owner: elwinter
  • License: gpl-3.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 1.92 MB
Statistics
  • Stars: 7
  • Watchers: 2
  • Forks: 6
  • Open Issues: 1
  • Releases: 1
Created about 6 years ago · Last pushed almost 4 years ago
Metadata Files
Readme Contributing License

README.md

nnde

nnde is a package of Python modules which implement a set of neural networks which solve ordinary and partial differential equations using technique of Lagaris et al. (1998).

The nnde package provides a pure-Python implementation of one of the earliest approaches to using neural networks to solve differential equations - the trial function method Lagaris et al. (1998). It was initially developed primarily as a vehicle for understanding the internal workings of feedforward neural networks, without the restrictions imposed by an existing neural network framework. The target audiences are machine learning researchers who want to develop an understanding of the basic steps needed to solve differential equations with neural networks and researchers from general engineering fields who want to solve a differential equation without using a complex neural network library.

The package is described in Winter and Weigel, 2021. Additional details on the method are given in Winter 2020.

Demos are available in the repository nnde_demos.

Install and Use

bash pip install nnde git clone https://github.com/elwinter/nnde_demos pip install matplotlib # optional cd nnde_demos; python lagaris01_demo.py

Developer

bash git clone https://github.com/elwinter/nnde cd nnde pip install -e . python setup.py test # Deprecated pytest # Preferred

An overview of nnde

The nnde package was developed as a tool to help understand how neural networks can be used to solve differential equations. The effort was originally inspired by work done in the 1990s showing how feedforward neural networks could be used as universal approximators. That work led to efforts to show how neural networks could be applied to differential equations. A good example of this technique can be found in Lagaris et al (1993).

The basic technique is straightforward:

  • Arrange the differential equation in a standard form:

G(x, y, dy/dx, ...) = 0

  • Define a trial solution y_trial that can be substituted into the differential equation. This trial solution includes a component computed by a neural network, as well as a term which incorporates all boundary conditions.

  • Use the analytical definition of y_trial to determine the analytical forms of the various derivatives of y used in the differential equation.

  • Define the structure of the neural network so that it has one input per independent variable, and a single output.

  • Using a set of training points defined on the domain of the differential equation, run the network and use the output to compute the value of the trial solution and its derivatives.

  • Compute the value of the standardized differential equation G() at each training point.

  • Compute the loss function as the sum of the squared values of G().

  • Train a neural network to solve the equation for the trial solution by minimizing the loss function at each training point: L = SUM(G_i^2). This is done by adjusting the network parameters (weights and biases) until a satifactory solution is obtained.

The nnde package is divided into 3 major packages (differentialequation, neuralnetwork, and trialfunction), and two auxiliary packages (exceptions and math).

The differentialequation package is divided into two sub-packages: ode (for ordinary differential equations) and pde (for partial differential equations). These sub-packages are very lightweight - they are composed of abstract classes used to define the methods that the user-defined differential equation must implement. These are primarily methods to evaluate the differential equation itself, and the various derivatives required for its evaluation. Each of these functions depends on the training points, and computes the values and derivatives of the trial solution during evaluation The ode and pde packages provide classes for 1st-order ODE initial-value problems, 1st-order PDE initial value problems, and diffusion problems in 1, 2, and 3 spatial dimensions. These classes can be used as-is to solve the corresponding equation types by defining the required methods.

The neuralnetwork package provides the core of the nnde functionality. Each module provides a customizable neural network tailored to the needs of a specific problem type. Currently support types are the same as those supported in the differentialequation package. A different class was used for each equation type because the details of the computation of the network output differ slightly for each equation type.

The trialfunction package provides a previously unavailable capability: determine the structure of the boundary condition component of the trial solution automatically. The algorithm for determining the form of this component of the trial solution is recursive, and the number of terms grows rapidly as the dimensionality of the problem is increased. However, if the user provides the boundary conditions (as another set of functions), these modules can automatically construct the boundary condition term, greatly easing the problem definition burden on the user. The modules also provide the option to short-circuit this process by allowing the user to define an optimized form of the boundary condition function that can greatly reduce the required amount of computation. Trial function classes are provided for diffusion problems in 1, 2, and 3 spatial dimensions. The code which solves 1st-order ODE IVP uses a trivial form of the boundary condition component (a constant), and therefore its use is coded directly, without a separate class.

A Jupyter notebook (tutorial.ipynb) providing a structured walkthrough of the process of defining and solving a problem using the nnde package is available in the examples directory.

Contribute

If you discover bugs in the nnde package, please create an issue at the project repository on GitHub at https://github.com/elwinter/nnde.

If you find the nnde package useful, we welcome your contributions of code and documentation. To contribute, fork the repository on GitHub, and submit a pull request at https://github.com/elwinter/nnde.

Contact

Submit bug reports and feature requests on the repository issue tracker.

Eric Winter eric.winter62@gmail.com

Owner

  • Name: Eric Winter
  • Login: elwinter
  • Kind: user
  • Company: Johns Hopkins University Applied Physics Laboratory

JOSS Publication

nnde: A Python package for solving differential equations using neural networks
Published
February 14, 2022
Volume 7, Issue 70, Page 3465
Authors
Eric Winter ORCID
Department of Physics and Astronomy, George Mason University, Fairfax, Virginia, USA
R.s. Weigel ORCID
Department of Physics and Astronomy, George Mason University, Fairfax, Virginia, USA
Editor
Patrick Diehl ORCID
Tags
neural networks differential equations

GitHub Events

Total
Last Year

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 287
  • Total Committers: 7
  • Avg Commits per committer: 41.0
  • Development Distribution Score (DDS): 0.547
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Eric Winter e****r@g****u 130
Eric Winter e****r@j****u 86
Eric Winter e****2@g****m 43
Eric Winter e****r@g****l 15
Bob Weigel R****l@g****m 10
hayesall a****r@b****t 2
Eric Winter e****r@s****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 18
  • Total pull requests: 5
  • Average time to close issues: 28 days
  • Average time to close pull requests: about 1 month
  • Total issue authors: 4
  • Total pull request authors: 3
  • Average comments per issue: 1.28
  • Average comments per pull request: 0.4
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • hayesall (14)
  • taless474 (2)
  • Arup-nit (1)
  • mombash (1)
Pull Request Authors
  • hayesall (2)
  • rweigel (2)
  • elwinter (1)
Top Labels
Issue Labels
bug (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 12 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 7
  • Total maintainers: 1
pypi.org: nnde

A package implementing a collection of neural networks to solve ordinary and partial differential equations

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 12 Last month
Rankings
Dependent packages count: 10.0%
Forks count: 14.2%
Average: 18.4%
Stargazers count: 19.3%
Dependent repos count: 21.7%
Downloads: 26.8%
Maintainers (1)
Last synced: 4 months ago

Dependencies

setup.py pypi
  • matplotlib *
  • numpy *
  • scipy *