Runfa-Zhang / Sophon.jl

Neural networks and neural operators for physics-informed machine learning

Home Page:https://yichengdwu.github.io/Sophon.jl/dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sophon

Stable Dev Build Status Coverage DOI

Sophon.jl provides specialized neural networks and neural operators for Physics-informed machine learning.

Use the documentation to explore the features.

Please star this repo if you find it useful.

Installation

julia>] add Sophon

Example: 1D Multi-scale Poisson Equation

Simply replace primitive fully connected neural nets with those defined in this pacakge!

using ModelingToolkit, IntervalSets, Sophon
using Optimization, OptimizationOptimisers, OptimizationOptimJL
using CairoMakie

@parameters x
@variables u(..)
Dₓ² = Differential(x)^2

f(x) = -4 * π^2 * sin(2 * π * x) - 250 * π^2 * sin(50 * π * x)
eq = Dₓ²(u(x)) ~ f(x)
domain = [x  0 .. 1]
bcs = [u(0) ~ 0, u(1) ~ 0]

@named poisson = PDESystem(eq, bcs, domain, [x], [u(x)])

chain = Siren(1, 32, 32, 32, 32, 1)
pinn = PINN(chain)
sampler = QuasiRandomSampler(100, 1) 
strategy = NonAdaptiveTraining(1 , 50)

prob = Sophon.discretize(poisson, pinn, sampler, strategy)

res = Optimization.solve(prob, LBFGS(); maxiters=2000)

phi = pinn.phi
xs = 0:0.001:1
u_true = @. sin(2 * pi * xs) + 0.1 * sin(50 * pi * xs)
us = phi(xs', res.u)
fig = Figure()
axis = Axis(fig[1, 1])
lines!(xs, u_true; label="Ground Truth")
lines!(xs, vec(us); label="Prediction")
axislegend(axis)
display(fig)

possion

Related Libraries

About

Neural networks and neural operators for physics-informed machine learning

https://yichengdwu.github.io/Sophon.jl/dev/

License:MIT License


Languages

Language:Julia 100.0%