PDA

View Full Version : Fan model for system optimization







autt
14-01-2007, 02: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.

nh3simman
26-03-2007, 06:55 AM
Hi Autt

This looks interesting.

When you refer to "platform" I assume you are talking about the network solver.

Can you please write out the process in pseudo code.
This would make it much more useful and easier to see your objective.

What is your terminating criteria?

autt
27-03-2007, 04:15 PM
Hi nh3simnan,

Basically platform processes network management and call different solver. I say platform because it is a separated module to component package.

Before processing, a network scan first executed to find the best calling sequence, the process or the sover just call component calculate procedure by sequence, and mainly include many data lookups, transfers, modifications and judgements, it may make everybody confused.

After each iteration, the sover check each component output data and compare to the last time value till all of them meet precision requirement, this terminate criteria proved to be effective as I used these years.

nh3simman
28-03-2007, 08:25 AM
Hi Autt

Have you heard of the Broyden method?

It is an iterative method of solving multi-dimensional non-linear systems.

As with the Newton-Raphson method, convergence is quadratic but the advantage is that you do not have to recalculate the slope matrix. You start with a calculation of the inverse slope matrix and only have to update the slope at each step.

I have tried this with 1000 branch airflow networks that includes active components like fans and leakage branches.

With object oriented design, the network can be written as an abstract solver. This means that you can plug in components like ducts, fans, etc...

nh3simman
28-03-2007, 08:38 AM
Hi Autt

In the The Lounge - Computers and the Internet - Network solvers ...

I posted a thread about network solutions

http://www.refrigeration-engineer.com/forums/showthread.php?goto=newpost&t=7427

It seems that you may have much to contribute to this topic.

autt
29-03-2007, 04:45 PM
Thank you nh3simman

There are a lot to learn, I will try them.

I don't know the Broyden method, what's the advantage of it? I have searched and need to understand for detail. The Newton-Raphson method in a small loop sometimes goes wrong, cause exception or dead loop, so I wrote program use a gradual average method, usually steady but converged slowly.

I borrowed a book about optimization, seems no good method suitable for non-linear system, do you have suggestions?

autt
29-03-2007, 05:35 PM
I have tried this with 1000 branch airflow networks that includes active components like fans and leakage branches.

1000 is a very large number, I just tried a 9 branches with flow and pressure balance from my DuctNet package, it takes 4 seconds in my computer at the best state, some iterations calculated in components.

nh3simman
30-03-2007, 11:02 AM
I don't know the Broyden method, what's the advantage of it?

I borrowed a book about optimization, seems no good method suitable for non-linear system, do you have suggestions?


Broyden is derived from Newton-Raphson. Basically is updates the inverse of the slope at each iteration. For big non-linear systems it is faster than newton.

You are right, there are no perfect solutions for big non-linear systems.

There is an amazing reference called numerical recipes. You can download the pdf's of the book from the NR web site. And guess what? You can copy/paste the source code from the book in C.

NR recommends the Broyden method

autt
31-03-2007, 05:34 AM
Thank you nh3simman, I've also found Broyden method in one of my books.