From b13f7c0c5bf2576ce87caa04282915582d279808 Mon Sep 17 00:00:00 2001 From: Sathvik Bhagavan Date: Tue, 12 Mar 2024 06:33:08 +0000 Subject: [PATCH] docs: update examples --- docs/src/examples/linear_parabolic.md | 8 ++++---- docs/src/examples/nonlinear_hyperbolic.md | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/src/examples/linear_parabolic.md b/docs/src/examples/linear_parabolic.md index 6a584d5f3e..2e7936f5c0 100644 --- a/docs/src/examples/linear_parabolic.md +++ b/docs/src/examples/linear_parabolic.md @@ -24,9 +24,9 @@ w(t, 1) = \frac{e^{\lambda_1} cos(\frac{x}{a})-e^{\lambda_2}cos(\frac{x}{a})}{\l with a physics-informed neural network. ```@example -using NeuralPDE, Lux, ModelingToolkit, Optimization, OptimizationOptimJL, LineSearches +using NeuralPDE, Lux, ModelingToolkit, Optimization, OptimizationOptimisers, OptimizationOptimJL, LineSearches using Plots -import ModelingToolkit: Interval, infimum, supremum +using ModelingToolkit: Interval, infimum, supremum @parameters t, x @variables u(..), w(..) @@ -71,7 +71,7 @@ input_ = length(domains) n = 15 chain = [Lux.Chain(Dense(input_, n, Lux.σ), Dense(n, n, Lux.σ), Dense(n, 1)) for _ in 1:2] -strategy = GridTraining(0.01) +strategy = StochasticTraining(500) discretization = PhysicsInformedNN(chain, strategy) @named pdesystem = PDESystem(eqs, bcs, domains, [t, x], [u(t, x), w(t, x)]) @@ -92,7 +92,7 @@ callback = function (p, l) return false end -res = Optimization.solve(prob, LBFGS(linesearch = BackTracking()); callback = callback, maxiters = 500) +res = Optimization.solve(prob, OptimizationOptimisers.Adam(1e-2); callback = callback, maxiters = 10000) phi = discretization.phi diff --git a/docs/src/examples/nonlinear_hyperbolic.md b/docs/src/examples/nonlinear_hyperbolic.md index 6ac3401dbb..6666912dd4 100644 --- a/docs/src/examples/nonlinear_hyperbolic.md +++ b/docs/src/examples/nonlinear_hyperbolic.md @@ -33,7 +33,7 @@ where k is a root of the algebraic (transcendental) equation f(k) = g(k), j0 and We solve this with Neural: ```@example -using NeuralPDE, Lux, ModelingToolkit, Optimization, OptimizationOptimJL, Roots +using NeuralPDE, Lux, ModelingToolkit, Optimization, OptimizationOptimJL, Roots, LineSearches using SpecialFunctions using Plots import ModelingToolkit: Interval, infimum, supremum @@ -99,7 +99,7 @@ callback = function (p, l) return false end -res = Optimization.solve(prob, BFGS(); callback = callback, maxiters = 1000) +res = Optimization.solve(prob, BFGS(linesearch = BackTracking()); callback = callback, maxiters = 200) phi = discretization.phi @@ -117,9 +117,5 @@ for i in 1:2 p2 = plot(ts, xs, u_predict[i], linetype = :contourf, title = "predict") p3 = plot(ts, xs, diff_u[i], linetype = :contourf, title = "error") plot(p1, p2, p3) - savefig("nonlinear_hyperbolic_sol_u$i") end ``` - -![nonlinear_hyperbolic_sol_u1](https://user-images.githubusercontent.com/26853713/126457614-d19e7a4d-f9e3-4e78-b8ae-1e58114a744e.png) -![nonlinear_hyperbolic_sol_u2](https://user-images.githubusercontent.com/26853713/126457617-ee26c587-a97f-4a2e-b6b7-b326b1f117af.png)