# Is it possible to solve pdes using neuralpde.jl that involve interpolated function

I am trying to solve a differential equation of the form dy(t)/dt = -y(t) f(t), but I do not know the function f(t). I generate f(t) by interpolating values from a data file. In that case, neuralpde.jl fails. Is it possible to convert an interpolating function to a symbolic function? Are there any other alternatives to solving such differential equations using neural networks?

It seems like that form could be solved with an integrating factor? Please forgive if math is shaky, it has been many many years since I took that class.

\begin{aligned} \frac{d y}{d t} + y f(t) &= 0 \\ E &= \exp\biggl(\int_{-\infty}^t f(w) dw \biggr) \\ E \frac{d y}{d t} + E y f(t) &= 0 \\ \frac{d}{dt}\bigl(y E \bigr) &= 0 \\ \therefore y &= C \exp\biggl(-\int_{-\infty}^t f(w) dw \biggr) \end{aligned}

Yes. I did not want to write the complicated pde I am trying to solve. Right now, I am solving the pde by discretizing it over the domain, and it is taking a long time. I was hoping that neural network-based methods would be helpful.

Using DataInterpolations.jl? That should work.

Why using Neural Networks? A traditional method will be a whole lot faster here.

I can get the interpolation to work, but neuralpde does not accept it.

The following code works:

## coll_t1p.jl
using DelimitedFiles
using DataInterpolations

cemit=LinearInterpolation(vec(cemit_fp[:,1]),vec(cemit_fp[:,2]))

println(size(vec(cemit_fp[:,1])))
println(typeof(vec(cemit_fp[:,1])))

println(size(vec(cemit_fp[:,2])))
println(typeof(vec(cemit_fp[:,2])))

println(cemit(20.0e0))


but when I try to solve the following differential equation, I get an error.

using NeuralPDE, Lux, ModelingToolkit, Optimization, OptimizationOptimisers
import ModelingToolkit: Interval, infimum, supremum
include("coll_t1.jl")

@parameters r cth
@variables u(..)
Dr = Differential(r)
Dcth = Differential(cth)
Icth = Integral(cth in DomainSets.OpenInterval(-1,1))

# 2D PDE
eq = cth * Dr(u(r,cth)) + ((1 - cth * cth) / r) * Dcth(u(r,cth)) ~ cemit(r) - d(r) * u(r,cth) + cd(r) * Icth(u(r,cth))



I am looking for a solution to this equation. The functions cemit, d and cd are interpolated from data files. The way I am solving the equation right now is by solving the time-dependent equation:

eq = Dt(u(t,r,ch)) + cth * Dr(u(t,r,cth)) + ((1 - cth * cth) / r) * Dcth(u(t,r,cth)) ~ cemit(r) - d(r) * u(t,r,cth) + cd(r) * Icth(u(t,r,cth))


by discretizing over r and cth and evolving over time using an odesolver. At long enough time, it reaches a steady state. I was thinking I could get the steady state directly using neuralpde.jl. I tried writing my own code using Flux.jl but I do not get the right results. The loss function does not decrease fast enough and the code is very slow because of the integral in the equation.

Did you try just using DifferenitalEquations.jl and SteadyStateProblem?

1 Like

Thanks a lot! I was not aware of that. Let me try it out and see whether it works in my case.