-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWATEshaftBase.int
More file actions
423 lines (355 loc) · 11.6 KB
/
WATEshaftBase.int
File metadata and controls
423 lines (355 loc) · 11.6 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
#ifndef _WATESHAFTBASE_
#define _WATESHAFTBASE_
//***********************************************************************
// This element calculates shaft weight, length, and diameter
//************************************************************************
class WATEshaftBase extends WATEelement
{
string inertiaComps[];
inertiaComps {
description = "Names of components contributing to the inertia of this shaft, in order from front to back. This list must contain a compressor and a turbine";
IOstatus = "input";
ptrType = "WATEelement";
trigger = 1;
}
defaultHideLevel = 1; // *********** hide this block
string burnerRef {
ptrType = "WATEburnerBase";
IOstatus = "input";
description = "Name of WATE burner for this shaft.";
}
defaultHideLevel = 2; // *********** REALLY hide this block
string turbineRef {
ptrType = "WATEturbineBase";
}
string aeroTurbRef;
string compressorRef {
ptrType = "WATEcompressorBase";
}
string ptr,ptr2;
ptr.ptrType = "real[]";
ptr2.ptrType = "real[]";
real routsh,tlen1,tlen2;
defaultHideLevel = 0; // ************* end hidden blocks
string bearings[];
bearings {
ptrType = "WATEbearingBase";
hide(1);
}
string innerShaftRef {
ptrType = "WATEshaftBase";
IOstatus = "input";
description = "name of shaft inside of this shaft";
}
int isOuterShaft {
IOstatus = "input";
description = "This is the outermost shaft if isOuterShaft != 0";
}
real limitStress {
value = 80000; IOstatus = "input"; units = "psia" ;
description = "Allowable stress in the shaft" ;
}
real diamRatio {
value = 0.866;
IOstatus = "input"; units = "none" ;
description = "Diameter ratio (Dinner/Douter). Used only for inner shaft. Default is a solid shaft (Dinner = 0)" ;
}
real s_Wt {
value = 1.0;
IOstatus = "input"; units = "none" ;
description = "Scalar on calculated weight.";
}
real maxTemp {
value = 400; IOstatus = "input";
description = "temperature used to determine material properties";
}
real innerDiameter {
IOstatus = "output"; units = "in";
description = "Shaft Inner Diameter" ;
}
real outerDiameter {
IOstatus = "output"; units = "in";
description = "Shaft Outer Diameter" ;
}
real inertia;
real bearWt;
real speed;
real des_Nmech;
real des_pwr;
real maxTorque {
IOstatus = "input";
}
WATEmaterial material;
MaxSaver max_pwr { var = "pwr"; }
/**
*
***********************************************************************/
void calculate() {
int i;
real rho;
int isRadial = turbineRef->hasInterface("WATEradialTurbine");
int centrif = (compressorRef=="") ? 0 : compressorRef->hasInterface("WATEcentrifCompressor");
//
// determine shaft length and min. speed
//
real rfLen;
real turbLen;
if(isOuterShaft) {
tlen1=turbineRef->outPort.axialPosition-burnerRef->inPort.axialPosition;
tlen2=burnerRef->inPort.axialPosition;
if(compressorRef != "") {
tlen2 = tlen2 - compressorRef->outPort.axialPosition;
routsh = compressorRef->outPort.innerRadius;
if(centrif) {
routsh *= 0.5;
}
}
else { routsh = 0.; }
}
else {
rfLen = turbineRef->rearFrameLength;
turbLen = turbineRef->length;
tlen2=0.5*(turbLen - rfLen);
tlen1=turbineRef->inPort.axialPosition + tlen2;
if(compressorRef != "") {
tlen1 = tlen1 - compressorRef->outPort.axialPosition;
}
if(isRadial) {
// routsh = turbineRef->outerRadius_stg[0]*0.5;
}
else {
routsh = turbineRef->outPort.innerRadius;
}
}
calcDiameter();
//
// input design data
//
rho=material.rho(maxTemp);
weight =.7853981*rho*tlen1*(outerDiameter*outerDiameter-innerDiameter*innerDiameter);
weight += PI*(outerDiameter*0.5+routsh)*sqrt((outerDiameter*0.5-routsh)**2
+tlen2*tlen2)*rho*0.5*(outerDiameter-innerDiameter);
length = tlen1+tlen2;
real tmp;
bearWt = 0.0;
for(i=0; i<bearings.entries(); ++i) {
bearings[i]->execute();
tmp = bearings[i]->weight;
bearWt += tmp;
}
weight += bearWt;
inertia = 0.;
for(i=0; i<inertiaComps.entries(); ++i) {
inertia = inertia + inertiaComps[i]->totInertia;
}
//??? this first part is here to agree with an apparent error in WATE due
// to confusion over the meaning of JCONF for shafts. WATE calc is:
// CG = TLENG(IDN1)-length/2, where IDN1 is the index of the 3rd
// component connected to the shaft. If the shaft has just one compressor
// and one turbine, TLENG(IDN1) evaluates to 0
if(inertiaComps.entries()<3) {
cg = -length/2.0;
}
else {
cg = inertiaComps[inertiaComps.entries()-1]->inPort.axialPosition - length/2.0;
}
} // end calculate
//
// some other components need a guess of our diameter, so do the
// diameter calc in the prePass
//
void prePass() {
if(executionState == "CALCULATE") {
calcDiameter();
WATEelement::prePass();
}
}
/**
*
***********************************************************************/
void variableChanged(string name, any oldval) {
int i;
if(name == "inertiaComps") {
turbineRef = "";
compressorRef = "";
aeroTurbRef = "";
for(i=0; i<inertiaComps.entries(); ++i) {
if(turbineRef == "" && inertiaComps[i]->hasInterface("WATEturbineBase")) {
turbineRef = inertiaComps[i];
aeroTurbRef = turbineRef->componentRef;
max_pwr.var = aeroTurbRef + ".pwr";
max_pwr.associatedVars = { "Nmech" };
}
else if(compressorRef == "" &&
inertiaComps[i]->hasInterface("WATEcompressorBase")) {
compressorRef = inertiaComps[i];
}
}
}
}
/**
* add to the bearing list whenever a new bearing object is created
* in this shaft
***********************************************************************/
void postcreate(string name) {
if(name->hasInterface("WATEbearingBase")) {
bearings.append(name);
needVerify();
}
}
/**
*
***********************************************************************/
void calcDiameter() {
//
// determine total shaft power (torque?)
//
real mxpwr = max_pwr.val;
real mxNmech = max_pwr.associatedVals[0];
maxTorque = mxpwr/mxNmech;
speed = turbineRef->spoolRPM;
//
// determine shaft location 1 is inner shaft
//ccj changes the constant in the diameter equation to be
//jjc (550*60*16*12)/(2*pi*pi) this gets the units right
//
real a,a1,a2,b,dold,dnew,do3;
if (innerShaftRef=="") {
do3=320985.51*(maxTorque*des_Nmech/speed)/(limitStress*(1.-diamRatio**4));
outerDiameter=do3**(1./3.);
innerDiameter=outerDiameter*diamRatio;
}
else { // outer shaft
//
// newton-raphson iteration for shaft outer diameter
//
innerDiameter=innerShaftRef->outerDiameter+.4;
dnew=innerDiameter;
b=-(innerDiameter**4);
a=-320985.51*(maxTorque*des_Nmech/speed)/limitStress;
int iter=0;
while(1) {
a1=dnew**4+a*dnew+b;
a2=4.*dnew**3+a;
dold=dnew;
dnew=dold-a1/a2;
if (abs(dnew-dold) <= .01) { break; }
dnew=max(innerDiameter,min(100.,dnew));
if(iter>50) {
error("WATEshaftBase diameter iteration failed");
dnew=5.;
break;
}
++iter;
}
outerDiameter=dnew;
}
// to ensure that the minimum-thickness requirement
// (i.e. innerDiameter/outerDiameter ratio), as specified in the input, is met
real ratio = innerDiameter/outerDiameter;
if (ratio > diamRatio && innerShaftRef=="") {
outerDiameter = innerDiameter/diamRatio;
}
setBearingLocations();
}
/**
* set bearing locations and radii only
***********************************************************************/
void setBearingLocations() {
int i;
for(i=0; i<bearings.entries(); ++i) { // do i = 1,6
bearings[i]->calcLocation(outerDiameter,i,isOuterShaft);
}
}
/**
*
***********************************************************************/
int verify() {
int ret = 1;
string burners[]={};
if(componentRef=="") { error("componentRef not set"); ret = 0; }
if(inertiaComps.entries() == 0) { error("inertiaComps not set"); ret = 0; }
if(turbineRef=="") { error("no turbine found in inertiaComps"); ret = 0; }
if(burnerRef=="") {
burners = parent.parent.list("WATEburnerBase",0);
if(burners.entries() == 1) {
burnerRef = burners[0];
}
else {
error("burnerRef string not set"); ret = 0;
}
}
return ret;
}
/**
*
***********************************************************************/
void saveMechDesignData() {
des_pwr = aeroTurbRef->pwr;
des_Nmech = componentRef->Nmech;
}
/**
*
***********************************************************************/
void calcGeometry() {
real x[3],y[3];
real xfrm=0.;
real spacerLen=0.;
real rotorLen=0.;
int isVar=0;
int numStgs=0;
int j;
// if I understand this, they are checking if the first upstream
// compressor (iwmec[7,i]) has a
// variable front frame (iwmec[7,compIdx]). If so, the first x location
// for the shaft is the axial position of the compressor exit, minus
// the length of the first stage of the compressor (clstage[1,compIdx])
if(compressorRef!="" && compressorRef->exists("S_FrontFrame.child.isVariable")) {
isVar = compressorRef->getVal("S_FrontFrame.child.isVariable");
if(isVar) {
ptr = compressorRef+".length_stg";
xfrm = ptr->getMember(0);
// xfrm=compressorRef->length_stg[0];
}
}
if(isOuterShaft) {
if(compressorRef != "") {
x[0] = compressorRef->outPort.axialPosition - xfrm;
}
else {
x[0] = -xfrm;
}
y[0] = routsh;
x[1] = x[0] + tlen2;
y[1] = outerDiameter/2.0;
x[2] = x[1] + tlen1;
y[2] = y[1];
}
else { // not outer shaft
// j indicates iwmec of most dwnstrm turbine
if(compressorRef != "") {
x[0] = compressorRef->outPort.axialPosition - 0.5*xfrm;
}
else {
x[0] = -0.5*xfrm;
}
y[0] = outerDiameter/2.0;
x[1] = x[0] + tlen1+ 0.5*xfrm;
y[1] = y[0];
ptr2 = turbineRef+".bladeLen_stg";
numStgs = turbineRef->numStages;
numStgs -= 1;
rotorLen = ptr2->getMember(numStgs);
ptr = turbineRef+".spacerLen_stg";
spacerLen = ptr->getMember(numStgs);
x[2] = x[1]+0.5*(turbineRef->length-turbineRef->rearFrameLength)-
spacerLen-0.5*rotorLen;
y[2] = routsh;
}
// setStyle("stroke-width: .4;");
setStyle("stroke-width: .7px;");
addPolyLine(x,y,drawDepth,1);
setStyle("");
}
} // end WATEshaftBase
#endif