Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Flux = "0.14.22, 0.15, 0.16"
ForwardDiff = "0.10.36, 1"
Functors = "0.4.12, 0.5"
Hwloc = "3.3.0"
Integrals = "4.5"
Integrals = "4.5 - 4.6, 4.9.1"
InteractiveUtils = "<0.0.1, 1"
IntervalSets = "0.7.10"
LineSearches = "7.3"
Expand All @@ -90,9 +90,9 @@ ModelingToolkit = "9.46, 10"
MonteCarloMeasurements = "1.1"
NeuralOperators = "0.5, 0.6"
Optimisers = "0.3.3, 0.4"
Optimization = "4, 5"
Optimization = "5.1"
OptimizationOptimJL = "0.4"
OptimizationOptimisers = "0.3"
OptimizationOptimisers = "0.3.14"
OrdinaryDiffEq = "6.87"
Printf = "1.10"
QuasiMonteCarlo = "0.3.2"
Expand All @@ -110,7 +110,7 @@ Symbolics = "6.14"
TensorBoardLogger = "0.1.24"
Test = "1.10"
WeightInitializers = "1.0.3"
Zygote = "0.6.71, 0.7"
Zygote = "0.6.71, 0.7.0 - 0.7.9"
julia = "1.10"

[extras]
Expand Down
5 changes: 3 additions & 2 deletions test/NNODE_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ end
end

@testitem "ODE Complex Numbers" tags = [:nnode] begin
using OrdinaryDiffEq, Random, Lux, Optimisers
using OrdinaryDiffEq, Random, Lux, Optimisers, Integrals

Random.seed!(100)

Expand Down Expand Up @@ -338,7 +338,8 @@ end
@test sol.u ≈ ground_truth.u rtol = 1.0e-1
end

alg = NNODE(chain, Adam(0.01); strategy = QuadratureTraining())
# Use HCubatureJL explicitly to avoid Julia base bug with @cfunction
alg = NNODE(chain, Adam(0.01); strategy = QuadratureTraining(quadrature_alg = HCubatureJL()))
@test_throws ErrorException solve(
problem, alg; verbose = false, maxiters = 5000, saveat = 0.01
)
Expand Down
39 changes: 25 additions & 14 deletions test/NNPDE_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@testsetup module NNPDE1TestSetup

using NeuralPDE, Cubature, Integrals, QuasiMonteCarlo
using NeuralPDE, Integrals, QuasiMonteCarlo

# DataGen is Real: https://github.com/SciML/NeuralPDE.jl/issues/906
@parameters x
Expand All @@ -18,8 +18,10 @@ function callback(p, l)
end

grid_strategy = GridTraining(0.1)
# Use HCubatureJL (pure Julia) instead of CubatureJLh to avoid Julia base bug
# with @cfunction type parameters (spvals typo in base/meta.jl partially_inline!)
quadrature_strategy = QuadratureTraining(
quadrature_alg = CubatureJLh(),
quadrature_alg = HCubatureJL(),
reltol = 1.0e3, abstol = 1.0e-3, maxiters = 50, batch = 100
)
stochastic_strategy = StochasticTraining(100; bcs_points = 50)
Expand All @@ -45,7 +47,7 @@ export callback, strategies
end

@testitem "Test Heterogeneous ODE" tags = [:nnpde1] setup = [NNPDE1TestSetup] begin
using Cubature, Integrals, QuasiMonteCarlo, DomainSets, Lux, Random, Optimisers
using Integrals, QuasiMonteCarlo, DomainSets, Lux, Random, Optimisers

function simple_1d_ode(strategy)
@parameters θ
Expand Down Expand Up @@ -118,8 +120,10 @@ end
]

grid_strategy = GridTraining(0.1)
# Note: quadrature_strategy defined but not used in this test
# Using HCubatureJL instead of CubatureJLh to avoid Julia base bug
quadrature_strategy = QuadratureTraining(
quadrature_alg = CubatureJLh(),
quadrature_alg = HCubatureJL(),
reltol = 1.0e-3, abstol = 1.0e-3, maxiters = 50, batch = 100
)

Expand Down Expand Up @@ -168,7 +172,7 @@ end
end

@testitem "PDE II: 2D Poisson" tags = [:nnpde1] setup = [NNPDE1TestSetup] begin
using Lux, Random, Optimisers, DomainSets, Cubature, QuasiMonteCarlo, Integrals
using Lux, Random, Optimisers, DomainSets, QuasiMonteCarlo, Integrals
import DomainSets: Interval, infimum, supremum

function test_2d_poisson_equation(chain, strategy)
Expand Down Expand Up @@ -214,7 +218,9 @@ end
test_2d_poisson_equation(chain, strategy)
end

algs = [CubatureJLp()]
# Use HCubatureJL instead of CubatureJLp to avoid Julia base bug
# with @cfunction type parameters (spvals typo in base/meta.jl)
algs = [HCubatureJL()]
@testset "$(nameof(typeof(alg)))" for alg in algs
strategy = QuadratureTraining(
quadrature_alg = alg, reltol = 1.0e-4,
Expand All @@ -225,7 +231,7 @@ end
end

@testitem "PDE III: 3rd-order ODE" tags = [:nnpde1] setup = [NNPDE1TestSetup] begin
using Lux, Random, Optimisers, DomainSets, Cubature, QuasiMonteCarlo, Integrals
using Lux, Random, Optimisers, DomainSets, QuasiMonteCarlo, Integrals
import DomainSets: Interval, infimum, supremum
import OptimizationOptimJL: BFGS

Expand Down Expand Up @@ -297,7 +303,7 @@ end
end

@testitem "PDE IV: System of PDEs" tags = [:nnpde1] setup = [NNPDE1TestSetup] begin
using Lux, Random, Optimisers, DomainSets, Cubature, QuasiMonteCarlo, Integrals
using Lux, Random, Optimisers, DomainSets, QuasiMonteCarlo, Integrals
import DomainSets: Interval, infimum, supremum

@parameters x, y
Expand All @@ -324,8 +330,10 @@ end
chain1 = Chain(Dense(2, 15, tanh), Dense(15, 1))
chain2 = Chain(Dense(2, 15, tanh), Dense(15, 1))

# Use HCubatureJL instead of CubatureJLh to avoid Julia base bug
# with @cfunction type parameters (spvals typo in base/meta.jl)
quadrature_strategy = QuadratureTraining(
quadrature_alg = CubatureJLh(),
quadrature_alg = HCubatureJL(),
reltol = 1.0e-3, abstol = 1.0e-3, maxiters = 50, batch = 100
)
chain = [chain1, chain2]
Expand Down Expand Up @@ -354,7 +362,7 @@ end
end

@testitem "PDE V: 2D Wave Equation" tags = [:nnpde1] setup = [NNPDE1TestSetup] begin
using Lux, Random, Optimisers, DomainSets, Cubature, QuasiMonteCarlo, Integrals,
using Lux, Random, Optimisers, DomainSets, QuasiMonteCarlo, Integrals,
LineSearches, Integrals
import DomainSets: Interval, infimum, supremum
import OptimizationOptimJL: BFGS
Expand Down Expand Up @@ -389,8 +397,10 @@ end
phi = NeuralPDE.Phi(chain)
derivative = NeuralPDE.numeric_derivative

# Use HCubatureJL instead of CubatureJLh to avoid Julia base bug
# with @cfunction type parameters (spvals typo in base/meta.jl)
quadrature_strategy = QuadratureTraining(
quadrature_alg = CubatureJLh(),
quadrature_alg = HCubatureJL(),
reltol = 1.0e-3, abstol = 1.0e-3, maxiters = 50, batch = 100
)

Expand Down Expand Up @@ -423,7 +433,7 @@ end
end

@testitem "PDE VI: PDE with mixed derivative" tags = [:nnpde1] setup = [NNPDE1TestSetup] begin
using Lux, Random, Optimisers, DomainSets, Cubature, QuasiMonteCarlo, Integrals
using Lux, Random, Optimisers, DomainSets, QuasiMonteCarlo, Integrals
import DomainSets: Interval, infimum, supremum
using OptimizationOptimJL: BFGS
using LineSearches: BackTracking
Expand Down Expand Up @@ -467,7 +477,7 @@ end
end

@testitem "NNPDE: Translating from Flux" tags = [:nnpde1] setup = [NNPDE1TestSetup] begin
using Lux, Random, Optimisers, DomainSets, Cubature, QuasiMonteCarlo, Integrals
using Lux, Random, Optimisers, DomainSets, QuasiMonteCarlo, Integrals
import DomainSets: Interval, infimum, supremum
import OptimizationOptimJL: BFGS
import Flux
Expand All @@ -481,7 +491,8 @@ end
domains = [θ ∈ Interval(0.0, 1.0)]

chain = Flux.Chain(Flux.Dense(1, 12, Flux.σ), Flux.Dense(12, 1))
discretization = PhysicsInformedNN(chain, QuadratureTraining())
# Use HCubatureJL explicitly to avoid Julia base bug with @cfunction
discretization = PhysicsInformedNN(chain, QuadratureTraining(quadrature_alg = HCubatureJL()))
@test discretization.chain isa Lux.AbstractLuxLayer

@named pde_system = PDESystem(eq, bcs, domains, [θ], [u])
Expand Down
5 changes: 3 additions & 2 deletions test/direct_function_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ end
end

@testitem "Empty boundary condition [] fails in solve phase" begin
using NeuralPDE, Optimization, OptimizationOptimisers, Lux
using NeuralPDE, Optimization, OptimizationOptimisers, Lux, Integrals
@parameters x
@variables u(..)

Expand All @@ -151,7 +151,8 @@ end
GridTraining(0.01),
StochasticTraining(1000),
QuasiRandomTraining(1000),
QuadratureTraining(),
# Use HCubatureJL explicitly to avoid Julia base bug with @cfunction
QuadratureTraining(quadrature_alg = HCubatureJL()),
)
discretization = PhysicsInformedNN(chain, strategy)
@named pde_system = PDESystem(eq, bc, domain, [x], [u(x)])
Expand Down
6 changes: 5 additions & 1 deletion test/neural_adapter_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ end

@testitem "Neural Adapter: 2D Poisson" tags = [:neuraladapter] setup = [NeuralAdapterTestSetup] begin
using Optimization, Lux, OptimizationOptimisers, Statistics, ComponentArrays, Random,
LinearAlgebra
LinearAlgebra, Integrals
import DomainSets: Interval, infimum, supremum

Random.seed!(100)
Expand All @@ -34,7 +34,9 @@ end
]
# Space and time domains
domains = [x ∈ Interval(0.0, 1.0), y ∈ Interval(0.0, 1.0)]
# Use HCubatureJL explicitly to avoid Julia base bug with @cfunction
quadrature_strategy = QuadratureTraining(
quadrature_alg = HCubatureJL(),
reltol = 1.0e-3, abstol = 1.0e-6, maxiters = 50, batch = 100
)
chain1 = Chain(Dense(2, 8, tanh), Dense(8, 8, tanh), Dense(8, 1))
Expand All @@ -60,7 +62,9 @@ end
loss(cord, θ) = first(chain2(cord, θ, st)) .- phi(cord, res.u)

grid_strategy = GridTraining(0.05)
# Use HCubatureJL explicitly to avoid Julia base bug with @cfunction
quadrature_strategy = QuadratureTraining(
quadrature_alg = HCubatureJL(),
reltol = 1.0e-3, abstol = 1.0e-6, maxiters = 50, batch = 100
)
stochastic_strategy = StochasticTraining(1000)
Expand Down
Loading