Can someone find why my C++ won\'t execute? Thanks! #include <iostream> #include
ID: 3853815 • Letter: C
Question
Can someone find why my C++ won't execute? Thanks!
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
string mat[] = {"Stainless Steel", " Titanium", "Aluminum"};
double yieldstr[] = { 200 * pow(10, 6), 900 * pow(10, 6), 350 * pow(10, 6) }; // Pa
double density[] = { 8000, 4420, 2700 }; // kg/m^3
double E[] = { 200 * pow(10, 9), 115 * pow(10, 9), 70 * pow(10, 9) }; // Pa
double v = 0.3;
double H = 0.05; //m
double tw = 0.0005; //m
// ti = tw, fail at same conditions
double tf = 0.0005; //m
double b = 0.1; //m
double Mx = 2000; //N-m
double V = 1000; // N
// storing best values
double Hb = 0;
double twb = 0;
double tfb = 0;
double tib = 0;
double weight = 10 * pow(10, 9); //kg
double cs = 0;
double fs = 0;
double ws = 0;
double ys = 0;
double vmf = 0;
double vmw = 0;
double cfb = 0;
double cwb = 0;
double fss = 0;
double fcss = 0;
double wss = 0;
double wcss = 0;
string m = "";
int config = 10;
for (int i = 0; i <= 2; i++)
{
double D = (M_PI * M_PI * E[i]) / (12 * (1 - v * v));
for (int n = 0; n <= 2; n++)
{
while (H <= 0.1)
{
while (tf <= 0.003)
{
while (tw <= 0.003)
{
double Ixx = (tw * pow(H, 3)) / 6 + (tf * b * pow(H, 2)) / 2 + n * (tw * pow(H, 3)) / 12;
double compressivestress = (Mx / Ixx) * H / 2; //Pa
double calcweight = density[i] * (2 * H * tw + 2 * b * tf + n * H * tw) * 2; // kg
double shearflow = (V * tf * H * b) / (4 * (n + 1) * Ixx);
double vonmisesflange = sqrt(compressivestress * compressivestress + 3 * (shearflow / tf) * (shearflow / tf));
double vonmisesweb = sqrt(compressivestress * compressivestress + 3 * (shearflow / tw) * (shearflow / tw));
double fcriticalnormalstress = 4 * D * pow((tf / (b / (n + 1))), 2);
double wcriticalnormalstress = 24 * D * pow((tw / H), 2);
double fshearstress = shearflow / tf;
double fcriticalshearstress = 5.36 * D * pow(tf / (b / (n + 1)), 2);
double wshearstress = shearflow / tw;
double wcriticalshearstress = 5.36 * D * pow(tw / H, 2);
double combinedflangebuckling = pow(compressivestress / fcriticalnormalstress, 2) + pow(fshearstress / fcriticalshearstress, 2);
double combinedwebbuckling = pow(compressivestress / wcriticalnormalstress, 2) + pow(wshearstress / wcriticalshearstress, 2);
if (yieldstr[i] >= vonmisesflange && yieldstr[i] >= vonmisesweb && combinedflangebuckling <= 1 && combinedwebbuckling <= 1 && calcweight < weight)
{
weight = calcweight;
Hb = H;
twb = tw;
tfb = tf;
tib = tw;
cs = compressivestress;
ys = yieldstr[i];
fs = fcriticalnormalstress;
vmf = vonmisesflange;
vmw = vonmisesweb;
cfb = combinedflangebuckling;
cwb = combinedwebbuckling;
ws = wcriticalnormalstress;
m = mat[i];
config = n;
fss = fshearstress;
fcss = fcriticalshearstress;
wss = wshearstress;
wcss = wcriticalshearstress;
}
tw += 0.00001; // add more decimal places for higher precision
}
tw = 0.0005;
tf += 0.00001; // add more decimal places for higher precision
}
tf = 0.0005;
H += 0.001; // add more decimal places for higher precision
}
H = 0.05;
}
}
}
Explanation / Answer
Below is the required code:-