I don't understand why the energygenerated doesn't equal to energystream at EXP-003
I want EXP-003 to drive COMP-001 and COMP-013 so I write the pythonscript like that. Does it correct?
If not please tell me the corectted python script please
Unfortunately you can't use the energy stream as a power source for the expander because it is the last step of the calculation (an output variable). You can, however, convert the power to head and use it as an input to the expander, using the 'Known Head' calculation mode.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Tanatip, you probably don't need a python script to fix your model.
Attached is my approach.
I've included a spec block Spec-016 that takes the power to run the compressor Comp-001 and gives a power set point to an adjuster Adj-019 that manipulates the heat input to the combustor Heat-002 in such a way the gas turbine Exp-003 generates enough power to drive the compressor C-001.
Then I included the spec block Spec-014 that takes the power output of the gas turbine Exp-003 and calculates a power set point for the adjuster Adj-018 that manipulates the Comp-013 inlet air flow-rate to match the available power.
In my example I considered that the turbine Exp-003 provides 65% power to run Comp-001 and 35% to drive the compressor Comp-013: these values can be changed by changing the values in the Y=f(X) of the spec blocks Spec-014 and Spec-016.
Thank you so much Luca and Deniel, But my turbine energy produced is a output data and I still don't understand about Logic Ops too. But anyway thank you for the answer.
Deniel I have trouble on ironpython script . My programming was poor.
I really want to know how to write a script, input some operation ops or somehow to get the energy produced at EXP-003 as output and enery required at COMP-001 and COMP-013 as input. (I want that when the input changed, output changed as well)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Daniel.
Though while setting this model (see my file in above post) I noticed a weird behaviour: solving the flowsheet after changing the functions Y=f(X) in spec blocks, specs recalculate Set Points but the Adj do not run the adjuster even if the Solve Globally is checked, so that I needed to open manually the Adj control panel and run the adjust routine.
If I recall well, in previous versions (DWSIM 4.xx) this did not happen and the adjust were executed during simulation is the Solve Globally was checked. How now the adjust routine is triggered for execution?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Then add another script to check if the energy balance is converging, that is, the expander power is matching the power of the two compressors. You may need to run the simulation a few times until the energy balance goes to zero.
This script must be linked to the Solver's Finished event.
Sorry, but I still can't get the turbine power generated as output(and I will link it by use energy stream function) and it will be equal to the sum of the power required of two compressors (by automatically not manually).
Last edit: Tanatip 2020-02-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The energy generated at turbine still be the input of this problem. I want it to be the output of the problem and sum of the power required of two compressors (by automatically not manually) as input instead. And the file that I attached, the energy convertion is almost zero but the energy generated doesn't equal to the energy stream.
I've checked your file sir, Would you please check my scirpt? Thankyou.
The scirpt in this file is what I want it to be.At Turbine, everytime I select "Calculation type" as "Energy stream" and "Solve the flowsheet". The "Calculation type" was return to the previous type before I select "Energy stream". And as you can see the "Energy stream" and "Energy generated" are not equal. Can I convert the energystream that I got from the script to "head" and link the script and flowsheet by use "Known head" calculation type ?
Thank you.
Don't you understand that the Turbine doesn't support the "Energy Stream" calculation mode? The script I've sent you is correct! You must WAIT for the turbine to calculate, then get its generated power and transfer it to the two compressors, then solve the flowsheet a few times until the energy balance gets close to zero. That's what my script does and it seems you are not able to understand it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't understand why the energygenerated doesn't equal to energystream at EXP-003
I want EXP-003 to drive COMP-001 and COMP-013 so I write the pythonscript like that. Does it correct?
If not please tell me the corectted python script please
Unfortunately you can't use the energy stream as a power source for the expander because it is the last step of the calculation (an output variable). You can, however, convert the power to head and use it as an input to the expander, using the 'Known Head' calculation mode.
How do I convert power to head ? by python script ? And if I already converted in python script, I can use 'Known head' as input. Am I correct?
Tanatip, you probably don't need a python script to fix your model.
Attached is my approach.
I've included a spec block Spec-016 that takes the power to run the compressor Comp-001 and gives a power set point to an adjuster Adj-019 that manipulates the heat input to the combustor Heat-002 in such a way the gas turbine Exp-003 generates enough power to drive the compressor C-001.
Then I included the spec block Spec-014 that takes the power output of the gas turbine Exp-003 and calculates a power set point for the adjuster Adj-018 that manipulates the Comp-013 inlet air flow-rate to match the available power.
In my example I considered that the turbine Exp-003 provides 65% power to run Comp-001 and 35% to drive the compressor Comp-013: these values can be changed by changing the values in the Y=f(X) of the spec blocks Spec-014 and Spec-016.
Hope this could help.
Luca
Great suggestion, Luca.
Tanatip, if you still need to convert power to head, you can use this equation:
Head = Q * 1000 * W / 9.8
Head = m
Q = heat flow in kW
W = mass flow in kg/s
https://github.com/DanWBR/dwsim5/blob/windows/DWSIM.UnitOperations/Unit%20Operations/Expander.vb#L609
Thank you so much Luca and Deniel, But my turbine energy produced is a output data and I still don't understand about Logic Ops too. But anyway thank you for the answer.
Deniel I have trouble on ironpython script . My programming was poor.
I really want to know how to write a script, input some operation ops or somehow to get the energy produced at EXP-003 as output and enery required at COMP-001 and COMP-013 as input. (I want that when the input changed, output changed as well)
Thanks Daniel.
Though while setting this model (see my file in above post) I noticed a weird behaviour: solving the flowsheet after changing the functions Y=f(X) in spec blocks, specs recalculate Set Points but the Adj do not run the adjuster even if the Solve Globally is checked, so that I needed to open manually the Adj control panel and run the adjust routine.
If I recall well, in previous versions (DWSIM 4.xx) this did not happen and the adjust were executed during simulation is the Solve Globally was checked. How now the adjust routine is triggered for execution?
Thanks
Hi Tanatip,
I'm sorry but I hadn't understand what you needed, now I've read your question again and got you a solution. Your script must be replaced by this one:
Then add another script to check if the energy balance is converging, that is, the expander power is matching the power of the two compressors. You may need to run the simulation a few times until the energy balance goes to zero.
This script must be linked to the Solver's Finished event.
This could be solved easily without scripts if we had an energy splitter, but unfortunately we don't.
Last edit: Daniel Medeiros 2020-02-05
Sorry, but I still can't get the turbine power generated as output(and I will link it by use energy stream function) and it will be equal to the sum of the power required of two compressors (by automatically not manually).
Last edit: Tanatip 2020-02-11
The file I've attached in the post before yours does what you need.
The energy generated at turbine still be the input of this problem. I want it to be the output of the problem and sum of the power required of two compressors (by automatically not manually) as input instead. And the file that I attached, the energy convertion is almost zero but the energy generated doesn't equal to the energy stream.
Check the attached file.
I've checked your file sir, Would you please check my scirpt? Thankyou.
The scirpt in this file is what I want it to be.At Turbine, everytime I select "Calculation type" as "Energy stream" and "Solve the flowsheet". The "Calculation type" was return to the previous type before I select "Energy stream". And as you can see the "Energy stream" and "Energy generated" are not equal. Can I convert the energystream that I got from the script to "head" and link the script and flowsheet by use "Known head" calculation type ?
Thank you.
Last edit: Tanatip 2020-02-13
Don't you understand that the Turbine doesn't support the "Energy Stream" calculation mode? The script I've sent you is correct! You must WAIT for the turbine to calculate, then get its generated power and transfer it to the two compressors, then solve the flowsheet a few times until the energy balance gets close to zero. That's what my script does and it seems you are not able to understand it.