I'm using a custom Python Script to calculate the equilibrium composition of a synthesis gas, because the Gibbs-Reactor won't converge when methane is taken into account. To test the implementation, I'm comparing both reactor models with a simpler mixture (no methane).
As you can see in the attached screenshot, both models produce pretty much the same results. However, I get a energy balance warning with my custom script, but none for the original reactor. Is there a difference in how both energy balances are calculated?
Hey Linus,
I don't think the energy is balanced. Heat load can be calculated as Hout-Hin.
In this case, heat load should have been (27391.9-28006.2)x44.4761/3600 =-7.6 KW. Check your energy balance once.
Thank you
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi TheOne,
the molar enthalpy, which you used to calculate the heat load, only accounts for the change in the heat capacity of the two gases. When you keep the temperature constant while the gas changes it heat capacity (for example in a reaction), you have to add/remove energy (in this case -7.6 kW)
The other part is the heat of reaction, which you can calculate quite easily in this case because its basically just a water gas shift reaction:
(CO2_out - CO2_in) * Q_r_WGS = Q_reaction
(4.35 mol/s - 3.23 mol/s) * 41 kJ/mol = 45.9 kW
If you add both, you should get the total amount of heat added/removed:
Q_total = 38.3 kW
This is the result for both reactors as well, but still I get a warning for the python implementation and none for the gibbs-reactor.
Maybe I overlooked something, let me know what you think!
Hey Linus,
I am a bit confused regarding the conservation of energy equation. Is it possible for you to post the Custom Model? I would love to go through it.
Thank you, Regards
Last edit: The One 2020-09-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sure, I've attached the code. Make sure to choose Python.NET as the interpreter and that you have python 3.7, scipy and numpy installed. All those are included in WinPython.
Thanks Daniel! Got some good ideas by looking through the code from the original gibbs reactor. Any idea why I would get the warning about the energy balance?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Linus,
Many thanks for sharing this gibbs code! I got an error
14 9/20/2020 3:57:32 PM Error RWGS: Unable to load DLL 'python37': The specified module could not be found. (Exception from HRESULT: 0x8007007E) + Info
I have Python 3.8 installed with SciPy. Is there any need to have Python 3.7?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ignore the energy balance error. I've hard coded an 'ignore' switch for energy balance in reactors since the balance check code doesn't account for reactions.
Daniel,
I have not read the source code of Gibbs reactor in DWSIM, but to my little understanding, I think to solve a Gibbs Reactor in adiabatic/non-isothermal mode one needs to account the heat of formation. So, the heat balance absolutely needs the heat of formation.
It should be possible to ignore reactions for equipments with no reaction!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I also think that the heat of formation should be respected in the heat balance. If no reaction occurs, the heat of reaction will automatically be 0, so there is no need to ignore the reactions in equipment where no reaction is expected.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Linus,
Thank you for a very nice example. I am trying to solve the flowsheet from your file, but I get an error message on the AUX_DELGF_T method. Do you have an idea what I am doing wrong?
I'm new to DWSIM, but find Linus' example model of a custom Gibbs reactor very helpful in trying to set up my own unit model based on thermodynamic equilibrium and membrane separation.
When trying to run the model Linus shared (https://sourceforge.net/p/dwsim/discussion/scripting/thread/e2b817afbf/#942a) I get the error message "System.Exception: CustomGibbs: 'IPropertyPackage' object has no attribute 'AUX_DELGF_T'".
Do you have any advice that can help me in the right direction trying to solve this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Daniel,
I'm using a custom Python Script to calculate the equilibrium composition of a synthesis gas, because the Gibbs-Reactor won't converge when methane is taken into account. To test the implementation, I'm comparing both reactor models with a simpler mixture (no methane).
As you can see in the attached screenshot, both models produce pretty much the same results. However, I get a energy balance warning with my custom script, but none for the original reactor. Is there a difference in how both energy balances are calculated?
Hey Linus,
I don't think the energy is balanced. Heat load can be calculated as Hout-Hin.
In this case, heat load should have been (27391.9-28006.2)x44.4761/3600 =-7.6 KW. Check your energy balance once.
Thank you
Hi TheOne,
the molar enthalpy, which you used to calculate the heat load, only accounts for the change in the heat capacity of the two gases. When you keep the temperature constant while the gas changes it heat capacity (for example in a reaction), you have to add/remove energy (in this case -7.6 kW)
The other part is the heat of reaction, which you can calculate quite easily in this case because its basically just a water gas shift reaction:
(CO2_out - CO2_in) * Q_r_WGS = Q_reaction
(4.35 mol/s - 3.23 mol/s) * 41 kJ/mol = 45.9 kW
If you add both, you should get the total amount of heat added/removed:
Q_total = 38.3 kW
This is the result for both reactors as well, but still I get a warning for the python implementation and none for the gibbs-reactor.
Maybe I overlooked something, let me know what you think!
Last edit: Linus 2020-09-17
Hey Linus,
I am a bit confused regarding the conservation of energy equation. Is it possible for you to post the Custom Model? I would love to go through it.
Thank you, Regards
Last edit: The One 2020-09-17
Sure, I've attached the code. Make sure to choose Python.NET as the interpreter and that you have python 3.7, scipy and numpy installed. All those are included in WinPython.
Could you also attach the custom model .dwxml file
See attached file
Linus, your script is so elegant and clean. Congratulations!
Thanks Daniel! Got some good ideas by looking through the code from the original gibbs reactor. Any idea why I would get the warning about the energy balance?
Linus,
Many thanks for sharing this gibbs code! I got an error
14 9/20/2020 3:57:32 PM Error RWGS: Unable to load DLL 'python37': The specified module could not be found. (Exception from HRESULT: 0x8007007E) + Info
I have Python 3.8 installed with SciPy. Is there any need to have Python 3.7?
How did you rectify the error , i didnt understand
Last edit: nihal 2021-02-25
I found the source of error as explained by Daniel https://sourceforge.net/p/dwsim/discussion/scripting/thread/7df261ad45/#e478
It seems DWSIM on Windows 10 uses Python 3.7
Hi Linus,
I went through your code. I am unable to find the bug.
Ignore the energy balance error. I've hard coded an 'ignore' switch for energy balance in reactors since the balance check code doesn't account for reactions.
https://github.com/DanWBR/dwsim6/blob/windows/DWSIM.SharedClasses/Base%20Class/SimulationObjectBaseClasses.vb#L292
Last edit: Daniel Medeiros 2020-09-21
Daniel, I got the same energy balance error! Would you please explain why we should ignore it? and why it has been hard coded. Thank you
The current balance check does not take into account the heats of formation, which is why it gives a "wrong" warning if applied to reactors.
Perhaps I should expand it to include heats of formation? Not sure if this would work for some unit ops like the component separator...
Daniel,
I have not read the source code of Gibbs reactor in DWSIM, but to my little understanding, I think to solve a Gibbs Reactor in adiabatic/non-isothermal mode one needs to account the heat of formation. So, the heat balance absolutely needs the heat of formation.
It should be possible to ignore reactions for equipments with no reaction!
I also think that the heat of formation should be respected in the heat balance. If no reaction occurs, the heat of reaction will automatically be 0, so there is no need to ignore the reactions in equipment where no reaction is expected.
Already done it a few days ago: https://github.com/DanWBR/dwsim6/blob/windows/DWSIM.SharedClasses/Base%20Class/SimulationObjectBaseClasses.vb#L226
Was this already included in Update 9? I still get the same warning (see attached model)
Hi Linus,
Thank you for a very nice example. I am trying to solve the flowsheet from your file, but I get an error message on the AUX_DELGF_T method. Do you have an idea what I am doing wrong?
Not yet, Linus, it will be available in Update 10, but is already coded. I just haven't compiled it yet.
Okay - thanks for your dedication to the project!
Last edit: Linus 2020-09-28
Hi Daniel,
I'm new to DWSIM, but find Linus' example model of a custom Gibbs reactor very helpful in trying to set up my own unit model based on thermodynamic equilibrium and membrane separation.
When trying to run the model Linus shared (https://sourceforge.net/p/dwsim/discussion/scripting/thread/e2b817afbf/#942a) I get the error message "System.Exception: CustomGibbs: 'IPropertyPackage' object has no attribute 'AUX_DELGF_T'".
Do you have any advice that can help me in the right direction trying to solve this?
check this