OpenWAM
TNewMapComp.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 "TNewMapComp.h"
32 
33 //---------------------------------------------------------------------------
34 TNewMapComp::TNewMapComp() {
35  FGastoMin = -0.07;
36 }
37 
38 TNewMapComp::~TNewMapComp() {
39 
40 }
41 
42 void TNewMapComp::ReadMap(FILE *fich, int correct) {
43 
44  double speed = 0., mass = 0., pres = 0., eff = 0.;
45  int filas = 0;
46  int i = 0; //Curva de isoregimen
47  int j = 0; //Puntos de la curva
48  if(correct == 1)
49  FCorrect = true;
50  else
51  FCorrect = false;
52  fscanf(fich, "%lf %lf", &FPresionRef, &FTempRef);
53  fscanf(fich, "%d ", &filas);
54  FPresionRef = __units::BarToPa(FPresionRef);
55 
56  dMatrix locSpeed;
57  dMatrix locMass;
58  dMatrix locPre;
59  dMatrix locEff;
60 
61  locSpeed.resize(i + 1);
62  locMass.resize(i + 1);
63  locPre.resize(i + 1);
64  locEff.resize(i + 1);
65 
66  for(int k = 0; k < filas; k++) {
67  fscanf(fich, "%lf %lf %lf %lf", &speed, &mass, &pres, &eff);
68  if(j > 0) {
69  if(speed != locSpeed[i][j - 1]) {
70  i++;
71  j = 0;
72  locSpeed.resize(i + 1);
73  locMass.resize(i + 1);
74  locPre.resize(i + 1);
75  locEff.resize(i + 1);
76  }
77  locSpeed[i].push_back(speed);
78  locMass[i].push_back(mass);
79  locPre[i].push_back(pres);
80  locEff[i].push_back(eff);
81  j++;
82  }
83  }
84 
85  dVector MassExtra;
86  dVector PreExtra;
87  dVector EffExtra;
88 
89  double r1 = sqrt((pow2(FRadHub) + pow2(FRadTip)) / 2);
90 
91  dVector::iterator it;
92 
93  for(Uint k = 0; k < locSpeed.size(); k++) {
94  MassExtra.resize(3);
95  PreExtra.resize(3);
96  EffExtra.resize(3);
97  MassExtra[0] = FGastoMin;
98  MassExtra[1] = -0.0001;
99  MassExtra[2] = 0;
100  PreExtra[0] = locPre[k][0];
101  PreExtra[1] = pow(1 + 1 / (__Gamma::Cp_x2 * (FTempRef)) * pow2(__units::RPMToRad_s(locSpeed[k][0])) * (pow2(
102  FRadWheel) - pow2(r1)), __Gamma::G_9);
103  PreExtra[2] = pow(1 + 1 / (__Gamma::Cp_x2 * (FTempRef)) * pow2(__units::RPMToRad_s(locSpeed[k][0])) * (pow2(
104  FRadWheel) - pow2(r1)), __Gamma::G_9);
105  EffExtra[0] = locEff[k][0];
106  EffExtra[1] = locEff[k][0];
107  EffExtra[2] = locEff[k][0];
108  it = locMass[i].begin();
109  locMass[i].insert(it, MassExtra.begin(), MassExtra.end());
110  it = locPre[i].begin();
111  locPre[i].insert(it, PreExtra.begin(), PreExtra.end());
112  it = locEff[i].begin();
113  locEff[i].insert(it, EffExtra.begin(), EffExtra.end());
114  }
115 
116 }
117 
118 #pragma package(smart_init)
Uint
unsigned int Uint
Unsigned integer.
Definition: Math_wam.h:69
dMatrix
std::vector< std::vector< double > > dMatrix
2-dimensional double matrix
Definition: Math_wam.h:71
pow2
T pow2(T x)
Returns x to the power of 2.
Definition: Math_wam.h:88
dVector
std::vector< double > dVector
Double vector.
Definition: Math_wam.h:70