1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double Pt1, Tt1, Tt1R,Tt2R,Ts25R,Tt4,Ts5,Tt2,Tt5,Ps1,Ps2,Ps3;
double Ps5,Pt2,Pt25,D1, D3,D5,DP25, Kloss, LD, Aratio, Cps,gamma1,flowparam;
double Length, A1,/*A4*/A3,A25,Wa1, Wa2,Wa2factor,Wa3factor, Vmix,PtPsSec,Pmixin,TtTsRatio;
double Mach1,Mach2,/*Mach3,*/Mach4,Mach3sec,Mach5,Cpcalc,Ps5calc,Mach3pri,Ts3Sec;
double A5,PtPsRatio,Pt1Ps3Ratio,A3Astar,A5Astar,mu,Vav,Accel,Blockage75;
double Ts1R,Rho1,Rho2,Rho3,Rho4,Rho5,Vel1,Vel2,Vel3,Vel5;
double Wa1check,Wa2check,Wa3check,Wa4check,Wa4factor,DP15,Wa3,Asec3,TtTs3Sec,Aprimary3;
double Tsmixed,Psmixed,DPerror,Dpsec,Pt5Ps5,lambda,Re,FfAt,Pexit,DPtPsdiff,Ptmixed,Ptideal;
int Npass;
double Wafactor = 0;
int NpassCount = 0;
//Inputs are below
Tt1 = 200;
Tt2 = 90;
LD = 7;
D1 = .05599;
D3 = .16;
Aratio = 4;
Pt1 = 51.2;
Pt2 = 14.7;
Ps5 = 18.7;
Kloss = .25;
Cps = .7;
//Inputs End
Tt1R = Tt1 + 460;
Tt2R = Tt2 + 460;
gamma1 = 0.000000000014 * (Tt1R*Tt1R*Tt1R) - 0.00000005575 * (Tt1R*Tt1R) + 0.00001864338 * Tt1R + 1.402579277865;
Mach1 = 1;
flowparam = Mach1 / pow((1 + (gamma1 - 1) / 2 * Mach1*Mach1), ((gamma1 + 1) / 2 / (gamma1 - 1)));
A1 = 3.14159 / 4 * D1*D1;
Wa1 = flowparam * Pt1 * A1 / pow((53.353 * Tt1R / 1.4 / 32.171), 0.5);
Length = LD * D3;
A3 = 3.14159 / 4 * D3 * D3;
A25 = 3.14159 / 4 * (D3 * D3 - D1 * D1);
D5 = pow((Aratio * 4 * A3 / 3.14159), 0.5);
A5 = 3.14159 / 4 * D5 * D5;
DP25 = Ps5 - Pt2;
DP15 = Ps5 - Pt1;
Wa2 = 0.1 * Wa1;
Ps2 = 0.9 * Pt2;
Ps3 = Ps2;
Vmix = 0.45 * pow((1.4 * 53.35 * 32.174 * Tt2R),.5);
Wa2factor = 0.2;
Wa3factor = 0.2;
Wa4factor = 0.2;
Vmix = 514.5177;
Wa2 = 0.003;
Npass = 1;
Mach1 = 1;
TtTsRatio = 1.2;
Ps2 = 13.47;
Ps3 = 13.4094;
PtPsRatio = pow(TtTsRatio, 3.5);
Ts1R = Tt1R / TtTsRatio;
Ps1 = Pt1 / PtPsRatio;
Rho1 = 144 * Ps1 / 53.353 / Ts1R;
Vel1 = Mach1 * pow((1.4 * 32.174 * 53.353 * Ts1R),0.5);
Wa1check = Rho1 * A1 * Vel1 / 144;
do
{
NpassCount = NpassCount++;
Wa2 = Wa2 * (1 + Wa2factor);
Tt4 = (Wa1 * Tt1R + Wa2 * Tt2R) / (Wa2 + Wa1);
Wa3 = Wa1 + Wa2;
Pt25 = (Pt2 + Kloss * Ps2) / (1 + Kloss);
Ts25R = Tt2R * pow((Ps2 / Pt25), (1 / 3.5));
Rho2 = 144 * Ps2 / 53.353 / Ts25R;
Vel2 = pow((2 * 32.174 * 778.17 * 0.24 * (Tt2R - Ts25R)), 0.5);
Mach2 = Vel2 / pow((1.4 * 32.174 * 53.353 * Ts25R), 0.5);
Wa2check = Rho2 * A25 * Vel2 / 144;
Wa2factor = Wa2check / Wa2 - 1;
Ps2 = Ps2 * (1 + Wa2factor / 50);
Wafactor = pow((Wa2factor*Wa2factor + Wa3factor*Wa3factor + Wa4factor*Wa4factor),.5);
//Wa2 = Wa2 + .001;// to increase Wa2
if(Wafactor < .0000001)
{
goto mylabelPrint;
}
Pt1Ps3Ratio = Pt1 / Ps3;
double x = Pt1Ps3Ratio;
double y = pow(x,1/3.5)-1;
double z = 5 * pow(y,0.5);
Mach3pri = z;
A3Astar = pow(((1 + 0.2 * Mach3pri*Mach3pri) / 1.2),3 / Mach3pri);
Aprimary3 = A3Astar * A1;
Asec3 = A3 - Aprimary3;
PtPsSec = Pt25 / Ps3;
double xx = PtPsSec;
double yy = pow(xx,1/3.5)-1;
double zz = 5 * pow(yy,0.5);
Mach3sec = zz;
TtTs3Sec = pow(PtPsSec, (1 / 3.5));
Ts3Sec = Tt2R / TtTs3Sec;
Rho3 = 144 * Ps3 / 53.353 / Ts3Sec;
Vel3 = Mach3sec * pow((1.4 * 32.174 * 53.353 * Ts3Sec), 0.5);
Wa2check = Rho3 * Asec3 * Vel3 / 144;
Wa3check = Rho3 * Asec3 * Vel3 / 144 + Wa1;
Wa3factor = (Wa3check) / Wa3 - 1;
Ps3 = Ps3 * (1 + Wa3factor / 10);
double newPs3 = Ps3;
Wafactor = pow((Wa2factor*Wa2factor + Wa3factor*Wa3factor + Wa4factor*Wa4factor),.5);
if(Wafactor < .0000001)
{
goto mylabelPrint;
}
Pmixin = (Ps2 * A25 + Ps1 * A1) / A3;
Vav = (Vel3 + Vmix) / 2;
mu = 1.26 * pow(10.0,-5);
Re = Rho2 * Vav * D3 / 12 / mu;
lambda = 0.3164 * pow(Re, -0.25);
FfAt = lambda * LD * Rho2 * Vav*Vav / 2 / 144 / 32.174;
Accel = (Wa2 * Vel2 + Wa1 * Vel1 - Wa3 * Vmix) / A3 / 32.174;
Psmixed = Pmixin - FfAt + Accel;
Tsmixed = Tt4 - (Vmix*Vmix) / 2 / 32.174 / 778.17 / 0.24;
Rho4 = 144 * Psmixed / 53.353 / Tsmixed;
Wa4check = Rho4 * A3 * Vmix / 144;
Wa4factor = Rho4 * A3 * Vmix / 144 / Wa3;
Vmix = Vmix * pow(Wa4factor+1,(-.25));
//H = pow(Wa4factor,(-0.25));
Mach4 = Vmix / pow((1.4 * 32.174 * 53.353 * Tsmixed), 0.5);
Ptmixed = Psmixed * pow((Tt4 / Tsmixed), 3.5);
Wafactor = pow((Wa2factor*Wa2factor + Wa3factor*Wa3factor + Wa4factor*Wa4factor),.5);
if(Wafactor < .0000001)
{
goto mylabelPrint;
}
DPtPsdiff = Ptmixed - Psmixed;
Pexit = Psmixed + Cps * DPtPsdiff;
Ps5calc = Pexit;
Ptideal = Ptmixed;
Tt5 = Tt4;
Ts5 = Tt5 * pow((Ps5calc / Ptideal),(1 / 3.5));
Rho5 = 144 * Ps5calc / 53.352 / Ts5;
Vel5 = pow((2 * 32.174 * 778.17 * 0.24 * (Tt5 - Ts5)), 0.5);
Mach5 = Vel5 / pow((1.4 * 32.174 * 53.353 * Ts5), 0.5);
A5Astar = pow(((1 + 0.2 * Mach5*Mach5) / 1.2), 3) / Mach5;
Blockage75 = (1 - 144 * Wa3 / Rho5 / A5 / Vel5);
Blockage75 = (1 - 144 * Wa3 / Rho5 / A5 / Vel5) * 0.75;
A5Astar = (1 - Blockage75) / (1 - Blockage75 / 0.75) * A5Astar;
/*415 Mach5 = Mach5 * (1 + (Mach5 / Mach5trial - 1) / 50)
Mach5trial = ((1 + 0.2 * Mach5 ^ 2) / 1.2) ^ 3 / A5Astar
If ((Mach5 / Mach5trial - 1) ^ 2 < 0.00001) Then GoTo 480
*/
Mach5 = pow(((1 + 0.2 * Mach5*Mach5) / 1.2), 3) / A5Astar;
Pt5Ps5 = (1 + 0.2 * pow((Mach5*Mach5), 3.5));
Ps5calc = Ptideal / Pt5Ps5;
Cpcalc = (Ps5calc - Psmixed) / (Ptmixed - Psmixed);
Dpsec = Ps5calc - Pt2;
DPerror = DP25 / Dpsec;
Wafactor = pow((Wa2factor*Wa2factor + Wa3factor*Wa3factor + Wa4factor*Wa4factor),.5);
}
while (Wafactor > .0000001);
{
cout << "Count: " <<NpassCount<<"\n";
|