Comments (6)
(Additional questions related to this thread)
I noticed biosteam has some cool functions - copylike and copyflow, which appeared in the units module in the cornstover biorefinery (e.g., when creating the PretreatmentReactorSystem
unit class, starting line 114):
I tried to use similar codes when creating the FakeTank unit:
This time, I got an error suggesting 'Outs' has no attribute 'copylike'
How should I use the copylike function?
Additionally, what does the "_linkedstreams = True" do? I added that line because that appears in cornstover codes, and I thought that could be used to link outs to ins.
Also, I noticed some codes used the "link_streams" function, what will this do?
As a summary to my above questions, what is the simplest way to make a unit that has the same outs as ins?
Thanks!!!
from biosteam.
(More questions related to this thread on the factories module)
I noticed some really cool codes the cornstover biorefinery used to batch-create units using the factories module of biosteam and an Excel spreadsheet:
Can you explain how this works? I couldn't really understand the raw codes in the factories module and additionally, I was baffled by the fact that/I wanted to know:
- Seems like not all units in the spreadsheet were used
- Only some units were created this way, was this intended to be a quick way for simple units?
- Is there anyway for me to check what units were created this way in the console?
Sorry I have a ton of questions... I tried to look at the tutorial but still couldn't figure these out. Let me know if the answers were somewhere in the tutorial , thanks!!!
from biosteam.
Nicee, its cool to see people trying to implement their own Unit subclass. Here is the explanation/fix to your bugs:
-
I noticed you replaced the
purchase_cost
andinstallation_cost
, these are not abstract properties. Best if you do not replace them! Your purchase/installation cost will be 0 anyways if you don't add any purchase costs to the_Cost
dictionary. -
Comment 1: BioSTEAM doesn't let you directly set
ins
orouts
because these are actually important objects that manage thesource
andsink
of Stream objects. The reference to the source and sink are what allow flowsheets to be created. You should use copylike instead (good job!). -
Comment 2: The
ins
andouts
attribute are actually lists of streams, so you would need to write:
...
def _run(self):
# Notice the commas
feed, = self.ins
effluent, = self.outs
# This should work
effluent.copylike(feed)
- About linked streams... The
_linkedstreams
attribute is deprecated, you might be looking at older versions of BioSTEAM. Thelink_streams
method ofStatic
unit operations makes the input and output stream share data on the flow rates. The_run
method inStatic
objects just copies T, P and phase from upstream to downstream, and the flow rates of both are always the same (so its faster!). Note that you can subclass fromStatic
and replace the_run
method, but the feed/effluent stream flow rates will always be linked. I'll use your fake tank as an example:
from biosteam import *
from biosteam.units.decorators import cost
# Create Unit subclass
@cost(basis='Flow rate', units='kg/hr', cost=0, CE=522, n=0.6)
class FakeTank(units.Static): pass
Now lets test it:
>>> Stream.species = Species('Water', 'Ethanol')
>>> feed = Stream('feed', Water=1, Ethanol=1)
>>> T1 = FakeTank('T1', ins=feed, outs='effluent')
>>> T1.show()
FakeTank: T1
ins...
[0] feed
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kmol/hr): Water 1
Ethanol 1
outs...
[0] effluent
phase: 'l', T: 298.15 K, P: 101325 Pa
flow (kmol/hr): Water 1
Ethanol 1
Also, notice that the flow rates are the same array:
>>> T1.ins[0].mol is T1.outs[0].mol
True
Hope this helps!
from biosteam.
Great! Now it works!
I found _linkedstream
in comment codes in biosteam BTW, so should have known it's not up to date
Only one thing, I do need to keep the line:
_N_outs = 1
Otherwise I will get two out streams and trigger an error when simulating the unit:
However I don't necessarily need to add:
_N_ins = 1
By adding a comma after feed/effluent, I can understand that two streams will be created for outs, but why there is only 1 ints? Is this because of some default setting?
Thanks!!!
from biosteam.
Ahh, yes, old commented code that shouldn't be there. Good catch, I'll remove it in the next BioSTEAM update.
As for the number of streams, I think you figured it out already:
>>> from biosteam import Unit
>>> Unit._N_ins
1
>>> Unit._N_outs
2
from biosteam.
Got it, thanks!!!
from biosteam.
Related Issues (20)
- High CAPEX cost at low pumping rates HOT 4
- Small error in `BoilerTurbogenerator` design cause negative work/cost HOT 2
- Negative water flows in permeate of AnMBR in high-rate WWT system HOT 4
- Notice: Moving to Python 3.11 in October
- AttributeError: 'Stream' object has no attribute 'indices' HOT 1
- Kinetic model does not take 't' into account HOT 1
- Unable to get graphic data like Diagrams and graphs HOT 1
- numba inlines biosteam.CE value into compiled code HOT 4
- Better batch design HOT 3
- Power consumption default in AeratedBioReactor needs more detail HOT 2
- Biogas upgrading HOT 1
- Depreciable capital in NPV calculation HOT 24
- Valve node has no label
- Unit z_mol_in and z_mol_out properties don't work
- Compressor type and adding Cooling Agent HOT 15
- Implement Blower as a Compressor type
- Include special-case utilities in utility worksheet.
- Sub class modelling of CSTR HOT 1
- Reactor duty for sub class modelling of CSTR
- Minor issues with high-rate WWT HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from biosteam.