
[Sponsors] 
January 31, 2014, 05:56 
Implementing tabular heat capacity

#1 
Senior Member
Join Date: Oct 2013
Posts: 382
Rep Power: 8 
Hello,
I'm currently working on implementing a heat capacity model using tabulated T and pdependent data. I based the library on the hPolynomial model which works with my solver, and reimplemented cp(), ha(), hs(), hc() and s() using an interpolation2DTable for cp and a Tintegrated table for enthalpy calculation. The values in the table are comparable to the values I used in the polynomial model, however, the temperature calculation fails on the very first step, with the "Maximum number of iterations exceeded" error in the temperature calculation function T(). When I use the limit() function to specify valid ranges for T, I see very extreme negative values (90000 to 1e7). Clamping them does not help. Why would there be negative temperature values? Are they an artifact of the iteration procedure in T()? Is it diverging because I can't provide meaningful data in this range? I have the tables set to clamp, so the capacity and the enthalpy will be constant for these temperatures. Would it help if I use linear extrapolation instead of clamping maybe? Is there anything tricky that I might have missed? The tabulated data isn't as smooth because it contains enthalpies of transitions, can this lead to problems? I'm also a bit confused about the mixture functionality. I only want to work with a single component, does this mean I can safely ignore the operatores for adding, subtracting and multiplying mixtures? I don't have meaningful implementations of them right now, but to my current understanding it should not be needed for my case? On a related note, where can I find information about the temperature calculation? I'm having some difficulties understanding the code in the T() function and it's subroutines. I'm also not quite sure where the reference temperature specie::Tstd comes from? I have looked into constants.h and its includes, but where is the value specified? Edit: I have looked some more into the temperature iteration routine, and I believe it uses a newton algorithm for inverting the H(T,p) function to T. This points indeed to problems when the gradient of this function becomes zero, as it does outside of the table range. I'll try to implement an extrapolating table class to fix this. However, please share your knowledge with me Last edited by chriss85; January 31, 2014 at 07:11. 

February 3, 2014, 05:09 

#2 
Senior Member
Join Date: Oct 2013
Posts: 382
Rep Power: 8 
I have created an extrapolating2DTable class which I successfully tested with some simple values, however I'm still getting this error in the temperature calculation.


February 3, 2014, 17:44 

#3 
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 425
Rep Power: 13 
I guess you tried this already but what happens if your heat capacity values are a constant over the full temperature range?


February 4, 2014, 03:11 

#4 
Senior Member
Join Date: Oct 2013
Posts: 382
Rep Power: 8 
So far I have not yet had much success, although some very simple cases seem to work (such as constant heat capacity and constant energy in the case so the temperature doesn't change).
I have tried to decrease the step in the temperature approximation newton method with some limited success, at the cost of having to use more steps until it converges. Using that, I was able to use a linear increasing heat capacity. I think that maybe the data I'm using was too rough, I'll have to check that. For example: Linear increasing heat capacity using two data points. Enthalpy should then be quadratic in temperature, however you can't have that with only two points. I'll try to see if this is one of the problems, however, I was also using finer data which also was problematic. I believe that something else is flawed, as the Newton method shouldn't need so many steps with linear data. The heat capacity is strictly positive, so there should not be a problem with Newtons method AFAIK. 

February 4, 2014, 09:19 

#5 
Senior Member
Join Date: Oct 2013
Posts: 382
Rep Power: 8 
I finally got it working, turns out I had incorrect enthalpy tables.


February 10, 2014, 08:29 

#6 
Senior Member
Join Date: Oct 2013
Posts: 382
Rep Power: 8 
I stumbled upon further problems, which are very likely caused by the tables not being continously differentiable, which is a prerequisite for the Newton method for rootfinding.
Now I'm wondering, is there a more robust method for finding roots that doesn't require continous differentiable functions, or do I need to implement an extrapolating table that employs spline interpolation? Edit: I implemented a bisection method in addition to the newton method used for inverting f(T). On the first look it appears to work, but I'm having other (mostly unrelated) problems which might interfere, so I need to do further comparisons. Last edited by chriss85; February 10, 2014 at 12:11. 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Question about heat transfer coefficient setting for CFX  Anna Tian  CFX  1  June 16, 2013 06:28 
error message  cuteapathy  CFX  14  March 20, 2012 07:45 
Constant velocity of the material  Sas  CFX  15  July 13, 2010 08:56 
mass flow in is not equal to mass flow out  saii  CFX  2  September 18, 2009 08:07 
TwoPhase Buoyant Flow Issue  Miguel Baritto  CFX  4  August 31, 2006 12:02 