Error: Missing from the variable map

Hi there,

I am trying to modelling the circulatory system as an electrical circuit, based on the following image:

My code is as follows, with resistors, capacitors and inductors based on those in the RC model example.

function elastance(t, E_s, E_d, T, T_s1, T_s2)
    """
    Inputs:
    t       Time relative to t=0
    E_s     Maximum elastance of chamber during systole
    E_d     Minimum elastance of chamber during diastole
    T       Period of cardiac cycle
    T_s1    Time of systolic phase peak relative to start of cycle
    T_s2    Time of end of systolic phase relative to start of cycle
    """

    # Find current time relative to start of current cycle
    t_pulse = rem(t,T);

    # Elastance activation function
    e = (t_pulse < T_s1) * cos((t_pulse*pi)/T_s1) +
        (t_pulse >= T_s1) * (t_pulse < T_s1) * cos(((t_pulse+T_s2-T_s1)*pi)/T_s1) +
        (t_pulse >= T_s2) * (t_pulse < T) * 0

    # Elastance
    E = E_d + (E_s-E_d)*e/2

    return E
end

@mtkmodel Ventricle begin
    @components begin
        in = Pin()
        out = Pin()
    end
    @variables begin
        p(t)
        V(t)
    end
    @parameters begin
        E_s = 2
        E_d = 1
        T = 60/72
        T_s1 = 0.25
        T_s2 = 0.5
        V0 = 5
        p0 = 1
        E = elastance(t, E_s, E_d, T, T_s1, T_s2)
    end
    @equations begin
        0 ~ in.p - out.p
        p ~ in.p
        p ~ (V-V0)*E + p0
        D(V) ~ in.q + out.q
    end
end

@mtkmodel systemic_circulation_model begin
    @components begin
        source = Ventricle()
        ground = Ground()
        # Aorta
        resistor_ao = Resistor(R = R_ao)
        capacitor_ao = Capacitor(C = C_ao)
        inductor_ao = Inductor(L = L_ao)
        # Arteries
        resistor_ar = Resistor(R = R_ar)
        capacitor_ar = Capacitor(C = C_ar)
        inductor_ar = Inductor(L = L_ar)
        # Artioles
        resistor_at = Resistor(R = R_at)
        # Capilliaries
        resistor_cp = Resistor(R = R_cp)
        # Veins
        resistor_vn = Resistor(R = R_vn)
        capacitor_vn = Capacitor(C = C_vn)
    end
    @equations begin
        connect(source.out, inductor_ao.in, capacitor_ao.in)
        connect(capacitor_ao.out, ground.g)
        connect(inductor_ao.out, resistor_ao.in)
        connect(resistor_ao.out, inductor_ar.in, capacitor_ar.in)
        connect(capacitor_ar.out, ground.g)
        connect(inductor_ar.out, resistor_ar.in)
        connect(resistor_ar.out, resistor_at.in)
        connect(resistor_at.out, resistor_cp.in)
        connect(resistor_cp.out, resistor_vn.in, capacitor_vn.in)
        connect(resistor_vn.out, capacitor_vn.out, ground.g)
        connect(source.in, ground.g)
    end
end

@mtkbuild systemic_circulation = systemic_circulation_model()

@nonamespace u0 = [
    systemic_circulation.inductor_ao.q => 50,
    systemic_circulation.capacitor_ar.Δp => -50,
    systemic_circulation.inductor_ar.q => 50,
    systemic_circulation.capacitor_vn.Δp => -20
]
prob = ODEProblem(systemic_circulation, u0, (0, 50.0))
sol= solve(prob, RK4(), reltol=1e-6)

However I am getting the following error:

ArgumentError: SymbolicUtils.BasicSymbolic{Real}[inductor_ao₊q(t), capacitor_ar₊Δp(t), inductor_ar₊q(t), capacitor_vn₊Δp(t)] are missing from the variable map.

Stacktrace:
  [1] throw_missingvars(vars::Vector{SymbolicUtils.BasicSymbolic{Real}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\variables.jl:122
  [2] _varmap_to_vars(varmap::Dict{Num, Int64}, varlist::Vector{SymbolicUtils.BasicSymbolic{Real}}; defaults::Dict{Any, Any}, check::Bool, toterm::typeof(ModelingToolkit.default_toterm))
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\variables.jl:116
  [3] varmap_to_vars(varmap::Vector{Pair{Num, Int64}}, varlist::Vector{Any}; defaults::Dict{Any, Any}, check::Bool, toterm::Function, promotetoconcrete::Nothing, tofloat::Bool, use_union::Bool)
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\variables.jl:85
  [4] get_u0_p(sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, parammap::SciMLBase.NullParameters; use_union::Bool, tofloat::Bool, symbolic_u0::Bool)
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:786
  [5] get_u0_p
    @ C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:768 [inlined]
  [6] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, parammap::SciMLBase.NullParameters; implicit_dae::Bool, du0map::Nothing, version::Nothing, tgrad::Bool, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::Symbolics.SerialForm, eval_expression::Bool, use_union::Bool, tofloat::Bool, symbolic_u0::Bool, u0_constructor::typeof(identity), kwargs::Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:t, :has_difference, :check_length), Tuple{Int64, Bool, Bool}}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:811
  [7] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, tspan::Tuple{Int64, Float64}, parammap::SciMLBase.NullParameters; callback::Nothing, check_length::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:936
  [8] ODEProblem
    @ C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:929 [inlined]
  [9] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, tspan::Tuple{Int64, Float64})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:929
 [10] (ODEProblem{true})(::ODESystem, ::Vector{Pair{Num, Int64}}, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:916
 [11] (ODEProblem{true})(::ODESystem, ::Vector{Pair{Num, Int64}}, ::Vararg{Any})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:915
...
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:912
 [13] ODEProblem(::ODESystem, ::Vector{Pair{Num, Int64}}, ::Vararg{Any})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:911
 [14] top-level scope
    @ c:\Users\aoife\Desktop\School\5 yr\Thesis\Julia\Thesis_code\heart_chambers.ipynb:7

I have done some quick searches and found this and this threads, but don’t quite understand the solutions they came to/they didn’t work in my case.

Any help is appreciated :slight_smile:

first comments:
parameters R_ao, C_ao, L_ao, ... are missing

you defined E = elastance(t, E_s, E_d, T, T_s1, T_s2) as parameter. But E is time-dependend, so it’s a variable + plus equation E ~ elastance(t, E_s, E_d, T, T_s1, T_s2)

What is the function of model Ventricle? Is it a kind of flow- or pressure-source. Not clear (for me).

Hi,

Sorry I forgot to include some of the parameters, they are as follows:

L_ao = 6.2e-5; C_ao = 0.08; R_ao = 0.003;
L_ar = 0.0017; C_ar = 1.6; R_ar = 0.05;
R_at = 0.5;
R_cp = 0.52;
C_vn = 20.5; R_vn = 0.075;

The Ventricle model is supposed to represent a pressure source. I changed the model to have elastance as a variable and equation:

@mtkmodel Ventricle begin
    @components begin
        in = Pin()
        out = Pin()
    end
    @variables begin
        p(t)
        V(t)
        E(t)
    end
    @parameters begin
        E_s = 2
        E_d = 1
        T = 60/72
        T_s1 = 0.25
        T_s2 = 0.5
        V0 = 5
        p0 = 1
        # E = elastance(t, E_s, E_d, T, T_s1, T_s2)
    end
    @equations begin
        E ~ elastance(t, E_s, E_d, T, T_s1, T_s2)
        0 ~ in.p - out.p
        p ~ in.p
        p ~ (V-V0)*E + p0
        D(V) ~ in.q + out.q
    end
end

but now the error looks like this:

ArgumentError: SymbolicUtils.BasicSymbolic{Real}[inductor_ao₊q(t), capacitor_ar₊Δp(t), inductor_ar₊q(t), capacitor_vn₊Δp(t), source₊Vˍt(t), source₊V(t)] are missing from the variable map.

Stacktrace:
  [1] throw_missingvars(vars::Vector{SymbolicUtils.BasicSymbolic{Real}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\variables.jl:122
  [2] _varmap_to_vars(varmap::Dict{Num, Int64}, varlist::Vector{SymbolicUtils.BasicSymbolic{Real}}; defaults::Dict{Any, Any}, check::Bool, toterm::typeof(ModelingToolkit.default_toterm))
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\variables.jl:116
  [3] varmap_to_vars(varmap::Vector{Pair{Num, Int64}}, varlist::Vector{Any}; defaults::Dict{Any, Any}, check::Bool, toterm::Function, promotetoconcrete::Nothing, tofloat::Bool, use_union::Bool)
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\variables.jl:85
  [4] get_u0_p(sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, parammap::SciMLBase.NullParameters; use_union::Bool, tofloat::Bool, symbolic_u0::Bool)
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:786
  [5] get_u0_p
    @ C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:768 [inlined]
  [6] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, parammap::SciMLBase.NullParameters; implicit_dae::Bool, du0map::Nothing, version::Nothing, tgrad::Bool, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::Symbolics.SerialForm, eval_expression::Bool, use_union::Bool, tofloat::Bool, symbolic_u0::Bool, u0_constructor::typeof(identity), kwargs::Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:t, :has_difference, :check_length), Tuple{Int64, Bool, Bool}}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:811
  [7] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, tspan::Tuple{Int64, Float64}, parammap::SciMLBase.NullParameters; callback::Nothing, check_length::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:936
  [8] ODEProblem
    @ C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:929 [inlined]
  [9] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, tspan::Tuple{Int64, Float64})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:929
 [10] (ODEProblem{true})(::ODESystem, ::Vector{Pair{Num, Int64}}, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:916
 [11] (ODEProblem{true})(::ODESystem, ::Vector{Pair{Num, Int64}}, ::Vararg{Any})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:915
...
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:912
 [13] ODEProblem(::ODESystem, ::Vector{Pair{Num, Int64}}, ::Vararg{Any})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:911
 [14] top-level scope
    @ c:\Users\aoife\Desktop\School\5 yr\Thesis\Julia\Thesis_code\heart_chambers.ipynb:7

Thanks for your help!

next steps:

  • I used electrical components R,L,C, OnePort from ModelingToolkitStandardLibrary.Electrical
  • connectors of elements are named p,n with quantities i (=flow), v (=pressure)
  • find modified full model below:

using ModelingToolkit
using ModelingToolkitStandardLibrary.Electrical
using OrdinaryDiffEq

@parameters t
D = Differential(t)

L_ao = 6.2e-5; C_ao = 0.08; R_ao = 0.003;
L_ar = 0.0017; C_ar = 1.6; R_ar = 0.05;
R_at = 0.5;
R_cp = 0.52;
C_vn = 20.5; R_vn = 0.075;


"""
    Inputs:
    t       Time relative to t=0
    E_s     Maximum elastance of chamber during systole
    E_d     Minimum elastance of chamber during diastole
    T       Period of cardiac cycle
    T_s1    Time of systolic phase peak relative to start of cycle
    T_s2    Time of end of systolic phase relative to start of cycle
"""
function elastance(t, E_s, E_d, T, T_s1, T_s2)
    # Find current time relative to start of current cycle
    t_pulse = rem(t,T);
    # Elastance activation function
    e = (t_pulse < T_s1) * cos((t_pulse*pi)/T_s1) +
        (t_pulse >= T_s1) * (t_pulse < T_s1) * cos(((t_pulse+T_s2-T_s1)*pi)/T_s1) +
        (t_pulse >= T_s2) * (t_pulse < T) * 0
    # Elastance
    E = E_d + (E_s-E_d)*e/2
    return E
end


@mtkmodel VentricleMod begin
    @extend v, i = oneport = OnePort()
    @variables begin
        V(t)
        E(t)
    end
    @parameters begin
        E_s = 2
        E_d = 1
        T = 60/72
        T_s1 = 0.25
        T_s2 = 0.5
        V0 = 5
        p0 = 1
    end
    @equations begin
        E ~ elastance(t, E_s, E_d, T, T_s1, T_s2)
        v ~ (V-V0)*E + p0
        D(V) ~ i
    end
end



@named source = VentricleMod()
@named ground = Ground()
# Aorta
@named resistor_ao = Resistor(R = R_ao)
@named capacitor_ao = Capacitor(C = C_ao)
@named inductor_ao = Inductor(L = L_ao)
# Arteries
@named resistor_ar = Resistor(R = R_ar)
@named capacitor_ar = Capacitor(C = C_ar)
@named inductor_ar = Inductor(L = L_ar)
# Artioles
@named resistor_at = Resistor(R = R_at)
# Capilliaries
@named resistor_cp = Resistor(R = R_cp)
# Veins
@named resistor_vn = Resistor(R = R_vn)
@named capacitor_vn = Capacitor(C = C_vn)


connections = [
        connect(source.p, inductor_ao.n, capacitor_ao.n)
        connect(capacitor_ao.p, ground.g)
        connect(inductor_ao.p, resistor_ao.n)
        connect(resistor_ao.p, inductor_ar.n, capacitor_ar.n)
        connect(capacitor_ar.p, ground.g)
        connect(inductor_ar.p, resistor_ar.n)
        connect(resistor_ar.p, resistor_at.n)
        connect(resistor_at.p, resistor_cp.n)
        connect(resistor_cp.p, resistor_vn.n, capacitor_vn.n)
        connect(resistor_vn.p, capacitor_vn.p, ground.g)
        connect(source.n, ground.g)     ]


@named systemic_circulation_model = ODESystem(connections, t,
    systems = [
        source,
        ground,
        resistor_ao, capacitor_ao, inductor_ao,
        resistor_ar, capacitor_ar, inductor_ar,
        resistor_at,
        resistor_cp,
        resistor_vn, capacitor_vn,      ])


sys = structural_simplify(systemic_circulation_model)


u0 = [  inductor_ao.i => 0.0   # should be updated
        capacitor_ar.v => 0.0
        inductor_ar.i => 0.0
        capacitor_vn.v => 0.0
        capacitor_ao.n.v => 0.0
        source.V => 0.0
        capacitor_ao.i  => 0.0   ]

prob = ODEProblem(sys, u0, (0, 50.0))
# sol= solve(prob, Tsit5(), reltol=1e-6)

VentricleMod in your definition is a kind of variable capacitor, which is connected to capacitor Cao . This cannot work.
Do you have a description of the physical model of Ventricle to find another way?

Hi,

Thanks for getting back to me, and sorry for the delay in reply! I have tried to simplify my problem a lot to get to the root of the issue, and am now just trying to solve the following model:

My code is as follows, with Δp representing pressure (or voltage), and q representing bloodflow (or current).

My code is as follows:

using ModelingToolkit
using Plots
using DifferentialEquations

@variables t
D = Differential(t)

@connector Pin begin
    p(t)
    q(t), [connect = Flow]
end

@mtkmodel Ground begin
    @components begin
        g = Pin()
    end
    @equations begin
        g.p ~ 0
    end
end

@mtkmodel OnePort begin
    @components begin
        in = Pin()
        out = Pin()
    end
    @variables begin
        Δp(t)
        q(t)
    end
    @equations begin
        Δp ~ out.p - in.p
        0 ~ in.q + out.q
        q ~ in.q
    end
end

@mtkmodel Resistor begin
    @extend OnePort()
    @parameters begin
        R = 1.0 # Sets the default resistance
    end
    @equations begin
        Δp ~ -q * R
    end
end

@mtkmodel Capacitor begin
    @extend OnePort()
    @parameters begin
        C = 1.0
    end
    @equations begin
        D(Δp) ~ -q / C
    end
end

@mtkmodel Inductor begin
    @extend OnePort()
    @parameters begin
        L = 1.0
    end
    @equations begin
        D(q) ~ -Δp / L
    end
end

@mtkmodel DrivenPressure begin
    @extend OnePort()
    @parameters begin
        P = 1.0
    end
    @equations begin
        Δp ~ P * pressure_flow(t)
    end
end

# Valves (diode-like behaviour)

@mtkmodel ResistorDiode begin
    @extend OnePort()
    @parameters begin
        R = 1.0
    end
    @equations begin
        q ~ Δp / R * (Δp<0)
    end
end

function pressure_flow(t)
    pressureflow = 20*sin(2*π*t/B)+100
    return pressureflow
end

@mtkmodel WK3model begin
    @components begin
        resistor_p = Resistor(R = 0.9)
        resistor_c = Resistor(R = 0.05)
        capacitor = Capacitor(C = 1.1)
        diode = ResistorDiode(R = 0.01)
        source = DrivenPressure(P = 1.0)
        ground = Ground()
    end
    @equations begin
        connect(source.out, resistor_c.in)
        connect(resistor_c.out, resistor_p.in, capacitor.in)
        connect(resistor_p.out, capacitor.out, diode.in)
        connect(diode.out, ground.g, source.in)
    end
end

@mtkbuild wk3model = WK3model()
u0 = [
    wk3model.capacitor.Δp => -78
]
prob = ODEProblem(wk3model, u0, (0, 6.0))
sol_3_elem = solve(prob, RK4(), reltol=1e-6)

The model works when no diode is present, but when I introduce the diode, I get the following error:

ArgumentError: SymbolicUtils.BasicSymbolic{Real}[diode₊q(t)] are missing from the variable map.

Stacktrace:
  [1] throw_missingvars(vars::Vector{SymbolicUtils.BasicSymbolic{Real}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\variables.jl:122
  [2] _varmap_to_vars(varmap::Dict{Num, Int64}, varlist::Vector{SymbolicUtils.BasicSymbolic{Real}}; defaults::Dict{Any, Any}, check::Bool, toterm::typeof(ModelingToolkit.default_toterm))
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\variables.jl:116
  [3] varmap_to_vars(varmap::Vector{Pair{Num, Int64}}, varlist::Vector{Any}; defaults::Dict{Any, Any}, check::Bool, toterm::Function, promotetoconcrete::Nothing, tofloat::Bool, use_union::Bool)
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\variables.jl:85
  [4] get_u0_p(sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, parammap::SciMLBase.NullParameters; use_union::Bool, tofloat::Bool, symbolic_u0::Bool)
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:786
  [5] get_u0_p
    @ C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:768 [inlined]
  [6] process_DEProblem(constructor::Type, sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, parammap::SciMLBase.NullParameters; implicit_dae::Bool, du0map::Nothing, version::Nothing, tgrad::Bool, jac::Bool, checkbounds::Bool, sparse::Bool, simplify::Bool, linenumbers::Bool, parallel::Symbolics.SerialForm, eval_expression::Bool, use_union::Bool, tofloat::Bool, symbolic_u0::Bool, u0_constructor::typeof(identity), kwargs::Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:t, :has_difference, :check_length), Tuple{Int64, Bool, Bool}}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:811
  [7] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, tspan::Tuple{Int64, Float64}, parammap::SciMLBase.NullParameters; callback::Nothing, check_length::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:936
  [8] ODEProblem
    @ C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:929 [inlined]
  [9] (ODEProblem{true, SciMLBase.AutoSpecialize})(sys::ODESystem, u0map::Vector{Pair{Num, Int64}}, tspan::Tuple{Int64, Float64})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:929
 [10] (ODEProblem{true})(::ODESystem, ::Vector{Pair{Num, Int64}}, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:916
 [11] (ODEProblem{true})(::ODESystem, ::Vector{Pair{Num, Int64}}, ::Vararg{Any})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:915
...
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:912
 [13] ODEProblem(::ODESystem, ::Vector{Pair{Num, Int64}}, ::Vararg{Any})
    @ ModelingToolkit C:\Users\aoife\.julia\packages\ModelingToolkit\oIgbi\src\systems\diffeqs\abstractodesystem.jl:911
 [14] top-level scope
    @ c:\Users\aoife\Desktop\School\5 yr\Thesis\Julia\Thesis_code\heart_chambers.ipynb:5```

I want the diode to act as a resistpor when the pressure difference across it is negative.

Any help is appreciated again!

Thanks