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