-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
add9ecf
commit 4b23584
Showing
1 changed file
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,61 @@ | ||
using Test | ||
using OrdinaryDiffEq, OptimizationOptimisers | ||
using Optimization, OptimizationOptimJL, OptimizationOptimisers | ||
using Lux | ||
using Statistics, Random | ||
using ModelingToolkit | ||
import ModelingToolkit: Interval, infimum, supremum | ||
using DomainSets | ||
using NeuralPDE | ||
|
||
|
||
@testset "Example du = cos(p * t)" begin | ||
#TODO | ||
end | ||
##example ODE | ||
@parameters t | ||
@variables u(..) | ||
# @parameters p #[bounds = (0.1f0, pi)] | ||
Dt = Differential(t) | ||
eq = [Dt(u(t)) ~ cos(t)] | ||
bc = [u(0) ~ 1.0f0] | ||
|
||
dom = [x ∈ Interval(0.0, 1.0)] | ||
# neural_operator = SomeNeuralOperator(some_args) | ||
neural_operator = Lux.Chain( | ||
Lux.Dense(1, 10, Lux.tanh), | ||
Lux.Dense(10, 10, Lux.tanh), | ||
Lux.Dense(10, 1)) | ||
|
||
# pino = PhysicsInformedNO(neural_operator, sometrainig) | ||
pino = NeuralPDE.PhysicsInformedNN(neural_operator, NeuralPDE.GridTraining(0.1)) | ||
|
||
@named pde_system = PDESystem(eq, bc, dom, [t], [u(t)]) #[p]; defaults = Dict([p => 1.0 for p in [p]])) | ||
|
||
# hasbounds(pde_system.ps[1]) | ||
# getbounds(pde_system.ps[1]) | ||
|
||
prob = discretize(pde_system, pino) | ||
sym_prob = symbolic_discretize(pde_system, pino) | ||
|
||
res = Optimization.solve(prob, ADAM(0.1); maxiters = 4000) | ||
phi = discretization.phi | ||
|
||
|
||
@parameters x | ||
@parameters p [bounds = (0.1f0, pi)] | ||
@variables u(..) | ||
Dx = Differential(x) | ||
|
||
eq = Dx(u(x)) ~ cos(p * x) | ||
bcs = [u(0.0) ~ 0.0] | ||
|
||
domains = [x ∈ Interval(0.0, 1.0)] | ||
|
||
chain = [Lux.Chain(Lux.Dense(1, 12, Lux.tanh), Lux.Dense(12, 12, Lux.tanh), Lux.Dense(12, 1)) ] | ||
|
||
strategy = NeuralPDE.GridTraining(0.1) | ||
discretization = NeuralPDE.PhysicsInformedNN(chain, strategy) | ||
|
||
@named pde_system = PDESystem(eq, bcs, domains, [x], [u(x)],[p]; defaults = Dict([p => 1.0 for p in [p]])) | ||
hasbounds(pde_system.ps[1]) | ||
getbounds(pde_system.ps[1]) | ||
|
||
prob = discretize(pde_system, discretization) | ||
sym_prob = symbolic_discretize(pde_system, discretization) |