|
45 | 45 | # 1516
|
46 | 46 | let
|
47 | 47 | @connector function Fluid_port(; name, p = 101325.0, m = 0.0, T = 293.15)
|
48 |
| - sts = @variables p(t) [guess=p] m(t) [guess = m, connect = Flow] T(t) [guess=T, connect = Stream] |
| 48 | + sts = @variables p(t) [guess = p] m(t) [guess = m, connect = Flow] T(t) [ |
| 49 | + guess = T, connect = Stream] |
49 | 50 | ODESystem(Equation[], t, sts, []; name = name)
|
50 | 51 | end
|
51 |
| - |
| 52 | + |
52 | 53 | #this one is for latter
|
53 | 54 | @connector function Heat_port(; name, Q = 0.0, T = 293.15)
|
54 |
| - sts = @variables T(t) [guess=T] Q(t) [guess = Q, connect = Flow] |
| 55 | + sts = @variables T(t) [guess = T] Q(t) [guess = Q, connect = Flow] |
55 | 56 | ODESystem(Equation[], t, sts, []; name = name)
|
56 | 57 | end
|
57 |
| - |
| 58 | + |
58 | 59 | # like ground but for fluid systems (fluid_port.m is expected to be zero in closed loop)
|
59 | 60 | function Compensator(; name, p = 101325.0, T_back = 273.15)
|
60 | 61 | @named fluid_port = Fluid_port()
|
|
63 | 64 | fluid_port.T ~ T_back]
|
64 | 65 | compose(ODESystem(eqs, t, [], ps; name = name), fluid_port)
|
65 | 66 | end
|
66 |
| - |
| 67 | + |
67 | 68 | function Source(; name, delta_p = 100, T_feed = 293.15)
|
68 | 69 | @named supply_port = Fluid_port() # expected to feed connected pipe -> m<0
|
69 | 70 | @named return_port = Fluid_port() # expected to receive from connected pipe -> m>0
|
|
74 | 75 | return_port.T ~ T_feed]
|
75 | 76 | compose(ODESystem(eqs, t, [], ps; name = name), [supply_port, return_port])
|
76 | 77 | end
|
77 |
| - |
| 78 | + |
78 | 79 | function Substation(; name, T_return = 343.15)
|
79 | 80 | @named supply_port = Fluid_port() # expected to receive from connected pipe -> m>0
|
80 | 81 | @named return_port = Fluid_port() # expected to feed connected pipe -> m<0
|
|
85 | 86 | return_port.T ~ T_return]
|
86 | 87 | compose(ODESystem(eqs, t, [], ps; name = name), [supply_port, return_port])
|
87 | 88 | end
|
88 |
| - |
| 89 | + |
89 | 90 | function Pipe(; name, L = 1000, d = 0.1, N = 100, rho = 1000, f = 1)
|
90 | 91 | @named fluid_port_a = Fluid_port()
|
91 | 92 | @named fluid_port_b = Fluid_port()
|
92 | 93 | ps = @parameters L=L d=d rho=rho f=f N=N
|
93 |
| - sts = @variables v(t) [guess=0.0] dp_z(t) [guess=0.0] |
| 94 | + sts = @variables v(t) [guess = 0.0] dp_z(t) [guess = 0.0] |
94 | 95 | eqs = [fluid_port_a.m ~ -fluid_port_b.m
|
95 | 96 | fluid_port_a.T ~ instream(fluid_port_a.T)
|
96 | 97 | fluid_port_b.T ~ fluid_port_a.T
|
|
114 | 115 | connect(return_pipe.fluid_port_a, source.return_port)]
|
115 | 116 | compose(ODESystem(eqs, t, [], ps; name = name), subs)
|
116 | 117 | end
|
117 |
| - |
| 118 | + |
118 | 119 | @named system = System(L = 10)
|
119 | 120 | @unpack supply_pipe, return_pipe = system
|
120 | 121 | sys = structural_simplify(system)
|
|
125 | 126 | prob1 = ODEProblem(sys, [], (0.0, 10.0), [], guesses = u0)
|
126 | 127 | prob2 = ODEProblem(sys, [], (0.0, 10.0), [], guesses = u0)
|
127 | 128 | prob3 = DAEProblem(sys, D.(unknowns(sys)) .=> 0.0, u0, (0.0, 10.0), [])
|
128 |
| - @test solve(prob1, FBDF()).retcode == ReturnCode.Success |
| 129 | + @test solve(prob1, FBDF()).retcode == ReturnCode.Success |
129 | 130 | #@test solve(prob2, FBDF()).retcode == ReturnCode.Success
|
130 | 131 | @test solve(prob3, DFBDF()).retcode == ReturnCode.Success
|
131 | 132 | end
|
|
0 commit comments