Create a out-of-place form for ODE over than 1 function

The tutorial of neuralPDE to solve the ODE system just has a simple function, and the optimizer just supports out-of-place form only. How could implement the ODE system with 2 or more functions? For example.

du[1] = cos(u[1] - u[2])
du[2] = sin(u[2] - u[1])

Furthermore, does NeuralPDE can solve the ODE system which transfer from DAEs system?

Just output an array:

function f(u,p,t)
  [cos(u[1] - u[2]),sin(u[2] - u[1])]
end

Not automatically. For now you’d have to use PDESystem, though doing something for DAEs is not out of the question.

I used the code following:

using NeuralPDE, Flux, OptimizationOptimisers

function f(u,p,t)
  [cos(u[1] - u[2]),sin(u[2] - u[1])]
end
tspan = (0.0f0, 1.0f0)
u0 = [0.0f0, 0.0f0]
prob = ODEProblem(f, u0, tspan)

chain = Flux.Chain(Dense(2, 10, sigmoid), Dense(10, 2))

opt = OptimizationOptimisers.Adam(0.1)

sol = solve(prob, NeuralPDE.NNODE(chain, opt), verbose=true, abstol=1f-6, maxiters=200)

However, I got the message:

DimensionMismatch: Dimensions of the initial u0 and chain should match.

Please help me with this error.

For the PDESystem, in all tutorials I saw that it requires the boundary conditions. How could I use it without boundary conditions? Because the system do not have the boundary.

should be chain = Flux.Chain(Dense(1, 10, sigmoid), Dense(10, 2)) since the number of independent variables is always 1 for an ODE. That should get a better error message.

For DAE, the boundary condition is the initial condition.

1 Like

Would you please provide me with some documents to create DAE on the PDE system?
Because I have one independent variable (a problem in 1 dimension) and 45 dependent variables, and I do not think the only way is to type all the variables but I can not find any instruction for that.
For example, I have 9 variables x and y variables y, I think the default method to implement is:

@parameters t
@variables x1(..) x2(..) x3(..) y1(..) y2(..) y(..)
Dx1 = Differential(t)
Dx2 = Differential(t)
Dx3 = Differential(t)

Thank you for your time and consideration.

No I’m suggesting just write down the equations. A DAE is a 1-dimensional PDE.