ModelingToolKit and the number pi

I am likely misunderstanding the issue below.

The issues, however, of ModelingToolkit not liking pi reported previously at Discretization of semi-coupled wave and diffusion equations fails for step size of pi/(25n) using MethodOfLines.jl seems to persist.

A MWE is below. The code as given does not work well. The same code with u(x,0) ~ sin(pi*x) replaced by u(x,0) ~ sin(mypi*x) works fine.

Thx for any insight.

# Parameters, variables, and derivatives
@parameters x t
@variables u(..)
Dxx = Differential(x)^2
Dtt = Differential(t)^2
Dt = Differential(t)
Dx = Differential(x)

#2D PDE
c=1 # wave velocity 
eq  = [ Dt(u(x,t)) ~ c^2*Dxx(u(x,t)) ] 

mypi = 3.1415

# Initial and boundary conditions
# Initial velocity is still missing 
bcs = [ u(0.,t) ~ 0.,# for all t > 0
        u(1.,t) ~ 0.,
        u(x,0) ~ sin(pi*x)]

# Space and time domains
maxt = .5 
domains = [x ∈ (0.0,1.0), 
           t ∈ (0.0,maxt)]

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

#  Define discretization 
N = 32
order = 2 
discretization = MOLFiniteDifference([x=>N], t, approx_order=order)

# Convert the PDE problem into an ODE problem
println("Discretization:")
@time prob = discretize(pdesys,discretization)

println("Solve:")
@time sol = solve(prob, TRBDF2(),saveat=maxt/10)

# Plot results
surface(sol[t], sol[x], sol[u(x,t)]) 

Does it work on a desktop computer? If it does, but not on a pi, perhaps you do not have enough RAM?

Can you share the output of:

julia> versioninfo()

?
And, inthe terminal (not in Julia), the output of

free -h

?

Thx @ufechner7

pi here is the number pi. pi here is not a hardware device.

I updated the title of your post for clarity.

1 Like