DESCRIPTION: A standard but complex problem in civil engineering and mechanics is to determine how tall a mast can be before it will begin to buckle under its own weight. You will write a program that finds the maximum lengths of masts made of different materials. The following quantities are defined:
L=mast length (meters)
Y=young’s modulus of the material (N/m2)
Lamda=(density * cross sectional area) (kg/m)
I2=pir^4/2 r=radius of round mast (meters)
X=dimensional quantity related to above quantities by:
X=(4/9)*g*(lamda*L^3/YI2) g=9.8m/sec2
THEORY: We need to find L in the above equation – L is the length of the mast. To find L, we must know all the other quantities. We know all the other quantities EXCEPT X. So, we need to find X, then we can find L. It has been found that the mast will just begin to buckle when X has the value corresponding to the smallest positive root of the following function:
This function actually continues on but the additional terms are so small that we ignore them.
So, we need to find the root of this equation – that is the X value that makes F(X)=0. It is this X value that we will use in the first equation to find L.
DETAILS: This is what you need to do in your program:
1. Find the value of X:
a. Let X range from 0 to 5 in increments of .25 and calculate F(X).
b. In this range, you need to find the two X values where F(X) changes sign. These two X values give us our starting point for finding the X value we need. Once you find two F(X) values that change sign, you can stop calculating F(X).
c. Now, using the two X values from step b. above, we’ll find the final value of X. To do this, we’ll use the formula below over and over again to get a good value for X (this is called the secant routine for root finding). We will execute this equation a set number of times to get the estimate we want for X
.
Xi+1 = Xi – F(Xi)(Xi-1-Xi) Xi-1 = one of the X values from step b above
F(Xi-1) – F(Xi) Xi = the other X value from step b above
Then, the next time you calculate:
Xi-1 will be the value that was Xi last time
Xi will be the Xi+1 value that you just calculated
and you will use these two values to calculate the next Xi+1
Then, the next time you calculate:
Xi-1 will be the value that was Xi last time (notice this is the first Xi+1 value you calculated)
Xi will be the Xi+1 value that you just calculated
and you will use these two values to calculate the next Xi+1
and so on, until you have the accuracy you want.
Now, for your program, do the calculation 4 times, then output the last two X values, then ask the user if they want to continue finding X or move on to the rest of the program.
After 4 times, you should have the X value you need!
2. Finding the L value: now we can calculate the maximum mast length for any material. We will assume all masts have a radius of 0.100 meters. Here’s the pertinent information for different materials:
MATERIAL YOUNG’S MODULUS DENSITY
(N/m2) * 1010 (kg/m3) * 103
_____________________________________________________________
Aluminum (cast) 5.6 – 7.7 2.70
Brass 9.02 8.44
Gold 7.85 19.8
Iron (cast) 8.4-9.8 7.86
Lead 1.5-1.67 11.0
Platinum 16.7 21.4
Steel 20.0 7.83
Tin 3.9-5.39 7.29
Tungsten 35.5 18.8
Your program needs to calculate the maximum mast length for each of these materials. For materials that have a range for Young’s modulus, calculate the mast length for both the upper and lower end of the range.
OUTPUT: Your program needs to output the following:
a. the two X values where F(X) changes sign (from step 1, b above)
b. the final X value (from step 1, c above)
c. the name of each material and its corresponding maximum mast length(s). This should be in table/chart form.
DELIVERABLES:
a. Problem statement with lists of inputs and outputs (typed)
b. Source code
c. Output
EVALUATION:
This project will be evaluated as project 1 was. To earn a maximum grade of an A, you must use array(s) and looping in your program. With looping but without an array(s), the maximum grade you can earn is a C. You CAN, but you don’t have to, use 2 dimensional array(s).
Then do the first step that has been written down for you:
a. Let X range from 0 to 5 in increments of .25 and calculate F(X).
It will look something like this:
1 2 3 4
for (double x = 0 ; 0 <= 5 ; x + x+0.25)
{
// calculate F(x) here
}
This is all there is to it. You do the first step, and you get it working. Then you do the next step, and get it working. Then you do the next step, and get it working. If a step ever seems too big or too difficult, you break it into smaller steps.
That creates an array of 21 floats. The whole point of programming is to make the computer do the work for you. Make the computer calculate the 21 values for you. If you're going to calculate all the needed values yourself and write them by hand, you might as well do the whole thing yourself on paper.
You don't need arrays. Full stop.
You just need xlast, xcurrent, xnext.
As far as finding the non-dimensional root is concerned you could break it down into
1 2 3
double f( double x ); // returns f(x)
void findStart( double &a, double &b ); // finds suitable start points for secant search
double secant( double a, double b ); // carries out secant search in a < x < b
Then int main() would look like
1 2 3 4 5 6
int main()
{
double a = 0, b = 0.25;
findStart( a, b );
cout << "x = " << secant( a, b ) << '\n';
}
for the purpose of this project, I have to use arrays and looping
You will have to loop, but there is absolutely no reason to use arrays.
FIRST. Write a function f(x) that returns that approximation given to you.
SECOND. Start with a=0, b=0.25 and keep this pair moving forward in steps of 0.25 until
f(a) * f(b) <= 0
which will mean that one of f(a) and f(b) is negative (or zero), the other positive (or zero). This will give you the interval [a,b] in which the solution lies.
THIRD. Do the secant search to make f=0 starting with the interval [a,b] from above. The secant expression, slightly rewritten without i's etc, looks like
xnext = xcurrent - Fcurrent / dFdx
with the slope approximated by
dFdx = ( Fcurrent - Fprev ) / ( xcurrent - xprev )
Keep looping this until
abs( F ) < small tolerance.
FOURTH. Use that fixed root for x, together with a collection of values of Young's modulus, density, second moment of area etc. (read from file maybe) to put out your solutions for different materials.