Applying heat flux on a tube surface

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2009
Posts: 9
Reputation: tendolm is an unknown quantity at this point 
Solved Threads: 0
tendolm tendolm is offline Offline
Newbie Poster

Re: Applying heat flux on a tube surface

 
0
  #11
Mar 15th, 2009
Dear friends
I have put my problem only in C++ so that you can be able to assist me. Please may you help me to:
1.write corectly the formular to determining Atb. It is supposed to be
Atb = a0 + a1exp(-k/cos_thetaz); With what I have done am getting wrong answers.
2. for a given value of n be able to print a table of p ie value of (x,y,z), h, n, (n was refered to as t in the first code sent)
3. develop a code such that for the same value of n, I can calculate h for different values of p(x,y,z) for example when x=
x=117.433
y=84.62-(1004.08180)n
z=124.621-(-1004.089)n
h=(Pb+Pgr)

x=87.5
y=73.837-(1004.087)n
z=113.837-(-1004.083)n
h=(Pgr+Pd)/2



#include <stdio.h>
main()
{
double x,y,z,n,h,p;
double BETA, AAZI, PHI, LTIME, SMER, LMER, N, ITIME, FTIME, LTUBE, IDTUBE, ODTUBE;
double THLCOEF, TCEF, ETAP, TCD, ATEMP, IAMC, CFFCT0, CFFCT1,CFFCTK,ALT, ALBEDO, FCS1, PI;
double B, P, E,E1,Tcorr, stime, del, omega, cos_theta1,cos_theta2, cos_theta3;
double cos_theta4, cos_theta5, cos_theta, theta, Ai, iam, cos_thetaz, Rb, Gon;
double a0c, a1c,kc, a0, a1, k, Atb, Gb, iamd,Pb, x1,x3, Z;
double f12, fcs, Atd, Gd, Pd, Ggr, Pgr, Pu;
double lower,upper,step;
double cos (), sin(), tan(), acos(), pow(), sqrt();
lower =0.0; /*lower value of n limit*/
upper =1.0; /* upper limit*/
step =0.1; /*step size*/
n=lower;
while (n<=upper)
{
x=87.5;
y = 126.1620 -(1004.0820*n);
z= 166.1620 -(-1004.0880*n);
p=(x,y,z);
BETA =45; /* defining constants*/
AAZI =15;
PHI= 43;
LTIME= 690.03;
SMER =90;
LMER =89.4;
N =234;
ITIME =690;
FTIME =790;
LTUBE= 1.8;
IDTUBE = 0.0192;
ODTUBE =0.0292;
THLCOEF= 0.9;
TCEF =0.98;
ETAP =0.856;
TCD =0.067;
ATEMP = 298.15;
IAMC = 3.8;
CFFCT0 =0.97;
CFFCT1 = 0.99;
CFFCTK = 1.02;
ALT =0.27;
ALBEDO = 0.5;
FCS1 = 0.5;
PI =3.141592;
B= 360*(N-81)/364;
P=PI/180;
E=9.87*sin(2*B*P)-7.53*cos(B*P)-1.5*sin(B*P);
E1= 4*(SMER-LMER);
Tcorr=E+E1;
stime = LTIME+Tcorr;
del = 23.45*sin(P*(360*(284+N)/365));
omega = (stime-720)/60*15;
cos_theta1 = sin(del*P)*cos(BETA*P)*sin(PHI*P);
cos_theta2 = sin(del*P)*sin(BETA*P)*cos(PHI*P)*cos(AAZI*P);
cos_theta3 = cos(del*P)*cos(PHI*P)*cos(BETA*P)*cos(omega*P);
cos_theta4 = cos(del*P)*sin(PHI*P)*sin(BETA*P)*cos(AAZI*P)*cos(omega*P);
cos_theta5 = cos(del*P)*sin(BETA*P)*sin(AAZI*P)*sin(omega*P);
cos_theta = cos_theta1-cos_theta2+cos_theta3+cos_theta4+cos_theta5;
theta = acos(cos_theta)*57.295779513;
Ai =tan(pow((theta/2)*P,IAMC));
iam = 1-Ai;
cos_thetaz = cos(del*P)*cos(PHI*P)*cos(omega*P)+sin(del*P)*sin(PHI*P);
Rb =cos_theta/cos_thetaz;
Gon = 1353*(1+0.033*cos(P*(360*N/365)));
a0c =0.4237-0.00821*((6-ALT)*(6-ALT));
a1c = 0.5055+0.00595*((6.5-ALT)*(6.5-ALT));
kc = 0.2711+0.01858*((2.5-ALT)*(2.5-ALT));
a0 = CFFCT0 *a0c;
a1 = CFFCT1*a1c;
k = CFFCTK *kc;
Atb = a0 + a1*pow(10,(-k/cos_theta));
Gb =Gon*Atb*cos_thetaz;
Pb=TCEF*ETAP*Gb*Rb*iam;
iamd =1-tan(pow(PI/6,IAMC));
x1= acos((ODTUBE-IDTUBE)/TCD);
x3 = acos((ODTUBE+IDTUBE)/TCD);
Z = sqrt(pow(TCD+ODTUBE*cos(PI+x1)- IDTUBE*sin(x1),2.)+
pow(ODTUBE*sin(PI+x1)-IDTUBE*sin(x1),2.));
f12 = 1*((PI-x1-x3)*IDTUBE+Z+(x3-x1)*ODTUBE-TCD*sin(x3))/(2*PI*IDTUBE);
fcs= FCS1 -f12;
Atd = .2710-.2939*Atb;
Gd = Atd*Gon;
Pd = TCEF*ETAP*iamd*Gd*fcs;
Ggr =ALBEDO*(Gb+Gd);
Pgr =TCEF*ETAP*iamd*Ggr*fcs;
Pu=Pb+Pd+Pgr;
h=Pb,
printf("\n%5.4f",Atb,n);
n=n+step;
}
}
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 71
Reputation: r.stiltskin is an unknown quantity at this point 
Solved Threads: 9
r.stiltskin r.stiltskin is offline Offline
Junior Poster in Training

Re: Applying heat flux on a tube surface

 
0
  #12
Mar 15th, 2009
You say C++ but you seem to be using C, as you #include <stdio.h> and use printf for printing. So, assuming you are using a C compiler, you should also #include <math.h> at the top of your program, unless you are planning to define your own math functions.

Also, delete the line double cos (), sin(), tan(), acos(), pow(), sqrt(); .

This line:
  1. Atb = a0 + a1*pow(10,(-k/cos_theta));
says
Atb = a_0 + a_1 \cdot 10^{-k/cos theta} which is clearly not what you wrote above.
Presumably you want
  1. Atb = a0 + a1 * exp(-k/cos_theta);

That long, long list of constants consists of constants, so you should define them just once, before the loop, not declare them over and over again inside the loop.

p=(x,y,z); is invalid. You have declared p as type double. That is a single value. If you want p to represent a 3-dimensional point, you have to define a structure that can hold 3 values.

Perhaps I am simply not seeing something because it's hidden among all those constants, but I don't see where you actually do anything with x,y,z (and p) after computing their values. Have you omitted something?
Last edited by r.stiltskin; Mar 15th, 2009 at 1:06 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 9
Reputation: tendolm is an unknown quantity at this point 
Solved Threads: 0
tendolm tendolm is offline Offline
Newbie Poster

Re: Applying heat flux on a tube surface

 
0
  #13
Mar 16th, 2009
Thanks for the correction. I am learning these softwares and do not actually know the differences between them. Yes I will use p when I do the analysis in Fluent. No further calculation will be done just use the 3-dimensional points I have managed to solve other problems. I am left with this p and calculating h for different locations. I think I use "if" but am failing to come up with that part of the code.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 71
Reputation: r.stiltskin is an unknown quantity at this point 
Solved Threads: 9
r.stiltskin r.stiltskin is offline Offline
Junior Poster in Training

Re: Applying heat flux on a tube surface

 
0
  #14
Mar 16th, 2009
You are not making yourself clear. Looking at the code you posted in Post #11, beginning on the line
BETA =45; /* defining constants*/
through and including the line
h=Pb, ,
everything is constant. (Incidentally, the line "h=Pb" should end with a semicolon ; not a comma.) Therefore, all of those lines should appear before the loop, not inside it.

So it seems you should have
  1. #include <stdio.h>
  2. #include <math.h> // provides math and trig functions
  3.  
  4. int main()
  5. {
  6. int n; // it is preferable to use integer for counting to avoid rounding problems
  7. double x,y,z,h; // eliminated p because p is a 3-valued point;
  8. double BETA, AAZI, PHI, LTIME, SMER, LMER, N, ITIME, FTIME, LTUBE, IDTUBE, ODTUBE;
  9. double THLCOEF, TCEF, ETAP, TCD, ATEMP, IAMC, CFFCT0, CFFCT1,CFFCTK,ALT, ALBEDO, FCS1, PI;
  10. double B, P, E,E1,Tcorr, stime, del, omega, cos_theta1,cos_theta2, cos_theta3;
  11. double cos_theta4, cos_theta5, cos_theta, theta, Ai, iam, cos_thetaz, Rb, Gon;
  12. double a0c, a1c,kc, a0, a1, k, Atb, Gb, iamd,Pb, x1,x3, Z;
  13. double f12, fcs, Atd, Gd, Pd, Ggr, Pgr, Pu;
  14. double lower,upper,step;
  15. // don't declare math.h functions: double cos (), sin(), tan(), acos(), pow(), sqrt();
  16.  
  17. // place all of the constant definitions next
  18.  
  19. x=87.5; // x is apparently constant
  20. // next is the loop; I made n an integer from 0 to 10, so I divide by
  21. // 10 in the expressions for y and z
  22. for( n = 0; n < 11; n++ )
  23. {
  24. y = 126.1620 -(1004.0820*n/10);
  25. z= 166.1620 -(-1004.0880*n/10);
  26. // now do something with these values: define points? store them in an array? ...
  27. // otherwise, the values will be overwritten (and lost) on the next iteration
  28. // so you have to add some code here, inside the loop
  29.  
  30. }
  31. // main function continues ...
  32.  
  33. }

Lines beginning with // are comments; have no effect on the program

The line: printf("\n%5.4f",Atb,n); made no sense -- why do you want to print the constant value Atb 11 times?

I eliminated the p=(x,y,z) as it is meaningless without a definition for p. Perhaps the Fluent system provides a definition (structure) for a point. If so, you must use the syntax they provide; I can't help you with that. Otherwise, you have to define "point". For example, a point might be defined this way:
  1. typedef struct{
  2. double xval;
  3. double yval;
  4. double zval;
  5. } point;
Then you could create an array of 10 points and assign values to the first point in the array like this:
  1. point pArray[10];
  2. pArray[0].xval = x;
  3. pArray[0].yval = y;
  4. pArray[0].zval = z;
There are many other ways to do this -- it all depends on how you are going to use it.
Last edited by r.stiltskin; Mar 16th, 2009 at 12:46 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 9
Reputation: tendolm is an unknown quantity at this point 
Solved Threads: 0
tendolm tendolm is offline Offline
Newbie Poster

Re: Applying heat flux on a tube surface

 
0
  #15
Mar 17th, 2009
thank youi very much
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC