# MethodOfLines.jl: time derivative as initial conditions

**URL:** https://discourse.julialang.org/t/methodoflines-jl-time-derivative-as-initial-conditions/86053
**Category:** General Usage
**Tags:** differentialequation
**Created:** [August 20, 2022, 5:16am UTC](https://discourse.julialang.org/t/methodoflines-jl-time-derivative-as-initial-conditions/86053 "2022-08-20T05:16:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Molox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/molox/32/35002_2.png) [@Molox](https://discourse.julialang.org/u/Molox)
#### Post date: [August 20, 2022, 5:16am UTC](https://discourse.julialang.org/t/methodoflines-jl-time-derivative-as-initial-conditions/86053/1 "2022-08-20T05:16:46Z")

</div>

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!

```julia

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

---

<div class="post-metadata">

### Author: ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)
#### Post date: [August 20, 2022, 6:54am UTC](https://discourse.julialang.org/t/methodoflines-jl-time-derivative-as-initial-conditions/86053/2 "2022-08-20T06:54:19Z")

</div>

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](http://methodoflines.sciml.ai/stable/#limitations)  
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…

---

<div class="post-metadata">

### Author: ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)
#### Post date: [August 20, 2022, 7:11am UTC](https://discourse.julialang.org/t/methodoflines-jl-time-derivative-as-initial-conditions/86053/3 "2022-08-20T07:11:54Z")

</div>

> [@Molox](#):
>
> beam vibration PDE

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

```julia
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.

---

<div class="post-metadata">

### Author: ![Molox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/molox/32/35002_2.png) [@Molox](https://discourse.julialang.org/u/Molox)
#### Post date: [August 20, 2022, 4:59pm UTC](https://discourse.julialang.org/t/methodoflines-jl-time-derivative-as-initial-conditions/86053/5 "2022-08-20T16:59:36Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Molox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/molox/32/35002_2.png) [@Molox](https://discourse.julialang.org/u/Molox)
#### Post date: [August 20, 2022, 5:08pm UTC](https://discourse.julialang.org/t/methodoflines-jl-time-derivative-as-initial-conditions/86053/6 "2022-08-20T17:08:56Z")

</div>

> [@SteffenPL](#):
>
> see [MethodOfLines.jl: Automated Finite Difference for Physics-Informed Learning · MethodOfLines.jl](http://methodoflines.sciml.ai/stable/#limitations)  
> 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.

That makes sense to me! Thank you so much.
