Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixed differentials #137

Closed
marcofrancis opened this issue Jul 19, 2022 · 5 comments
Closed

Mixed differentials #137

marcofrancis opened this issue Jul 19, 2022 · 5 comments

Comments

@marcofrancis
Copy link

Do I understand correctly that right now it's not possible to use second order mixed derivatives when defining the equation to solve but one has to introduce an auxiliary variable?

If I modify slightly the Brusselator example as this:

using ModelingToolkit, MethodOfLines, OrdinaryDiffEq

@parameters x y t
@variables u(..) v(..)
Dt = Differential(t)
Dx = Differential(x)
Dy = Differential(y)
Dxx = Differential(x)^2
Dyy = Differential(y)^2

# MIXED DIFFERENTIAL
Dxy = Differential(x)*Differential(y)

∇²(u) = Dxx(u) + Dyy(u) + Dxy(u)

brusselator_f(x, y, t) = (((x-0.3)^2 + (y-0.6)^2) <= 0.1^2) * (t >= 1.1) * 5.

x_min = y_min = t_min = 0.0
x_max = y_max = 1.0
t_max = 11.5

α = 10.

u0(x,y,t) = 22(y*(1-y))^(3/2)
v0(x,y,t) = 27(x*(1-x))^(3/2)

eq = [Dt(u(x,y,t)) ~ 1. + v(x,y,t)*u(x,y,t)^2 - 4.4*u(x,y,t) + α*∇²(u(x,y,t)) + brusselator_f(x, y, t),
       Dt(v(x,y,t)) ~ 3.4*u(x,y,t) - v(x,y,t)*u(x,y,t)^2 + α*∇²(v(x,y,t))]

domains = [x ∈ Interval(x_min, x_max),
              y ∈ Interval(y_min, y_max),
              t ∈ Interval(t_min, t_max)]

# Periodic BCs
bcs = [u(x,y,0) ~ u0(x,y,0),
       u(0,y,t) ~ u(1,y,t),
       u(x,0,t) ~ u(x,1,t),

       v(x,y,0) ~ v0(x,y,0),
       v(0,y,t) ~ v(1,y,t),
       v(x,0,t) ~ v(x,1,t)] 

@named pdesys = PDESystem(eq,bcs,domains,[x,y,t],[u(x,y,t),v(x,y,t)])

N = 32

dx = (x_max-x_min)/N
dy = (y_max-y_min)/N

order = 2

discretization = MOLFiniteDifference([x=>dx, y=>dy], t, approx_order=order, grid_align=center_align)

# Convert the PDE problem into an ODE problem
prob = discretize(pdesys,discretization)

I get the following error:

ERROR: MethodError: no method matching collect_ivs_from_nested_operator!(::Set{Any}, ::SymbolicUtils.Add{Real, Int64, Dict{Any, Number}, Nothing}, ::Type{Differential})
Closest candidates are:
  collect_ivs_from_nested_operator!(::Any, ::Term, ::Any)
@xtalax
Copy link
Member

xtalax commented Jul 19, 2022

Thinking about it there is no way to get them to discretize at present, sorry. I will add this to known limitations. We can eventually support this, but don't expect it until after v1.0.

Though I invite you to try an auxiliary variable.

@marcofrancis
Copy link
Author

Wait, can't I just add a new unknown function that represents the first derivative wrt one of the state space variables, and add an equation for it?

@xtalax
Copy link
Member

xtalax commented Jul 20, 2022

Actually yes, good point! Let me know if that works.

@henry2004y
Copy link

I fell into the same issue. Trying to see if a workaround with auxiliary variables can work.

@xtalax
Copy link
Member

xtalax commented Jul 28, 2022

#145 related

@xtalax xtalax linked a pull request Oct 7, 2022 that will close this issue
@xtalax xtalax closed this as completed Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants