| | |
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:
Solved Threads: 0
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
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;
}
}
•
•
Join Date: Feb 2009
Posts: 71
Reputation:
Solved Threads: 9
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
This line: says
which is clearly not what you wrote above.
Presumably you want
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.
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?
Also, delete the line
double cos (), sin(), tan(), acos(), pow(), sqrt(); .This line:
C++ Syntax (Toggle Plain Text)
Atb = a0 + a1*pow(10,(-k/cos_theta));
Presumably you want
C++ Syntax (Toggle Plain Text)
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.
•
•
Join Date: Feb 2009
Posts: 9
Reputation:
Solved Threads: 0
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.
•
•
Join Date: Feb 2009
Posts: 71
Reputation:
Solved Threads: 9
You are not making yourself clear. Looking at the code you posted in Post #11, beginning on the line
through and including the line
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
Lines beginning with // are comments; have no effect on the program
The line:
I eliminated the Then you could create an array of 10 points and assign values to the first point in the array like this: There are many other ways to do this -- it all depends on how you are going to use it.
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
C++ Syntax (Toggle Plain Text)
#include <stdio.h> #include <math.h> // provides math and trig functions int main() { int n; // it is preferable to use integer for counting to avoid rounding problems double x,y,z,h; // eliminated p because p is a 3-valued point; 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; // don't declare math.h functions: double cos (), sin(), tan(), acos(), pow(), sqrt(); // place all of the constant definitions next x=87.5; // x is apparently constant // next is the loop; I made n an integer from 0 to 10, so I divide by // 10 in the expressions for y and z for( n = 0; n < 11; n++ ) { y = 126.1620 -(1004.0820*n/10); z= 166.1620 -(-1004.0880*n/10); // now do something with these values: define points? store them in an array? ... // otherwise, the values will be overwritten (and lost) on the next iteration // so you have to add some code here, inside the loop } // main function continues ... }
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: C++ Syntax (Toggle Plain Text)
typedef struct{ double xval; double yval; double zval; } point;
C++ Syntax (Toggle Plain Text)
point pArray[10]; pArray[0].xval = x; pArray[0].yval = y; pArray[0].zval = z;
Last edited by r.stiltskin; Mar 16th, 2009 at 12:46 pm.
![]() |
Other Threads in the C++ Forum
- Previous Thread: problem in makefile
- Next Thread: windows api help
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings struct temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





