CoolProp  4.2.5
An open-source fluid property and humid air property database
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Ice.cpp
Go to the documentation of this file.
1 
2 #ifndef __powerpc__
3 #include <math.h>
4 #include <complex>
5 #include <iostream>
6 static std::complex <double> t1 ( 0.368017112855051e-1, 0.510878114959572e-1);
7 static std::complex <double> r1 ( 0.447050716285388e2, 0.656876847463481e2);
8 static std::complex <double> t2 ( 0.337315741065416, 0.335449415919309);
9 static std::complex <double> r20 (-0.725974574329220e2, -0.781008427112870e2);
10 static std::complex <double> r21 (-0.557107698030123e-4, 0.464578634580806e-4);
11 static std::complex <double> r22 ( 0.234801409215913e-10,-0.285651142904972e-10);
12 #endif
13 
14 #include "Ice.h"
15 
16 static double T_t=273.16,p_t=0.611657,p_0=101.325;
17 
18 // Complex Constants for EOS
19 static double g00=-0.632020233449497e6;
20 static double g01= 0.655022213658955;
21 static double g02=-0.189369929326131e-7;
22 static double g03= 0.339746123271053e-14;
23 static double g04=-0.556464869058991e-21;
24 static double s0= -0.332733756492168e4;
25 
26 
27 double IsothermCompress_Ice(double T, double p)
28 {
29  #ifndef __powerpc__
30  // Inputs in K,kPa, Output in 1/Pa
31  return -dg2_dp2_Ice(T,p)/dg_dp_Ice(T,p)/1000.0;
32  #else
33  return 1e99;
34  #endif
35 }
36 double psub_Ice(double T)
37 {
38  #ifndef __powerpc__
39  double a[]={0,-0.212144006e2,0.273203819e2,-0.610598130e1};
40  double b[]={0,0.333333333e-2,0.120666667e1,0.170333333e1};
41  double summer=0,theta;
42  theta=T/T_t;
43  for (int i=1;i<=3;i++)
44  {
45  summer+=a[i]*pow(theta,b[i]);
46  }
47  return p_t*exp(1/theta*summer);
48  #else
49  return 1e99;
50  #endif
51 }
52 
53 double g_Ice(double T,double p)
54 {
55  #ifndef __powerpc__
56  std::complex<double> r2,term1,term2;
57  double g0,theta,pi,pi_0;
58  theta= T/T_t; pi=p/p_t; pi_0=p_0/p_t;
59  g0=g00*pow(pi-pi_0,0.0)+g01*pow(pi-pi_0,1.0)+g02*pow(pi-pi_0,2.0)+g03*pow(pi-pi_0,3.0)+g04*pow(pi-pi_0,4.0);
60  r2=r20*pow(pi-pi_0,0.0)+r21*pow(pi-pi_0,1.0)+r22*pow(pi-pi_0,2.0);
61  // The two terms of the summation
62  term1=r1*((t1-theta)*log(t1-theta)+(t1+theta)*log(t1+theta)-2.0*t1*log(t1)-theta*theta/t1);
63  term2=r2*((t2-theta)*log(t2-theta)+(t2+theta)*log(t2+theta)-2.0*t2*log(t2)-theta*theta/t2);
64  return g0-s0*T_t*theta+T_t*real(term1+term2);
65  #else
66  return 1e99;
67  #endif
68 }
69 
70 double dg_dp_Ice(double T, double p)
71 {
72  #ifndef __powerpc__
73  std::complex<double> r2_p;
74  double g0_p,theta,pi,pi_0;
75  theta= T/T_t; pi=p/p_t; pi_0=p_0/p_t;
76  g0_p=g01*1.0/p_t*pow(pi-pi_0,1-1.0)+g02*2.0/p_t*pow(pi-pi_0,2-1.0)+g03*3.0/p_t*pow(pi-pi_0,3-1.0)+g04*4.0/p_t*pow(pi-pi_0,4-1.0);
77  r2_p=r21*1.0/p_t*pow(pi-pi_0,1-1.0)+r22*2.0/p_t*pow(pi-pi_0,2-1.0);
78  return g0_p+T_t*real(r2_p*((t2-theta)*log(t2-theta)+(t2+theta)*log(t2+theta)-2.0*t2*log(t2)-theta*theta/t2));
79  #else
80  return 1e99;
81  #endif
82 }
83 
84 double dg2_dp2_Ice(double T, double p)
85 {
86  #ifndef __powerpc__
87  std::complex<double> r2_pp;
88  double g0_pp,theta,pi,pi_0;
89  theta= T/T_t; pi=p/p_t; pi_0=p_0/p_t;
90  g0_pp=g02*2.0*(2.0-1.0)/p_t/p_t*pow(pi-pi_0,2.0-2.0)+g03*3.0*(3.0-1.0)/p_t/p_t*pow(pi-pi_0,3.0-2.0)+g04*4.0*(4.0-1.0)/p_t/p_t*pow(pi-pi_0,4-2.0);
91  r2_pp=r22*2.0/p_t/p_t;
92  return g0_pp+T_t*real(r2_pp*((t2-theta)*log(t2-theta)+(t2+theta)*log(t2+theta)-2.0*t2*log(t2)-theta*theta/t2));
93  #else
94  return 1e99;
95  #endif
96 }
97 
98 double dg_dT_Ice(double T, double p)
99 {
100  #ifndef __powerpc__
101  std::complex<double> r2,term1,term2;
102  double theta,pi,pi_0;
103  theta= T/T_t; pi=p/p_t; pi_0=p_0/p_t;
104  r2=r20*pow(pi-pi_0,0.0)+r21*pow(pi-pi_0,1.0)+r22*pow(pi-pi_0,2.0);
105  // The two terms of the summation
106  term1=r1*(-log(t1-theta)+log(t1+theta)-2.0*theta/t1);
107  term2=r2*(-log(t2-theta)+log(t2+theta)-2.0*theta/t2);
108  return -s0+real(term1+term2);
109  #else
110  return 1e99;
111  #endif
112 }
113 
114 double h_Ice(double T, double p)
115 {
116  #ifndef __powerpc__
117  // Returned value is in units of J/kg
118  return g_Ice(T,p)-T*dg_dT_Ice(T,p);
119  #else
120  return 1e99;
121  #endif
122 }
123 
124 double rho_Ice(double T, double p)
125 {
126  #ifndef __powerpc__
127  // Returned value is in units of kg/m3
128  return 1/g_Ice(T,p);
129  #else
130  return 1e99;
131  #endif
132 }
133 
134 double s_Ice(double T, double p)
135 {
136  #ifndef __powerpc__
137  // Returned value is in units of J/kg/K
138  return -dg_dT_Ice(T,p);
139  #else
140  return 1e99;
141  #endif
142 }
143 
double h_Ice(double T, double p)
Definition: Ice.cpp:114
double dg_dT_Ice(double T, double p)
Definition: Ice.cpp:98
double rho_Ice(double T, double p)
Definition: Ice.cpp:124
double g_Ice(double T, double p)
Definition: Ice.cpp:53
double dg2_dp2_Ice(double T, double p)
Definition: Ice.cpp:84
double IsothermCompress_Ice(double T, double p)
Definition: Ice.cpp:27
double psub_Ice(double T)
Definition: Ice.cpp:36
double dg_dp_Ice(double T, double p)
Definition: Ice.cpp:70
double s_Ice(double T, double p)
Definition: Ice.cpp:134