MethodOfLines.jl: time derivative as initial conditions

Hi, I am using MethodOfLines.jl for solving the beam vibration PDE.

I need to implement an initial condition that the initial velocity is zero, or Dt(u(t=0,x)) ~ 0.

I tried to put it into the bcs but failed.

The problem is in the expression Dt(u(t,x)), I could not set t to be 0.

Thank you!


using OrdinaryDiffEq, ModelingToolkit, MethodOfLines, DomainSets
@parameters t x
@variables u(..)
Dt = Differential(t)
Dt2 = Differential(t)
Dx2 = Differential(x)^2
Dx4 = Differential(x)^4
L = 1;
eq  = Dt2(u(t, x)) ~ -Dx4(u(t, x)) + 1;
bcs = [#u(0, x) ~ 0.0, 
        Dt(u(0, x)) ~ 0.0,
        #u(t, 0) ~ 0.0, Dx2(u(t, 0)) ~ 0.0,
        #u(t, L) ~ 0.0, Dx2(u(t, L)) ~ 0.0,
        ];
domains = [t ∈ Interval(0.0, 1.0),
        x ∈ Interval(0.0, L)];
@named pdesys = PDESystem(eq, bcs, domains,[t, x],[u(t, x)]);
dx = 0.05; order = 2;
discretization = MOLFiniteDifference([x => dx],t);
prob = discretize(pdesys, discretization);

ERROR: AssertionError: Boundary condition Differential(t)(u(0, x)) ~ 0.0 is not on a boundary of the domain, or is not a valid boundary condition

There are two points here.

First, MethodOfLines kind of applies a smart set of heuristics to support as many initial/boundary conditions are possible, see MethodOfLines.jl: Automated Finite Difference for Physics-Informed Learning · MethodOfLines.jl
In particular, one of the currently known limitation is this:

  • That initial conditions are of the form u(...) ~ ..., and don’t reference the initial time derivative.

To solve the PDE anyway, you could translate into the common form:
Firstly, your PDE equation is \partial_t u = \partial_x^4 u +1 and the initial condition \partial_t u = 0 at t=0 which implies \partial_x^4 u = -1 at t = 0.
Then, if we denote u_0(x) = u(0,x) we get \partial_x^4 u_0 = -1 which is satisfied exactly if u_0 = c_3 x^3 + c_2 x^2 + c_1 x^1 + c_0.

With the four boundary conditions (which are commented in your code) you could determine the four unknowns c_3, ..., c_0 and obtain the initial data u = u_0 at t=0.


As a side note: If the initial velocity is zero and the boundary conditions are satisfied, then the solution of the PDE will be constant…

1 Like

Ah, I think you want to solve this PDE (i.e. second-order time derivative in the PDE, not first order)

eq  = Dt(Dt(u(t, x))) ~ -Dx4(u(t, x)) + 1;
bcs = [u(0, x) ~ 0.0, 
        Dt(u(0, x)) ~ 0.0,
        u(t, 0) ~ 0.0, Dx2(u(t, 0)) ~ 0.0,
        u(t, L) ~ 0.0, Dx2(u(t, L)) ~ 0.0,
        ];

That should work since Dt(u(0,x)) is then part of the initial data.

Thank you! That was a mistake. It should be 2nd derivative of time
I applied the changes but still got the same error.

That makes sense to me! Thank you so much.