Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabular ammonia calc yields very different results using TTSE vs. bicubic, including non-physical and NaN quantities #914

Closed
mapipolo opened this issue Jan 6, 2016 · 6 comments
Milestone

Comments

@mapipolo
Copy link

mapipolo commented Jan 6, 2016

This is another case where tabular results using PT inputs can be unpredictable near the melting line. The "bump" work done in early December seems to have gone some distance toward fixing these issues, but I have another example. Here, I'm calculating ammonia at about 0.3°C above its saturation temperature--it should be a superheated vapor--with no phase specification, liquid phase specification and gas phase specification.

Using the January 4th nightly build and C#.

AbstractState s;
double t = 259.22008730402689;
double p = 243647.89803050642;

s = AbstractState.factory("?", "Ammonia");
s.update(input_pairs.PT_INPUTS, p, t);
Console.WriteLine("?, no specification");
Console.WriteLine("h = " + s.hmass());
Console.WriteLine("rho = " + s.rhomass());
Console.WriteLine("Cp = " + s.cpmass());
Console.WriteLine("Cv = " + s.cvmass());
Console.WriteLine("AV = " + s.speed_sound());
Console.WriteLine();

s = AbstractState.factory("TTSE&HEOS", "Ammonia");
s.update(input_pairs.PT_INPUTS, p, t);
Console.WriteLine("TTSE&HEOS, no specification");
Console.WriteLine("h = " + s.hmass());
Console.WriteLine("rho = " + s.rhomass());
Console.WriteLine("Cp = " + s.cpmass());
Console.WriteLine("Cv = " + s.cvmass());
Console.WriteLine("AV = " + s.speed_sound());
Console.WriteLine();

s = AbstractState.factory("BICUBIC&HEOS", "Ammonia");
s.update(input_pairs.PT_INPUTS, p, t);
Console.WriteLine("BICUBIC&HEOS, no specification");
Console.WriteLine("h = " + s.hmass());
Console.WriteLine("rho = " + s.rhomass());
Console.WriteLine("Cp = " + s.cpmass());
Console.WriteLine("Cv = " + s.cvmass());
Console.WriteLine("AV = " + s.speed_sound());
Console.WriteLine();

s = AbstractState.factory("?", "Ammonia");
s.specify_phase(phases.iphase_liquid);
s.update(input_pairs.PT_INPUTS, p, t);
Console.WriteLine("?, liquid specification");
Console.WriteLine("h = " + s.hmass());
Console.WriteLine("rho = " + s.rhomass());
Console.WriteLine("Cp = " + s.cpmass());
Console.WriteLine("Cv = " + s.cvmass());
Console.WriteLine("AV = " + s.speed_sound());
Console.WriteLine();

s = AbstractState.factory("TTSE&HEOS", "Ammonia");
s.specify_phase(phases.iphase_liquid);
s.update(input_pairs.PT_INPUTS, p, t);
Console.WriteLine("TTSE&HEOS, liquid specification");
Console.WriteLine("h = " + s.hmass());
Console.WriteLine("rho = " + s.rhomass());
Console.WriteLine("Cp = " + s.cpmass());
Console.WriteLine("Cv = " + s.cvmass());
Console.WriteLine("AV = " + s.speed_sound());
Console.WriteLine();

s = AbstractState.factory("BICUBIC&HEOS", "Ammonia");
s.specify_phase(phases.iphase_liquid);
s.update(input_pairs.PT_INPUTS, p, t);
Console.WriteLine("BICUBIC&HEOS, liquid specification");
Console.WriteLine("h = " + s.hmass());
Console.WriteLine("rho = " + s.rhomass());
Console.WriteLine("Cp = " + s.cpmass());
Console.WriteLine("Cv = " + s.cvmass());
Console.WriteLine("AV = " + s.speed_sound());
Console.WriteLine();

s = AbstractState.factory("?", "Ammonia");
s.specify_phase(phases.iphase_gas);
s.update(input_pairs.PT_INPUTS, p, t);
Console.WriteLine("?, gas specification");
Console.WriteLine("h = " + s.hmass());
Console.WriteLine("rho = " + s.rhomass());
Console.WriteLine("Cp = " + s.cpmass());
Console.WriteLine("Cv = " + s.cvmass());
Console.WriteLine("AV = " + s.speed_sound());
Console.WriteLine();

s = AbstractState.factory("TTSE&HEOS", "Ammonia");
s.specify_phase(phases.iphase_gas);
s.update(input_pairs.PT_INPUTS, p, t);
Console.WriteLine("TTSE&HEOS, gas specification");
Console.WriteLine("h = " + s.hmass());
Console.WriteLine("rho = " + s.rhomass());
Console.WriteLine("Cp = " + s.cpmass());
Console.WriteLine("Cv = " + s.cvmass());
Console.WriteLine("AV = " + s.speed_sound());
Console.WriteLine();

s = AbstractState.factory("BICUBIC&HEOS", "Ammonia");
s.specify_phase(phases.iphase_gas);
s.update(input_pairs.PT_INPUTS, p, t);
Console.WriteLine("BICUBIC&HEOS, gas specification");
Console.WriteLine("h = " + s.hmass());
Console.WriteLine("rho = " + s.rhomass());
Console.WriteLine("Cp = " + s.cpmass());
Console.WriteLine("Cv = " + s.cvmass());
Console.WriteLine("AV = " + s.speed_sound());
Console.WriteLine();

This yields the following. Of particular note are the results from bicubic with no phase specification and gas phase specification. Cp is problematic, and should speed_sound ever be returning NaN?

?, no specification
h = 1589308.15501223
rho = 2.02116229454812
Cp = 2485.8498342892
Cv = 1813.80307140545
AV = 396.054452773309

TTSE&HEOS, no specification
h = 1589308.20202773
rho = 2.02116167285379
Cp = 2485.67989170978
Cv = 1813.69501345677
AV = 396.060171091979

BICUBIC&HEOS, no specification
h = 1535981.46402616
rho = 28.7121267057629
Cp = -10921.9539007639
Cv = 1932.89232666428
AV = NaN

?, liquid specification
h = 279235.096619057
rho = 657.241982690691
Cp = 4543.8218258468
Cv = 2822.53886097131
AV = 1630.06163266137

TTSE&HEOS, liquid specification
h = 279234.434452441
rho = 657.244241532264
Cp = 4543.51592322407
Cv = 2823.00343754034
AV = 1633.41441219947

BICUBIC&HEOS, liquid specification
h = 279235.003034553
rho = 657.242056171001
Cp = 4543.74671714548
Cv = 2822.54041114895
AV = 1630.05090022732

?, gas specification
h = 1589308.15501223
rho = 2.02116229454812
Cp = 2485.8498342892
Cv = 1813.80307140545
AV = 396.054452773309

TTSE&HEOS, gas specification
h = 1589316.71208627
rho = 2.02108456602461
Cp = 2480.81825249268
Cv = 1810.6057482359
AV = 396.249732401816

BICUBIC&HEOS, gas specification
h = 1535981.46402616
rho = 28.7121267057629
Cp = -10921.9539007639
Cv = 1932.89232666428
AV = NaN
@jowr
Copy link
Member

jowr commented Jan 6, 2016

How close are you to the 2-phase region? Please note that the tables become somewhat unreliable in the vicinity of the phase boundaries. See also: #882

@mapipolo
Copy link
Author

mapipolo commented Jan 6, 2016

I'm familiar with #882, but didn't realize that the vapor side hasn't had the "bump" implemented yet. This could explain what I'm seeing here. However, it would seem that I'm adequately above the dew temperature to avoid these issues: t=259.22 and t_dew=258.89°C > dt = 0.33°C.

@jowr
Copy link
Member

jowr commented Jan 6, 2016

The grid is quite coarse and your dt might not be large enough. We currently use 200 cells in log p, h and T direction (https://github.com/CoolProp/CoolProp/blob/master/src/Backends/Tabular/TabularBackends.h#L366).

from CoolProp.CoolProp import PropsSI
fluid = "NH3"
Tmax = 1.5*PropsSI("Tmax","T",0,"D",0,fluid)
Tmin = PropsSI("Tmin","T",0,"D",0,fluid)
dT = (Tmax-Tmin)/200.0
4.272525

@mapipolo
Copy link
Author

mapipolo commented Jan 6, 2016

OK. I'll revisit this issue once the "bump" functionality is implemented on the vapor side.

@mapipolo
Copy link
Author

mapipolo commented Jan 7, 2016

Commit aeb05b0 fixed this issue, so long as the phase is specified. Thanks, Ian!

New results from running same code as above:

?, no specification
h = 1589308.15501223
rho = 2.02116229454812
Cp = 2485.8498342892
Cv = 1813.80307140545
AV = 396.054452773309

TTSE&HEOS, no specification
h = 1589308.20202773
rho = 2.02116167285379
Cp = 2485.67989170978
Cv = 1813.69501345677
AV = 396.060171091979

BICUBIC&HEOS, no specification
h = 1535981.46402616
rho = 28.7121267057629
Cp = -10921.9539007639
Cv = 1932.89232666428
AV = NaN

?, liquid specification
h = 279235.096619057
rho = 657.241982690691
Cp = 4543.8218258468
Cv = 2822.53886097131
AV = 1630.06163266137

TTSE&HEOS, liquid specification
h = 279234.434452441
rho = 657.244241532264
Cp = 4543.51592322407
Cv = 2823.00343754034
AV = 1633.41441219947

BICUBIC&HEOS, liquid specification
h = 279235.003034553
rho = 657.242056171001
Cp = 4543.74671714548
Cv = 2822.54041114895
AV = 1630.05090022732

?, gas specification
h = 1589308.15501223
rho = 2.02116229454812
Cp = 2485.8498342892
Cv = 1813.80307140545
AV = 396.054452773309

TTSE&HEOS, gas specification
h = 1589316.71208627
rho = 2.02108456602461
Cp = 2480.81825249268
Cv = 1810.6057482359
AV = 396.249732401816

BICUBIC&HEOS, gas specification
h = 1589309.37660036
rho = 2.0211525798191
Cp = 2485.07314156424
Cv = 1813.22898133764
AV = 396.057834501687

@ibell
Copy link
Contributor

ibell commented Jan 7, 2016

Go ahead and close then
On Jan 7, 2016 6:37 AM, "mapipolo" notifications@github.com wrote:

Commit aeb05b0
aeb05b0
fixed this issue, so long as the phase is specified. Thanks, Ian!

New results from running same code as above:

?, no specification
h = 1589308.15501223
rho = 2.02116229454812
Cp = 2485.8498342892
Cv = 1813.80307140545
AV = 396.054452773309

TTSE&HEOS, no specification
h = 1589308.20202773
rho = 2.02116167285379
Cp = 2485.67989170978
Cv = 1813.69501345677
AV = 396.060171091979

BICUBIC&HEOS, no specification
h = 1535981.46402616
rho = 28.7121267057629
Cp = -10921.9539007639
Cv = 1932.89232666428
AV = NaN

?, liquid specification
h = 279235.096619057
rho = 657.241982690691
Cp = 4543.8218258468
Cv = 2822.53886097131
AV = 1630.06163266137

TTSE&HEOS, liquid specification
h = 279234.434452441
rho = 657.244241532264
Cp = 4543.51592322407
Cv = 2823.00343754034
AV = 1633.41441219947

BICUBIC&HEOS, liquid specification
h = 279235.003034553
rho = 657.242056171001
Cp = 4543.74671714548
Cv = 2822.54041114895
AV = 1630.05090022732

?, gas specification
h = 1589308.15501223
rho = 2.02116229454812
Cp = 2485.8498342892
Cv = 1813.80307140545
AV = 396.054452773309

TTSE&HEOS, gas specification
h = 1589316.71208627
rho = 2.02108456602461
Cp = 2480.81825249268
Cv = 1810.6057482359
AV = 396.249732401816

BICUBIC&HEOS, gas specification
h = 1589309.37660036
rho = 2.0211525798191
Cp = 2485.07314156424
Cv = 1813.22898133764
AV = 396.057834501687


Reply to this email directly or view it on GitHub
#914 (comment).

@ibell ibell added this to the v5.1.2 milestone Jan 7, 2016
@mapipolo mapipolo closed this as completed Jan 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants