?? rgwsbxhs.cpp
字號(hào):
//日光溫室熱環(huán)境模擬程序的函數(shù)
//本文件為備選函數(shù),有些函數(shù)根據(jù)具體問題需改寫
//2007年9月
int month,date;
double bw,dj,timeb,bmfw,bmqx,IDS;
//-------------------------------------------------------------------------------------------------------
//日期遞進(jìn)計(jì)算函數(shù)datecount()----------------------------------------------------------2007.9.4調(diào)試
//本函數(shù)根據(jù)起始日期和時(shí)間,計(jì)算經(jīng)過(guò)一個(gè)步長(zhǎng)的時(shí)間(s,3600s以內(nèi))后的月、日、時(shí)
//時(shí)間累計(jì)尚未進(jìn)入下一日時(shí),返回0;進(jìn)入下一日但尚未跨月時(shí),返回1;跨月時(shí),返回2.
//全局變量說(shuō)明
//AAI[30] -- 用于將整型局部變量的計(jì)算結(jié)果從函數(shù)內(nèi)傳送到外部的數(shù)組,各函數(shù)通用,
// 但不同函數(shù)分配使用不同的區(qū)段,日期遞進(jìn)計(jì)算函數(shù)使用AAI[0]~AAI[4]的區(qū)段
//AAD[80] -- 用于將雙精度型局部變量的計(jì)算結(jié)果從函數(shù)內(nèi)傳送到外部的數(shù)組,各函數(shù)通用,
// 但不同函數(shù)分配使用不同的區(qū)段,日期遞進(jìn)計(jì)算函數(shù)使用AAD[15]~AAD[19]的區(qū)段
//調(diào)用本函數(shù)的實(shí)參依次為 函數(shù)調(diào)用后,下一步的日期與時(shí)間放在傳送數(shù)組中對(duì)應(yīng)元素中↓
//month -- 月 -----------------------------------------------------------------------AAI[1]
//date -- 日 -----------------------------------------------------------------------AAI[2]
//timeb -- 時(shí)(北京時(shí)間),形式為xx.xx時(shí)(24時(shí)制),分以下單位需化成時(shí) -----------------AAD[16]
//dtao -- 時(shí)間步長(zhǎng),s;
//---------------------------------------------------------------------------------------------
int datecount(int month,int date,double timeb,double dtao)
{
AAI[1]=month; AAI[2]=date; AAD[16]=timeb;
AAD[16]=timeb+dtao/3600.0;
if(AAD[16]<24.0)return(0); //時(shí)間累計(jì)尚未進(jìn)入下一日
AAI[2]=AAI[2]+1; AAD[16]=AAD[16]-24.0;
if(AAI[2]>28 && AAI[1]==2) //2月跨到3月,2月按平年28日計(jì)算
{
AAI[1]=AAI[1]+1; AAI[2]=1; return(2);
}
if(AAI[2]>30) //小月的月末跨月的情況
if(AAI[1]==4 || AAI[1]==6 || AAI[1]==9 || AAI[1]==11)
{
AAI[1]=AAI[1]+1; AAI[2]=1; return(2);
}
if(AAI[2]>31) //大月的月末跨月的情況
if(AAI[1]==1 || AAI[1]==3 || AAI[1]==5 || AAI[1]==7 || AAI[1]==8 || AAI[1]==10 || AAI[1]==12)
{
AAI[1]=AAI[1]+1; if(AAI[1]>12)AAI[1]=AAI[1]-12; AAI[2]=1; return(2);
}
return(1); //跨日不能跨月的情況
}
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
//大氣透明度計(jì)算函數(shù)dqtmd()
//執(zhí)行本函數(shù)的結(jié)果返回大氣透明度值
//調(diào)用本函數(shù)的實(shí)參依次為
//bw -- 北緯度數(shù),度
//month -- 月份
//---------------------------------------------------------------------------------------------
double dqtmd(double bw,int month)
{ double x;
x=month;
if(bw<27.5) return (0.0021*x*x - 0.0254*x + 0.7005);
if(bw>27.5 && bw<=32.5) return (0.0038*x*x - 0.0471*x + 0.7707);
if(bw>32.5 && bw<=37.5) return (0.0038*x*x - 0.0459*x + 0.7691);
if(bw>37.5 && bw<=42.5) return (0.0033*x*x - 0.0409*x + 0.772);
if(bw>42.5) return (0.0039*x*x - 0.0481*x + 0.787);
}
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
//計(jì)算太陽(yáng)輻射照度的函數(shù)TYFZ()---------------------------------------------------------2007.9.6調(diào)試
//執(zhí)行本函數(shù)的結(jié)果返回指定傾角表面的太陽(yáng)總輻射照度值IDS,計(jì)算出水平面的直接輻射IDH和散射輻射ISH,W/m2,
//并將其以及一些中間計(jì)算結(jié)果存入數(shù)組AAD[],以便調(diào)試檢查和使用
//本函數(shù)執(zhí)行將調(diào)用大氣透明度計(jì)算函數(shù)dqtmd()
//調(diào)用本函數(shù)的實(shí)參依次為
//bw -- 北緯度數(shù),度
//dj -- 東經(jīng)度數(shù),度
//month,date -- 月、日
//timeb -- 時(shí)(北京時(shí)間),形式為xx.xx時(shí)(24時(shí)制),分以下單位需化成時(shí)
//bmfw -- 表面方位角,度
//bmqx -- 表面傾斜角,度
//全局變量說(shuō)明
//AAD[80] -- 用于將雙精度型局部變量的計(jì)算結(jié)果從函數(shù)內(nèi)傳送到外部的數(shù)組,各函數(shù)通用,
// 但不同函數(shù)分配使用不同的區(qū)段,太陽(yáng)輻射照度相關(guān)函數(shù)使用AAD[0]~AAD[14]的區(qū)段
//IDS -- 指定傾角表面的太陽(yáng)總輻射照度,W/m2 (是函數(shù)返回值,但未在本函數(shù)中出現(xiàn))
//局部變量說(shuō)明 傳送數(shù)組中對(duì)應(yīng)元素↓
//time -- 當(dāng)?shù)仄骄?yáng)時(shí),形式為xx.xx時(shí)(24時(shí)制),分以下單位需化成時(shí) ------------AAD[0]
//sj -- 時(shí)間角,度 -------------------------------------------------------------AAD[1]
//tycw -- 太陽(yáng)赤緯角,度 -------------------------------------------------------AAD[2]
//tygd -- 太陽(yáng)高度角,弧度 -----------------------------------------------------AAD[3]
//tyfw -- 太陽(yáng)方位角,弧度 -----------------------------------------------------AAD[4]
//p -- 大氣透明度 --------------------------------------------------------------AAD[5]
//I0 -- 大氣層外邊界處法向太陽(yáng)輻射照度,W/m2 -----------------------------------AAD[6]
//IDN -- 法向太陽(yáng)直接輻射,W/m2 ------------------------------------------------AAD[7]
//ID -- 指定位置表面上的太陽(yáng)直接輻射,W/m2 -------------------------------------AAD[8]
//IDH -- 水平面太陽(yáng)直接輻射 ----------------------------------------------------AAD[9]
//IS -- 指定位置表面上的太陽(yáng)散射輻射,W/m2 -------------------------------------AAD[10]
//ISH -- 水平面太陽(yáng)散射輻射(實(shí)際上為天空散射,僅計(jì)算天空散射輻射),W/m2 --------AAD[11]
//d -- 1月1日至所計(jì)算日之前天數(shù)之和
//m -- 大氣質(zhì)量
//sinh -- 太陽(yáng)高度角的正弦
//cosbt -- 太陽(yáng)光線與表面法線夾角的余弦
//temp -- 中間變量
//---------------------------------------------------------------------------------------------
double TYFZ(double bw,double dj,int month,int date,double timeb,double bmfw,double bmqx)
{
double time,sj,tycw,tygd,tyfw,p,I0,IDN,ID,IDH,IS,ISH;
double d,dp,m,sinh,cosbt,temp;
if (month==1) {I0=1405.0; d=date;}
else if (month==2) {I0=1394.0; d=31+date;}
else if (month==3) {I0=1378.0; d=59+date;}
else if (month==4) {I0=1353.0; d=90+date;}
else if (month==5) {I0=1334.0; d=120+date;}
else if (month==6) {I0=1316.0; d=151+date;}
else if (month==7) {I0=1308.0; d=181+date;}
else if (month==8) {I0=1315.0; d=212+date;}
else if (month==9) {I0=1330.0; d=243+date;}
else if (month==10){I0=1350.0; d=273+date;}
else if (month==11){I0=1372.0; d=304+date;}
else if (month==12){I0=1392.0; d=334+date;}
dp=3.1416/180.0;
tycw=23.45*cos((360.0*(d-172.0)/365.0)*dp);
time=timeb-(120.0-dj)/15.0; sj=15.0*(time-12.0);
sinh=cos(bw*dp)*cos(tycw*dp)*cos(sj*dp)+sin(bw*dp)*sin(tycw*dp);
tygd=asin(sinh);
//太陽(yáng)方位角的計(jì)算,多數(shù)書籍上說(shuō)法不準(zhǔn)確,見《建筑熱過(guò)程》86年版上的紅字批注
temp=(sin(tygd)*sin(bw*dp)-sin(tycw*dp))/cos(tygd)/cos(bw*dp);
if(temp<=-1.0)tyfw=180.0; //由于計(jì)算機(jī)的數(shù)字存儲(chǔ)方式產(chǎn)生的誤差,可能出現(xiàn)temp絕對(duì)值略大于1的情況
if(temp>=1.0)tyfw=0.0;
if(temp>-1.0 && temp<1.0)tyfw=acos(temp);
if(sj<0)tyfw=(-1.0)*tyfw; //太陽(yáng)方位角正負(fù)與時(shí)角相同,acos()只能計(jì)算出正角,負(fù)角只能根據(jù)時(shí)角判斷
cosbt=sin(tygd)*cos(bmqx*dp)+cos(tygd)*sin(bmqx*dp)*cos(tyfw-bmfw*dp);
p=dqtmd(bw,month);
m=1.0/sin(tygd);
if(sinh<=0.0) {IDN=0.0; ID=0.0; IDH=0.0; IS=0.0; ISH=0.0;}
if(sinh>0.0)
{
IDN=I0*pow(p,m);
IDH=IDN*sin(tygd);
ID=IDN*cosbt; if(cosbt<0.0)ID=0.0; //cosbt<0.0,有bt>90度,即光線照到該表面背面去了
ISH=I0/2.0*(1.0-pow(p,m))/(1.0-1.4*log(p))*sin(tygd);
IS=ISH*cos(bmqx*dp/2.0)*cos(bmqx*dp/2.0);
}
//以下將局部變量的計(jì)算結(jié)果放入傳送數(shù)組中,以便以后在函數(shù)外部使用或調(diào)試中輸出檢查
AAD[0]=time;
AAD[1]=sj; AAD[2]=tycw; AAD[3]=tygd; AAD[4]=tyfw; AAD[5]=p;
AAD[6]=I0; AAD[7]=IDN; AAD[8]=ID; AAD[9]=IDH; AAD[10]=IS; AAD[11]=ISH;
return (ID+IS);
}
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
//以下為內(nèi)外側(cè)流體溫度、相對(duì)濕度、熱源以及對(duì)流換熱系數(shù)
//---------------------------------------------------------------------------------------------
double tf_0(double h) //h為24時(shí)制的時(shí)數(shù)
{
double pi,tp,a1,a2,f1,f2,tmax,tmin,t;
pi=3.1416; tp=-0.016; a1=0.48; a2=0.08; f1=3.8; f2=0.005;
tmax=5.0; tmin=-10.0;
t=(tmax+tmin)/2.0+(tmax-tmin)*(tp+a1*cos(2.0*h*pi/24.0-f1)+a2*cos(4.0*h*pi/24.0-f2));
return (t);
}
//---------------------------------------------------------------------------------------------
double fi_0(double h) //h為24時(shí)制的時(shí)數(shù)(fi為小數(shù))
{
double pi,fip,a1,a2,f1,f2,fimax,fimin,fi;
pi=3.1416; fip=-0.016; a1=0.48; a2=0.08; f1=3.8; f2=0.005;
fimax=0.90; fimin=0.40;
fi=(fimax+fimin)/2.0-(fimax-fimin)*(fip+a1*cos(2.0*h*pi/24.0-f1)+a2*cos(4.0*h*pi/24.0-f2));
return (fi);
}
//---------------------------------------------------------------------------------------------
double tf_n(double h) //h為24時(shí)制的時(shí)數(shù)
{
double pi,tp,a1,a2,f1,f2,tmax,tmin,t;
pi=3.1416; tp=-0.016; a1=0.48; a2=0.08; f1=3.8; f2=0.005;
tmax=25.0; tmin=10.0;
t=(tmax+tmin)/2.0+(tmax-tmin)*(tp+a1*cos(2.0*h*pi/24.0-f1)+a2*cos(4.0*h*pi/24.0-f2));
return (t);
}
//---------------------------------------------------------------------------------------------
double alf_0()
{
return(23.0);
}
//---------------------------------------------------------------------------------------------
double alf_n()
{
return(8.7);
}
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
//確定風(fēng)速的函數(shù)v_o()
//---------------------------------------------------------------------------------------------
double v_o()
{
return(4.0);
}
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
//確定揭簾(保溫被)時(shí)間的函數(shù)t_0()
//本函數(shù)根據(jù)日光溫室的管理制度,給出某月份和日期揭簾(保溫被)的時(shí)間
//調(diào)用本函數(shù)的實(shí)參依次為
//month,date -- 月、日
//---------------------------------------------------------------------------------------------
double t_0(int month,int date)
{
if(month==10) return 6.5;
if(month==11) return 7.0;
if(month==12) return 7.5;
if(month==1) return 7.5;
if(month==2) return 7.0;
if(month==3) return 6.5;
return 6.0;
}
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
//確定蓋簾(保溫被)時(shí)間的函數(shù)t_1()
//本函數(shù)根據(jù)日光溫室的管理制度,給出某月份和日期蓋簾(保溫被)的時(shí)間
//調(diào)用本函數(shù)的實(shí)參依次為
//month,date -- 月、日
//---------------------------------------------------------------------------------------------
double t_1(int month,int date)
{
if(month==10) return 18.0;
if(month==11) return 17.5;
if(month==12) return 17.0;
if(month==1) return 17.0;
if(month==2) return 17.5;
if(month==3) return 18.0;
return 19.0;
}
//---------------------------------------------------------------------------------------------
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -