ModelingToolKit and the number pi

Did you ever figure this out? Your code works for me. I had to add the imports back but otherwise it runs unaltered

# crazypi.jl
using ModelingToolkit
using MethodOfLines
using DifferentialEquations
using Plots

# 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)])
julia> include("crazypi.jl")
Discretization:
 91.253485 seconds (101.89 M allocations: 5.144 GiB, 2.25% gc time, 99.09% compilation time: 100% of which was recompilation)
Solve:
  4.446597 seconds (4.89 M allocations: 259.379 MiB, 99.04% compilation time: 100% of which was recompilation)

julia> versioninfo()
Julia Version 1.12.0
Commit b907bd0600 (2025-10-07 15:42 UTC)
Build Info:

    Note: This is an unofficial build, please report bugs to the project
    responsible for this build and not to the Julia project unless you can
    reproduce the issue using official builds available at https://julialang.org

Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: 4 × Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, haswell)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)
1 Like