Skip to content

Latest commit

History

45 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

NeuralSolvers

Neural network based solvers for partial differential equations.

P. Stiller, F. Bethke, M. Böhme, R. Pausch, S. Torge, A. Debus, J. Vorberger, M.Bussmann, N. Hoffmann: Large-scale Neural Solvers for Partial Differential Equations.

Requirements

Libaries

cuda 10.2 # if gpu support is needed
python/3.6.5
gcc/5.5.0
openmpi/3.1.2

Python requirements

torch==1.7.1 h5py==2.10.0
numpy==1.19.0
Pillow==7.2.0
matplotlib==3.3.3
scipy==1.6.1
pyDOE==0.3.8

Usage of Interface

At the beginning you have to implement the datasets following the torch.utils.Dataset interface

importtorch.utils.DatasetasDatasetimportPINN.InterfaceasInterfacesys.path.append(PATH_TO_PINN_FRAMEWORK) # adding the pinn framework to your pathimportPINNFrameworkaspfclassBoundaryConditionDataset(Dataset):
def__init__(self, nb, lb, ub):
""" Constructor of the initial condition dataset """def__getitem__(self, idx):
""" Returns data for initial state """def__len__(self):
""" Length of the dataset """classInitialConditionDataset(Dataset):
def__init__(self, **kwargs):
""" Constructor of the boundary condition dataset """def__len__(self):
""" Length of the dataset """def__getitem__(self, idx):
""" Returns item at given index """classPDEDataset(Dataset):
def__init__(self, nf, lb, ub):
""" Constructor of the PDE dataset """def__len__(self):
""" Length of the dataset """def__getitem__(self, idx):
""" Returns item at given index """

In the main function you can create the loss-terms and the corresponding datasets. And define the pde function f which is the residual of the pde given residual points and model predictions u. For the boundary conditions: neumann, robin, dirchlet and periodic boundary condititions are supported.

if__name__==main :
# initial conditionic_dataset=InitialConditionDataset(...)
initial_condition=pf.InitialCondition(dataset=ic_dataset)
# boundary conditionsbc_dataset=BoundaryConditionDataset(...)
periodic_bc_u=pf.PeriodicBC(...)
periodic_bc_v=pf.PeriodicBC(...)
periodic_bc_u_x=pf.RobinBC(...)
periodic_bc_v_x=pf.NeumannBC(...)
# PDE pde_dataset=PDEDataset(...)
deff(x, u):
""" Defines the residual of the pde f(x,u)=0 """pde_loss=pf.PDELoss(dataset=pde_dataset, func=f)

Finally you can create a model which is the surrogate for the PDE and create the PINN enviorment which helps you to train the surrogate.

model=pf.models.MLP(input_size=2, output_size=2, hidden_size=100, num_hidden=4) # creating a model. For example a mlppinn=pf.PINN(model, input_size=2, output_size=2 ,pde_loss=pde_loss, initial_condition=initial_condition, boundary_condition= [...], use_gpu=True)
pinn.fit(50000, 'Adam', 1e-3)

Deep HPM support

Instead of a PDE loss you can use a HPM model. The HPM model needs a function derivatives that calculates the needed derivatives, while the last returned derivative is the time_derivative. You can use the HPM loss a follows.

derderivatives(x,u):
"""	Returns the derivatives	Args:  x (torch.Tensor) : residual points u (torch.Tensor) : predictions of the pde model	"""passhpm_loss=pf.HPMLoss(pde_dataset,derivatives,hpm_model)
pinn=pf.PINN(model, input_size=2, output_size=2 ,pde_loss=hpm_loss, initial_condition=initial_condition, boundary_condition= [...], use_gpu=True)

About

Neural network based solvers for partial differential equations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages