Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Physics informed neural operator ode #806

Merged
merged 160 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 157 commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
9988925
pino_ode_draft
KirillZubov Feb 12, 2024
5fc72b9
pino ode prot
KirillZubov Feb 13, 2024
25e4764
add physics loss function
KirillZubov Feb 13, 2024
5888e12
add doc draft
KirillZubov Feb 13, 2024
b6ae2b4
add test mapping inital condition u0 -> solution u(t){u0}
KirillZubov Feb 15, 2024
ad0902a
support train family ode by initial conditions
KirillZubov Feb 16, 2024
c7b10f8
generate prob set
KirillZubov Feb 28, 2024
911ec4e
ode system
KirillZubov Feb 29, 2024
a4ff413
support Fourier Neural Operator
KirillZubov Mar 1, 2024
cbf01af
update
KirillZubov Mar 5, 2024
db50090
clear up code
KirillZubov Mar 6, 2024
a08af21
Merge branch 'master' into pino_ode
KirillZubov Mar 6, 2024
60cda53
update tests
KirillZubov Mar 7, 2024
5781cb5
gpu
KirillZubov Mar 8, 2024
b562ebe
fix spelling
KirillZubov Mar 8, 2024
eb2e9c1
add PINOsolution
KirillZubov Mar 15, 2024
ca2b802
add NeuralOperator deps
KirillZubov Mar 15, 2024
96057a3
Merge branch 'master' into pino_ode
KirillZubov Mar 15, 2024
5b8d226
update Project.toml
KirillZubov Mar 18, 2024
c711b0d
update Project.toml
KirillZubov Mar 18, 2024
2ad84ac
update Project.toml
KirillZubov Mar 18, 2024
a71c469
update
KirillZubov Mar 18, 2024
fb73003
update
KirillZubov Mar 18, 2024
6c524ab
update
KirillZubov Mar 18, 2024
2addf6c
update gpu test
KirillZubov Mar 18, 2024
c058f5e
updste version Statistics
KirillZubov Mar 18, 2024
48c762b
add docs
KirillZubov Mar 19, 2024
671cedc
fix
KirillZubov Mar 19, 2024
fe8a819
fix
KirillZubov Mar 19, 2024
2c87492
fix TRAINSET
KirillZubov Mar 19, 2024
3905b14
fix typo
KirillZubov Mar 19, 2024
652fb72
add dep NeuralOperators
KirillZubov Mar 19, 2024
f74a46f
fix test
KirillZubov Mar 19, 2024
c163e28
fix gpu test
KirillZubov Mar 19, 2024
b52c4c2
fix tests
KirillZubov Mar 19, 2024
b829265
remove dep NeuralOperator
KirillZubov Mar 20, 2024
9870858
update tests
KirillZubov Mar 20, 2024
c5e7348
fix
KirillZubov Mar 20, 2024
cefb901
fix
KirillZubov Mar 20, 2024
10169cb
fix
KirillZubov Mar 20, 2024
2f2be69
fine tuning
KirillZubov Mar 21, 2024
c38a78f
fine tunnning update
KirillZubov Mar 22, 2024
1e38676
fix
KirillZubov Mar 22, 2024
8a98880
Merge branch 'master' into pino_ode
KirillZubov Apr 8, 2024
2cc1d1f
implement DeepONet, refactor pinoode
KirillZubov Apr 25, 2024
f873541
pure PINO with DeepOnet
KirillZubov May 2, 2024
0b4de35
support case right side eq depends on 'u'
KirillZubov May 6, 2024
68e38d5
example with data loss
KirillZubov May 6, 2024
345040b
support GridTraining
KirillZubov May 8, 2024
60005c8
update doc
KirillZubov May 8, 2024
fbef5c7
PINOPhi immutable
KirillZubov Jun 12, 2024
0fb7d23
Update src/pino_ode_solve.jl
KirillZubov Jun 12, 2024
b6639ea
Update src/pino_ode_solve.jl
KirillZubov Jun 12, 2024
cc1fada
remove SomeStrategy
KirillZubov Jun 12, 2024
bb0863b
rename operator_loss to inital_condition_loss
KirillZubov Jun 12, 2024
ea7c638
mutable PINOPhi
KirillZubov Jun 14, 2024
09f4891
support u0 is param
KirillZubov Jun 14, 2024
188ceec
update
KirillZubov Jun 17, 2024
eb005c6
update multiple parameters task
KirillZubov Jun 18, 2024
d754e30
add ParametricFunction
KirillZubov Jun 19, 2024
214b178
vector outputs and multiple parameters
KirillZubov Jun 20, 2024
7d81063
clear code, rm ParametricFunction
KirillZubov Jun 21, 2024
f5e2b06
begin migrate LuxNeuralOperators and add QuasiRandomTraining
KirillZubov Jun 21, 2024
30a5134
migrate to LuxNeuralOperators.DeepOnet
KirillZubov Jun 25, 2024
2818f34
add StochasticTraining
KirillZubov Jun 26, 2024
8895693
add interpolation
KirillZubov Jun 27, 2024
06ce517
update doc
KirillZubov Jun 27, 2024
7953468
output vector
KirillZubov Jul 1, 2024
f6f0405
Update docs/src/manual/pino_ode.md
KirillZubov Jul 2, 2024
e16b168
Update docs/src/tutorials/pino_ode.md
KirillZubov Jul 2, 2024
596a80a
Update docs/src/tutorials/pino_ode.md
KirillZubov Jul 2, 2024
445dfd0
Update docs/src/tutorials/pino_ode.md
KirillZubov Jul 2, 2024
d7b7a36
Update docs/src/tutorials/pino_ode.md
KirillZubov Jul 2, 2024
fe40cfd
Update docs/src/tutorials/pino_ode.md
KirillZubov Jul 2, 2024
e45011e
Update docs/src/tutorials/pino_ode.md
KirillZubov Jul 2, 2024
7fe3244
Update test/runtests.jl
KirillZubov Jul 2, 2024
839e1d5
revert "vector output"
KirillZubov Jul 2, 2024
53a52f8
fix
KirillZubov Jul 2, 2024
a39bb69
Add Unregistered LuxNeuralOperators
KirillZubov Jul 2, 2024
2983c18
CI.yml fix
KirillZubov Jul 2, 2024
885aa29
revert Add Unregistered LuxNeuralOperators
KirillZubov Jul 2, 2024
38a872e
fix
KirillZubov Jul 2, 2024
28447b6
add unregistered LuxNeuralOperators attempt 2
KirillZubov Jul 2, 2024
1292900
undo "add unregistered LuxNeuralOperators attempt 2"
KirillZubov Jul 2, 2024
10e08c2
FNO first shot
KirillZubov Jul 12, 2024
61fa804
fix
KirillZubov Jul 12, 2024
99e8e2d
Update docs/src/tutorials/pino_ode.md
KirillZubov Jul 17, 2024
c01c0ad
Update .github/workflows/CI.yml
KirillZubov Jul 17, 2024
1a8fd17
Update src/NeuralPDE.jl
KirillZubov Jul 17, 2024
c5bf9ca
Update Project.toml
KirillZubov Jul 17, 2024
c5d2501
Update docs/src/tutorials/pino_ode.md
KirillZubov Jul 17, 2024
fc38b50
Update docs/src/tutorials/pino_ode.md
KirillZubov Jul 17, 2024
09e5555
Update src/pino_ode_solve.jl
KirillZubov Jul 17, 2024
8ae7b0f
Update src/pino_ode_solve.jl
KirillZubov Jul 17, 2024
15e6124
vector output
KirillZubov Jul 22, 2024
efd2a40
wip FourierNeuralOperator
KirillZubov Jul 23, 2024
89fc2d9
update
KirillZubov Aug 14, 2024
5ab8a6a
update
KirillZubov Aug 16, 2024
433e529
update
KirillZubov Aug 20, 2024
c54d62f
update
KirillZubov Aug 26, 2024
d99062d
update
KirillZubov Aug 27, 2024
0bc28da
remove all unnecessary
KirillZubov Aug 29, 2024
2b45d10
update
KirillZubov Aug 30, 2024
d5b9d6d
update
KirillZubov Aug 30, 2024
7059e37
Merge branch 'master' into pino_ode
KirillZubov Aug 30, 2024
c4092b5
imutable
KirillZubov Aug 30, 2024
3ae25ce
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 2, 2024
908ca8a
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 2, 2024
13f955b
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 2, 2024
3813b1b
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 2, 2024
5be5db1
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 2, 2024
d0665ec
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 2, 2024
5295ceb
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 2, 2024
cc67c31
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 2, 2024
cf5221c
Update test/runtests.jl
KirillZubov Sep 2, 2024
a3dbfc6
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 2, 2024
0cdd8dc
Update src/pino_ode_solve.jl
KirillZubov Sep 5, 2024
bc32c45
Update src/pino_ode_solve.jl
KirillZubov Sep 5, 2024
6c49dd8
Update src/pino_ode_solve.jl
KirillZubov Sep 5, 2024
ff04565
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 5, 2024
2366840
Update docs/src/tutorials/pino_ode.md
KirillZubov Sep 5, 2024
b1209ab
lux v1.0
KirillZubov Sep 19, 2024
9fa2162
Merge branch 'master' into pino_ode
KirillZubov Sep 24, 2024
86677d0
Update Project.toml
KirillZubov Sep 24, 2024
6813c5d
lux 1
KirillZubov Sep 24, 2024
786035f
support Chain
KirillZubov Sep 24, 2024
5428b01
Update test/PINO_ode_tests.jl
KirillZubov Sep 24, 2024
60c3995
vector input Chain
KirillZubov Sep 25, 2024
90dfdb0
Update test/PINO_ode_tests.jl
KirillZubov Sep 27, 2024
2d7be46
Update test/PINO_ode_tests.jl
KirillZubov Sep 27, 2024
e342a7d
Update test/PINO_ode_tests.jl
KirillZubov Sep 27, 2024
000d8b5
input vector chain
KirillZubov Sep 28, 2024
5e9a025
support chain with StochasticTraining
KirillZubov Oct 1, 2024
e0cb528
NeuralOperators v0.5.0 in project
KirillZubov Oct 1, 2024
f1b3a36
wip output vector
KirillZubov Oct 2, 2024
ca24323
output vector
KirillZubov Oct 3, 2024
f74cf63
update Project.toml
KirillZubov Oct 3, 2024
885a72e
update
KirillZubov Oct 4, 2024
3baa5a6
update Project.toml
KirillZubov Oct 9, 2024
de008b3
undo
KirillZubov Oct 9, 2024
356083b
update runtests.jl
KirillZubov Oct 10, 2024
f59f225
update NeuralPDE
KirillZubov Oct 10, 2024
526fd0c
update Doc
KirillZubov Oct 10, 2024
d3ae594
update
KirillZubov Oct 10, 2024
1925aaf
Merge branch 'master' into pino_ode
KirillZubov Oct 17, 2024
6dd9e38
update
KirillZubov Oct 17, 2024
6748feb
update
KirillZubov Oct 17, 2024
2967a4a
Merge branch 'master' into pino_ode
KirillZubov Oct 18, 2024
36226f9
update
KirillZubov Oct 18, 2024
22f5144
PINOODETestSetup
KirillZubov Oct 18, 2024
18e45d2
update
KirillZubov Oct 18, 2024
aef24e3
update
KirillZubov Oct 18, 2024
501496e
update Project.toml docs
KirillZubov Oct 28, 2024
e8ac7f5
add sol(t)
KirillZubov Oct 28, 2024
11c67da
sol(t)
KirillZubov Oct 28, 2024
35d8346
update
KirillZubov Oct 29, 2024
c5a456a
Interpolation
KirillZubov Oct 29, 2024
b6609f9
fix
KirillZubov Oct 29, 2024
0617f42
update PINOODEInterpolation
KirillZubov Oct 30, 2024
9c857a5
update
KirillZubov Oct 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- "Forward"
- "DGM"
- "NNODE"
- "PINOODE"
- "NeuralAdapter"
- "IntegroDiff"
uses: "SciML/.github/.github/workflows/tests.yml@v1"
Expand Down
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
MLDataDevices = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
NeuralOperators = "ea5c82af-86e5-48da-8ee1-382d6ad7af4b"
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1"
Expand Down Expand Up @@ -79,12 +80,13 @@ LogDensityProblems = "2"
Lux = "1.1.0"
LuxCUDA = "0.3.3"
LuxCore = "1.0.1"
LuxLib = "1.3.2"
LuxLib = "1.3"
MCMCChains = "6"
MLDataDevices = "1.2.0"
MethodOfLines = "0.11.6"
ModelingToolkit = "9.46"
MonteCarloMeasurements = "1.1"
NeuralOperators = "0.5"
Optimisers = "0.3.3"
Optimization = "4"
OptimizationOptimJL = "0.4"
Expand Down
4 changes: 3 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ MethodOfLines = "94925ecb-adb7-4558-8ed8-f975c56a0bf4"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
NeuralPDE = "315f7962-48a3-4962-8226-d0f33b1235f0"
NeuralOperators = "ea5c82af-86e5-48da-8ee1-382d6ad7af4b"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
OptimizationOptimisers = "42dfb2eb-d2b4-4451-abcd-913932933ac1"
Expand Down Expand Up @@ -44,6 +45,7 @@ MethodOfLines = "0.11"
ModelingToolkit = "9.7"
MonteCarloMeasurements = "1"
NeuralPDE = "5"
NeuralOperators = "0.5"
Optimization = "4"
OptimizationOptimJL = "0.4"
OptimizationOptimisers = "0.3"
Expand All @@ -53,4 +55,4 @@ Plots = "1.36"
QuasiMonteCarlo = "0.3.2"
Random = "1"
Roots = "2.0"
SpecialFunctions = "2.1"
SpecialFunctions = "2.1"
4 changes: 3 additions & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pages = ["index.md",
"Bayesian PINNs for Coupled ODEs" => "tutorials/Lotka_Volterra_BPINNs.md",
"PINNs DAEs" => "tutorials/dae.md",
"Parameter Estimation with PINNs for ODEs" => "tutorials/ode_parameter_estimation.md",
"Physics informed Neural Operator ODEs" => "tutorials/pino_ode.md",
"Deep Galerkin Method" => "tutorials/dgm.md" #"examples/nnrode_example.md", # currently incorrect
],
"PDE PINN Tutorials" => Any[
Expand Down Expand Up @@ -31,6 +32,7 @@ pages = ["index.md",
"manual/training_strategies.md",
"manual/adaptive_losses.md",
"manual/logging.md",
"manual/neural_adapters.md"],
"manual/neural_adapters.md",
"manual/pino_ode.md"],
"Developer Documentation" => Any["developer/debugging.md"]
]
5 changes: 5 additions & 0 deletions docs/src/manual/pino_ode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Physics-Informed Neural Operator (PINO) for ODEs

```@docs
PINOODE
```
99 changes: 99 additions & 0 deletions docs/src/tutorials/pino_ode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Physics Informed Neural Operator for ODEs

This tutorial provides an example of how to use the Physics Informed Neural Operator (PINO) for solving a family of parametric ordinary differential equations (ODEs).

## Operator Learning for a family of parametric ODEs

In this section, we will define a parametric ODE and then learn it with a PINO using [`PINOODE`](@ref). The PINO will be trained to learn the mapping from the parameters of the ODE to its solution.

```@example pino
using Test
KirillZubov marked this conversation as resolved.
Show resolved Hide resolved
using OptimizationOptimisers
using Lux
using Statistics, Random
using NeuralOperators
using NeuralPDE

# Define the parametric ODE equation
equation = (u, p, t) -> p[1] * cos(p[2] * t) + p[3]
tspan = (0.0, 1.0)
u0 = 1.0
prob = ODEProblem(equation, u0, tspan)

# Set the number of parameters for the ODE
number_of_parameter = 3
# Define the DeepONet architecture for the PINO
deeponet = NeuralOperators.DeepONet(
Chain(
Dense(number_of_parameter => 10, Lux.tanh_fast), Dense(10 => 10, Lux.tanh_fast), Dense(10 => 10)),
Chain(Dense(1 => 10, Lux.tanh_fast), Dense(10 => 10, Lux.tanh_fast),
Dense(10 => 10, Lux.tanh_fast)))

# Define the bounds for the parameters
bounds = [(1.0, pi), (1.0, 2.0), (2.0, 3.0)]
number_of_parameter_samples = 50
# Define the training strategy
strategy = StochasticTraining(20)
# Define the optimizer
opt = OptimizationOptimisers.Adam(0.03)
alg = PINOODE(deeponet, opt, bounds, number_of_parameters; strategy = strategy)
# Solve the ODE problem using the PINOODE algorithm
sol = solve(prob, alg, verbose = false, maxiters = 4000)
```

Now let's compare the prediction from the learned operator with the ground truth solution which is obtained by analytic solution of the parametric ODE.

```@example pino
using Plots
KirillZubov marked this conversation as resolved.
Show resolved Hide resolved

function get_trainset(bounds, tspan, number_of_parameters, dt)
p_ = [range(start = b[1], length = number_of_parameters, stop = b[2]) for b in bounds]
p = vcat([collect(reshape(p_i, 1, size(p_i, 1))) for p_i in p_]...)
t_ = collect(tspan[1]:dt:tspan[2])
t = collect(reshape(t_, 1, size(t_, 1), 1))
(p, t)
end

# Compute the ground truth solution for each parameter
ground_solution = (u0, p, t) -> u0 + p[1] / p[2] * sin(p[2] * t) + p[3] * t
function ground_solution_f(p, t)
reduce(hcat,
[[ground_solution(u0, p[:, i], t[j]) for j in axes(t, 2)] for i in axes(p, 2)])
end

# generate the solution with new parameters for test the model
(p, t) = get_trainset(bounds, tspan, 50, 0.025)
# compute the ground truth solution
ground_solution_ = ground_solution_f(p, t)
# predict the solution with the PINO model
predict = sol.interp((p, t))

# calculate the errors between the ground truth solution and the predicted solution
errors = ground_solution_ - predict
# calculate the mean error and the standard deviation of the errors
mean_error = mean(errors)
# calculate the standard deviation of the errors
std_error = std(errors)

p, t = get_trainset(bounds, tspan, 100, 0.01)
ground_solution_ = ground_solution_f(p, t)
predict = sol.interp((p, t))

errors = ground_solution_ - predict
mean_error = mean(errors)
std_error = std(errors)

# Plot the predicted solution and the ground truth solution as a filled contour plot
# predict, represents the predicted solution for each parameter value and time
plot(predict, linetype = :contourf)
plot!(ground_solution_, linetype = :contourf)
```

```@example pino
# 'i' is the index of the parameter 'p' in the dataset
i = 20
# 'predict' is the predicted solution from the PINO model
plot(predict[:, i], label = "Predicted")
# 'ground' is the ground truth solution
plot!(ground_solution_[:, i], label = "Ground truth")
```
4 changes: 3 additions & 1 deletion src/NeuralPDE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ using IntervalSets: infimum, supremum
using LinearAlgebra: Diagonal
using Lux: Lux, Chain, Dense, SkipConnection, StatefulLuxLayer
using Lux: FromFluxAdaptor, recursive_eltype
using NeuralOperators: DeepONet
using LuxCore: LuxCore, AbstractLuxLayer, AbstractLuxWrapperLayer
using MLDataDevices: CPUDevice, get_device
using Optimisers: Optimisers, Adam
Expand Down Expand Up @@ -79,7 +80,7 @@ include("adaptive_losses.jl")

include("ode_solve.jl")
include("dae_solve.jl")

include("pino_ode_solve.jl")
include("transform_inf_integral.jl")
include("discretize.jl")

Expand All @@ -90,6 +91,7 @@ include("PDE_BPINN.jl")

include("dgm.jl")

export PINOODE
export NNODE, NNDAE
export BNNODE, ahmc_bayesian_pinn_ode, ahmc_bayesian_pinn_pde
export PhysicsInformedNN, discretize
Expand Down
Loading
Loading