OpenWAM
TTurbineMap.cpp
1 /* --------------------------------------------------------------------------------*\
2 ==========================|
3  \\ /\ /\ // O pen | OpenWAM: The Open Source 1D Gas-Dynamic Code
4  \\ | X | // W ave |
5  \\ \/_\/ // A ction | CMT-Motores Termicos / Universidad Politecnica Valencia
6  \\/ \// M odel |
7  ----------------------------------------------------------------------------------
8  License
9 
10  This file is part of OpenWAM.
11 
12  OpenWAM is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  OpenWAM is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with OpenWAM. If not, see <http://www.gnu.org/licenses/>.
24 
25 
26  \*-------------------------------------------------------------------------------- */
27 
28 // ---------------------------------------------------------------------------
29 #pragma hdrstop
30 
31 #include "TTurbineMap.h"
32 //#include <cmath>
33 
34 TTurbineMap::TTurbineMap() {
35  FIsAdiabatic = true;
36  FFixedTurbine = false;
37 
38 }
39 
40 TTurbineMap::~TTurbineMap() {
41 
42  FTurbPosition.clear();
43 }
44 
45 void TTurbineMap::LoadTurbineMap(FILE *Input, double Diam1, double Diam2, double Diam3, double Diam4,
46  double CriticalAngle) {
47 
48  int rows = 0, Adiab = 0;
49  double pos = 0., ang = 0.;
50  double Area = __geom::Circle_area(Diam4);
51  double n_limit = 1.165;
52  bool CalculaGR = false;
53 
54 #ifdef tchtm
55  fscanf(Input, "%d ", &Adiab);
56  if(Adiab == 0) {
57  FIsAdiabatic = false;
58  fscanf(Input, "%lf ", &FTempMeasure);
59  }
60 #endif
61 
62  fscanf(Input, "%d ", &FNumPositions);
63  FTurbPosition.resize(FNumPositions);
64  for(int i = 0; i < FNumPositions; i++) {
65  fscanf(Input, "%d %lf %lf", &rows, &pos, &ang);
66  FTurbPosition[i].ReadTurbinPosition(Input, rows, pos, ang);
67  if(ang > CriticalAngle)
68  CalculaGR = false;
69  else
70  CalculaGR = true;
71  FTurbPosition[i].EffectiveArea(Area, CalculaGR, Diam1, Diam2, Diam3, n_limit);
72  // FTurbPosition[i].CalculatePower(923);
73  FTurbPosition[i].SearchMapLimits();
74 
75  // FPowerMin.push_back(FTurbPosition[i].MinPowerLimit(80));
76  // FPowerMax.push_back(FTurbPosition[i].MaxPowerLimit(80));
77  // printf("%lf %lf %lf\n", FTurbPosition[i].Rack(), FPowerMin[i], FPowerMax[i]);
78 
79  }
80  if(FNumPositions == 1)
81  FFixedTurbine = true;
82 }
83 
84 void TTurbineMap::CurrentEffectiveSection(double n, double er, double rack, double T10T00) {
85  if(FFixedTurbine) {
86  FTurbPosition[0].InterpolaPosicion(n, er);
87  FStatorES = FTurbPosition[0].StatorSec();
88  FRotorES = FTurbPosition[0].RotorSec() * sqrt(T10T00);
89  FEffTurb = FTurbPosition[0].Efficiency();
90  } else {
91  int i = 0;
92  while(rack > FTurbPosition[i].Rack() && i < FNumPositions) {
93  ++i;
94  }
95  if(i == 0) {
96  FTurbPosition[i].InterpolaPosicion(n, er);
97  FStatorES = FTurbPosition[i].StatorSec();
98  FRotorES = FTurbPosition[i].RotorSec();
99  FEffTurb = FTurbPosition[i].Efficiency();
100  } else {
101  FTurbPosition[i].InterpolaPosicion(n, er);
102  FTurbPosition[i - 1].InterpolaPosicion(n, er);
103  double DeltaRack = (rack - FTurbPosition[i - 1].Rack()) / (FTurbPosition[i].Rack() - FTurbPosition[i - 1].Rack());
104  FStatorES = FTurbPosition[i - 1].StatorSec() * (1 - DeltaRack) + FTurbPosition[i].StatorSec() * DeltaRack;
105  FRotorES = (FTurbPosition[i - 1].RotorSec() * (1 - DeltaRack) + FTurbPosition[i].RotorSec() * DeltaRack) * sqrt(T10T00);
106  FEffTurb = FTurbPosition[i - 1].Efficiency() * (1 - DeltaRack) + FTurbPosition[i].Efficiency() * DeltaRack;
107  }
108  }
109 }
110 // ---------------------------------------------------------------------------
111 
112 void TTurbineMap::PrintFinalMap(FILE *fich) {
113  for(int i = 0; i < FNumPositions; ++i) {
114  fprintf(fich, "%lf\n", FTurbPosition[i].Rack());
115  FTurbPosition[i].PrintTurbinePosition(fich);
116  }
117 }
118 
119 void TTurbineMap::CalculateAdiabaticEfficiency(TTC_HTM *HTM, double TinC) {
120  if(!FIsAdiabatic) {
121  for(int i = 0; i < FNumPositions; ++i) {
122  FTurbPosition[i].AdiabaticEfficiency(HTM, FTempMeasure, TinC);
123 
124  }
125  }
126 }
127 
128 #pragma package(smart_init)
TTC_HTM
Definition: TTC_HTM.h:307