MethodOfLines & functions in BCs

I’m trying to implement a distributed model using MethodOfLines with:

  • 3 PDEs + a number of AEs within the volume
  • a number of Boundary conditions

In the boundary conditions, some flows depend on valve signals, e.g., as:

function f_v(u)
    if u < 1/20
        return 0
    elseif u < 1/2
        return (11.1*u-0.556)/30
    else
        return (50u-20)/30
    end
end

which is used as follows in the Boundary Conditions…

...
    ṁ ~ K*f_v(u_v)*sqrt(Δp_v),
...

where , u_v, Δp_v are defined as MTK variables of time, and K is an MTK parameter.
leading to an error message as follows:

TypeError: non-boolean (Num) used in boolean context

Stacktrace:
 [1] f_v(u::Num)...
  • What is the problem here?
  • How can I get around the problem?

Ah… I figured it out: I needed to @register_symbolical the function. I never thought about that – I’ve only done that in the past with functions of time.

Anyways, now MTK/MethodOfLines accepts that part of the model.