OpenWAM
TCompTubos.h
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 #ifndef TCompTubosH
30 #define TCompTubosH
31 
32 #include "TCompresor.h"
33 #include "Constantes.h"
34 // #include "SolverCompresor.h"
35 #include "NewCompSolver.h"
36 // #include "roots.h"
37 
38 // ---------------------------------------------------------------------------
39 // ---------------------------------------------------------------------------
40 
41 class TCondicionContorno;
42 class TTubo;
43 
44 struct stCompOut {
45  double A1in;
46  double U1in;
47  double A1out;
48  double U1out;
49  double Rc;
50  double Cpre;
51  double Gam;
52  double Ga1;
53  double Ga3;
54  double Ga8;
55  double E1;
56  double M1;
57  double A1outA;
58 
59  stCompOut(double iA1in, double iU1in, double iRc, double iCpre, double iGam) :
60  A1in(iA1in), U1in(iU1in), Rc(iRc), Cpre(iCpre), Gam(iGam) {
61 
62  Ga1 = Gam - 1;
63  Ga3 = Ga1 / 2;
64  Ga8 = Gam / Ga1;
65  E1 = (pow2(A1in) + Ga3 * pow2(U1in)) * (1 + Cpre);
66  M1 = pow(A1in, 1 / Ga3) * U1in / Rc * pow(1 + Cpre, Ga8);
67  }
68  ;
69  double operator()(const double U1out) {
70 
71  A1outA = pow(E1 - Ga3 * pow2(U1out), 1 / Ga1);
72  double A1outB = M1 / U1out;
73  return A1outA - A1outB;
74  }
75  ;
76 
77 };
78 
79 class TCompTubos: public TCompresor {
80  private:
81 
82  TTubo *FTuboRot;
83  TTubo *FTuboEst;
84 
85  int FPosicionRotor; // Posicion en el vector estructura TuboExtremo del tubo del rotor
86  int FPosicionEstator; // Posicion en el vector estructura TuboExtremo del tubo del estator
87  int FIndiceCCRotor; // Posicion del vector para tomar datos del tubo para la BC (0 Nodo izquierdo; 1 Nodo derecho)
88  int FIndiceCCStator; // Posicion del vector para tomar datos del tubo para la BC (0 Nodo izquierdo; 1 Nodo derecho)
89 
90  double FPresionIn; // Pressure a la entrada del compresor (p_in)
91  double FAsonidoIn; // Velocity del sonido a la entrada del compresor (a_in)
92  double FDensidadIn; // Density a la entrada del compresor (den_in)
93  double FTempIn; // Temperature a la entrada del compresor (t_in)
94  double FVelInMax; // Velocity a la entrada maxima (x_max)
95  double FVelInMin; // Velocity a la entrada minima (x_min)
96  double FErrorVelIn; // Error de la velocidad a la entrada (error_x)
97  double FVelocidadIn; // Velocity a la entrada (x)
98  double FErrorCarIn; // Error limite de la caracteristica a la entrada (err_in)
99  int FTuboIn; // Numero del tubo de entrada
100  nmPipeEnd FExtremoIn; // PipeEnd del tubo de entrada
101  int FCuentaVelIn; // (contx)
102 
103  double FPresionOut; // Pressure a la salida del compresor (p_out)
104  double FAsonidoOut; // Velocity del sonido a la salida del compresor (a_out)
105  double FDensidadOut; // Density a la salida del compresor (den_out)
106  double FTempOut; // Temperature a la salida del compresor (t_out)
107  double FVelOutMax; // Velocity a la salida maxima (y_max)
108  double FVelOutMin; // Velocity a la salida minima (y_min)
109  double FErrorVelOut; // Error de la velocidad a la salida (error_y)
110  double FVelocidadOut; // Velocity a la salida del compresor (y)
111  double FErrorCarOut; // Error limite de la caracteristica a la salida (err_out)
112  int FTuboOut; // Numero del tubo de salida
113  nmPipeEnd FExtremoOut; // PipeEnd del tubo de salida
114  int FCuentaVelOut; // (conty)
115 
116  double FTempTotalInAnt; // Temperature total a la entrada anterior (tt_in_ant)
117  double FTempTotalOutAnt; // Temperature total a la salida anterior (tt_out_ant)
118  double FTempTotalIn;
119  double FTempTotalOut;
120  double FPreTotalIn;
121  double FPreTotalOut;
122 
123  bool FFlujoDirecto; // Indicador del sentido del flujo
124  bool FCambioSentido; // Indicador del cambido de sentido (svc_inverter)
125  int FSentidoFlujo; // Indicador del sentido del flujo (svc)
126  bool FPrimerCiclo;
127  bool FCheckSentido;
128  int FContadorCheckSentido; // Cuenta el numero de cambios de sentido en el mismo instante.
129  // Si vale 2 se pasa a calcular las caracteristicas como extremo cerrado.
130 
131  double *FCarCIn;
132  double *FCarDIn;
133  double *FAaIn;
134 
135  double *FCarCOut;
136  double *FCarDOut;
137  double *FAaOut;
138 
139  int FSignoRotor;
140  int FSignoStator;
141 
142  nmPipeEnd FExtremoRotor;
143  nmPipeEnd FExtremoStator;
144 
145  // int FIndExtRotor;
146  // int FIndExtStator;
147 
148  int FTuboRotor;
149  int FTuboStator;
150 
151  double FAreaIn; // Area del conducto de entrada (areain)
152  double FAreaOut; // Area del conducto de salida (areaout)
153 
154  double FAreaRotor;
155  double FAreaStator;
156 
157  double FGasto1; // Masa en el compresor (mc)
158  double FGastoOut;
159 
160  double FAout;
161 
162  double FLongitudCaract; // Longitud caracteristica del compresor
163 
164  double FCoefPresiones;
165 
166  double FRadioHub;
167  double FRadioRodete;
168  double FRadioTip;
169 
170  int FNodoFinRotor;
171  int FNodoFinStator;
172 
173  double FGamma1;
174  double FGamma2;
175  double FGamma3;
176  double FGamma4;
177  double FGamma5;
178 
179  double FVolumen;
180  double FPresionDep;
181  double FAsonidoDep;
182  double FTempDep;
183  double FMasaDep;
184 
185  double FA1in;
186  double FA1out;
187  double FU1in;
188  double FU1out;
189  double FA2;
190  double FU2;
191 
192  double FFlowIn;
193  double FFlowOut;
194 
195  void Biseccion(double *VelIn, double *VelOut, double *AIn, double *AOut, double CarIn, double AaIn, double CarOut,
196  int sig);
197 
198  void MetodoNewton2D(double *a1, double *a2, double *u1, double *u2, double aa1, double aa2, double cc1, double cc2,
199  double s1, double s2, double k, int sig);
200 
201  void Solver(double *a1, double *a2, double *u1, double *u2, double aa1, double aa2, double cc1, double cc2, double s1,
202  double s2, double k, int sig);
203 
204  void ExtremoCerrado();
205 
206  double EntalpiaEntrada(double ASonidoE, double VelocidadE, double MasaE, double ASonidoD, double MasaD, double Gamma);
207 
208  protected:
209 
210  public:
211 
212  TCompTubos(int i, nmTipoCalculoEspecies SpeciesModel, int numeroespecies, nmCalculoGamma GammaCalculation,
213  bool ThereIsEGR);
214 
215  ~TCompTubos();
216 
217  void CondicionCompresor(double Theta, stTuboExtremo *TuboExtremo, double TiempoActual, int TuboCalculado);
218 
219  void LeeCompresor(const char *FileWAM, fpos_t &filepos);
220 
221  void RelacionTubos(TCondicionContorno **BC, int NumeroCC);
222 
223  // NO SE UTILIZA EN ESTE TIPO DE COMPRESOR
224  void CalculaGasto(double TrabajoInsTurbina, double TiempoActual) {
225  }
226 
227  void Solver();
228 
229  void SolveInletBoundary(double &A, double &U, double &Ao, double &Uo);
230 
231  void SolveOutletBoundary(double &A, double &U);
232 
233  void NewPropertiesInTheVolume();
234 
235  void InFlow(double Ad, double &A, double &U);
236 
237  void OutFlow(double Ad, double &A, double &U);
238 
239  void AsignPipes(TCondicionContorno **BC, int NumeroCC);
240 
241  void Initialize();
242 
243 };
244 
245 // ---------------------------------------------------------------------------
246 // ---------------------------------------------------------------------------
247 
248 #endif
249 
TTubo
a Finite differences pipe.
Definition: TTubo.h:116
Constantes.h
stTuboExtremo
Definition: Globales.h:730
TCompresor
Definition: TCompresor.h:47
TCondicionContorno
Definition: TCondicionContorno.h:54
TCompTubos
Definition: TCompTubos.h:79
stCompOut
Definition: TCompTubos.h:44
pow2
T pow2(T x)
Returns x to the power of 2.
Definition: Math_wam.h:88