Closed jbolorinos closed 2 years ago
Hi @jbolorinos , thanks for posting this issue! The problem actually comes from one of QSDsan's dependent package (BioSTEAM), it removed the _islinked
property at a certain point.
Can you try to install the following versions: biosteam==2.32.6, thermosteam==0.28.8? It worked on my end, let me know if you still run into problems!
Thanks @yalinli2!
I installed those versions of biosteam and thermosteam and now, when I run the first line:
ins1 = qs.WasteStream(H2O=100)
I get the following:
`--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) Input In [7], in <cell line: 5>() 1 # Make three random influents, I'm deliberately using different ways to make these streams 2 # as a recap previous tutorials 3 4 # Method 1: by directly providing the flow rates of select components ----> 5 ins1 = qs.WasteStream(H2O=100)
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/qsdsan/_waste_stream.py:276, in WasteStream.init(self, ID, flow, phase, T, P, units, price, thermo, pH, SAlk, COD, BOD, uBOD, ThOD, cnBOD, TC, TOC, TN, TKN, TP, TK, TMg, TCa, dry_mass, charge, ratios, stream_impact_item, component_flows) 269 def init(self, ID='', flow=(), phase='l', T=298.15, P=101325., 270 units='kg/hr', price=0., thermo=None, 271 pH=7., SAlk=2.5, COD=None, BOD=None, uBOD=None, (...) 274 TMg=None, TCa=None, dry_mass=None, charge=None, ratios=None, 275 stream_impact_item=None, component_flows): --> 276 SanStream.init(self=self, ID=ID, flow=flow, phase=phase, T=T, P=P, 277 units=units, price=price, thermo=thermo, 278 stream_impact_item=stream_impact_item, **component_flows) 280 self._init_ws(pH, SAlk, COD, BOD, uBOD, TC, TOC, TN, TKN, 281 TP, TK, TMg, TCa, ThOD, cnBOD, dry_mass, charge, ratios)
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/qsdsan/_sanstream.py:59, in SanStream.init(self, ID, flow, phase, T, P, units, price, thermo, stream_impact_item, component_flows)
56 if 'impact_item' in component_flows.keys():
57 raise ValueError('The keyword impact_item
is deprecated, '
58 'please use stream_impact_item
instead.')
---> 59 super().init(ID=ID, flow=flow, phase=phase, T=T, P=P,
60 units=units, price=price, thermo=thermo,
61 component_flows)
62 if stream_impact_item:
63 stream_impact_item._linked_stream = self
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/thermosteam/_stream.py:270, in Stream.init(self, ID, flow, phase, T, P, units, price, total_flow, thermo, characterization_factors, **chemical_flows) 268 self.characterization_factors = {} if characterization_factors is None else {} 269 self._thermal_condition = tmo.ThermalCondition(T, P) --> 270 thermo = self._load_thermo(thermo) 271 chemicals = thermo.chemicals 272 self.price = price
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/thermosteam/utils/decorators/thermo_user.py:22, in _load_thermo(self, thermo) 21 def _load_thermo(self, thermo): ---> 22 self._thermo = thermo = tmo.settings.get_default_thermo(thermo) 23 return thermo
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/thermosteam/_settings.py:74, in Settings.get_default_thermo(self, thermo)
68 def get_default_thermo(self, thermo):
69 """
70 Return default Thermo object if thermo
is None. Otherwise, return
71 the same object.
72
73 """
---> 74 return thermo if thermo else self.get_thermo()
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/thermosteam/_settings.py:130, in Settings.get_thermo(self) 128 """Return a default Thermo object.""" 129 thermo = self._thermo --> 130 if not thermo: raise_no_thermo_error() 131 return thermo
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/thermosteam/_settings.py:16, in raise_no_thermo_error() 15 def raise_no_thermo_error(): ---> 16 raise RuntimeError("no available 'Thermo' object; " 17 "use settings.set_thermo")
RuntimeError: no available 'Thermo' object; use settings.set_thermo
`
I get the same error if I use qsdsan 0.3.5
Hi @jbolorinos , the issue comes exactly from what the message says - you'll need to set the CompiledComponents
object so that QSDsan knows what components you'll want to work with in the system (only including the components you want helps speed things up), see the note in Cell 3 in the WasteStream
tutorial
is it possible that you didn't run Cell 11 (specifically, the qs.set_thermo(cmps)
line)?
BTW, we'll start up the weekly QSDsan office hour soon (Mondays 4-5pm CT, either the coming Monday or the Monday after), we will send out a group email once we schedule it, I can make sure you get the notice if you are interested :)
If you want help before that, we can have a Zoom call this week, just let me know!
Hi @yalinli2,
Yes it was exactly that (apologies), forgot to run that line after restarting my notebook kernel. Got it working with qsdsan==1.2.0, biosteam==2.32.6 and thermosteam==0.28.8.
Really appreciate the help! And I would definitely be interested in getting the office hours notice (intend to use QSDSAN for my research), email is jbolorin@stanford.edu
@jbolorinos sure thing! I just added you to QSDsan's newsletter group (feel free to unsubscribe whenever you want :) ) so you'll get important updates. We should send out the announcement before/during the weekend.
I'll close this issue since you got things working, but feel free to reopen/post new ones!
Hello,
I was going through this QSDSAN tutorial and am trying to run the following:
`
# Make three random influents, I'm deliberately using different ways to make these streams # as a recap previous tutorials
# Method 1: by directly providing the flow rates of select components ins1 = qs.WasteStream(H2O=100)
# Method 2: using
copy
and adjust flow rates later ins2 = ins1.copy() ins2.imol['X_GAO_Gly'] = ins2.imol['X_GAO_PHA'] = 0.01# Method 3: using default models ins3 = qs.WasteStream.codstates_inf_model('', flow_tot=50)
# Use a shorthand to make our lives easier su = qs.sanunits
# This is the actual line used to initialize the instance, # and we can pass the influents through the
ins
argument M1 = su.Mixer(ins=(ins3)) `I am getting the following error:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [22], in <cell line: 19>() 15 su = qs.sanunits 17 # This is the actual line used to initialize the instance, 18 # and we can pass the influents through the
ins` argument ---> 19 M1 = su.Mixer(ins=(ins3))File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/qsdsan/sanunits/_abstract.py:48, in Mixer.init(self, ID, ins, outs, thermo, init_with, F_BM_default, isdynamic, rigorous) 45 def init(self, ID='', ins=None, outs=(), thermo=None, 46 init_with='WasteStream', F_BM_default=None, isdynamic=False, 47 rigorous=False): ---> 48 SanUnit.init(self, ID, ins, outs, thermo, init_with, 49 F_BM_default=F_BM_default, isdynamic=isdynamic) 50 self.rigorous = rigorous
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/qsdsan/_sanunit.py:161, in SanUnit.init(self, ID, ins, outs, thermo, init_with, construction, transportation, equipments, add_OPEX, uptime_ratio, lifetime, F_BM_default, isdynamic, **kwargs) 159 self._init_with = init_with 160 self._init_ins(ins, init_with) --> 161 self._init_outs(outs, init_with) 162 self._init_utils() 163 self._init_results()
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/qsdsan/_sanunit.py:256, in SanUnit._init_outs(self, outs, init_with) 254 def _init_outs(self, outs, init_with): 255 super()._init_outs(outs) --> 256 converted, missing = self._convert_stream(outs, self.outs, init_with, 'outs') 257 _outs = self._outs = Outlets(self, self._N_outs, converted, self._thermo, 258 self._outs_size_is_fixed, self._stacklevel) 259 _replace_missing_streams(_outs, missing)
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/qsdsan/_sanunit.py:217, in SanUnit._convert_stream(self, strm_inputs, streams, init_with, ins_or_outs) 215 converted.append(SanStream.from_stream(SanStream, s)) 216 else: --> 217 converted.append(WasteStream.from_stream(WasteStream, s)) 219 diff = len(converted) + len(missing) - len(streams) 220 if diff != 0:
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/qsdsan/_waste_stream.py:359, in WasteStream.from_stream(cls, stream, ID, **kwargs) 356 return new 358 # An actual stream --> 359 new = SanStream.from_stream(cls, stream, ID) 360 for attr, val in kwargs.items(): 361 setattr(new, attr, val)
File ~/.local/share/virtualenvs/energy_inflows-sTQfUhBs/lib/python3.9/site-packages/qsdsan/_sanstream.py:344, in SanStream.from_stream(cls, stream, ID, **kwargs) 341 new_ID = '' 342 new.init(ID=new_ID) --> 344 new._islinked = stream._islinked 346 source = new._source = stream._source 347 if source:
AttributeError: 'Stream' object has no attribute '_islinked'
`
I am using version 1.1.4. Maybe this is a bug in the newest version? Should I use an older version while it is being fixed?
Thank you!