Physics-Informed Neural Networks (PINN) Solvers of (Partial) Differential Equations for Scientific Machine Learning (SciML) accelerated simulation
See the codeNeuralPDE.jl is a solver package which consists of neural network solvers for partial differential equations using physics-informed neural networks (PINNs). This package utilizes neural stochastic differential equations to solve PDEs at a greatly increased generality compared with classical methods.
Assuming that you already have Julia correctly installed, it suffices to install NeuralPDE.jl in the standard way, that is, by typing ] add NeuralPDE. Note:
to exit the Pkg REPL-mode, just press Backspace or Ctrl + C.
For information on using the package, see the stable documentation. Use the in-development documentation for the version of the documentation, which contains the unreleased features.
ModelingToolkit.System whose optimization problem is generated by the
standard ModelingToolkit compiler: weighted or constrained boundary conditions, quadrature and
quasi-random training strategies, and Reactant-compiled training loopsODEProblems with neural networksusing NeuralPDE, Lux, OptimizationOptimisers
using DomainSets: Interval
@parameters x y
@variables u(..)
Dxx = Differential(x)^2
Dyy = Differential(y)^2
# 2D PDE
eq = Dxx(u(x, y)) + Dyy(u(x, y)) ~ -sinpi(x) * sinpi(y)
# Boundary conditions
bcs = [
u(0, y) ~ 0.0, u(1, y) ~ 0,
u(x, 0) ~ 0.0, u(x, 1) ~ 0,
]
# Space and time domains
domains = [
x ∈ Interval(0.0, 1.0),
y ∈ Interval(0.0, 1.0),
]
# Neural network
dim = 2 # number of dimensions
chain = Chain(Dense(dim, 16, σ), Dense(16, 16, σ), Dense(16, 1))
discretization = PhysicsInformedNN(chain, QuasiRandomTraining(400; bcs_points = 50))
@named pde_system = PDESystem(eq, bcs, domains, [x, y], [u(x, y)])
prob = discretize(pde_system, discretization)
callback = function (p, l)
println("Current loss is: $l")
return false
end
res = solve(prob, Adam(0.1); callback = callback, maxiters = 4000)
prob = remake(prob, u0 = res.original_sol.u)
sol = solve(prob, Adam(0.01); callback = callback, maxiters = 2000)
And some analysis:
xs = ys = 0:0.01:1
analytic_sol_func(x, y) = sinpi(x) * sinpi(y) / (2pi^2)
u_predict = sol(xs, ys; dv = u(x, y))
u_real = [analytic_sol_func(x, y) for x in xs, y in ys]
diff_u = abs.(u_predict .- u_real)
using Plots
p1 = plot(xs, ys, u_real', linetype = :contourf, title = "analytic");
p2 = plot(xs, ys, u_predict', linetype = :contourf, title = "predict");
p3 = plot(xs, ys, diff_u', linetype = :contourf, title = "error");
plot(p1, p2, p3)

If you use NeuralPDE.jl in your research, please cite this paper:
@article{zubov2021neuralpde,
title={NeuralPDE: Automating Physics-Informed Neural Networks (PINNs) with Error Approximations},
author={Zubov, Kirill and McCarthy, Zoe and Ma, Yingbo and Calisto, Francesco and Pagliarino, Valerio and Azeglio, Simone and Bottero, Luca and Luj{\'a}n, Emmanuel and Sulzer, Valentin and Bharambe, Ashutosh and others},
journal={arXiv preprint arXiv:2107.09443},
year={2021}
}
573 followers · starred Sep 2020
158 followers · starred Sep 2023
23 followers · starred May 2024
88 followers · starred Sep 2026
Physics-Informed Neural Networks (PINN) Solvers of (Partial) Differential Equations for Scientific Machine Learning (SciML) accelerated simulation
See the codeNeuralPDE.jl is a solver package which consists of neural network solvers for partial differential equations using physics-informed neural networks (PINNs). This package utilizes neural stochastic differential equations to solve PDEs at a greatly increased generality compared with classical methods.
Assuming that you already have Julia correctly installed, it suffices to install NeuralPDE.jl in the standard way, that is, by typing ] add NeuralPDE. Note:
to exit the Pkg REPL-mode, just press Backspace or Ctrl + C.
For information on using the package, see the stable documentation. Use the in-development documentation for the version of the documentation, which contains the unreleased features.
ModelingToolkit.System whose optimization problem is generated by the
standard ModelingToolkit compiler: weighted or constrained boundary conditions, quadrature and
quasi-random training strategies, and Reactant-compiled training loopsODEProblems with neural networksusing NeuralPDE, Lux, OptimizationOptimisers
using DomainSets: Interval
@parameters x y
@variables u(..)
Dxx = Differential(x)^2
Dyy = Differential(y)^2
# 2D PDE
eq = Dxx(u(x, y)) + Dyy(u(x, y)) ~ -sinpi(x) * sinpi(y)
# Boundary conditions
bcs = [
u(0, y) ~ 0.0, u(1, y) ~ 0,
u(x, 0) ~ 0.0, u(x, 1) ~ 0,
]
# Space and time domains
domains = [
x ∈ Interval(0.0, 1.0),
y ∈ Interval(0.0, 1.0),
]
# Neural network
dim = 2 # number of dimensions
chain = Chain(Dense(dim, 16, σ), Dense(16, 16, σ), Dense(16, 1))
discretization = PhysicsInformedNN(chain, QuasiRandomTraining(400; bcs_points = 50))
@named pde_system = PDESystem(eq, bcs, domains, [x, y], [u(x, y)])
prob = discretize(pde_system, discretization)
callback = function (p, l)
println("Current loss is: $l")
return false
end
res = solve(prob, Adam(0.1); callback = callback, maxiters = 4000)
prob = remake(prob, u0 = res.original_sol.u)
sol = solve(prob, Adam(0.01); callback = callback, maxiters = 2000)
And some analysis:
xs = ys = 0:0.01:1
analytic_sol_func(x, y) = sinpi(x) * sinpi(y) / (2pi^2)
u_predict = sol(xs, ys; dv = u(x, y))
u_real = [analytic_sol_func(x, y) for x in xs, y in ys]
diff_u = abs.(u_predict .- u_real)
using Plots
p1 = plot(xs, ys, u_real', linetype = :contourf, title = "analytic");
p2 = plot(xs, ys, u_predict', linetype = :contourf, title = "predict");
p3 = plot(xs, ys, diff_u', linetype = :contourf, title = "error");
plot(p1, p2, p3)

If you use NeuralPDE.jl in your research, please cite this paper:
@article{zubov2021neuralpde,
title={NeuralPDE: Automating Physics-Informed Neural Networks (PINNs) with Error Approximations},
author={Zubov, Kirill and McCarthy, Zoe and Ma, Yingbo and Calisto, Francesco and Pagliarino, Valerio and Azeglio, Simone and Bottero, Luca and Luj{\'a}n, Emmanuel and Sulzer, Valentin and Bharambe, Ashutosh and others},
journal={arXiv preprint arXiv:2107.09443},
year={2021}
}
573 followers · starred Sep 2020
158 followers · starred Sep 2023
23 followers · starred May 2024
88 followers · starred Sep 2026