OpenWAM
TBloqueMotor.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 TBloqueMotorH
30 #define TBloqueMotorH
31 #include <iostream>
32 
33 #include "TCilindro4T.h"
34 #include "TCilindro2T.h"
35 #include "Constantes.h"
36 #include "Globales.h"
37 #include "TController.h"
38 
39 // ---------------------------------------------------------------------------
40 // ---------------------------------------------------------------------------
41 class TTubo;
42 
43 class TBloqueMotor {
44  private:
45 
46  double FTemperaturaAmbiente;
47  double FPresionAmbiente;
48 
49  TTubo *FTuboRendVol;
50  int FNodoMedio;
51  int FNumTuboRendVol; /* Pipe de la admision al que se refiere el rendimiento volumetrico */
52 
53  std::vector<stLeyQuemadoBD> FLeyQuemadoBD;
54 
55  double FLQRegMax;
56  double FLQMfMax;
57  double FLQMaMax;
58 
59  int FTipoDatosIny;
60  int FNumeroInyecciones;
61  dVector FAngIny;
62  dVector FTIny;
63  dVector FPercentIny;
64  double FAngIniIny;
65  double FTStepIny;
66  double FAStepIny;
67  int xnum;
68  dVector FY_dat;
69  dVector FX_dat;
70  double FFuelTasaInt;
71  int TipoInterp; // Tipo de interpolación: 1. Lineal, 2. Hermite (spinlines), 3. Step
72 
73  double fOutput;
74  Base_interp *fDatosTasa;
75  nmTipoInterpolacion fTipo;
76 
77  double FTime;
78 
79  bool FACT;
80  double FMixtureProcessCte;
81 
82  nmTipoModelado FTipoModelado;
83 
84  stWoschni FWoschni;
85  stGeometria FGeom;
86  stPropTermicas FParedCulata;
87  stPropTermicas FParedPiston;
88  stPropTermicas FParedCilindro;
89  stRoadLoad FCoefRoadLoad;
90  stInjectionSys FInjectionSys;
91 
92  std::vector<stInjecPulse> FInjecPulse;
93 
94  stTemperaturasPared FTempInicial;
95  nmCalculoPared FCalculoPared;
96 
97  stResMediosMotor FResMediosMotor;
98 
99  nmTipoDesfase FTipoDesfase;
100  int FNumeroCiclosSinInerciaTermica;
101 
102  int FNumeroLeyesQuemado;
103  int FNWiebes;
104 
105  double *FDesfase;
106  // double FRegimen;
107  double FPresionInicialRCA;
108  double FMasaInicial;
109  double FPresionAAE;
110  double FMasaFuel;
111  double FDosadoInicial;
112  double FRendimientoCombustion;
113  double FPoderCalorifico;
114  double FDensidadCombustible;
115 
116  // double FAjusteTranCalAdm;
117  // double FAjusteTranCalEsc;
118  double FParPotMax;
119  double FTempRefrigerante;
120 
121  TCilindro **FCilindro;
122 
123  double FAngTotalCiclo;
124 
125  nmTipoMotor FTipoMotor;
126  nmTipoCombustion FCombustible;
127  nmCalculoPAAE FCalculoDePAAE;
128 
129  stPerdMecanicas FPerMec;
130 
131  double FMasaTotalVehiculo;
132  double FInerciaTotal;
133  double FRelCajaCambios;
134  double FRelTrasmision;
135  double FRendCajaCambios;
136  double FRadioRueda;
137  double FAnguloCarretera;
138  double FPendiente;
139  double FCoeficienteInercias;
140  double FRoadLoad;
141  double FParResistente;
142  double FParPerdidasMecanicas;
143  double FParMotor;
144 
145  // double FTheta;
146 
147  double FTrabajoNetoMotor;
148  double FTrabajoBombeoMotor;
149  double FPMNMotor;
150  double FPMBMotor;
151  double FPMIMotor;
152  double FPMEMotor;
153  double FPMPMMotor;
154  double FParEfectivo;
155  double FPotenciaEfectiva;
156  double FRendimientoEfectivo;
157  double FRendimientoIndicado;
158  double FConsumoEspecifico;
159  double FVelocidadVehiculo;
160 
161  double FAFRMedio;
162 
163  // int FCiclo; // Controla el numero de ciclo de la ejecucion. (para salida de resultados)
164  bool FPrimeravezAcumulaFuel; // Variable para controlar en el 1er ciclo la salida en resultados de MFuel.
165  bool FPrimeravezAcumulaMasaAtrapada; // Variable para controlar en el 1er ciclo la salida en resultados del Rend Volumetrico.
166 
167  // Transporte de Especies Quimicas
168  nmTipoCalculoEspecies FCalculoEspecies;
169  int FNumeroEspecies;
170  bool FImponerComposicionAE;
171  double *FComposicionInicial;
172  double *FComposicionAtmosfera;
173  nmCalculoGamma FCalculoGamma;
174  bool FHayEGR;
175  int FIntEGR;
176 
177  TController *FRPMController;
178  int FRPMControllerID;
179  bool FRPMControlled;
180 
181  TController *FMfController;
182  int FMfControllerID;
183  bool FMfControlled;
184 
185  // void PutTheta(double valor);
186 
187  // void PutRegimen(double valor);
188 
189  // void PutCiclo(int valor);
190 
191  // ---------------------------------------------------------------------------
192  // ---------------------------------------------------------------------------
193 
194  protected:
195 
196  // ---------------------------------------------------------------------------
197  // ---------------------------------------------------------------------------
198 
199  public:
200 
201  bool getACT() {
202  return FACT;
203  }
204  ;
205 
206  double getMixtureProcessCte() {
207  return FMixtureProcessCte;
208  }
209  ;
210 
211  stGeometria getGeometria() {
212  return FGeom;
213  }
214  ;
215 
216  stWoschni getWoschni() {
217  return FWoschni;
218  }
219  ;
220 
221  void PutRegimen(double valor) {
222  try {
223 
224  FRegimen = valor;
225 
226  } catch(exception & N) {
227  std::cout << "ERROR: TBloqueMotor::PutRegimen en el EngineBlock. " << std::endl;
228  std::cout << "Tipo de error: " << N.what() << std::endl;
229  throw Exception(N.what());
230  }
231  }
232 
233  double FRegimen;
234 
235  double getRegimen() {
236  return FRegimen;
237  }
238 
239  double getMasaFuel() {
240  return FMasaFuel;
241  }
242  ;
243 
244  void setMasaFuel(double fuel) {
245  FMasaFuel = fuel;
246  }
247 
248  double getMasaInicial() {
249  return FMasaInicial;
250  }
251  ;
252 
253  double getPresionAAE() {
254  return FPresionAAE;
255  }
256  ;
257 
258  double getPresionInicial() {
259  return FPresionInicialRCA;
260  }
261  ;
262 
263  stTemperaturasPared getTempInicial() {
264  return FTempInicial;
265  }
266  ;
267 
268  void PutTheta(double valor) {
269  try {
270  FTheta = valor;
271  } catch(exception & N) {
272  std::cout << "ERROR: TBloqueMotor::PutTheta en el EngineBlock. " << std::endl;
273  std::cout << "Tipo de error: " << N.what() << std::endl;
274  throw Exception(N.what());
275  }
276  }
277 
278  double FTheta;
279 
280  double getTheta() {
281  return FTheta;
282  }
283 
284  void PutCiclo(int valor) {
285  try {
286 
287  FCiclo = valor;
288 
289  } catch(exception & N) {
290  std::cout << "ERROR: TBloqueMotor::PutCiclo en el EngineBlock. " << std::endl;
291  std::cout << "Tipo de error: " << N.what() << std::endl;
292  throw Exception(N.what());
293  }
294  }
295 
296  int FCiclo; // Controla el numero de ciclo de la ejecucion. (para salida de resultados)
297 
298  int getCiclo() {
299  return FCiclo;
300  }
301 
302  double getAngTotalCiclo() {
303  return FAngTotalCiclo;
304  }
305  ;
306 
307  double GetDesfase(int i);
308 
309  nmTipoMotor getEngineType() {
310  return FTipoMotor;
311  }
312  ;
313 
314  nmTipoCombustion getCombustible() {
315  return FCombustible;
316  }
317  ;
318 
319  double getPoderCalorifico() {
320  return FPoderCalorifico;
321  }
322  ;
323 
324  double getDensidadCombustible() {
325  return FDensidadCombustible;
326  }
327  ;
328 
329  double getRendimientoCombustion() {
330  return FRendimientoCombustion;
331  }
332  ;
333 
334  double getDosadoInicial() {
335  return FDosadoInicial;
336  }
337  ;
338 
339  stPropTermicas getParedPiston() {
340  return FParedPiston;
341  }
342  ;
343 
344  stPropTermicas getParedCulata() {
345  return FParedCulata;
346  }
347  ;
348 
349  stPropTermicas getParedCilindro() {
350  return FParedCilindro;
351  }
352  ;
353 
354  nmCalculoPared getCalculoPared() {
355  return FCalculoPared;
356  }
357  ;
358 
359  double FAjusteTranCalAdm;
360 
361  double getAjusteTranCalAdm() {
362  return FAjusteTranCalAdm;
363  }
364  void PutATCAdm(double valor);
365 
366  double FAjusteTranCalEsc;
367 
368  double getAjusteTranCalEsc() {
369  return FAjusteTranCalEsc;
370  }
371 
372  void PutATCEsc(double valor);
373 
374  double getParPotMax() {
375  return FParPotMax;
376  }
377  ;
378 
379  const std::vector<stLeyQuemadoBD> getLeyQuemadoBD() {
380  return FLeyQuemadoBD;
381  }
382  ;
383 
384  double getLQRegMax() {
385  return FLQRegMax;
386  }
387  ;
388 
389  double getLQMfMax() {
390  return FLQMfMax;
391  }
392  ;
393 
394  double getLQMaMax() {
395  return FLQMaMax;
396  }
397  ;
398 
399  double getPresionAmb() {
400  return FPresionAmbiente;
401  }
402  ;
403 
404  double getTemperaturaAmb() {
405  return FTemperaturaAmbiente;
406  }
407  ;
408 
409  double getTempRefrigerante() {
410  return FTempRefrigerante;
411  }
412  ;
413 
414  int getNumCiclosSinInerciaTermica() {
415  return FNumeroCiclosSinInerciaTermica;
416  }
417  ;
418 
419  int getNumTuboRendVol() {
420  return FNumTuboRendVol;
421  }
422  ;
423 
424  TCilindro* GetCilindro(int i);
425 
426  TTubo* getTuboRendVol() {
427  return FTuboRendVol;
428  }
429  ;
430 
431  int getNodoMedio() {
432  return FNodoMedio;
433  }
434  ;
435 
436  double getAFRMedio() {
437  return FAFRMedio;
438  }
439  ;
440 
441  nmCalculoPAAE getCalculoDePAAE() {
442  return FCalculoDePAAE;
443  }
444  ;
445 
446  nmTipoCalculoEspecies getSpeciesModel() {
447  return FCalculoEspecies;
448  }
449  ;
450 
451  int getSpeciesNumber() {
452  return FNumeroEspecies;
453  }
454  ;
455 
456  bool getImponerComposicionAE() {
457  return FImponerComposicionAE;
458  }
459  ;
460 
461  double GetComposicionInicial(int i);
462 
463  double GetComposicionAtmosfera(int i);
464 
465  nmCalculoGamma getGammaCalculation() {
466  return FCalculoGamma;
467  }
468  ;
469 
470  stInjectionSys getInjectionSys() {
471  return FInjectionSys;
472  }
473  ;
474 
475  stInjecPulse getInjecPulse(int i) {
476  return FInjecPulse[i];
477  }
478  ;
479 
480  int getFTipoDatosIny() {
481  return FTipoDatosIny;
482  }
483  ;
484 
485  int getFNumeroInyecciones() {
486  return FNumeroInyecciones;
487  }
488  ;
489 
490  dVector getFAngIny() {
491  return FAngIny;
492  }
493  ;
494 
495  dVector getFTIny() {
496  return FTIny;
497  }
498  ;
499 
500  dVector getFPercentIny() {
501  return FPercentIny;
502  }
503  ;
504 
505  double getFAngIniIny() {
506  return FAngIniIny;
507  }
508  ;
509 
510  double getFAStepIny() {
511  return FAStepIny;
512  }
513  ;
514 
515 // dVector getFY_dat() {
516 // return FY_dat;
517 // };
518 //
519 // dVector getFX_dat() {
520 // return FX_dat;
521 // };
522 //
523 // int getxnum() {
524 // return xnum;
525 // };
526 
527  TBloqueMotor(double AmbientPressure, double AmbientTemperature, nmTipoCalculoEspecies SpeciesModel, int numeroespecies,
528  nmCalculoGamma GammaCalculation, bool ThereIsEGR);
529 
530  ~TBloqueMotor();
531 
532  void LeeMotor(const char *FileWAM, fpos_t &filepos, nmTipoModelado& SimulationType, int CiclosSinInerciaTermica,
533  nmTipoMotor EngineType, double *AtmosphericComposition);
534 
535  void IniciaAnguloCalculo();
536 
537  void ReadAverageResultsBloqueMotor(const char *FileWAM, fpos_t &filepos);
538 
539  void HeaderAverageResultsBloqueMotor(std::stringstream& medoutput);
540 
541  void ImprimeResultadosMediosBloqueMotor(std::stringstream& medoutput);
542 
543  void ResultadosMediosBloqueMotor();
544 
545  void AcumulaResultadosMediosBloqueMotor(double TActual, int CilindroActual);
546 
547  void PrestacionesMotor();
548 
549  void ModeloDeVehiculo(double Time);
550 
551  void AsignacionTuboRendVol(TTubo **Pipe);
552 
553  void IniciaVarCilindro();
554 
555  void AsignRPMController(TController **Controller);
556 
557  void AsignMfController(TController **Controller);
558 
559  void NewInjectionData(double Time);
560 
561  double TasaInyInterp(double Angle);
562 
563 };
564 
565 // ---------------------------------------------------------------------------
566 #endif
stInjectionSys
Definition: Globales.h:997
stResMediosMotor
Definition: Globales.h:1102
TTubo
a Finite differences pipe.
Definition: TTubo.h:116
stInjecPulse
Definition: Globales.h:1019
TController
Definition: TController.h:37
Constantes.h
TCilindro
Definition: TCilindro.h:59
stTemperaturasPared
Definition: Globales.h:1183
stRoadLoad
Definition: Globales.h:1079
stWoschni
Definition: Globales.h:1092
stPropTermicas
Definition: Globales.h:1033
Base_interp
Definition: Math_wam.h:285
Exception
Custom exception class.
Definition: Exception.hpp:39
TBloqueMotor
Definition: TBloqueMotor.h:43
dVector
std::vector< double > dVector
Double vector.
Definition: Math_wam.h:70
stPerdMecanicas
Definition: Globales.h:1069
stGeometria
Definition: Globales.h:969