Skip to main content

Structure-preserving neural networks

Project description

STRUPNET: structure-preserving neural networks

This package implements structure-preserving neural networks for learning dynamics of differential systems from data.

Installing

Install it using pip: pip install strupnet

SympNet: Symplectic neural networks

This package implements the symplectic neural networks found in [1] ("G" and "LA"-SympNets) and [2] ("H"-SympNets) as well as some new ones [3] ("P", "R" and "GR"-SympNets).

Basic example

import torch
from strupnet import SympNet

dim = 2 # degrees of freedom for the Hamiltonian system. x = (p, q) \in R^{2*dim}
sympnet = SympNet(dim=dim, layers=12, width=8)

timestep = torch.tensor([0.1]) # time-step 
x0 = torch.randn(2 * dim) # phase space coordinate x0 = (p0, q0) 

x1 = sympnet(x0, timestep) # defines a random but symplectic transformation from x0 to x1

The rest of your code is identical to you how you would train any module that inherits from torch.nn.Module.

VolNet: Volume-preserving neural networks

This module neural networks with unit Jacobian determinant. The VolNet is constructed from compositions of SympNets, and therefore requires you to pass through arguments that define one of the above SympNets. See the below example on how it's initialised.

Basic example

import torch
from strupnet import VolNet

dim = 3 # dimension of the ODE 

p_sympnet_kwargs = dict(
    method="P",
    layers=6,
    max_degree=4, # used for method='P' only, method='R' requires you to specify width.
)

volnet = VolNet(dim=DIM, **p_sympnet_kwargs)

timestep = torch.tensor([0.1]) # time-step 
x0 = torch.randn(3)

x1 = sympnet(x0, timestep) # defines a random but volume-preserving neural network mapping from x0 to x1

The rest of your code is identical to you how you would train any module that inherits from torch.nn.Module.

Example notebooks

See the examples/ folder for notebooks on basic implementation of SympNet and VolNet

References

[1] Jin, P., Zhang, Z., Zhu, A., Tang, Y. and Karniadakis, G.E., 2020. SympNets: Intrinsic structure-preserving symplectic networks for identifying Hamiltonian systems. Neural Networks, 132, pp.166-179.

[2] Burby, J.W., Tang, Q. and Maulik, R., 2020. Fast neural Poincaré maps for toroidal magnetic fields. Plasma Physics and Controlled Fusion, 63(2), p.024001.

[3] In press.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strupnet-0.0.4.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

strupnet-0.0.4-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file strupnet-0.0.4.tar.gz.

File metadata

  • Download URL: strupnet-0.0.4.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for strupnet-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b45b6dcb3e9cc3263e06854ce30c93bd40586bf3ca597899e86cb24534f1e9e0
MD5 79742817ab7479334741f37e3a0baa46
BLAKE2b-256 e42ee783e6c46cbc27f61acf07ea961f8641b3219aa8446723a0d6a27692bab2

See more details on using hashes here.

File details

Details for the file strupnet-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: strupnet-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for strupnet-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4b2db8880f5d74963dc69b74e34506ba3317152deb2996cf09ea1b3ef62aa451
MD5 04796cc1ad4994e4510488233c6f0194
BLAKE2b-256 929623f26746258e94cc77b3bd3ea2c7f1d3cd6a518bf92b378e5e2462e873f5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page