# Discretization problem using MOL

**URL:** <https://discourse.julialang.org/t/discretization-problem-using-mol/105514>\
**Category:** Modelling & Simulations\
**Created:** [October 28, 2023, 4:54pm UTC](https://discourse.julialang.org/t/discretization-problem-using-mol/105514 "2023-10-28T16:54:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johan\_Ekberg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johan_ekberg/32/202779_2.png) [@Johan\_Ekberg](https://discourse.julialang.org/u/Johan_Ekberg)\
**Post date:** [October 28, 2023, 4:54pm UTC](https://discourse.julialang.org/t/discretization-problem-using-mol/105514/1 "2023-10-28T16:54:37Z")

</div>

Hi im trying to solve a 4th order PDE using the MethodOfLines package but im getting the following error messege when trying to discretize my system in space. Could the problem be caused by the mixed derivative? The PDESystem is created successfully.

ArgumentError: Differential w.r.t. multiple variables Any[0.54, 0.86, 0.09, 0.35, 0.22, 0.38, 0.56, 0.2, t, 0.89, 0.06, 0.05, 0.48, 0.49, 0.57, 0.67, 0.71, 0.83, 0.24, 0.11, 0.95, 0.3, 0.74, 0.08, 0.7, 0.58, 0.76, 0.78, 0.34, 0.88, 0.81, 0.63, 0.27, 0.46, 0.19, 0.4, 0.37, 0.36, 0.42, 0.12, 0.23, 0.39, 0.75, 0.96, 0.32, 0.26, 0.16, 0.45, 0.25, 0.85, 0.9, 0.8, 0.14, 0.98, 0.5, 0.55, 0.02, 0.69, 0.77, 0.73, 0.47, 0.79, 0.64, 0.62, 0.44, 0.92, 0.43, 0.04, 0.72, 0.66, 0.84, 0.51, 0.93, 0.28, 0.68, 0.15, 0.07, 0.31, 0.65, 0.87, 0.97, 0.59, 0.18, 0.33, 0.91, 0.1, 0.82, 0.13, 0.21, 0.94, 0.61, 0.53, 0.03, 0.52, 0.17, 0.29, 0.41, 0.6] are not allowed

```julia
using MethodOfLines, ModelingToolkit, DomainSets

@parameters t,x
@variables w(..)
Dt = Differential(t); Dtt = Differential(t)^2
Dxxxx = Differential(x)^4;
Dxx = Differential(x)^2; Dx = Differential(x)

E = 210e9;
r1 = 0.035;
r = 0.045;
A_water = pi*r1^2;
A_pipe = pi*(r^2-r1^2);
rho_water = 1000;
rho_pipe = 7850;
I = pi*(r^4-r1^4)/4;
L = 1;
m = rho_water*A_water;
M = rho_pipe*A_pipe;
U = 3;

eq = E*I*Dxxxx(w(t,x)) + M*U^2*Dxx(w(t,x)) + 2*M*U*Dx(Dt(w(t,x))) + (M+m)*Dtt(w(t,x)) ~ 0
domain = [x ∈ Interval(0.0, 1.0),
t ∈ Interval(0.0, 5.0)];

ic_bc = [w(0.0, x) ~ cos(2*pi*L*x)/2,
Dt(w(0.0, x)) ~ 0,
w(t, 0) ~ 0,
w(t, 1.0) ~ 0,
Dx(w(t, 0)) ~ 0,
Dx(w(t, 1.0)) ~ 0]

@named sys = PDESystem(eq, ic_bc, domain, [t, x], [w(t,x)])

dx = 0.01;
disc = MOLFiniteDifference([x => dx], t, advection_scheme = WENOScheme());
prob = discretize(sys, disc);

```

---

<div class="post-metadata">

**Author:** ![Johan\_Ekberg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johan_ekberg/32/202779_2.png) [@Johan\_Ekberg](https://discourse.julialang.org/u/Johan_Ekberg)\
**Post date:** [October 29, 2023, 5:28pm UTC](https://discourse.julialang.org/t/discretization-problem-using-mol/105514/2 "2023-10-29T17:28:55Z")

</div>

I manage to solve my frist problem by chaning the order of differentiation in the mixed derivative. But now i get an error telling me that i have an unblanced system. Im new to using Julia so im not sure if the problem is how i set up the problem or something with my initial conditions.

```julia
using MethodOfLines, ModelingToolkit, DomainSets, OrdinaryDiffEq, DiffEqOperators, DiffEqBase

@parameters t,x
@variables w(..)
Dt = Differential(t); Dtt = Differential(t)^2
Dxxxx = Differential(x)^4; 
Dxx = Differential(x)^2; Dx = Differential(x)
Dtx = Dt*Dx
E = 210e9;
r1 = 0.035; 
r = 0.045; 
A_water = pi*r1^2;
A_pipe = pi*(r^2-r1^2);
rho_water = 1000;
rho_pipe = 7850;
I = pi*(r^4-r1^4)/4; 
L = 1;
m = rho_water*A_water; 
M = rho_pipe*A_pipe; 
U = 3;

eq = 2*M*U*Dtx(w(t,x)) + (M+m)*Dtt(w(t,x)) ~ -E*I*Dxxxx(w(t,x)) - M*U^2*Dxx(w(t,x)) 
domain = [x ∈ Interval(0.0, L),
        t ∈ Interval(0.0, 5.0)];

ic_bc = [w(0,x) ~ cos(2*pi*L*x)/2,
        Dt(w(0,x)) ~ 0,
         w(t, 0) ~ 0,
         w(t, L) ~ 0,
         Dx(w(t, 0)) ~ 0,
         Dx(w(t, L)) ~ 0]
    
@named sys = PDESystem(eq, ic_bc, domain, [t, x], [w(t,x)])
    

        
        
dx = 0.1;
disc = MOLFiniteDifference([x => dx], t, advection_scheme = WENOScheme());
prob = discretize(sys, disc);

```

```julia
There are 11 variables and 11 equations.

There are 7 time derivatives.

The variables without time derivatives are:
SymbolicUtils.BasicSymbolic{Real}[(w(t))[1], (w(t))[2], (w(t))[10], (w(t))[11]]

The equations without time derivatives are:
Equation[(w(t))[1] ~ 0, (w(t))[11] ~ 0, 20.0(w(t))[2] - 5.0(w(t))[3] - 15.0(w(t))[1] ~ 0, 5.0(w(t))[9] + 15.0(w(t))[11] - 20.0(w(t))[10] ~ 0]
ExtraVariablesSystemException: The system is unbalanced. There are 16 highest order derivative variables and 9 equations.
More variables than equations, here are the potential extra variable(s):

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 6, 2024, 9:50pm UTC](https://discourse.julialang.org/t/discretization-problem-using-mol/105514/3 "2024-04-06T21:50:00Z")

</div>

Did this ever get captured in an issue @xtalax ?
