# Modelling simple hydraulic using MTK Library

**URL:** <https://discourse.julialang.org/t/modelling-simple-hydraulic-using-mtk-library/118028>\
**Category:** Modelling & Simulations\
**Tags:** question, sciml, modelingtoolkit\
**Created:** [August 10, 2024, 1:34pm UTC](https://discourse.julialang.org/t/modelling-simple-hydraulic-using-mtk-library/118028 "2024-08-10T13:34:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![romantimo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/romantimo/32/46841_2.png) [@romantimo](https://discourse.julialang.org/u/romantimo)\
**Post date:** [August 10, 2024, 1:34pm UTC](https://discourse.julialang.org/t/modelling-simple-hydraulic-using-mtk-library/118028/1 "2024-08-10T13:34:04Z")

</div>

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.

```julia
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:

```julia
 Warning: Potential Rank Deficient Matrix Detected. Attempting to solve using Pivoted QR Factorization.
└ @ NonlinearSolve 

```

```julia
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!
