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