Issue with PDEBase or PDEsystems!

Hello everyone !

I’m trying to solve a 3 coupled and non linear PDE equations as a first work later Iwill see how to use Catalyst to add sources and sinks processes. for now its just the transport of coupled PDE of gases.

I established my equations everything went well formula after formula till setting up the equations using examples provided in MethodeOlines docs
the error happens after invoking discretization as follow

# PDE system

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

# Method of lines discretization

dx = 0.001

order = 4

discretization = MOLFiniteDifference([x => dx], t, approx_order=order, grid_align=center_align)

# Convert the PDE problem into an ODE problem

prob = discretize(pdesys, discretization)

Here is the error displayed

Activating project at ~/Documents/JULIA-2-GAS
ERROR: UndefVarError: similarterm not defined in PDEBase
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] ex2term(term::SymbolicUtils.BasicSymbolic{Real}, v::PDEBase.VariableMap)
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/symbolic_utils.jl:276
[2] create_aux_variable!(eqs::Vector{…}, bcs::Vector{…}, boundarymap::Dict{…}, v::PDEBase.VariableMap, term::SymbolicUtils.BasicSymbolic{…})
@ MethodOfLines ~/.julia/packages/MethodOfLines/NV0bv/src/system_parsing/pde_system_transformation.jl:207
[3] transform_pde_system!(v::PDEBase.VariableMap, boundarymap::Dict{…}, sys::PDESystem, disc::MOLFiniteDifference{…})
@ MethodOfLines ~/.julia/packages/MethodOfLines/NV0bv/src/system_parsing/pde_system_transformation.jl:27
[4] symbolic_discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/symbolic_discretize.jl:31
[5] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…}; analytic::Nothing, kwargs::@Kwargs{})
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/discretization_state.jl:57
[6] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/discretization_state.jl:54
[7] top-level scope
@ ~/Documents/JULIA-2-GAS/3-Diff-EQS.jl:348
Some type information was truncated. Use show(err) to see complete types.

Naceur

In one of the equations I have Dx(g(x)*f(x)+h(x)*Dx(w(t,x))

w(t,x) is one of the variables to be found

I will try to develop this using mathematica and put the equation in developed form and see if it works

since I cant interpret this error !
I will be back to you with this attempt
Naceur

Sounds like you have an older version of PDEBase?

Hi Chris,

Long time no see! :blush:

I’ve started coding again and decided to skip Mathematica this time—too prone to errors and delays. Symbolics.jl has been great for handling derivations and expression expansions.

I’m using PDEBase v0.1.15, but I ran into an issue in PDEBase.jl/src/symbolic_utils.jl from lines 270 to 277.

I have no idea how to fix this, any help from you guys will make me smile again

Also, I noticed that GitHub shows v0.1.10 as the latest release, even though v0.1.15 installs automatically. Any idea why?

Thanks!

Tagbot has issues but you seem to have latest.

What’s the reproducer?

Hey Chris,

I’m not quite sure what you meant by “producer.” If you meant which line in my code is causing the error, it’s the last line in this portion of code:

discretization = MOLFiniteDifference([x => dx], t, approx_order=order, grid_align=center_align)
# Convert the PDE problem into an ODE problem

prob = discretize(pdesys, discretization)

My Julia setup seems pretty messy right now :cry:. I noticed the file in question, PDEBase.jl/src/symbolic_utils.jl, is actually located in two places:

  1. .julia/packages/PDEBase/EWM3U/src/symbolic_utils.jl
  2. .julia/packages/PDEBase/WnliA/src/symbolic_utils.jl

What’s odd is that these files aren’t identical. For example, in the first one, there’s a portion of code like this:

function ex2term(term, v)
    iscall(term) || return term
    termdvs = collect(get_depvars(term, v.depvar_ops))
    symdvs = filter(u -> all(x -> !(safe_unwrap(x) isa Number), arguments(u)), termdvs)
    exdv = last(sort(symdvs, by=u -> length(arguments(u))))
    name = Symbol("⟦" * string(term) * "⟧")
    return setname(similarterm(typeof(exdv), rename(operation(exdv), name), arguments(exdv), symtype(exdv), metadata(exdv)), name)
end

And in the second:

function ex2term(term, v)
    iscall(term) || return term
    termdvs = collect(get_depvars(term, v.depvar_ops))
    symdvs = filter(u -> all(x -> !(safe_unwrap(x) isa Number), arguments(u)), termdvs)
    exdv = last(sort(symdvs, by=u -> length(arguments(u))))
    name = Symbol("⟦" * string(term) * "⟧")
    return setname(similarterm(exdv, rename(operation(exdv), name), arguments(exdv), symtype(exdv), metadata(exdv)), name)
end

The difference is in the syntax near similarterm—the first file uses similarterm(typeof(exdv), ...).

I didn’t check both files line by line,

but my error persists.
here it is

Activating project at ~/Documents/JULIA-2-GAS
ERROR: UndefVarError: similarterm not defined in PDEBase
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] ex2term(term::SymbolicUtils.BasicSymbolic{Real}, v::VariableMap)
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/symbolic_utils.jl:277
[2] create_aux_variable!(eqs::Vector{…}, bcs::Vector{…}, boundarymap::Dict{…}, v::VariableMap, term::SymbolicUtils.BasicSymbolic{…})
@ MethodOfLines ~/.julia/packages/MethodOfLines/NV0bv/src/system_parsing/pde_system_transformation.jl:207
[3] transform_pde_system!(v::VariableMap, boundarymap::Dict{…}, sys::PDESystem, disc::MOLFiniteDifference{…})
@ MethodOfLines ~/.julia/packages/MethodOfLines/NV0bv/src/system_parsing/pde_system_transformation.jl:27
[4] symbolic_discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/symbolic_discretize.jl:31
[5] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…}; analytic::Nothing, kwargs::@Kwargs{})
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/discretization_state.jl:57
[6] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/discretization_state.jl:54
[7] top-level scope
@ ~/Documents/JULIA-2-GAS/3-Diff-EQS.jl:374
Some type information was truncated. Use show(err) to see complete types.

Any idea what’s going on?

Share ]st?

Here it is in the directory where I’m working

(JULIA-2-GAS) pkg> st
Status ~/Documents/JULIA-2-GAS/Project.toml
[6e4b80f9] BenchmarkTools v1.5.0
[5b8099bc] DomainSets v0.7.14
[23fbe1c1] Latexify v0.16.5
[94925ecb] MethodOfLines v0.11.6
[961ee093] ModelingToolkit v9.49.0
[1dea7af3] OrdinaryDiffEq v6.89.0
[f0f68f2c] PlotlyJS v0.18.14
[d1185830] SymbolicUtils v3.7.2
[0c5d862f] Symbolics v6.18.3

It looks like it was a bad update, or rather when updating to SymbolicUtils v3 we missed to update one function.

1 Like

The problem is with this

UndefVarError: **similarterm** not defined in PDEBase
Suggestion: check for spelling errors or missing imports.

similarterm seems to be a function in Julia

yesterday I attempted to trace each file calling the other, but I did not succeed to solve the problem, here are the files I visited to see where is the problem

ERROR: UndefVarError: similarterm not defined in PDEBase
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] ex2term(term::SymbolicUtils.BasicSymbolic{Real}, v::PDEBase.VariableMap)
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/symbolic_utils.jl:276
[2] create_aux_variable!(eqs::Vector{…}, bcs::Vector{…}, boundarymap::Dict{…}, v::PDEBase.VariableMap, term::SymbolicUtils.BasicSymbolic{…})
@ MethodOfLines ~/.julia/packages/MethodOfLines/NV0bv/src/system_parsing/pde_system_transformation.jl:207
[3] transform_pde_system!(v::PDEBase.VariableMap, boundarymap::Dict{…}, sys::PDESystem, disc::MOLFiniteDifference{…})
@ MethodOfLines ~/.julia/packages/MethodOfLines/NV0bv/src/system_parsing/pde_system_transformation.jl:27
[4] symbolic_discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/symbolic_discretize.jl:31
[5] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…}; analytic::Nothing, kwargs::@Kwargs{})
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/discretization_state.jl:57
[6] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/EWM3U/src/discretization_state.jl:54
[7] top-level scope
@ ~/Documents/JULIA-2-GAS/3-Diff-EQS.jl:374
Some type information was truncated. Use show(err) to see complete types.

here is line 374 in my code
prob = discretize(pdesys, discretization)

I can send you the code I’m writing because maybe I’m not doing thing as it should much more earlier in the code

Great Chris :slight_smile: I will wait to see the fix and give it a new try

Hi

It seems to work
but I’m running in a new problem.
The solve of the problem is running now it’s almost 50hours for just those 3 PDE equations. Yes they are coupled Yes they are non linear (not high non linearity)
just physics of diffusion and advection that do not over pass exponent 2 we can encounter sqrt() also between the variables in coefficient of the physics I’m modeling.

The problem is that
sol = solve(prob, Rodas5P(), saveat=0.01)
keep working 50 hours without end !
but I’m sure that will over pass my memory access if thing continue like that

I can see the memory rising and that will finish by reaching all my available memory which is around 60GB (32 RAM and my swap 30 GB)

solve() did not claim anything and keep calculating

and I do not know whit it is happening

So I went on julia to see how I can make calculation using parallel or gpu that could accelerate the calculations (knowing that I’m using MethodOfLines for discretisation
I did not find suitable and easy way to do that

I found this https://www.youtube.com/watch?v=vPsfZUqI4_0

But I need first advise before diving and changing everything

Thank you for reading my problem and commenting

Naceur

You want to use FBDF or something of the sort instead. And set sparse. Or FBDF(linsolve = LinearSolve.KrylovJL_GMRES()) for example.

Hi Chris,

I’ll give this a try! I converted the problem to LaTeX, and the result was pretty overwhelming—those physics coefficients showed massive non-linearity, and I’m not sure how to approach linearizing it.

If we can solve this in Julia, it’ll be a big win!
I’m sending you the notebook