IF97.c ( File view )

  • By 拖鞋宝贝 2014-01-21
  • View(s):16
  • Download(s):6
  • Point(s): 0
			#include <math.h>
#include "lpc_types.h"


#define IF97_FM1_MAX	34		//第一象限
#define IF97_FM2_MAX	43		//第二象限
#define IF97_FM4_MAX	10		//第四象限
#define IF97_FM2_I0		9

#define IF97_R		0.461526f

//第一象限
const S32 c_FM1_Ii[IF97_FM1_MAX] = 
{
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,
 1 ,1 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,3 ,
 3 ,3 ,4 ,4 ,4 ,5 ,8 ,8 ,21,23,
 29,30,31,32
};

const S32 c_FM1_Ji[IF97_FM1_MAX] = 
{
-2,-1, 0, 1, 2, 3, 4, 5,-9,-7,
 -1, 0, 1, 3,-3, 0, 1, 3,17,-4, 
  0, 6,-5,-2,10,-8,-11,-6,-29,
  -31,-38,-39,-40,-41
};

const F64 c_FM1_Ni[IF97_FM1_MAX]= {
 
 0.14632971213167E+00,
-0.84548187169114E+00,
-0.37563603672040E+01,
 0.33855169168385E+01,
-0.95791963387872E+00,
 0.15772038513228E+00,
-0.16616417199501E-01,
 0.81214629983568E-03,
 0.28319080123804E-03,
-0.60706301565874E-03,
-0.18990068218419E-01,
-0.32529748770505E-01,
-0.21841717175414E-01,
-0.52838357969930E-04,
-0.47184321073267E-03,
-0.30001780793026E-03,
 0.47661393906987E-04,
-0.44141845330846E-05,
-0.72694996297594E-15,
-0.31679644845054E-04,
-0.28270797985312E-05,
-0.85205128120103E-09,
-0.22425281908000E-05,
-0.65171222895601E-06,
-0.14341729937924E-12,
-0.40516996860117E-06,
-0.12734301741641E-08,
-0.17424871230634E-09,
-0.68762131295531E-18,
 0.14478307828521E-19,
 0.26335781662795E-22,
-0.11947622640071E-22,
 0.18228094581404E-23,
-0.93537087292458E-25
};

//第二象限
const S32 c_FM2_Ii[IF97_FM2_MAX] = {

1,1,1,1,1,2,2,2,2,2,
3,3,3,3,3,4,4,4,5,6,
6,6,7,7,7,8,8,9,10,10,
10,16,16,18,20,20,20,21,22,23,
24,24,24,

};
const S32 c_FM2_Ji[IF97_FM2_MAX] = {

0,1,2,3,6,1,2,4,7,36,
0,1,3,6,35,1,2,3,7,3,
16,35,0,11,25,8,36,13,4,10,
14,29,50,57,20,35,48,21,53,39,
26,40,58,

};
const F64 c_FM2_Ni[IF97_FM2_MAX]= {
 
-0.17731742473213E-02,
-0.17834862292358E-01,
-0.45996013696365E-01,
-0.57581259083432E-01,
-0.50325278727930E-01,
-0.33032641670203E-04,
-0.18948987516315E-03,
-0.39392777243355E-02,
-0.43797295650573E-01,
-0.26674547914087E-04,
 0.20481737692309E-07,
 0.43870667284435E-06,
-0.32277677238570E-04,
-0.15033924542148E-02,
-0.40668253562649E-01,
-0.78847309559367E-09,
 0.12790717852285E-07,
 0.48225372718507E-06,
 0.22922076337661E-05,
-0.16714766451061E-10,
-0.21171472321355E-02,
-0.23895741934104E+02,
-0.59059564324270E-17,
-0.12621808899101E-05,
-0.38946842435739E-01,
 0.11256211360459E-10,
-0.82311340897998E+01,
 0.19809712802088E-07,
 0.10406965210174E-18,
-0.10234747095929E-12,
-0.10018179379511E-08,
-0.80882908646985E-10,
 0.10693031879409E+00,
-0.33662250574171E+00,
 0.89185845355421E-24,
 0.30629316876232E-12,
-0.42002467698208E-05,
-0.59056029685639E-25,
 0.37826947613457E-05,
-0.12768608934681E-14,
 0.73087610595061E-28,
 0.55414715350778E-16,
-0.94369707241210E-06,

};

const S32 c_FM2_Ji0[IF97_FM2_I0] = {

0,1,-5,-4,-3,-2,-1, 2, 3,

};

const F64 c_FM2_Ni0[IF97_FM2_I0]= {
 
 -0.96927686500217E+1, 
  0.10086655968018E+2, 
 -0.56087911283020E-2,
  0.71452738081455E-1, 
 -0.40710498223928,
  0.14240819171444E+1,
 -0.43839511319450E+1,
 -0.28408632460772,
  0.21268463753307E-1,

};

//第四象限
const F64 c_FM4_Ni[IF97_FM4_MAX]= {

 0.11670521452767E+04,
-0.72421316703206E+06,
-0.17073846940092E+02,
 0.12020824702470E+05,
-0.32325550322333E+07,
 0.14915108613530E+02,
-0.48232657361591E+04,
 0.40511340542057E+06,
-0.23855557567849E+00,
 0.65017534844798E+03,

};

 

void IF97_fram1(F32 p,F32 T,F32 *v,F32 *h)
{

	F64 sumv = 0.0f,sumh=0.0f;
	F64 pi,tao;
	S32 i;
	
	pi = p/16.53f;
	tao= 1386/T;
	for( i=0;i<IF97_FM1_MAX;i++)
	{

		sumv+= -c_FM1_Ni[i]*c_FM1_Ii[i]*pow(7.1f-pi,c_FM1_Ii[i]-1)*pow(tao-1.222f,c_FM1_Ji[i]);
		sumh+= c_FM1_Ni[i]*c_FM1_Ji[i]*pow(7.1f-pi,c_FM1_Ii[i])*pow(tao-1.222f,c_FM1_Ji[i]-1);
	
}
	
	*v = sumv*pi*IF97_R*T/(p*1000);
	*h = tao*sumh*IF97_R*T;

}

void IF97_fram2(F32 p,F32 T,F32 *v,F32 *h)
{

	F64 sum0=0.0f,sumv=0.0f,sumh=0.0f;
	F64 pi,tao;
	S32 i;
	
	pi = p;
	tao= 540.0f/T;
	
	for(i=0;i<IF97_FM2_I0;i++)
	{

		sum0 += c_FM2_Ni0[i]*c_FM2_Ji0[i]*pow(tao,c_FM2_Ji0[i]-1);
	
}
	
	for(i=0;i<IF97_FM2_MAX;i++)
	{

		sumv += c_FM2_Ni[i]*c_FM2_Ii[i]*pow(pi,c_FM2_Ii[i]-1.0f)*pow(tao-0.5f,c_FM2_Ji[i]);
		sumh += c_FM2_Ni[i]*c_FM2_Ji[i]*pow(pi,c_FM2_Ii[i])*pow(tao-0.5f,c_FM2_Ji[i]-1);
	
}
	
	*v = (1+pi*sumv)*IF97_R*T/(p*1000);
	*h = tao*(sum0+sumh)*IF97_R*T;

}

void IF97_fram4_T2p(F32 T,F32 *p)
{

	F32 A,B,C;
	F32 v,v2;
	
	v = T+c_FM4_Ni[8]/(T-c_FM4_Ni[9]);
	v2 = v*v;
	A = v2+c_FM4_Ni[0]*v+c_FM4_Ni[1];
	B = v2*c_FM4_Ni[2]+v*c_FM4_Ni[3]+c_FM4_Ni[4];
	C = v2*c_FM4_Ni[5]+v*c_FM4_Ni[6]+c_FM4_Ni[7];
	*p = pow(C*2/(pow(B*B-4*A*C,0.5f)-B),4);

}

void IF97_fram4_p2T(F32 p,F32 *T)
{

	F32 b,b2;
	F32 D,E,F,G;
	b = pow(p,0.25f);
	b2= b*b;
	E = b2+c_FM4_Ni[2]*b+c_FM4_Ni[5];
	F = c_FM4_Ni[0]*b2+c_FM4_Ni[3]*b+c_FM4_Ni[6];
	G = c_FM4_Ni[1]*b2+c_FM4_Ni[4]*b+c_FM4_Ni[7];
	D = 2*G/(-F-pow(F*F-4*E*G,0.5));
	*T = (c_FM4_Ni[9]+D-pow((c_FM4_Ni[9]+D)*(c_FM4_Ni[9]+D)-4*(c_FM4_Ni[8]+c_FM4_Ni[9]*D),0.5))/2;

}

			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 0

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
IF97.c4.92 kB2013-12-20 10:54
...
Sponsored links

IF97.c (2.13 kB)

Need 0 point
Your Point(s)
Download Download

Download failed? Click here to download one by one.

Tip: this source code project contains 2 packages, please click the allow button on the browser pop-up dialog,after you click the download button.

▪ Click to download this source code directly

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D