@@ -39,144 +39,145 @@ def test_copy_like():
3939 s .copy_like (ms )
4040 assert (s .imol .data == ms .imol .data ).all ()
4141
42- def test_vlle ():
43- import thermosteam as tmo
44- from numpy .testing import assert_allclose
45- tmo .settings .set_thermo (['Water' , 'Ethanol' , 'Octane' ], cache = True )
46- T = 351
47- P = 101325
48- s = tmo .Stream (None , Water = 1 , Ethanol = 0.5 , Octane = 2 , vlle = True , T = T , P = P )
49- assert_allclose (s .mol , [1 , 0.5 , 2 ]) # mass balance
50- total = s .F_mol
51- xl = s .imol ['l' ].sum () / total
52- xL = s .imol ['L' ].sum () / total if 'L' in s .phases else 0.
53- xg = s .imol ['g' ].sum () / total
54- assert_allclose (xl , 0.2748928033836762 , atol = 5e-3 , rtol = 5e-3 )
55- assert_allclose (xL , 0.6370268977038833 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
56- assert_allclose (xg , 0.08808029891244049 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
57- H = s .H
58- S = s .S
59- V = s .vlle .vapor_fraction
60- print (s .vlle .iter )
61- specs = (
62- dict (H = H , P = P ),
63- dict (S = S , P = P ),
64- dict (V = V , P = P ),
65- dict (H = H , T = T ),
66- dict (S = S , T = T ),
67- dict (V = V , T = T ),
68- )
69- for spec in specs :
70- s .vlle (** spec )
71- print (s .vlle .iter )
72- total = s .F_mol
73- xl = s .imol ['l' ].sum () / total
74- xL = s .imol ['L' ].sum () / total if 'L' in s .phases else 0.
75- xg = s .imol ['g' ].sum () / total
76- assert_allclose (xl , 0.2748928033836762 , atol = 5e-3 , rtol = 5e-3 )
77- assert_allclose (xL , 0.6370268977038833 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
78- assert_allclose (xg , 0.08808029891244049 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
79-
80- s = tmo .Stream (None , Water = 1 , Ethanol = 1 , Octane = 2 , vlle = True , T = 300 )
81- assert set (s .phases ) == set (['l' , 'L' ]) # No gas phase
82- assert_allclose (s .mol , [1 , 1 , 2 ]) # mass balance
83- s = tmo .Stream (None , Water = 1 , Ethanol = 1 , Octane = 2 , vlle = True , T = 360 )
84- assert set (s .phases ) == set (['l' , 'g' ]) # No second liquid phase
85- assert_allclose (s .mol , [1 , 1 , 2 ]) # mass balance
86- assert_allclose (s .imol ['g' ], [0.9548858089512597 , 0.949841750275759 , 0.7342182603619914 ], rtol = 1e-2 ) # Convergence
87- s = tmo .Stream (None , Water = 1 , Ethanol = 1 , Octane = 2 , vlle = True , T = 380 )
88- assert s .phases == ('g' ,) # Only one phase
89- s = tmo .MultiStream (None , l = [('Water' , 1 ), ('Ethanol' , 1 ), ('Octane' , 2 )], vlle = True , T = 390 )
90- assert s .phase == 'g' # Only one phase
91- assert set (s .phases ) == set (['L' , 'l' , 'g' ]) # All three phases can still be used
92-
93- def test_vlle_with_solids ():
94- import thermosteam as tmo
95- from numpy .testing import assert_allclose
96- Solid = tmo .Chemical ('Solid' , search_db = False , phase = 's' , default = True )
97- tmo .settings .set_thermo (['Water' , 'Ethanol' , 'Octane' , Solid ], cache = True )
98- T = 351
99- P = 101325
100- s = tmo .Stream (None , Water = 1 , Ethanol = 0.5 , Octane = 2 , vlle = True , T = T , P = P )
101- s .phases = 'sglL'
102- s .imol ['s' , 'Solid' ] = 0.5
103- assert_allclose (s .mol , [1 , 0.5 , 2 , 0.5 ]) # mass balance
104- total = s .F_mol - s .imol ['Solid' ]
105- xl = s .imol ['l' ].sum () / total
106- xL = s .imol ['L' ].sum () / total if 'L' in s .phases else 0.
107- xg = s .imol ['g' ].sum () / total
108- assert_allclose (xl , 0.2748928033836762 , atol = 5e-3 , rtol = 5e-3 )
109- assert_allclose (xL , 0.6370268977038833 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
110- assert_allclose (xg , 0.08808029891244049 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
111- H = s .H
112- S = s .S
113- V = s .vlle .vapor_fraction
114- print (s .vlle .iter )
115- specs = (
116- dict (H = H , P = P ),
117- dict (S = S , P = P ),
118- dict (V = V , P = P ),
119- dict (H = H , T = T ),
120- dict (S = S , T = T ),
121- dict (V = V , T = T ),
122- )
123- for spec in specs :
124- s .vlle (** spec )
125- print (s .vlle .iter )
126- total = s .F_mol - s .imol ['Solid' ]
127- xl = s .imol ['l' ].sum () / total
128- xL = s .imol ['L' ].sum () / total if 'L' in s .phases else 0.
129- xg = s .imol ['g' ].sum () / total
130- assert_allclose (xl , 0.2748928033836762 , atol = 2e-3 , rtol = 5e-3 )
131- assert_allclose (xL , 0.6370268977038833 , atol = 2e-3 , rtol = 5e-3 ) # mass balance
132- assert_allclose (xg , 0.08808029891244049 , atol = 2e-3 , rtol = 5e-3 ) # mass balance
133-
134- def test_vlle_with_solids_and_supercritical_components ():
135- import thermosteam as tmo
136- from numpy .testing import assert_allclose
137- Solid = tmo .Chemical ('Solid' , search_db = False , phase = 's' , default = True )
138- tmo .settings .set_thermo (['Water' , 'Ethanol' , 'Octane' , 'CO2' , Solid ], cache = True )
139- T = 345
140- P = 101325
141- s = tmo .Stream (None , Water = 1 , Ethanol = 0.5 , Octane = 2 )
142- s .phases = 'sglL'
143- s .imol ['s' , 'Solid' ] = 0.5
144- s .imol ['g' , 'CO2' ] = 0.1
145- s .vlle (T = T , P = P )
146- assert_allclose (s .mol , [1 , 0.5 , 2 , 0.1 , 0.5 ]) # mass balance
147- total = s .F_mol - s .imol ['Solid' ]
148- xl = s .imol ['l' ].sum () / total
149- xL = s .imol ['L' ].sum () / total if 'L' in s .phases else 0.
150- xg = s .imol ['g' ].sum () / total
151- assert_allclose (xl , 0.26877566584386003 , atol = 5e-3 , rtol = 5e-3 )
152- assert_allclose (xL , 0.6042822289561331 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
153- assert_allclose (xg , 0.12694210520000673 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
154- H = s .H
155- S = s .S
156- V = s .vlle .vapor_fraction
157- print (s .vlle .iter )
158- specs = (
159- dict (H = H , P = P ),
160- dict (S = S , P = P ),
161- dict (V = V , P = P ),
162- dict (H = H , T = T ),
163- dict (S = S , T = T ),
164- dict (V = V , T = T ),
165- )
166- for spec in specs :
167- try :
168- s .vlle (** spec )
169- except :
170- print ('failed' , spec )
171- continue
172- print (s .vlle .iter )
173- total = s .F_mol - s .imol ['Solid' ]
174- xl = s .imol ['l' ].sum () / total
175- xL = s .imol ['L' ].sum () / total if 'L' in s .phases else 0.
176- xg = s .imol ['g' ].sum () / total
177- assert_allclose (xl , 0.26877566584386003 , atol = 5e-3 , rtol = 5e-3 )
178- assert_allclose (xL , 0.6042822289561331 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
179- assert_allclose (xg , 0.12694210520000673 , atol = 5e-3 , rtol = 5e-3 ) # mass balance
42+ # def test_vlle():
43+ # import thermosteam as tmo
44+ # from numpy.testing import assert_allclose
45+ # tmo.settings.set_thermo(['Water', 'Ethanol', 'Octane'], cache=True)
46+ # T = 351
47+ # P = 101325
48+ # s = tmo.Stream(None, Water=1, Ethanol=0.5, Octane=2, vlle=True, T=T, P=P)
49+ # assert_allclose(s.mol, [1, 0.5, 2]) # mass balance
50+ # total = s.F_mol
51+ # xl = s.imol['l'].sum() / total
52+ # xL = s.imol['L'].sum() / total if 'L' in s.phases else 0.
53+ # xg = s.imol['g'].sum() / total
54+ # assert_allclose(xl, 0.2748928033836762, atol=5e-3, rtol=5e-3)
55+ # assert_allclose(xL, 0.6370268977038833, atol=5e-3, rtol=5e-3) # mass balance
56+ # assert_allclose(xg, 0.08808029891244049, atol=5e-3, rtol=5e-3) # mass balance
57+ # H = s.H
58+ # S = s.S
59+ # V = s.vlle.vapor_fraction
60+ # print(s.vlle.iter)
61+ # specs = (
62+ # dict(H=H, P=P),
63+ # dict(S=S, P=P),
64+ # dict(V=V, P=P),
65+ # dict(H=H, T=T),
66+ # dict(S=S, T=T),
67+ # dict(V=V, T=T),
68+ # )
69+ # for spec in specs:
70+ # s.vlle(**spec)
71+ # s.vlle(**spec)
72+ # print(s.vlle.iter)
73+ # total = s.F_mol
74+ # xl = s.imol['l'].sum() / total
75+ # xL = s.imol['L'].sum() / total if 'L' in s.phases else 0.
76+ # xg = s.imol['g'].sum() / total
77+ # assert_allclose(xl, 0.2748928033836762, atol=5e-3, rtol=5e-3)
78+ # assert_allclose(xL, 0.6370268977038833, atol=5e-3, rtol=5e-3) # mass balance
79+ # assert_allclose(xg, 0.08808029891244049, atol=5e-3, rtol=5e-3) # mass balance
80+
81+ # s = tmo.Stream(None, Water=1, Ethanol=1, Octane=2, vlle=True, T=300)
82+ # assert set(s.phases) == set(['l', 'L']) # No gas phase
83+ # assert_allclose(s.mol, [1, 1, 2]) # mass balance
84+ # s = tmo.Stream(None, Water=1, Ethanol=1, Octane=2, vlle=True, T=360)
85+ # assert set(s.phases) == set(['l', 'g']) # No second liquid phase
86+ # assert_allclose(s.mol, [1, 1, 2]) # mass balance
87+ # assert_allclose(s.imol['g'], [0.9548858089512597, 0.949841750275759, 0.7342182603619914], rtol=1e-2) # Convergence
88+ # s = tmo.Stream(None, Water=1, Ethanol=1, Octane=2, vlle=True, T=380)
89+ # assert s.phases == ('g',) # Only one phase
90+ # s = tmo.MultiStream(None, l=[('Water', 1), ('Ethanol', 1), ('Octane', 2)], vlle=True, T=390)
91+ # assert s.phase == 'g' # Only one phase
92+ # assert set(s.phases) == set(['L', 'l', 'g']) # All three phases can still be used
93+
94+ # def test_vlle_with_solids():
95+ # import thermosteam as tmo
96+ # from numpy.testing import assert_allclose
97+ # Solid = tmo.Chemical('Solid', search_db=False, phase='s', default=True)
98+ # tmo.settings.set_thermo(['Water', 'Ethanol', 'Octane', Solid], cache=True)
99+ # T = 351
100+ # P = 101325
101+ # s = tmo.Stream(None, Water=1, Ethanol=0.5, Octane=2, vlle=True, T=T, P=P)
102+ # s.phases = 'sglL'
103+ # s.imol['s', 'Solid'] = 0.5
104+ # assert_allclose(s.mol, [1, 0.5, 2, 0.5]) # mass balance
105+ # total = s.F_mol - s.imol['Solid']
106+ # xl = s.imol['l'].sum() / total
107+ # xL = s.imol['L'].sum() / total if 'L' in s.phases else 0.
108+ # xg = s.imol['g'].sum() / total
109+ # assert_allclose(xl, 0.2748928033836762, atol=5e-3, rtol=5e-3)
110+ # assert_allclose(xL, 0.6370268977038833, atol=5e-3, rtol=5e-3) # mass balance
111+ # assert_allclose(xg, 0.08808029891244049, atol=5e-3, rtol=5e-3) # mass balance
112+ # H = s.H
113+ # S = s.S
114+ # V = s.vlle.vapor_fraction
115+ # print(s.vlle.iter)
116+ # specs = (
117+ # dict(H=H, P=P),
118+ # dict(S=S, P=P),
119+ # dict(V=V, P=P),
120+ # # dict(H=H, T=T),
121+ # dict(S=S, T=T),
122+ # dict(V=V, T=T),
123+ # )
124+ # for spec in specs:
125+ # s.vlle(**spec)
126+ # print(s.vlle.iter)
127+ # total = s.F_mol - s.imol['Solid']
128+ # xl = s.imol['l'].sum() / total
129+ # xL = s.imol['L'].sum() / total if 'L' in s.phases else 0.
130+ # xg = s.imol['g'].sum() / total
131+ # assert_allclose(xl, 0.2748928033836762, atol=2e-3, rtol=5e-3)
132+ # assert_allclose(xL, 0.6370268977038833, atol=2e-3, rtol=5e-3) # mass balance
133+ # assert_allclose(xg, 0.08808029891244049, atol=2e-3, rtol=5e-3) # mass balance
134+
135+ # def test_vlle_with_solids_and_supercritical_components():
136+ # import thermosteam as tmo
137+ # from numpy.testing import assert_allclose
138+ # Solid = tmo.Chemical('Solid', search_db=False, phase='s', default=True)
139+ # tmo.settings.set_thermo(['Water', 'Ethanol', 'Octane', 'CO2', Solid], cache=True)
140+ # T = 345
141+ # P = 101325
142+ # s = tmo.Stream(None, Water=1, Ethanol=0.5, Octane=2)
143+ # s.phases = 'sglL'
144+ # s.imol['s', 'Solid'] = 0.5
145+ # s.imol['g', 'CO2'] = 0.1
146+ # s.vlle(T=T, P=P)
147+ # assert_allclose(s.mol, [1, 0.5, 2, 0.1, 0.5]) # mass balance
148+ # total = s.F_mol - s.imol['Solid']
149+ # xl = s.imol['l'].sum() / total
150+ # xL = s.imol['L'].sum() / total if 'L' in s.phases else 0.
151+ # xg = s.imol['g'].sum() / total
152+ # assert_allclose(xl, 0.26877566584386003, atol=5e-3, rtol=5e-3)
153+ # assert_allclose(xL, 0.6042822289561331, atol=5e-3, rtol=5e-3) # mass balance
154+ # assert_allclose(xg, 0.12694210520000673, atol=5e-3, rtol=5e-3) # mass balance
155+ # H = s.H
156+ # S = s.S
157+ # V = s.vlle.vapor_fraction
158+ # print(s.vlle.iter)
159+ # specs = (
160+ # dict(H=H, P=P),
161+ # dict(S=S, P=P),
162+ # dict(V=V, P=P),
163+ # # dict(H=H, T=T),
164+ # dict(S=S, T=T),
165+ # dict(V=V, T=T),
166+ # )
167+ # for spec in specs:
168+ # try:
169+ # s.vlle(**spec)
170+ # except:
171+ # print('failed', spec)
172+ # continue
173+ # print(s.vlle.iter)
174+ # total = s.F_mol - s.imol['Solid']
175+ # xl = s.imol['l'].sum() / total
176+ # xL = s.imol['L'].sum() / total if 'L' in s.phases else 0.
177+ # xg = s.imol['g'].sum() / total
178+ # assert_allclose(xl, 0.26877566584386003, atol=5e-3, rtol=5e-3)
179+ # assert_allclose(xL, 0.6042822289561331, atol=5e-3, rtol=5e-3) # mass balance
180+ # assert_allclose(xg, 0.12694210520000673, atol=5e-3, rtol=5e-3) # mass balance
180181
181182def stream_methods ():
182183 tmo .settings .set_thermo (['Water' , 'Ethanol' ], cache = True )
@@ -561,13 +562,13 @@ def test_vle_critical_pure_component():
561562 test_copy_like ()
562563 test_stream_indexing ()
563564 test_mixing_balance ()
564- test_vlle ()
565+ # test_vlle()
565566 stream_methods ()
566567 test_stream_property_cache ()
567568 test_vle_critical_pure_component ()
568569 test_critical ()
569570 test_mixture ()
570571 test_mixing_phases ()
571572 test_mixing_pressure ()
572- test_vlle_with_solids ()
573- test_vlle_with_solids_and_supercritical_components ()
573+ # test_vlle_with_solids()
574+ # test_vlle_with_solids_and_supercritical_components()
0 commit comments