What's new

C++ help

  • Thread starter controler12
  • Start date
  • Views 471
controler12

controler12

Enthusiast
Messages
392
Reaction score
30
I am taking an online C++ class with my local college, but im i have fallen behind due to all my junior stuff for high school, can someone give me some pointers on how to set up this program? I understand how to load in the variables from a file but part b has me a bit confused. The rest is pretty easy for me. I will rep anyone who helps.

When the space shuttle reenters the earth's atmosphere, air friction generates a large amount of heat at the leading edges of the ship. An energy balance on the shuttle's surface yields the following equation:

( v / b ) ^2sin(alpha)= kr * Ts^4 +Uc *Ts -q


where:
v............reentry velocity in miles per hour
alpha....reentry angle in degrees (90 degrees when reentry is perpendicular to the earth's surface)
T[sub]s[/sub] .........shuttle outside surface temperature (K)
b........... a constant = 17,000 miles per hour
k[sub]r[/sub]...........radiation heat transfer constant = 1.1e[sup]− 12[/sup] (1/K)[sup]4[/sup]
u[sub]c[/sub]..........convective heat transfer coefficient = 0.002 1/K
q............a dimensionless constant = 2.5

Note: k[sub]r[/sub], u[sub]c[/sub], q, and b are all constants read in from a text file, shuttle.txt.

To solve this equation using a root-finding method, you must first set the equation equal to zero by subtracting the (v/b)[sup]2[/sup] sin (alpha) term from both sides.

Your task is to solve this equation for various reentry conditions (alpha and v) to determine: (1) whether the reentry surface temperature is safe, and (2) which set of alpha and v give the minimum and maximum values for T[sub]s[/sub].

Program specifics:

Write a C++ program that does the following:

a. Reads the heat transfer parameters (k[sub]r[/sub], u[sub]c[/sub], q, and b) from the file shuttle.txt, found by clicking here. (You must use this exact file.)

b. Using the secant method, solves for the shuttle surface temperature (T[sub]s[/sub]) for the 20 combinations of five reentry angles (10, 25, 40, 55, and 70 degrees) and four reentry velocities (16,000, 16500, 17,000, and 17,50 mph). Use a void function called secant, which calls a single assignment function called fx to solve for T[sub]s[/sub] for each combination of v and alpha.

c. Determines whether the surface temperature is below 1000 K (safety limit) for each combination of conditions.

d. Determines the combination of v and alpha that cause both the maximum and minimum temperature conditions.

e. Writes a well-formatted table (20 rows by 4 columns) to the screen and to a file called results.txt. The title of the table must clearly indicate what the table shows, and the heat transfer parameters (kr, uc, b, and q) employed, including their units. The heading of the table must indicate the property listed in each column and its units. Each column lists, respectively, the angle, the velocity, the resultant surface temperature, and the word "safe" if the temperature is below 1000 K, or "unsafe" if it exceeds 1000 K.

f. Following the table, the program must list, clearly labeled, the maximum and minimum temperatures and the combination of conditions (velocity and angle) for which they would be achieved.

Here is an example output of a similar program.
 
Seahawk

Seahawk

Enthusiast
Messages
138
Reaction score
21
I'm not very experienced but just insert a function that doesn't return anything (void) above main so you don't have to declare a prototype. Then pass in the necessary data required as parameters. Then I am not sure but I think if you insert #include <math.h> at the top then you can use the sin function in there. But I'm not experienced with C++.

Here is a link for some math related functions in C++:
http://www.cplusplus.com/reference/clibrary/cmath/
 
A

AsparagusMan

Enthusiast
Messages
493
Reaction score
115
It sounds like you are in over your head, programming is not something where you can come in half way and understand sh*t. Streams, functions, and variables are beginner stuff, google c++ tutorials, read through them, if you dont get it still,
a ) get help from a tutor or your teacher
or
b ) drop the class and retake it

people on this forum can only help you but no one is going to sit down and be your teacher.
 
controler12

controler12

Enthusiast
Messages
392
Reaction score
30
i understand the basics, im just curious if there is a way to easily make a loop that will enter both the velocity and the angle of reentry at the same time. The way i have it right now is pretty dirty and i am look for advice to clean it up.
 
Forgoten Dynasty

Forgoten Dynasty

Free Sosa #bangbang
VIP
Retired
Messages
5,833
Reaction score
2,611
i understand the basics, im just curious if there is a way to easily make a loop that will enter both the velocity and the angle of reentry at the same time. The way i have it right now is pretty dirty and i am look for advice to clean it up.

Sorry I edited your post but it was murder to read. This is what i would do for B/C
(Note the code may not work perfectly as i didn't test it)



Code:
const int ALPHADEGREE[]={10,25,40,55,70};
const int REENTRYVELOCITY[]={16000,16500,17000,17500};



int main(){
for (int outer=0;outer<5;outer++){
for (int inner=0;inner<4;inner++){
//call to secant method
//Lets assume the first parameter is the degree
// and the second is the reentry Velocity
SolveForSurfaceTemp(ALPHADEGREE[outer], REENTRYVELOCITY[inner]);
}
}

return 0;
}




bool checkTemp(double temp){
if (temp < 1000 ? true:false);
}

The above probably isn't the greatest practice. Typically you wouldn't put that in your main.
 
Top Bottom