Closed zasddsgg closed 1 month ago
Since the price only affects TEA, not mass/energy flows, we are setting the element to TEA.
In general, BioSTEAM looks at the the selection of the elements and decide how much of the system it needs to re-simulate in uncertainty analysis. If all the uncertain parameters are TEA-related, which means they don't affect mass/energy flows, we actually don't need to re-simulate the system at all, we only need to rerun the TEA with each set of inputs. So you can adjust the element setting to whichever you think make the most sense (i.e., including all the streams/units that you think will be affected by that particular parameter).
At the same time, if your uncertain parameter include the feedstock, then the entire system will be re-simulated anyway, so the element setting in the other parameters won't really impact the re-simulation scope.
Another thing that the element setting will affect is how the results are organized in the final dataframe - uncertain parameters under the same element will be grouped together.
Thank you for your answer. May I ask you the following questions. Thanks for your help. Wish you a good day.
a) For “So you can adjust the element setting to whichever you think make the most sense (i.e., including all the streams/units that you think will be affected by that particular parameter).”
, does Element refer to the affected unit or stream? Can there be more than one unit or stream in an Element (such as Element=unit1, unit2)?
b) For “At the same time, if your uncertain parameter include the feedstock, then the entire system will be re-simulated anyway, so the element setting in the other parameters won't really impact the re-simulation scope.”
, does the system need to be re-simulated every time an element is set in a parameter (except when element=TEA
)? So the element setting in the other parameters seem to also affect the range of new simulations (refer to the simulation for the element setting in the other parameters), not related to feedstock in uncertain parameter?
c) If the Monte Carlo simulation is set to 1000 times, is the system to be re-run for every element that is not TEA?
d) If there is no TEA element in 1000 Monte Carlo simulations, does that mean the system will run 1000 times?
e) For Element or kind setting, which determines whether the system should be re-simulated?
f) For @param(name='Feedstock flow rate', element=feedstock)
in https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L236,element did not choose TEA, does it because feedstock.mass
would affect the mass and energy balance?
g) For the top questions 2, 4 and 5, could I trouble you to look at them?
a. It can be either a unit or a stream, but you can just indicate one unit/stream. b. Each run in uncertainty analysis involves a new "simulation", the scope of the simulation (i.e., just a unit, or just TEA, or the entire system and TEA) depending on your setting of the elements. c. See answer above. d. Whether having TEA element or not doesn't affect whether mass/energy will be simulated or not. Because TEA doesn't affect mass/energy flow. e. Please read my previous replies. f. Yes. Top 2. I suggest you try different way of the settings, see if the results change as they should be, and make decisions. Top 3. Yes. Top 4. See my previous replies, R301 is simulated before R302, if I set the element to be R302, then R301 will not be resimulated. But if I set the element to be R301, then R302 will be resimulated since it's downstream of R301. But it makes no difference in that lactic acid model, because the model include feedstock mass flowrate as an uncertain parameter, which means everything downstream of the feedstock (i.e., the entire system) will be resimulated anyway.
Thank you for your answer.
a) For the scope of the simulation (i.e., just a unit), what does it mean that just a unit is re-simulated. If an element is a unit or a stream, are the units following the element also re-simulated?
b) Does Element refer to the first stream or unit that is affected by the parameter?
c) If the element is stream or unit, whether it's kind = coupled
or kind = isolated
or kind = design
, the system will all be re-simulated, right?
d) If element=TEA, should it be kind
of isolated
?
e) Does Element just affect the scope of the re-simulation? Is kind deciding whether design and cost algorithms will be run, as well as mass balance and energy balance? That is, if kind=design, design and cost algorithms will be run, if kind=coupled, mass balance and energy balance, design and cost algorithms will be run, and if kind=isolated, design and cost algorithms, mass balance and energy balance will not be run, right?
f) Is bst.speed_up()
(https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L122) needed for uncertainty analysis and sensitivity analysis? In addition to speed up the operation, will it affect the results?
g) Is convergence_model
and optimize=True
(https://biosteam.readthedocs.io/en/latest/tutorial/Uncertainty_and_sensitivity.html#:~:text=optimize%3DTrue,%3Dconvergence_model%2C) needed for uncertainty analysis and sensitivity analysis? In addition to speed up the operation, will it affect the results?
h) Do the above answers Top2-Top 4
refer to questions 2,3,4 or 2,4,5?
@zasddsgg,
a) If the element is a stream, it looks at where the stream is connected to (Parameter(value)
).
f) That line does nothing. That line is there for backwards compatibility. It used to allow for delayed JIT compiling using Numba (which takes a long time), but now Numba has a cool cache feature that makes it quick.
g) No, it is not needed. It does not affect results.
h) I think so. You can figure these questions on your on by running the cases. Unfortunately, we don't have time to answer more than just a few questions a week and many times we cannot help everybody.
Thanks,
Thanks for your answer. May I confirm the following questions with you again.
a) For the scope of the simulation (i.e., just a unit), what does it mean that just a unit is re-simulated.
b) If an element is a unit or a stream, are the units following the element also re-simulated?
c) Does Element just affect the scope of the re-simulation?
d) In your reply e
just now, does the right
refer to “Is kind deciding whether design and cost algorithms will be run, as well as mass balance and energy balance? That is, if kind=design, design and cost algorithms will be run, if kind=coupled, mass balance and energy balance, design and cost algorithms will be run, and if kind=isolated, design and cost algorithms, mass balance and energy balance will not be run, right”?
e) I get an error (AttributeError: module 'biosteam' has no attribute 'speed_up'
) when I call bst.speed_up
, so I do not need to use code bst.speed_up
in https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/analyses/1_uncertainties.py#L122 when conducting uncertainty analysis and global sensitivity analysis, right?
For a-d, per #120, the entire system will be re-simulated in evaluation, so the settings don't matter now.
For e, speed_up
has long been deprecated, you don't need to use it now.
Could I confirm with you if my understanding is correct. The Element just affect the scope of the re-simulation, no other functions, right? Kind decides whether design and cost algorithms will be run, as well as mass balance and energy balance. That is, if kind=design, design and cost algorithms will be run, if kind=coupled, mass balance and energy balance, design and cost algorithms will be run, and if kind=isolated, design and cost algorithms, mass balance and energy balance will not be run. Am I right?
Please do read our replies in #120, element and kind don't affect scope of the re-simulations.
I read it, so whatever kind and element I set, it doesn't affect the result, does it?
I think you are correct, but it doesn’t hurt to run some analyses and see if the results are what you expect.
On Mon, May 6, 2024 at 9:43 PM zasddsgg @.***> wrote:
I read it, so whatever kind and element I set, it doesn't affect the result, does it?
— Reply to this email directly, view it on GitHub https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/issues/119#issuecomment-2097218392, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALV5VLMW3FJFH5DWAYDJTELZBAWV3AVCNFSM6AAAAABGX72XHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJXGIYTQMZZGI . You are receiving this because you modified the open/close state.Message ID: <BioSTEAMDevelopmentGroup/Bioindustrial-Park/issues/119/2097218392@ github.com>
I got it. Thanks for your help.
Hello, could I ask you some questions about element setting in uncertainty analysis in BioSTEAM. Thanks for your help. Wish you a good day.
For all prices in lactic acid models.py (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L242-L301), the element is TEA, not the corresponding stream as in the uncertainty tutorial (https://biosteam.readthedocs.io/en/latest/tutorial/Uncertainty_and_sensitivity.html#:~:text=%40model.parameter(element%3Dfeedstock%2C%20kind%3D%27isolated%27%2C%20units%3D%27USD/kg%27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20distribution%3Dshape.Uniform(lb%2C%20ub)))? In lactic acid models.py, why is the stream price returned in def(), and the element selected is TEA, shouldn’t stream be selected as element? For example, for @param(name='Feedstock unit price'), why is the element not feedstock? For @param(name='Natural gas unit price'), why isn't element natural_gas (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L260-L266) (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L285-L289)?
Is it OK to select
M203
orR201
forelement
ofsolids loading
, or can only selectM203
(https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L303-L309)? ForPretreatment sulfuric acid loading
(https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L311-L316), is it ok to select unit sulfuric acid storage tank or M201 for the element? ForEnzymatic hydrolysis solids loading
andEnzyme loading
, why the element isM301
instead ofH301
orR301
(https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L331-L343)?The element is
M301
, why use def set_R301
_solidsloading and def setR301
_enzyme_loading (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L336-L342)How to tell which element is (https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py)? In the
def()
function, is the property of which unit or stream is to the left of the equal sign, and is element the property of which unit or stream? Is element the unit or stream that has the properties of variable (left side of the equal sign)? For example, forR302.ferm_ratio = ratio
indef set_ferm_ratio(ratio):
,ferm_ratio
is the property ofR302
, so the element isR302
(https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L368-L371)?For
set_yield(lactic_yield, R301, R302)
(https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L378), It seems that bothR301
andR302
are affected, why is elementR301
? ForR302.productivity = productivity * R302.ferm_ratio
(https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L385),def set_acetic_yield(acetic_yield)
(https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L390-394), It seems that also bothR301
andR302
are affected, why is elementR301
? Can an element have two units or streams?For
@param(name='Feedstock flow rate')
in https://github.com/BioSTEAMDevelopmentGroup/Bioindustrial-Park/blob/master/biorefineries/lactic/models.py#L233-L240, why isn'telement
TEA?