#include<iostream>
#include<math.h>
#define pi 3.1415926535897939
using namespace std;
float psat(float Tsat)
{
float psat;
psat=exp(21.51297-2200.9809/(Tsat+246.61));
return (psat);
}
float Tsat(float psat)
{
float Tsat;
Tsat=-2200.9809/(log(psat)-21.51297)-246.61;
return (Tsat);
}
float v(float tsh,float Tsat)
{
float v,vs;
vs=exp(-12.4539+2669.0/(Tsat+273.15))*(1.01357+10.6736*pow(10,-4)*Tsat-9.2532*pow(10,-6)*pow(Tsat,2)-3.2192*pow(10,-7)*pow(Tsat,3));
v=(1+4.7881*pow(10,-3)*tsh-3.965*pow(10,-6)*pow(tsh,2)+2.5817*pow(10,-5)*tsh*Tsat-1.8506*pow(10,-7)*pow(tsh,2)*Tsat
+8.5739*pow(10,-7)*tsh*pow(Tsat,2)-5.401*pow(10,-9)*pow(tsh,2)*pow(Tsat,2))*vs;
return(v);
}
float ug(float Tg)
{
float ug;
ug=pow(10,-7)*(-5.083+0.50162*(Tg+273.15)-1.18e-4*pow(Tg+273.15,2));
return(ug);
}
float uf(float Tf)
{
float uf;
uf=pow(10,-3)*pow(10,-14.4406+1256.3/(Tf+273.15)+0.052393*(Tf+273.15)-6.9771*pow(10,-5)*pow((Tf+273.15),2));
return(uf);
}
float utp(float uf,float ug,float x)
{
float utp;
utp=uf*ug/(x*uf+(1-x)*ug);
return(utp);
}
float g(float t)
{
float g,T,j;
T=t+273.15;
j=-pow(1-T/380,0.31372);
g=0.49834*pow(0.24141,j)*1000;
return(g);
}
float vs(float Tsat)
{
float vs(Tsat);
vs=exp(-12.4539+2669.0/(Tsat+273.15))*(1.01357+10.6736*pow(10,-4)*Tsat-9.2532*pow(10,-6)*pow(Tsat,2)-3.2192*pow(10,-7)*pow(Tsat,3));
return(vs);
}
float hf(float T1)
{
float hf;
hf=200000+1335.29*T1+1.70650*pow(T1,2)+7.6741*pow(10,-3)*pow(T1,3);
return(hf);
}
float T(float h)
{
float t,h1,t1,t2;
for(t1=60,t2=-60,t=(t1+t2)/2,h1=200000+1335.29*t+1.70650*pow(t,2)+7.6741*pow(10,-3)*pow(t,3);
fabs(h-h1)>0.01;
t=(t1+t2)/2,h1=200000+1335.29*t+1.70650*pow(t,2)+7.6741*pow(10,-3)*pow(t,3))
{
if(h1>h)
t1=t;
else
t2=t;}
return(t);
}
float hv(float Tsat)
{
float hv,hi1;
hi1=249455+606.163*Tsat-1.05644*pow(Tsat,2)-18.2426*pow(10,-3)*pow(Tsat,3);
hv=hi1+149048;
return(hv);
}
float hs(float Tsat,float tsh)
{
float hs,hi1,hi2;
hi1=249455+606.163*Tsat-1.05644*pow(Tsat,2)-18.2426*pow(10,-3)*pow(Tsat,3);
hi2=(1+3.48186*pow(10,-3)*tsh+16.886*pow(10,-7)*pow(tsh,2)+9.2642*pow(10,-6)*tsh*Tsat-7.698*pow(10,-8)*pow(tsh,2)*Tsat
+17.07*pow(10,-8)*tsh*pow(Tsat,2)-12.13*pow(10,-10)*pow(tsh,2)*pow(Tsat,2))*hi1;
hs=hi2+149048;
return(hs);
}
float Tsh(float h,float Tsat)
{
float t,h1,t1,t2;
for(t1=0,t2=40,t=(t1+t2)/2,h1=hs(t,Tsat);
fabs(h-h1)>0.01;
t=(t1+t2)/2,h1=hs(t,Tsat))
{
if(h1>h)
t2=t;
else
t1=t;
}
return(t);
}
float cpf(float Tf)
{
float cpf;
cpf=pow(10,3)*(-14.015+1.4306*(Tf+273.15)-0.006022*pow((Tf+273.15),2)+9.9834*pow(10,-6)*pow((Tf+273.15),3))/86.5;//为什么要除以86.5
return(cpf);
}
float cpg(float Tg)
{
float cpg;
cpg=pow(10,3)*(8.429+0.34966*(Tg+273.15)-3.3281*pow(10,-4)*pow((Tg+273.15),2)+1.5603*pow(10,-7)*pow((Tg+273.15),3)-2.8939*pow(10,-11)*pow((Tg+273.15),4))/86.5;
return(cpg);
}
float rg(float Tg)
{
float rg;
rg=-0.00668+4.8544*pow(10,-5)*(Tg+273.15)+1.2108*pow(10,-8)*pow(Tg+273.15,2);
return(rg);
}
float rf(float Tf)
{
float rf;
rf=pow(10,(-1.7425+0.9769*pow(1-(Tf+273.15)/380,2.0/7.0)));
return (rf);
}
float d(float Tg,float Tw)
{
float d,a,b,c,tg,tw;
tg=Tg+273.15;
tw=Tw+273.15;
a=166.31*pow(647.3-tw,0.38);
b=1e5*exp(3816.44/(tw-46.13)-23.1964)-1;
c=267.38*pow(647.3-tw,0.38)+1.88*(tg-tw);
d=(a*1.0/b-1.01*(tg-tw))/c;
return(d);
}
float cpma(float Tg,float Tw)
{
float cpma,cpda,cpv,da;
cpda=1.00687*pow(10,3)-8.722*pow(10,-2)*Tg+1.236*pow(10,-4)*pow(Tg,2);
cpv=1.85314*pow(10,3)+0.6133*Tg+1.014*pow(10,-3)*pow(Tg,2);
da=d(Tg,Tw);
cpma=(cpda/(1+da))*(1+da*cpv/cpda);
return(cpma);
}
float Re(float G,float d,float u)
{
float Re;
Re=G*d/u;
return (Re);
}
float ha(float Tg,float Tw)
{
float ha,da,w;
w=pow(10,5)*exp(3816.44/(Tw+273.15-46.13)-23.1964)-1;
da=d(Tg,Tw);
ha=(1.01*Tg+0.001*(da*1000)*(2501+1.85*Tg))*1000;
return(ha);
}
float ra(float Tg,float Tw)
{
float ra,uda,uv,rda,rv,w,d;
w=pow(10,5)*exp(3816.44/(Tw+273.15-46.13)-23.1964)-1;
d=(166.31*pow((647.3-Tw-273.15),0.38)*1.0/w-1.01*(Tg-Tw))*1.0/(267.38*pow((647.3-Tw-273.15),0.38)+1.88*(Tg-Tw));
uda=(17.4945+4.779e-2*Tg-3.526e-5*pow(Tg,2))*pow(10,-6);
uv=(8.1804+4.011e-2*Tg-1.7858e-5*pow(Tg,2))*pow(10,-6);
rda=(2.4587+7.5855e-3*Tg-1.69e-6*pow(Tg,2))*pow(10,-2);
rv=(1.6+6.179e-3*Tg+2.7535e-5*pow(Tg,2))*pow(10,-2);
ra=(rda*4.56724/pow((1+0.881*pow((uda/uv),0.5)),2))*(1/(1+1.60746*d)+(rv/rda)/(1+(uv/uda)*(1/d)));
return(ra);
}
float ua(float Tg,float Tw)
{
float ua,uda,uv,d,w;
uda=(17.4945+4.779e-2*Tg-3.526e-5*pow(Tg,2))*pow(10,-6);
uv=(8.1804+4.011e-2*Tg-1.7858e-5*pow(Tg,2))*pow(10,-6);
w=pow(10,5)*exp(3816.44/(Tw+273.15-46.13)-23.1964)-1;
d=(166.31*pow((647.3-Tw-273.15),0.38)*1.0/w-1.01*(Tg-Tw))*1.0/(267.38*pow((647.3-Tw-273.15),0.38)+1.88*(Tg-Tw));
ua=uda*(1+1.268*(uv/uda)*d)/(1+1.268*d);
return(ua);
}
float a(float Tg,float Tw,float Ga,float gjv,float jv,float ch,float de,float Hp,float D,float W)
{
float a,Rea,pr,r,cpa,u;
u=ua(Tg,Tw);
Rea=Re(Ga,de,u);
r=ra(Tg,Tw);
cpa=cpma(Tg,Tw);
pr=cpa*u/r;
a=0.1758*(r/de)*pow(Rea,0.505)*pow(pr,0.3333)*pow((W/de),0.485)*pow((D/de),1.9908)*pow((Hp/de),-0.5268);
return(a);
}
float Tg(float d1,float tw)
{
float t1,t2,t,da;
for (t1=-15,t2=70,t=(t1+t2)/2,da=d(t,tw);
fabs(da-d1)>0.0001;
t=(t1+t2)/2,da=d(t,tw))
{
if(da>d1)
t1=t;
else
t2=t;
}
return(t);
}
float ga(float tg,float tw)
{
float a,ga,da,ps;
ps=exp(6.42+0.072*tg-2.71e-3*pow(tg,2)+7.23e-7*pow(tg,3));
da=d(tg,tw);
a=101325/(0.622/da+1)/ps;
ga=101325*(1-0.378*a*ps/101325)/(287.06*(tg+273.15));
return(ga);
}
float t_w(float h)
{
float t,t1,t2,ha,da;
for(t1=-20,t2=70,t=(t1+t2)/2,da=d(t,t),
ha=(1.01*t+0.001*(da*1000)*(2501+1.85*t))*1000;
fabs(ha-h)>1;
t=(t1+t2)/2,da=d(t,t),ha=(1.01*t+0.001*(da*1000)*(2501+1.85*t))*1000)
{
if (ha>h)
t2=t;
else
t1=t;
}
return(t);
}
float x(float htp,float t)
{
float x;
x=(htp-hf(t))/(hv(t)-hf(t));
return(x);
}
float ash(float Gr,float t,float de)
{
float ash,re,pr,nu,r,cp,u;
u=uf(t);
cp=cpf(t);
r=rf(t);
re=Gr*de/u;
pr=cp*u/r;
nu=0.023*pow(re,0.8)*pow(pr,0.4);
ash=nu*r/de;
return(ash);
}
float asc(float Gr,float de,float t)
{
float asc,re,pr,nu,r,cp,u;
u=ug(t);
cp=cpg(t);
r=rg(t);
re=Gr*de/u;
pr=cp*u/r;
nu=0.023*pow(re,0.8)*pow(pr,0.4);
asc=nu*r/de;
return(asc);
}
float atp(float x,float Gr,float t,float de)
{
float atp,cp,r,u,pr,g1,vs1,nu;
cp=cpf(t);
u=uf(t);
r=x*rg(t)+(1-x)*rf(t);
pr=cp*u/r;
g1=g(t);
vs1=vs(t);
nu=0.0265*pow(Gr,0.8)*pow(((1-x+x*pow(g1*vs1,0.5))/u),0.8)*pow(pr,1/3);
atp=nu*r/de;
return(atp);
}
void Lsh(float L,float ta,float tw,float v,float Tc,float mr,float gjv,float jv,float ch,float de,float ck,
float e,float Hp,float D,float W,float hjs,float *ta2,float *tw2,float *Lsh,float *tout,float *Qr)
{
float L_sh;
float tsh,h2,t1,t2,h1,trm,a_sh;
float ta1,tw1,da,ha1,Qr1,ha2,tam,twm,ao,Aa;
float ma,g_a,As,Gr,Ga,Qa;
float n,i;
float Ai,Ao;
As=pi*pow(de/2-e,2);
Gr=mr/As;
g_a=ga(ta,tw);
ma=g_a*v/3600;
Aa=pi*(gjv/2)*(gjv/2+de);
Ga=ma/Aa;
Ai=pi*(de-2*e)*L;
Ao=pi*de*L;
*tout=T(hjs);
n=50;
tsh=(Tc-*tout)/n;
t2=*tout;
h2=hf(t2);
ta1=ta;
tw1=tw;
ha1=ha(ta1,tw1);
da=d(ta,tw);
*Lsh=0;
*Qr=0;
for(i=1;i<=n;i++)
{
t1=t2+tsh;
h1=hf(t1);
Qr1=mr*(h1-h2);
Qa=Qr1;
ha2=Qa/ma+ha1;
*tw2=t_w(ha2);
*ta2=Tg(da,*tw2);
trm=(t1+t2)/2;
tam=(ta1+*ta2)/2;
twm=(tw1+*tw2)/2;
a_sh=ash(Gr,trm,de-2*e);
ao=a(tam,twm,Ga,gjv,jv,ch,de,Hp,D,W);
L_sh=(1/a_sh+Ai/(Ao*ao))*mr*(h1-h2)/((trm-tam)*pi*(de-2*e));
*Lsh=*Lsh+L_sh;
*Qr=*Qr+Qr1;
t2=t1;
h2=h1;
}
}
void Ltp(float L,float ta,float tw,float v,float Tc,float mr,float gjv,float jv,float ch,float de,float ck,float e,
float Hp,float D,float W,float hout,float *Ltp,float *ta2,float *tw2,float *Qr,float *xout)
{
float h2,h1,hin,htp,x1,x2,a_tp,xm;
float ta1,tw1,da,ha1,Q_r,ha2,tam,twm,ao,Qa,Aa;
float L_tp;
float n,i;
float ma,g_a,As,Gr,Ga;
float Ai,Ao;
As=pi*pow(de/2-e,2);
Gr=mr/As;
g_a=ga(ta,tw);
ma=g_a*v/3600;
Aa=pi*(gjv/2)*(gjv/2+de);
Ga=ma/Aa;
Ai=pi*(de-2*e)*L;
Ao=pi*de*L;
hin=hv(Tc);
n=100;
htp=(hin-hout)/n;
ta1=ta;
tw1=tw;
ha1=ha(ta1,tw1);
da=d(ta,tw);
*xout=x(hout,Tc);
h2=hout;
x2=*xout;
*Ltp=0;
*Qr=0;
for(i=1;i<=n;i++)
{
h1=h2+htp;
x1=x(h1,Tc);
xm=(x1+x2)/2;
Q_r=mr*(h1-h2);
Qa=Q_r;
ha2=Qa/ma+ha1;
*tw2=t_w(ha2);
*ta2=Tg(da,*tw2);
*tw2=t_w(ha2);
*ta2=Tg(da,*tw2);
tam=(ta1+*ta2)/2;
twm=(tw1+*tw2)/2;
ao=a(tam,twm,Ga,gjv,jv,ch,de,Hp,D,W);
a_tp=atp(xm,Gr,Tc,de-2*e);
L_tp=(1/a_tp+Ai/(Ao*ao))*mr*htp/((Tc-tam)*pi*(de-2*e));
*Ltp=*Ltp+L_tp;
*Qr=*Qr+Q_r;
h2=h1;
x2=x1;
}
}
void Lsc(float L,float ta,float tw,float tin,float v,float Tc,float mr,float gjv,float jv,float ch,float de,float ck,float e,
float Hp,float D,float W,float *ta2,float *tw2,float *Lsc,float *Qr)
{
float tout,t2,h2,t1,h1,trm,a_sc,tsc;
float ta1,tw1,da,ha1,Q_r,ha2,tam,twm,ao,Qa,Aa;
float n,i;
float L_sc;
float ma,g_a,As,Gr,Ga;
float Ai,Ao;
As=pi*pow(de/2-e,2);
Gr=mr/As;
g_a=ga(ta,tw);
ma=g_a*v/3600;
Aa=pi*(gjv/2.0)*(gjv/2.0+de);
Ga=ma/Aa;
Ai=pi*(de-2*e)*L;
Ao=pi*de*L;
tout=Tc;
n=50;
tsc=(tin-tout)/n;
t2=tout;
h2=hv(t2);
ta1=ta;
tw1=tw;
ha1=ha(ta1,tw1);
da=d(ta,tw);
*Lsc=0;
*Qr=0;
for(i=1;i<=n;i++)
{
t1=t2+tsc;
h1=hs(t1-Tc,Tc);
Q_r=mr*(h1-h2);
Qa=Q_r;
ha2=Qa/ma+ha1;
*tw2=t_w(ha2);
*ta2=Tg(da,*tw2);
trm=(t1+t2)/2;
tam=(ta1+*ta2)/2;
twm=(tw1+*tw2)/2;
a_sc=asc(Gr,trm,de-2*e);
ao=a(tam,twm,Ga,gjv,jv,ch,de,Hp,D,W);
L_sc=(1/a_sc+Ai/(Ao*ao))*mr*(h1-h2)/((trm-tam)*pi*(de-2*e));
*Lsc=*Lsc+L_sc;
*Qr=*Qr+Q_r;
t2=t1;
h2=h1;
//ta1=*ta2;
//tw1=*tw2;
//ha1=ha2;
}
}
void condenser(float gjv,float jv,float ch,float de,float ck,float e,float Hp,float D,float W,float L,float mr,float tin,float Tc, float ta,float tw,
float v,float*tout,float*L_sh_con,float*L_tp_con,float*L_sc_con,float*Qr_sh_con,float*Qr_tp_con,float*Qr_sc_con,
float*Qz,float*Lz,float*hjs,float*hyt,float*xout)
{
float pc,hsx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-L)>0.1)
hxx=*hjs;
else if((*Lz-L)<0.1)
hsx=*hjs;
else
break;
}
}
void main()
{
float gjv,jv,ch,de,ck,e,L,Hp,D,W;
float mr,tin,Tc;
float ta,tw,v;
float Qr_sh,Qr_sc,Qr_tp,Qz;
float Lz,L_sh,L_tp,L_sc;
float hjs,hyt,tout,xout;
gjv=10e-3;
jv=2.5e-3;
ch=0.1e-3;
de=3.74e-3;
ck=0.016;
e=0.0005;
Tc=45;
tin=75;
mr=0.005;
v=360/2.0;
ta=20;
tw=12;
L=0.62;
Hp=0.008;
D=0.0015;
W=0.001;
condenser(gjv,jv,ch,de,ck,e,Hp,D,W,L,mr,tin,Tc,ta,tw,v,&tout,&L_sh,&L_tp,&L_sc,&Qr_sh,&Qr_tp,&Qr_sc,&Qz,&Lz,&hjs,&hyt,&xout);
if (hjs<hyt)
{
cout<<"冷凝器过冷"<<endl;
cout<<"制冷剂出口温度tout="<<tout<<endl;
cout<<"过冷区长度L_sh="<<L_sh<<endl;
cout<<"过冷区换热量Qr_sh="<<Qr_sh<<endl;
cout<<"两相区长度L_tp="<<L_tp<<endl;
cout<<"两相区换热量Qr_tp="<<Qr_tp<<endl;
cout<<"过热区长度L_sc="<<L_sc<<endl;
cout<<"过热区换热量Qr_sc="<<Qr_sc<<endl;
cout<<"总换热量Qz="<<Qz<<endl;
cout<<"总长Lz="<<Lz<<endl;
}
else
{
cout<<"两相区长度L_tp="<<L_tp<<endl;
cout<<"两相区换热量Qr_tp="<<Qr_tp<<endl;
cout<<"两相区出口干度xcout="<<xout<<endl;
cout<<"过热区长度L_sc="<<L_sc<<endl;
cout<<"过热区换热量Qr_sc="<<Qr_sc<<endl;
cout<<"总换热量Qz="<<Qz<<endl;
cout<<"总长Lz="<<Lz<<endl;
}
}