Hello everyone!
I am trying to include the convolution integral
\int_0^tKr(t -\tau)\dot x(\tau)d\tau
in my equation and I keep coming up with this error when trying to do NeuralPDE.discretize
ERROR: KeyError: key :tau not found
Below is a reduced version of my code.
using NeuralPDE, ModelingToolkit, Optimization, OptimizationOptimJL
using DomainSets
using Lux: Chain, Dense
K_func(t) = exp(-t)*cos(t)
@parameters t
@parameters tau
@variables x(..)
Dt = Differential(t)
DDt = Differential(t)^2
integral_tau = Integral(tau in DomainSets.ClosedInterval(0.0, t))
eq = DDt(x(t)) + integral_tau(K_func(t - tau) * Dt(x(tau))) + x(t) ~ 0
domains = [
t ∈ Interval(0.0, 60.0),
tau ∈ Interval(0.0, 60.0)
]
bcs = [
x(0.0) ~ 0.0,
Dt(x(0.0)) ~ 0.0,
]
chain = Chain([Dense(1, 4), Dense(4, 1)])
strategy = QuasiRandomTraining(10)
discretization = PhysicsInformedNN(chain, strategy)
@named pde_system = PDESystem(eq, bcs, domains, [t], [x])
prob = NeuralPDE.discretize(pde_system, discretization) # KeyError: key :tau not found
opt = Optim.LBFGS()
maxiters=1
res = Optimization.solve(prob, opt; maxiters)
This happens with julia v1.10.11 and the latest version right now, v1.12.6.
This is on NeuralPDE v6.0.0
I’ve tried both @parameters and @variables; I understand that @parameters for independent variables and @variables are for functions of variables. I’m not sure where tau would fall under the current implementation.
I got a version running when I include tau as one of the independent variables, but that required also rewriting every instance of x(t) to also include tau “x(t, tau)”.
There was a somewhat similar issue a few years ago (I couldn’t find how to do the linked topic sorry, https://discourse.julialang_org/t/way-to-write-the-integral-with-modelingtoolkit/82347/5), so I am hoping that this is an error on my part.
Any help would be greatly appreciated, thanks in advance!