OpenWAM
TRotorTurbina.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 "TRotorTurbina.h"
32 
33 //---------------------------------------------------------------------------
34 //---------------------------------------------------------------------------
35 
36 TRotorTurbina::TRotorTurbina() :
37  TTipoValvula(nmRotor) {
38 
39 }
40 
41 //---------------------------------------------------------------------------
42 //---------------------------------------------------------------------------
43 
44 TRotorTurbina::~TRotorTurbina() {
45 }
46 
47 //---------------------------------------------------------------------------
48 //---------------------------------------------------------------------------
49 
50 TRotorTurbina::TRotorTurbina(TRotorTurbina *Origen, int Valvula) :
51  TTipoValvula(nmRotor) {
52 
53  FValvula = Valvula;
54 
55  FTipoRotor = Origen->FTipoRotor;
56  FCDEInicial = Origen->FCDEInicial;
57  FCDSInicial = Origen->FCDSInicial;
58  FDiametroRef = Origen->FDiametroRef;
59 
60  FNumeroOrden = Origen->FNumeroOrden;
61 
62  FDiamRef = FDiametroRef;
63 
64  FCDTubVol = FCDEInicial;
65  FCDVolTub = FCDSInicial;
66 
67  FCDVbl = FCDEInicial;
68 
69 }
70 
71 //---------------------------------------------------------------------------
72 //---------------------------------------------------------------------------
73 
74 void TRotorTurbina::LeeDatosIniciales(const char *FileWAM, fpos_t &filepos, int norden, bool HayMotor,
75  TBloqueMotor *Engine) {
76  try {
77  int tprotor = 0;
78 
79  FILE *fich = fopen(FileWAM, "r");
80  fsetpos(fich, &filepos);
81 
82  FNumeroOrden = norden;
83 
84  fscanf(fich, "%lf %lf %lf ", &FCDEInicial, &FCDSInicial, &FDiametroRef);
85 
86  fgetpos(fich, &filepos);
87  fclose(fich);
88 
89  } catch(exception &N) {
90  std::cout << "ERROR: LeeDatosIniciales CDFijo" << std::endl;
91  //std::cout << "Tipo de error: " << N.what().scr() << std::endl;
92  throw Exception(N.what());
93 
94  }
95 }
96 
97 //---------------------------------------------------------------------------
98 //---------------------------------------------------------------------------
99 
100 void TRotorTurbina::TipodeRotor(nmTipoRotor TipoRotor) {
101  try {
102 
103  FTipoRotor = TipoRotor;
104 
105  } catch(exception &N) {
106  std::cout << "ERROR: TRotorTurbina::TipodeRotor " << std::endl;
107 //std::cout << "Tipo de error: " << N.what().scr() << std::endl;
108  throw Exception(N.what());
109  }
110 }
111 
112 //---------------------------------------------------------------------------
113 //---------------------------------------------------------------------------
114 
115 void TRotorTurbina::CalculaCD() {
116  try {
117  switch(FTipoRotor) {
118  case nmRotFijo:
119  FCDTubVol = FCDEInicial * FSectionRatio;
120  FCDVolTub = FCDSInicial * FSectionRatio;
121  break;
122  case nmRotMapa:
123  FCDTubVol = FAreaEff / __geom::Circle_area(FDiamTubo);
124  FCDVolTub = FAreaEff / __geom::Circle_area(FDiamTubo);
125  break;
126  case nmRotVariable:
127  FCDTubVol = FCDVbl * FSectionRatio;
128  FCDVolTub = FCDVbl * FSectionRatio;
129  break;
130  }
131  if(FCDTubVol > 1) {
132  FCDTubVol = 1.;
133  } else if(FCDTubVol < 0) {
134  FCDTubVol = 0.001;
135  }
136  if(FCDVolTub > 1) {
137  FCDVolTub = 1.;
138  } else if(FCDVolTub < 0) {
139  FCDVolTub = 0.001;
140  }
141  } catch(exception &N) {
142  std::cout << "ERROR: CalculaCD RotorTurbine" << std::endl;
143  //std::cout << "Tipo de error: " << N.what().scr() << std::endl;
144  throw Exception(N.what());
145 
146  }
147 }
148 
149 void TRotorTurbina::GetCDin(double Time) {
150 
151  switch(FTipoRotor) {
152  case nmRotFijo:
153  FCDTubVol = FCDEInicial * FSectionRatio;
154  break;
155  case nmRotMapa:
156  FCDTubVol = FAreaEff / __geom::Circle_area(FDiamTubo);
157  break;
158  case nmRotVariable:
159  FCDTubVol = FCDVbl * FSectionRatio;
160  break;
161  }
162  if(FCDTubVol > 1) {
163  FCDTubVol = 1.;
164  } else if(FCDTubVol < 0) {
165  FCDTubVol = 0.001;
166  }
167 }
168 
169 void TRotorTurbina::GetCDout(double Time) {
170 
171  switch(FTipoRotor) {
172  case nmRotFijo:
173  FCDVolTub = FCDSInicial * FSectionRatio;
174  break;
175  case nmRotMapa:
176  FCDVolTub = FAreaEff / (pow2(FDiamTubo) * __cons::Pi_4);
177  break;
178  case nmRotVariable:
179  FCDVolTub = FCDVbl * FSectionRatio;
180  break;
181  }
182  if(FCDVolTub > 1) {
183  FCDVolTub = 1.;
184  } else if(FCDVolTub < 0) {
185  FCDVolTub = 0.001;
186  }
187 }
188 
189 //---------------------------------------------------------------------------
190 //---------------------------------------------------------------------------
191 
192 void TRotorTurbina::AsignaTurbina(int NTurb) {
193  FNumeroTurbina = NTurb;
194 }
195 
196 //---------------------------------------------------------------------------
197 //---------------------------------------------------------------------------
198 #pragma package(smart_init)
199 
TRotorTurbina
Definition: TRotorTurbina.h:48
TTipoValvula
Definition: TTipoValvula.h:53
Exception
Custom exception class.
Definition: Exception.hpp:39
TBloqueMotor
Definition: TBloqueMotor.h:43
pow2
T pow2(T x)
Returns x to the power of 2.
Definition: Math_wam.h:88