NeuralPDE.jl icon indicating copy to clipboard operation
NeuralPDE.jl copied to clipboard

KeyError when solving Parameter Identification problem using NeuralPDE.jl

Open hippyhippohops opened this issue 3 months ago • 9 comments

Hi, I am getting the following error when trying to solve the inverse problem (learning \lambda) using NeuralPDE.jl: "KeyError: key λ not found" and it points towards the line @named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ]).My code is as follows:

using NeuralPDE, Lux, ModelingToolkit, Optimization, OptimizationOptimJL, LineSearches,  OptimizationOptimisers
import ModelingToolkit: Interval
using CSV
using DataFrames
using Plots
complex_scattered_field = CSV.read("/Users/aravinthkrishnan/Desktop/ComplexScatteredField.csv", DataFrame, header=false);
real_scattered_field = CSV.read("/Users/aravinthkrishnan/Desktop/RealScatteredField.csv", DataFrame, header=false); 
complex_scattered_field_matrix = Matrix(complex_scattered_field)
real_scattered_field_matrix = Matrix(real_scattered_field)
@parameters x,y, λ
@variables u(..)
Dxx = Differential(x)^2
Dyy = Differential(y)^2
frequency_of_wave = 8
#Equation
eq = Dxx(u(x, y)) + Dyy(u(x, y)) + (frequency_of_wave^2) * λ * u(x,y) ~ 0
# Boundary conditions
bcs = [u(0, y) ~ 0.0, u(1, y) ~ 0.0, u(x, 0) ~ 0.0, u(x, 1) ~ 0.0]
# Space and time domains
domains = [x ∈ Interval(0.0, 1.0), y ∈ Interval(0.0, 1.0)]
# Neural network
dim = 2 # number of dimensions
chain = Lux.Chain(Dense(dim, 3, Lux.σ), Dense(3, 2))
number_of_scattered_points = 50 #We will determine this
set_of_coordinates = []
# Discretization
dx = 0.05
discretization = PhysicsInformedNN(chain, QuadratureTraining(),param_estim = true)
@named pde_system = PDESystem(eq, bcs, domains, [x,y], [u(x,y)], [λ])
prob = discretize(pde_system, discretization)

hippyhippohops avatar Mar 10 '24 03:03 hippyhippohops