Modelling simple hydraulic using MTK Library

Hi everyone,

I’ll appreciate an advice on how to split fluid flow using MTK Standard Library.
Volume1 (pressured) connected to tube1. Tube1 connected to tube2 and tube3. tube2 and tube3 connected to empty volumes 2 and 3 respectively.

systems = @named begin
    fluid = HydraulicFluid(density = 876, bulk_modulus = 1.2e9, viscosity = 0.034)
    volume1 = FixedVolume(p_int = 1000, vol = 10.0)
    volume2 = FixedVolume(p_int = 0, vol = 10.0)
    volume3 = FixedVolume(p_int = 0, vol = 10.0)
    tube1 = Tube(1, false; p_int = 0, area = 0.01, length = 500.0)
    tube2 = Tube(1, false; p_int = 0, area = 0.01, length = 500.0)
    tube3 = Tube(1, false; p_int = 0, area = 0.01, length = 500.0)
  end

 eqs = [
  connect(volume1.port, tube1.port_a)
  connect(tube1.port_b, tube2.port_a)
  connect(tube1.port_b, tube3.port_a)
  connect(tube2.port_b, volume2.port)
  connect(tube3.port_b, volume3.port)
  connect(volume1.port, fluid)
]

@named model = ODESystem(eqs, t, systems=systems)

sys = structural_simplify(model)

prob = ODEProblem(sys, [], (0,20));

sol = solve(prob, QBDF())

Now it gives an Error on solver:

 Warning: Potential Rank Deficient Matrix Detected. Attempting to solve using Pivoted QR Factorization.
└ @ NonlinearSolve 
retcode: InitialFailure
Interpolation: 3rd order Hermite
t: 1-element Vector{Float64}:
 0.0
u: 1-element Vector{Vector{Float64}}:
 [876.0007299999999, 876.0, 876.0, 1000.0, 0.0, 0.0, 0.03411099676834439, 0.034110936294946145]

Thank you!

1 Like