autt

14-01-2007, 03:13 PM

Fan model may be the simplest in refreigration system, here is part of the model's C++ code I used, include thermal and optimization object calculation.

Model for system optimization is different from that of simulate, or part design, this model is used to select the fan for system, not used to simulate the fan, or to design a fan.

For people don't programming ,the code may be hard for reading even has annotate, so feel free to ask and comments.

//----------------------------------------------------

//Main calculating procedure

int TFCFanDesign::SS(TFCSwapData* Data)

{

//Place steady processing code here

//First, InPort->Input;

//Then, Input--calculate->Output;

//In the end, Output->OutPort.

//Return value: -1=error; 0=Warning; 1=normal; 2=need iterate at once; 3=need iterate

TYYDAirProperty ap; //Air property calculation model

double PIc;

//Subscript 1=Inlet; 2=Outlet

//Retrieve data transfered from platform

cW1=pW1; //Inlet air flow

cP1=pP1; //Inlet air pressure, used for downstream calculating

cT1=pT1+273.15; //Inlet air temperature

cSH1=pSH1; //Inlet air humidity ratio

cFW1=pFW1; //Inlet air free water

cPU2=pPU2; //Outlet air pressure, used for upstream calculating

//Outlet pressure

cP2=pPU2; //Outlet pressure is determined by upstream pressure in system design state

//Outlet air flow

cW2=cW1;

//Compress ratio

if(cP1>0) PIc=cPU2/cP1;

else PIc=1;

//Outlet temperaure

cT2=cT1*(pow(PIc,0.286)-1)/cEC+cT1; //cEC=Efficiency of compression, user inputed

//Fan power needed, W

cPF=cW1*ap.GetCp(cPU1,cT1,cSH1)*(cT2-cT1)/cEE; //cEE=Electric efficiency, user inputed

//Change temperature unit to Celsius degree

cT1-=273.15;

cT2-=273.15;

//Save output data, used to send to platform

pPU1=cP1;

pW2=cW2;

pP2=cPU2;

pT2=cT2;

pSH2=cSH1;

pFW2=cFW1;

return 1;

}

//----------------------------------------------------

//Weight calculating procedure

int TFCFanDesign::GetWeight(TFCSwapData* Data)

{

//Place weight code here

double w;

int OB=YYDRound(cOB); //cOB=Optimize object, 0=weight; 1= price; 2=life time cost. user inputed

w=21.3+0.00682*cPF; //Fan weight estimation, data comes from some types of centrifugal fan

if(OB==0)Data->Weight=w;

if(OB==1)Data->Weight=w*cCW; //cCW=Coefficient of price, cost per kilogram, user inputed, from fan select book

if(OB==2)Data->Weight=w*cCW+cCE*cLT*0.001*cPF; //cCE=Electricity price; cLT=Design life time

//Fan weight estimation is varies from different type of fan, will be updated, and cCW

return 1;

}

//----------------------------------------------------

To get exact pressure at model inlet and outlet, system use two pressures calculating from direction of upstream and downstream respectively. So from whole system suction and discharge pressure, we can determine pressures at each line node.

Weight is returned to platform to join the sum of whole system models' weight, then the platform can compare different optimizing quantities combinations to find the best one with smallest weight.

For a good system scheme and calculation setting, the finding process usually gives a reasonable result,

but for safely calculating, it is best to set optimizing data varies range, and set constraint range for any output data.

I found this is hard to express my ideas:confused: , so I have to draw a whole system optimization diagram these days to illustrate them.

Model for system optimization is different from that of simulate, or part design, this model is used to select the fan for system, not used to simulate the fan, or to design a fan.

For people don't programming ,the code may be hard for reading even has annotate, so feel free to ask and comments.

//----------------------------------------------------

//Main calculating procedure

int TFCFanDesign::SS(TFCSwapData* Data)

{

//Place steady processing code here

//First, InPort->Input;

//Then, Input--calculate->Output;

//In the end, Output->OutPort.

//Return value: -1=error; 0=Warning; 1=normal; 2=need iterate at once; 3=need iterate

TYYDAirProperty ap; //Air property calculation model

double PIc;

//Subscript 1=Inlet; 2=Outlet

//Retrieve data transfered from platform

cW1=pW1; //Inlet air flow

cP1=pP1; //Inlet air pressure, used for downstream calculating

cT1=pT1+273.15; //Inlet air temperature

cSH1=pSH1; //Inlet air humidity ratio

cFW1=pFW1; //Inlet air free water

cPU2=pPU2; //Outlet air pressure, used for upstream calculating

//Outlet pressure

cP2=pPU2; //Outlet pressure is determined by upstream pressure in system design state

//Outlet air flow

cW2=cW1;

//Compress ratio

if(cP1>0) PIc=cPU2/cP1;

else PIc=1;

//Outlet temperaure

cT2=cT1*(pow(PIc,0.286)-1)/cEC+cT1; //cEC=Efficiency of compression, user inputed

//Fan power needed, W

cPF=cW1*ap.GetCp(cPU1,cT1,cSH1)*(cT2-cT1)/cEE; //cEE=Electric efficiency, user inputed

//Change temperature unit to Celsius degree

cT1-=273.15;

cT2-=273.15;

//Save output data, used to send to platform

pPU1=cP1;

pW2=cW2;

pP2=cPU2;

pT2=cT2;

pSH2=cSH1;

pFW2=cFW1;

return 1;

}

//----------------------------------------------------

//Weight calculating procedure

int TFCFanDesign::GetWeight(TFCSwapData* Data)

{

//Place weight code here

double w;

int OB=YYDRound(cOB); //cOB=Optimize object, 0=weight; 1= price; 2=life time cost. user inputed

w=21.3+0.00682*cPF; //Fan weight estimation, data comes from some types of centrifugal fan

if(OB==0)Data->Weight=w;

if(OB==1)Data->Weight=w*cCW; //cCW=Coefficient of price, cost per kilogram, user inputed, from fan select book

if(OB==2)Data->Weight=w*cCW+cCE*cLT*0.001*cPF; //cCE=Electricity price; cLT=Design life time

//Fan weight estimation is varies from different type of fan, will be updated, and cCW

return 1;

}

//----------------------------------------------------

To get exact pressure at model inlet and outlet, system use two pressures calculating from direction of upstream and downstream respectively. So from whole system suction and discharge pressure, we can determine pressures at each line node.

Weight is returned to platform to join the sum of whole system models' weight, then the platform can compare different optimizing quantities combinations to find the best one with smallest weight.

For a good system scheme and calculation setting, the finding process usually gives a reasonable result,

but for safely calculating, it is best to set optimizing data varies range, and set constraint range for any output data.

I found this is hard to express my ideas:confused: , so I have to draw a whole system optimization diagram these days to illustrate them.