s-amouyal12 / cantera

Automatically exported from code.google.com/p/cantera
0 stars 0 forks source link

Convergence error for setState_HP method #60

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. From GRI30 create an initial state #1: 1 kmol CH4 and 2 kmol O2 at 1 atm and 
300 K, that is, a stoichiometric mixture (CH4 + 2O2 --> CO2 + 2H2O).
2. Use equilibrate('TP') method to calculate the adiabatic flame temperature. 
Get the enthalpy value of this new state #2.
3. Create a new state #3 consist of: 1 kmol C, 4 kmol H, and 4 kmol O at 1 atm 
and 300 K. That is, the same state #1 in terms of the element balance.
4. From the state #3 try to reach the state #2 applying the setState_HP method.
5. Convergence error!

What is the expected output? What do you see instead?
I expected to have the same state # 2 given the enthalpy obtained from 
equilibrate('TP') method. Instead this I have a convergence error.

What version of the product are you using? On what operating system?
Cantera 1.8.0 beta
Ubuntu 10.04 64-bit

Please provide any additional information below.
A sample of python code is attached.

Original issue reported on code.google.com by rodolfo.enq on 20 Oct 2011 at 4:25

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by yarmond on 10 Apr 2012 at 3:18

GoogleCodeExporter commented 9 years ago
Calling the setState_HP method holds the composition fixed, so it can't end up 
at state 2. If you set the mass fractions as they are in state 2 and then call 
setState_HP, it works fine.

Original comment by yarmond on 18 May 2012 at 8:27

GoogleCodeExporter commented 9 years ago
Thank you, Ray! This clarifies how setState_HP function works exactly but it 
doesn't solve my problem, sorry. I want to obtain the state 2 from state 3 
given only enthalpy and pressure. So far I solve this problem with an external 
iteration that gives values for temperature of state 3 and applies 
equilibrate('TP') until the new enthalpy of state 3 be equal to the enthalpy of 
state 2. It can be very useful if Cantera could do this internally.

Original comment by rodolfo.enq on 18 May 2012 at 9:55

GoogleCodeExporter commented 9 years ago
The problem is that your state 2 has an extremely non-physical composition and 
extremely high enthalpy. You can get from State 3 to state 2 with the following:

gas.set(T = 300, P = OneAtm, X = 'C:1, H:4, O:4') # state #3
gas.equilibrate('TP', solver=1)
gas.set(H=h2, P=OneAtm)
gas.equilibrate('HP')

By equilibrating first at constant T and P, you get to a more realistic 
composition while keeping T and P finite and positive. Then setting the 
enthalpy to the value you want will work. Even in this case, I found it 
necessary to use the alternative (nominally more stable) equilibrium solver.

Original comment by yarmond on 19 May 2012 at 12:21

GoogleCodeExporter commented 9 years ago
Thanks again, Ray. This solves my issue definitively.

Original comment by rodolfo.enq on 19 May 2012 at 3:14