# MethodOfLines.jl not working

Hello All.
I am to solve a PDE numerically (called Klein-Kramers-Chandrasekhar equation KKC eqn ) for some parameters. I followed the getting started instructions intro and after writing the step for

prob = discretize(pdesys, discretization)

for my system, I got this error message:

Discretization:
ERROR: LoadError: MethodError: no method matching real(::Equation)
The function `real` exists, but no method is defined for this combination of argument types.

I have imported the following packages: Plots,ModelingToolkit, MethodOfLines, OrdinaryDiffEq, DomainSets using the using keyword.

What did I do wrong? Any help will be very appreciated.

``````using Plots
using ModelingToolkit, MethodOfLines, OrdinaryDiffEq, DomainSets

function main()
@parameters x v t
@variables P(..)

Dt = Differential(t);Dx = Differential(x)
Dv = Differential(v);Dvv = Differential(v)^2

k=0.5;T=2;g=1;m=1/g

domains = [x in Interval(-5.0, 5.0), v in Interval(-5.0, 5.0),t in Interval(0.0,4.0)]

eq = [Dt(P(x, v, t)) ~ -v*Dx(P(x,v,t)) +g*P(x,v,t) + (g*v+k*x/m)*Dv(P(x,v,t)) +(g*T/m)*Dvv(P(x,v,t))]

bcs= [P(x,v,0)~ (m/(2*pi*T))*exp((-0.5*k*x*x -0.5*m*v*v)/T), Dx(P(x,v,0)) ~ -(m*k/(2*pi*T*T))*x*exp( (-0.5*k*x*x -0.5*m*v*v)/T),Dv(P(x,v,0)) ~ -(m^2/(2*pi*T*T))*v*exp( (-0.5*k*x*x -0.5*m*v*v)/T), Dv(Dv(P(x,v,0))) ~ -(m*m/(2*pi*T*T))*exp( (-0.5*k*x*x -0.5*m*v*v)/T)*(1-(m*(v^2)/T))]

@named pdesys = PDESystem(eq, bcs, domains, [x, v, t], [P(x,v,t)])
discretization = MOLFiniteDifference([x => 0.01, v => 0.01,t=>0.01], approx_order = 2)
@time prob = discretize(pdesys, discretization)

end

@time main()
``````

This is my code.

During pre-compilation I get:

``````        Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`
Precompiling project...
6 dependencies successfully precompiled in 54 seconds. 352 already precompiled.
2 dependencies had output during precompilation:
┌ Interpolations
│  WARNING: method definition for checkbounds at /home/ufechner/.julia/packages/Interpolations/USkTk/src/Interpolations.jl:454 declares type variable N but does not use it.
│  WARNING: method definition for checkbounds at /home/ufechner/.julia/packages/Interpolations/USkTk/src/Interpolations.jl:457 declares type variable N but does not use it.
│  WARNING: method definition for GriddedInterpolation at /home/ufechner/.julia/packages/Interpolations/USkTk/src/gridded/gridded.jl:37 declares type variable pad but does not use it.
│  WARNING: method definition for GriddedInterpolation at /home/ufechner/.julia/packages/Interpolations/USkTk/src/gridded/gridded.jl:60 declares type variable pad but does not use it.
│  WARNING: method definition for interpolate! at /home/ufechner/.julia/packages/Interpolations/USkTk/src/deprecations.jl:30 declares type variable TWeights but does not use it.
└
┌ MethodOfLines
│  ┌ Warning: The system contains interface boundaries, which are not compatible with system transformation. The system will not be transformed. Please post an issue if you need this feature.
│  └ @ MethodOfLines ~/.julia/packages/MethodOfLines/iIYN1/src/system_parsing/pde_system_transformation.jl:43
└
``````

And executing it results in:

``````julia> include("method.jl")
ERROR: LoadError: MethodError: no method matching real(::Equation)

Closest candidates are:
real(::Type{Union{}}, Any...)
@ Base complex.jl:123
real(::ChainRulesCore.ZeroTangent)
@ ChainRulesCore ~/.julia/packages/ChainRulesCore/I1EbV/src/tangent_arithmetic.jl:111
real(::Symbolics.SemiMonomial)
@ Symbolics ~/.julia/packages/Symbolics/Nk48t/src/semipoly.jl:123
...

Stacktrace:
[3] getindex
[4] copy
[5] materialize
[7] real(A::Matrix{Any})
@ Base ./abstractarraymath.jl:170
[8] hascomplex(term::Matrix{Any})
@ PDEBase ~/.julia/packages/PDEBase/nzap9/src/symbolic_utils.jl:292
[9] #127
@ ~/.julia/packages/PDEBase/nzap9/src/make_pdesys_compatible.jl:86 [inlined]
[10] _any(f::PDEBase.var"#127#135", itr::Vector{Matrix{Any}}, ::Colon)
@ Base ./reduce.jl:1220
[11] any(f::Function, a::Vector{Matrix{Any}}; dims::Function)
@ Base ./reducedim.jl:1020
[12] handle_complex(pdesys::PDESystem)
@ PDEBase ~/.julia/packages/PDEBase/nzap9/src/make_pdesys_compatible.jl:86
[13] symbolic_discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization})
@ PDEBase ~/.julia/packages/PDEBase/nzap9/src/symbolic_discretize.jl:9
[14] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}; analytic::Nothing, kwargs::@Kwargs{})
@ PDEBase ~/.julia/packages/PDEBase/nzap9/src/discretization_state.jl:58
[15] discretize
@ ~/.julia/packages/PDEBase/nzap9/src/discretization_state.jl:55 [inlined]
[16] macro expansion
@ ./timing.jl:279 [inlined]
[17] main()
@ Main ~/repos/tmp/method.jl:22
[18] macro expansion
@ ./timing.jl:279 [inlined]
[19] top-level scope
@ ~/repos/tmp/method.jl:269
[20] include(fname::String)
@ Base.MainInclude ./client.jl:489
[21] top-level scope
@ REPL[1]:1
in expression starting at /home/ufechner/repos/tmp/method.jl:26
``````

The line that causes the error is the last line, the call of `main()`.

So… what is the actual issue here?
That I need different kind of boundary conditions or initial conditions?

@ChrisRackauckas Can you have a look?

Can you open an issue with the MWE? This is going to get lost in the pre-JuliaCon madness