Skip to main content

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.

Metadata

Release files for strupnet 0.0.4

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

Source distribution (sdist)

Source distribution for strupnet 0.0.4
File Size Uploaded Provenance Actions
strupnet-0.0.4.tar.gz 15.0 kB Without provenance Details for strupnet-0.0.4.tar.gz

Built distribution (wheel)

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

Total release size: 34.3 kB

Release files / strupnet-0.0.4.tar.gz

Download URL strupnet-0.0.4.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b45b6dcb3e9cc3263e06854ce30c93bd40586bf3ca597899e86cb24534f1e9e0
BLAKE2b-256 checksum
How to use checksums
e42ee783e6c46cbc27f61acf07ea961f8641b3219aa8446723a0d6a27692bab2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release files / strupnet-0.0.4-py3-none-any.whl

Download URL strupnet-0.0.4-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b2db8880f5d74963dc69b74e34506ba3317152deb2996cf09ea1b3ef62aa451
BLAKE2b-256 checksum
How to use checksums
929623f26746258e94cc77b3bd3ea2c7f1d3cd6a518bf92b378e5e2462e873f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Security for strupnet 0.0.4

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.

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