# Error in PDE Example

**URL:** https://discourse.julialang.org/t/error-in-pde-example/60040
**Category:** Modelling & Simulations
**Tags:** diffeq, pde
**Created:** [April 26, 2021, 4:02pm UTC](https://discourse.julialang.org/t/error-in-pde-example/60040 "2021-04-26T16:02:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mihalybaci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihalybaci/32/13528_2.png) [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)
#### Post date: [April 26, 2021, 4:02pm UTC](https://discourse.julialang.org/t/error-in-pde-example/60040/1 "2021-04-26T16:02:24Z")

</div>

I’m trying to follow the example for solving the heat equation PDE from the [DiffEqOperators](https://github.com/SciML/DiffEqOperators.jl) page, but I am running into an error in the discretization step. The code is

```julia
using OrdinaryDiffEq, ModelingToolkit, DiffEqOperators

# Parameters, variables, and derivatives
@parameters t x
@variables u(..)
# Warning: `@derivatives D'''~x` is deprecated. Use `Differential(x)^3` instead.
#@derivatives Dt'~t
#@derivatives Dxx''~x
Dt = Differential(t)
Dxx = Differential(x)^2
# 1D PDE and boundary conditions

eq = Dt(u(t,x)) ~ Dxx(u(t,x))
bcs = [u(0,x) ~ cos(x),
       u(t,0) ~ exp(-t),
       u(t,Float64(pi)) ~ -exp(-t)]

# Space and time domains
domains = [t ∈ IntervalDomain(0.0, 1.0),
           x ∈ IntervalDomain(0.0, Float64(pi))]

# PDE system
pdesys = PDESystem(eq,bcs,domains,[t,x],[u])

# Method of lines discretization
dx = 0.1
order = 2
discretization = MOLFiniteDifference(dx,order)

# Convert the PDE problem into an ODE problem
prob = discretize(pdesys,discretization) # <--- Error occurs here

# Solve ODE problem
sol = solve(prob,Tsit5(),saveat=0.1)

```

Side note, using `@derivatives` as in the example gives a deprecation warning. With this setup, the error I get is

```julia
julia> prob = discretize(pdesys,discretization)
ERROR: LoadError: type Int64 has no field val

```

This is with Julia v1.6.1 and

```julia
(diffeq) pkg> st
      Status `~/dev/learning/diffeq/Project.toml`
  [9fdde737] DiffEqOperators v4.24.0
  [961ee093] ModelingToolkit v5.16.0
  [1dea7af3] OrdinaryDiffEq v5.52.4
  [91a5bcdd] Plots v1.12.0

```

Thank you in advance for any help.

Edit: This error seems similar to [this one](https://discourse.julialang.org/t/pde-errors/59707/5), however, that issue was traced to using complex numbers, which does not seem to be the case here.

---

<div class="post-metadata">

### Author: ![mihalybaci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihalybaci/32/13528_2.png) [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)
#### Post date: [April 26, 2021, 4:57pm UTC](https://discourse.julialang.org/t/error-in-pde-example/60040/2 "2021-04-26T16:57:42Z")

</div>

I found a similar example in the `DiffEqOperators` docs that does work, and I think I’ve found the problem. In the above example, if `Float64(pi)` in both `bcs` and `domains` is changed to any whole number (1 and 1.0, 2 and 2.0, etc), then it works. It also works for `u(t, 4.5)` and `x ∈ IntervalDomain(0.0, 4.5)`, but fails for 4.55. So, is the problem that `IntervalDomain` cannot break up 4.55 (or pi) evenly?

---

<div class="post-metadata">

### Author: ![Ian\_Slagle](https://avatars.discourse-cdn.com/v4/letter/i/b5a626/32.png) [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)
#### Post date: [April 26, 2021, 10:37pm UTC](https://discourse.julialang.org/t/error-in-pde-example/60040/3 "2021-04-26T22:37:32Z")

</div>

I encountered something similar. Not sure if this helps, but it appears the examples in the docs are not fully working, but the examples that can be found in the test/MOL folder of DiffEqOperators.jl are working, so those might be useful as a starting point.

---

<div class="post-metadata">

### Author: ![mihalybaci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihalybaci/32/13528_2.png) [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)
#### Post date: [April 27, 2021, 11:59am UTC](https://discourse.julialang.org/t/error-in-pde-example/60040/4 "2021-04-27T11:59:36Z")

</div>

Oh, looking at the tests is a good idea. I hadn’t thought of that. Thanks.

---

<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 27, 2021, 1:31pm UTC](https://discourse.julialang.org/t/error-in-pde-example/60040/5 "2021-04-27T13:31:21Z")

</div>

> [@Ian\_Slagle](#):
>
> I encountered something similar. Not sure if this helps, but it appears the examples in the docs are not fully working, but the examples that can be found in the test/MOL folder of DiffEqOperators.jl are working, so those might be useful as a starting point.

I mean, the first line of that tutorial right now is:

> [Note: This uses a currently unreleased interface that is still a work in progress. Use at your own risk!](http://diffeqoperators.sciml.ai/dev/symbolic_tutorials/mol_heat/#Note:-This-uses-a-currently-unreleased-interface-that-is-still-a-work-in-progress.-Use-at-your-own-risk!)

We will remove that statement when it’s all good, but right now it’s partially in development and the docs are very clear about that.
