OpenWAM
TBloqueMotor.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 <cmath>
32 
33 #include "TBloqueMotor.h"
34 #include "TTubo.h"
35 
36 // ---------------------------------------------------------------------------
37 // ---------------------------------------------------------------------------
38 
39 TBloqueMotor::TBloqueMotor(double AmbientPressure, double AmbientTemperature, nmTipoCalculoEspecies SpeciesModel,
40  int numeroespecies, nmCalculoGamma GammaCalculation, bool ThereIsEGR) {
41  FMasaFuel = 0.;
42  FDosadoInicial = 0.;
43  FCiclo = 0;
44  FPresionAmbiente = AmbientPressure;
45 
46  FCalculoGamma = GammaCalculation;
47 
48  FNumeroEspecies = numeroespecies;
49  FCalculoEspecies = SpeciesModel;
50  FComposicionInicial = NULL;
51  FComposicionAtmosfera = NULL;
52 
53  FDesfase = NULL;
54  FCilindro = NULL;
55 
56  FPrimeravezAcumulaFuel = true;
57 
58  FHayEGR = ThereIsEGR;
59  if(FHayEGR)
60  FIntEGR = 0;
61  else
62  FIntEGR = 1;
63 
64  FTemperaturaAmbiente = __units::degCToK(AmbientTemperature);
65  // FTemperaturaAmbiente=273;
66  // FACT=true;
67 
68  FImponerComposicionAE = false;
69 
70  FRPMControlled = false;
71  FMfControlled = false;
72  FInjectionSys.InjectPCtrd = false;
73 }
74 
75 // ---------------------------------------------------------------------------
76 // ---------------------------------------------------------------------------
77 
78 TBloqueMotor::~TBloqueMotor() {
79 
80  // Liberacion memoria dinamica Cilindros.
81  if(FGeom.NCilin > 0 && FCilindro != NULL) {
82  for(int i = 0; i < FGeom.NCilin; i++)
83  delete FCilindro[i];
84  delete[] FCilindro;
85  }
86 
87  if(FDesfase != NULL)
88  delete[] FDesfase;
89  if(FComposicionInicial != NULL)
90  delete[] FComposicionInicial;
91  if(FComposicionAtmosfera != NULL)
92  delete[] FComposicionAtmosfera;
93 
94 }
95 
96 // ---------------------------------------------------------------------------
97 // ---------------------------------------------------------------------------
98 
99 void TBloqueMotor::LeeMotor(const char *FileWAM, fpos_t &filepos, nmTipoModelado& SimulationType,
100  int CiclosSinInerciaTermica, nmTipoMotor EngineType, double *AtmosphericComposition) {
101  try {
102  double daux = 0.;
103  double ddaux = 0.;
104  int tipodesfa = 0, cil = 0, tipocombustion = 0, TipoPresionAAE = 0;
105  int NumeroLeyesQuemado = 0, CalculoTempPared = 0, nwiebes = 0, ImponerComposicionAE = 0;
106 
107  FTipoMotor = EngineType;
108  FTipoModelado = SimulationType;
109  FILE *fich = fopen(FileWAM, "r");
110  fsetpos(fich, &filepos);
111 
112  // -------------------------------
113  // UTILIZACION COMBUSTION ACT
114  // -------------------------------
115 
116  int aux = 0;
117  fscanf(fich, "%d ", &aux);
118  aux == 0 ? FACT = false : FACT = true;
119  if(FACT) {
120  fscanf(fich, "%lf ", &FMixtureProcessCte);
121  cout << FMixtureProcessCte << endl;
122  if(!FHayEGR) {
123  std::cout << "WARNING: If the combustion is calculated by ACT and the engine" << std::endl;
124  std::cout << " has EGR, you must select the option 'To calculate" << std::endl;
125  std::cout << " EGR transport, in the other case, the results" << std::endl;
126  std::cout << " provided by ACT won't be correct" << std::endl;
127  }
128  }
129 
130  // -------------------------------
131  // CILINDROS Y ORDEN DE ENCENDIDO
132  // -------------------------------
133 
134  fscanf(fich, "%d ", &FGeom.NCilin);
135  FDesfase = new double[FGeom.NCilin];
136 
137  FCilindro = new TCilindro*[FGeom.NCilin];
138  if(FTipoMotor == nm2T) {
139  FAngTotalCiclo = 360.;
140  } else {
141  FAngTotalCiclo = 720.;
142  }
143 
144  // ----------------------
145  // CONDICIONES INICIALES
146  // ----------------------
147 
148  fscanf(fich, "%lf ", &FRegimen); // Regimen de giro motor (inicial para transitorios)
149  fscanf(fich, "%lf ", &FPresionInicialRCA); // Pressure inicial al cierre de la admision
150  fscanf(fich, "%lf ", &FMasaInicial); // Masa inicial en los cilindros
151  FComposicionInicial = new double[FNumeroEspecies - FIntEGR];
152  FComposicionAtmosfera = new double[FNumeroEspecies - FIntEGR];
153  fscanf(fich, "%d ", &ImponerComposicionAE);
154  ImponerComposicionAE == 0 ? FImponerComposicionAE = false : FImponerComposicionAE = true;
155  for(int i = 0; i < FNumeroEspecies - 1; i++) {
156  fscanf(fich, "%lf ", &FComposicionInicial[i]);
157  FComposicionAtmosfera[i] = AtmosphericComposition[i];
158  }
159 
160  if(FHayEGR) {
161  if(FCalculoEspecies == nmCalculoCompleto) {
162  FComposicionAtmosfera[FNumeroEspecies - 1] = 0.;
163  if(FComposicionInicial[0] > 0.2)
164  FComposicionInicial[FNumeroEspecies - 1] = 0.;
165  else
166  FComposicionInicial[FNumeroEspecies - 1] = 1.;
167  } else {
168  FComposicionAtmosfera[FNumeroEspecies - 1] = 0.;
169  if(FComposicionInicial[0] > 0.5)
170  FComposicionInicial[FNumeroEspecies - 1] = 1.;
171  else
172  FComposicionInicial[FNumeroEspecies - 1] = 0.;
173  }
174  }
175 
176  fscanf(fich, "%d ", &TipoPresionAAE); // Pressure impuesta en el AAE, si es 0 se calcula
177  if(TipoPresionAAE == 0) {
178  FCalculoDePAAE = nmPAAECalculada;
179  FPresionAAE = 0;
180  } else if(TipoPresionAAE == 1) {
181  FCalculoDePAAE = nmPAAEImpuesta;
182  fscanf(fich, "%lf ", &FPresionAAE);
183  }
184 
185  fscanf(fich, "%d ", &tipocombustion);
186  if(tipocombustion == 0) {
187  FCombustible = nmMEC;
188  } else if(tipocombustion == 1) {
189  FCombustible = nmMEP;
190  } else {
191  std::cout << "ERROR: Tipo de combustible mal definido " << std::endl;
192  }
193  if(FCombustible == nmMEC) {
194  fscanf(fich, "%lf ", &FMasaFuel);
195  } else {
196  fscanf(fich, "%lf ", &FDosadoInicial);
197  }
198 
199  fscanf(fich, "%lf ", &FRendimientoCombustion);
200  fscanf(fich, "%lf ", &FPoderCalorifico);
201  fscanf(fich, "%lf ", &FDensidadCombustible);
202 
203  fscanf(fich, "%d ", &FNumTuboRendVol);
204  // --------------------
205  // PARAMETROS TERMICOS
206  // --------------------
207 
208  FNumeroCiclosSinInerciaTermica = CiclosSinInerciaTermica;
209  fscanf(fich, "%lf ", &FTempInicial.Piston);
210  fscanf(fich, "%lf ", &FTempInicial.Culata);
211  fscanf(fich, "%lf ", &FTempInicial.Cylinder);
212 
213  fscanf(fich, "%lf ", &FGeom.AreaPiston);
214  fscanf(fich, "%lf ", &FGeom.AreaCulata);
215 
216  fscanf(fich, "%lf %lf %lf %lf ", &FParedPiston.Espesor, &FParedPiston.Conductividad, &FParedPiston.Density,
217  &FParedPiston.CalorEspecifico);
218  fscanf(fich, "%lf %lf %lf %lf ", &FParedCulata.Espesor, &FParedCulata.Conductividad, &FParedCulata.Density,
219  &FParedCulata.CalorEspecifico);
220  fscanf(fich, "%lf %lf %lf %lf ", &FParedCilindro.Espesor, &FParedCilindro.Conductividad, &FParedCilindro.Density,
221  &FParedCilindro.CalorEspecifico);
222 
223  fscanf(fich, "%lf %lf %lf %lf", &FAjusteTranCalAdm, &FAjusteTranCalEsc, &FParPotMax, &FTempRefrigerante);
224 
225  fscanf(fich, "%d ", &CalculoTempPared);
226  switch(CalculoTempPared) {
227  case 0:
228  FCalculoPared = nmConInercia;
229  break;
230  case 1:
231  FCalculoPared = nmSinInercia;
232  break;
233  case 2:
234  FCalculoPared = nmTempFija;
235  break;
236  }
237 
238  // ------------------------------
239  // WOSCHNI.TRANSMISION DE CALOR
240  // ------------------------------
241  fscanf(fich, "%lf ", &FWoschni.cw1);
242  fscanf(fich, "%lf ", &FWoschni.cw2);
243  fscanf(fich, "%lf ", &FWoschni.xpe);
244 
245  // -----------------------
246  // PARAMETROS GEOMETRICOS
247  // -----------------------
248 
249  fscanf(fich, "%lf ", &FGeom.Biela);
250  fscanf(fich, "%lf ", &FGeom.Carrera);
251  fscanf(fich, "%lf ", &FGeom.Diametro);
252  fscanf(fich, "%lf ", &FGeom.RelaCompresion);
253  fscanf(fich, "%lf ", &FGeom.DiametroBowl);
254  fscanf(fich, "%lf ", &FGeom.AlturaBowl);
255  fscanf(fich, "%lf ", &FGeom.DistanciaValvulas);
256  fscanf(fich, "%lf ", &FGeom.AreaBlowBy);
257  fscanf(fich, "%lf ", &FGeom.CDBlowBy);
258  fscanf(fich, "%lf ", &FGeom.Excentricidad);
259  fscanf(fich, "%lf ", &FGeom.DiametroBulon);
260  fscanf(fich, "%lf ", &FGeom.AlturaCoronaPiston);
261  fscanf(fich, "%lf ", &FGeom.MasaBiela);
262  fscanf(fich, "%lf ", &FGeom.MasaPistonSegmentosBulon);
263  fscanf(fich, "%lf ", &FGeom.ModuloElasticidad);
264  fscanf(fich, "%lf ", &FGeom.CoefDeformaciones);
265 
266  FGeom.VCC = __geom::Cylinder_volume(FGeom.Diametro, FGeom.Carrera) / (FGeom.RelaCompresion - 1.);
267  FGeom.CilindradaUnitaria = __geom::Cylinder_volume(FGeom.Diametro, FGeom.Carrera);
268  FGeom.CilindradaTotal = FGeom.CilindradaUnitaria * (double) FGeom.NCilin;
269 
270  // --------------------
271  // PERDIDAS MECANICAS
272  // --------------------
273 
274  fscanf(fich, "%lf %lf %lf %lf ", &FPerMec.Coef0, &FPerMec.Coef1, &FPerMec.Coef2, &FPerMec.Coef3);
275 
276  // --------------------
277  // MODELO DE VEHdegCULO
278  // --------------------
279 
280  if(SimulationType == nmTransitorioRegimen) {
281  double mv = 0., mt = 0., mr = 0.;
282  double Imc = 0., Ict = 0., Itr = 0.;
283 
284  // Lectura de las masas
285  fscanf(fich, "%lf %lf %lf ", &mv, &mt, &mr);
286  FMasaTotalVehiculo = mv + mt + 4 * mr;
287 
288  // Lectura de las inercias
289  fscanf(fich, "%lf %lf %lf ", &Imc, &Ict, &Itr);
290 
291  // Lectura caracteristicas transmision
292  fscanf(fich, "%lf %lf %lf ", &FRelCajaCambios, &FRendCajaCambios, &FRelTrasmision);
293 
294  // Lectura del radio de la rueda
295  fscanf(fich, "%lf ", &FRadioRueda);
296 
297  // Lectura del CrankAngle de la carretera
298  fscanf(fich, "%lf ", &FAnguloCarretera);
299 
300  FInerciaTotal = pow2(FRelCajaCambios * FRelTrasmision) * Imc + pow2(FRelTrasmision) * Ict + Itr + FMasaTotalVehiculo *
301  pow2(FRadioRueda);
302 
303  FPendiente = FMasaTotalVehiculo * 9.81 * sin(FAnguloCarretera);
304 
305  FCoeficienteInercias = FRendCajaCambios * pow2(FRelCajaCambios * FRelTrasmision) / (FInerciaTotal + FMasaTotalVehiculo *
306  pow2(FRadioRueda));
307 
308  // Lectura de los coeficientes para obtener el Road Load
309  fscanf(fich, "%lf %lf %lf ", &FCoefRoadLoad.A0, &FCoefRoadLoad.B0, &FCoefRoadLoad.C0);
310  fscanf(fich, "%lf %lf %lf %lf ", &FCoefRoadLoad.n, &FCoefRoadLoad.cd, &FCoefRoadLoad.rho, &FCoefRoadLoad.A);
311  }
312 
313  if(FACT) {
314  fscanf(fich, "%d ", &FInjectionSys.HoleNumber);
315  fscanf(fich, "%lf ", &FInjectionSys.HoleDiame);
316  fscanf(fich, "%lf ", &FInjectionSys.CDHole);
317  fscanf(fich, "%lf ", &FInjectionSys.InjectPressure);
318 
319  fscanf(fich, "%lf ", &FInjectionSys.PendOpen_A1);
320  fscanf(fich, "%lf ", &FInjectionSys.PendOpen_A2);
321  fscanf(fich, "%lf ", &FInjectionSys.LevMax_B1);
322  fscanf(fich, "%lf ", &FInjectionSys.LevMax_B2);
323  fscanf(fich, "%lf ", &FInjectionSys.PendClose_C1);
324  fscanf(fich, "%lf ", &FInjectionSys.PendClose_C2);
325  fscanf(fich, "%lf ", &FInjectionSys.Desfase_D1);
326  fscanf(fich, "%lf ", &FInjectionSys.Desfase_D2);
327  fscanf(fich, "%d ", &FInjectionSys.NumPulsos);
328 
329  // FInjecPulse=new stInjecPulse[FInjectionSys.NumPulsos];
330  stInjecPulse aux2;
331  for(int i = 0; i < FInjectionSys.NumPulsos; ++i) {
332  fscanf(fich, "%lf ", &aux2.Angulo);
333  fscanf(fich, "%lf ", &aux2.Masa);
334  fscanf(fich, "%d ", &aux2.CtrAngID);
335  if(aux2.CtrAngID > 0)
336  aux2.CtrAngd = true;
337  else
338  aux2.CtrAngd = false;
339  fscanf(fich, "%d ", &aux2.CtrMasID);
340  if(aux2.CtrMasID > 0)
341  aux2.CtrMasd = true;
342  else
343  aux2.CtrMasd = false;
344  FInjecPulse.push_back(aux2);
345  }
346  } else {
347 
348  // -----------------------------
349  // LEYES DE LIBERACION DE CALOR
350  // -----------------------------
351 
352  FLQRegMax = 0.;
353  FLQMfMax = 0.;
354  FLQMaMax = 0.;
355 
356  stWiebe WiebeSimple;
357  stLeyQuemadoBD LeyQuemadoSimple;
358  fscanf(fich, "%d ", &FNumeroLeyesQuemado);
359  for(int j = 0; j < FNumeroLeyesQuemado; ++j) {
360  fscanf(fich, "%lf %lf %lf", &LeyQuemadoSimple.ma, &LeyQuemadoSimple.mf, &LeyQuemadoSimple.n);
361  if(LeyQuemadoSimple.ma > FLQMaMax)
362  FLQMaMax = LeyQuemadoSimple.ma;
363  if(LeyQuemadoSimple.mf > FLQMfMax)
364  FLQMfMax = LeyQuemadoSimple.mf;
365  if(LeyQuemadoSimple.n > FLQRegMax)
366  FLQRegMax = LeyQuemadoSimple.n;
367  fscanf(fich, "%d ", &FNWiebes);
368  for(int i = 0; i < FNWiebes; i++) {
369  fscanf(fich, "%lf %lf %lf %lf %lf ", &WiebeSimple.m, &WiebeSimple.C, &WiebeSimple.Beta, &WiebeSimple.IncAlpha,
370  &WiebeSimple.Alpha0);
371  WiebeSimple.Alpha0 = -WiebeSimple.Alpha0;
372  WiebeSimple.Inicia = WiebeSimple.Alpha0;
373  LeyQuemadoSimple.Wiebes.push_back(WiebeSimple);
374  }
375  FLeyQuemadoBD.push_back(LeyQuemadoSimple);
376  LeyQuemadoSimple.Wiebes.clear();
377  }
378  }
379 
380  // ------------------------------
381  // INYECCIÓN DE COMBUSTIBLE.
382  // ------------------------------
383 
384  fscanf(fich, "%d ", &FTipoDatosIny);
385  switch(FTipoDatosIny) {
386  case 0: // No hay datos de inyeccion
387  FNumeroInyecciones = 0;
388  break;
389  case 1: // Datos de Angulo y tiempo de inyecciones
390  fscanf(fich, "%d ", &FNumeroInyecciones); // Numero de inyecciones
391  if(FNumeroInyecciones == 0) {
392  FTipoDatosIny = 0;
393  break;
394  }
395  FAngIny.resize(FNumeroInyecciones);
396  FTIny.resize(FNumeroInyecciones);
397  FPercentIny.resize(FNumeroInyecciones);
398  for(int i = 0; i < FNumeroInyecciones; i++) {
399  fscanf(fich, "%lf %lf %lf ", &FAngIny[i], &FTIny[i],
400  &FPercentIny[i]); // Angulo de la inyeccion con pms como referencia, duracion en ms y porcentaje del total
401  }
402  break;
403  case 2: // Datos de tabla de tasa de inyeccion
404  fscanf(fich, "%lf %lf", &FAngIniIny, &FTStepIny); // Angulo de inicio de inyeccion y paso en ms entre datos de la tabla
405  fscanf(fich, "%d ", &xnum);
406  FY_dat.resize(xnum);
407  for(int i = 0; i < xnum; i++) {
408  fscanf(fich, "%lf ", &FY_dat[i]);
409  }
410  FX_dat.resize(xnum);
411  FX_dat[0] = FAngIniIny;
412  FAStepIny = FTStepIny * FRegimen / 60. * 360. / 1000.;
413  for(int i = 1; i < xnum; i++) {
414  FX_dat[i] = FX_dat[i - 1] + FAStepIny;
415  }
416 // Se comprueba que la integral de la tasa corresponde al combustible total inyectado, si no, se reescala
417  for(int i = 0; i < xnum; i++) {
418  FFuelTasaInt += FY_dat[i] * FTStepIny / 1000.;
419  }
420  for(int i = 0; i < xnum; i++) {
421  FY_dat[i] = FY_dat[i] * FMasaFuel / FFuelTasaInt;
422  }
423  fscanf(fich, "%d ", &TipoInterp);
424  switch(TipoInterp) {
425  case 0:
426  fTipo = nmLineal;
427  fDatosTasa = new Linear_interp(FX_dat, FY_dat);
428  break;
429  case 1:
430  fTipo = nmHermite;
431  fDatosTasa = new Hermite_interp(FX_dat, FY_dat);
432  break;
433  case 2:
434  fTipo = nmSteps;
435  fDatosTasa = new Step_interp(FX_dat, FY_dat);
436  break;
437  }
438  break;
439  }
440 
441  // ------------------------------
442  // CREACION OBJETO CILINDRO.
443  // ------------------------------
444 
445  if(FGeom.NCilin > 1) {
446  fscanf(fich, "%d ", &tipodesfa);
447  switch(tipodesfa) {
448  case 0:
449  FTipoDesfase = nmPersonalizado;
450  break;
451  case 1:
452  FTipoDesfase = nmImpuesto;
453  break;
454  }
455  if(FTipoDesfase == nmPersonalizado) {
456  for(int i = 0; i < FGeom.NCilin; ++i) {
457  fscanf(fich, "%lf ", &FDesfase[i]);
458  if(FTipoMotor == nm2T) {
459  FCilindro[i] = new TCilindro2T(this, i + 1, FHayEGR);
460  } else {
461  FCilindro[i] = new TCilindro4T(this, i + 1, FHayEGR);
462  }
463  }
464  } else {
465  for(int i = 0; i < FGeom.NCilin; ++i) {
466  fscanf(fich, "%d ", &cil);
467  FDesfase[cil - 1] = (double) i * FAngTotalCiclo / (double) FGeom.NCilin;
468  if(FTipoMotor == nm2T) {
469  FCilindro[cil - 1] = new TCilindro2T(this, cil, FHayEGR);
470  } else {
471  FCilindro[cil - 1] = new TCilindro4T(this, cil, FHayEGR);
472  }
473  }
474  }
475  } else {
476  FDesfase[0] = 0.;
477  if(FTipoMotor == nm2T) {
478  FCilindro[0] = new TCilindro2T(this, 1, FHayEGR);
479  } else {
480  FCilindro[0] = new TCilindro4T(this, 1, FHayEGR);
481  }
482  }
483  int controllers = 0;
484  int param = 0;
485  fscanf(fich, "%d ", &controllers);
486  for(int i = 0; i < controllers; ++i) {
487  fscanf(fich, "%d ", &param);
488  switch(param) {
489  case 0: // Engine speed controller
490  fscanf(fich, "%d ", &FRPMControllerID);
491  FRPMControlled = true;
492  SimulationType = nmTransitorioRegimen;
493  break;
494  case 1:
495  fscanf(fich, "%d ", &FInjectionSys.InjectPCtrID);
496  FInjectionSys.InjectPCtrd = true;
497  break;
498  }
499  }
500 
501  int MfControllerID = 0;
502  for(int i = 0; i < FGeom.NCilin; ++i) {
503  fscanf(fich, "%d ", &controllers);
504  for(int j = 0; j < controllers; ++j) {
505  fscanf(fich, "%d ", &param);
506  switch(param) {
507  case 0: // Mass fluel controller
508  fscanf(fich, "%d ", &MfControllerID);
509  FCilindro[i]->PutMfControllerID(MfControllerID);
510  break;
511  }
512  }
513  }
514 
515  fgetpos(fich, &filepos);
516  fclose(fich);
517  } catch(exception & N) {
518  std::cout << "ERROR: TBloqueMotor::LeeMotor en el Bloque Engine. " << std::endl;
519  std::cout << "Tipo de error: " << N.what() << std::endl;
520  throw Exception(N.what());
521  }
522 }
523 
524 // ---------------------------------------------------------------------------
525 // ---------------------------------------------------------------------------
526 
527 void TBloqueMotor::AsignacionTuboRendVol(TTubo **Pipe) {
528  try {
529 
530  // Asignacion del tubo al que se refiere el rendimiento volumetrico.
531 
532  FTuboRendVol = Pipe[FNumTuboRendVol - 1];
533 
534  FNodoMedio = floor((FTuboRendVol->getNin()) / 2.);
535 
536  } catch(exception & N) {
537  std::cout << "ERROR: TBloqueMotor::AsignacionTuboRendVol en el Bloque Engine. " << std::endl;
538  std::cout << "Tipo de error: " << N.what() << std::endl;
539  throw Exception(N.what());
540  }
541 }
542 
543 // ---------------------------------------------------------------------------
544 // ---------------------------------------------------------------------------
545 
546 void TBloqueMotor::IniciaAnguloCalculo() {
547  try {
548  if(FTipoMotor == nm4T) {
549  FTheta = FCilindro[0]->getDistribucion().CA;
550  } else if(FTipoMotor == nm2T) {
551  FTheta = 256.;
552  } else {
553  std::cout << "ERROR: Tipo de motor mal definido" << std::endl;
554  }
555  } catch(exception & N) {
556  std::cout << "ERROR: TBloqueMotor::IniciaAnguloCalculo en el Bloque Engine. " << std::endl;
557  std::cout << "Tipo de error: " << N.what() << std::endl;
558  throw Exception(N.what());
559  }
560 }
561 
562 // ---------------------------------------------------------------------------
563 // ---------------------------------------------------------------------------
564 
565 void TBloqueMotor::ReadAverageResultsBloqueMotor(const char *FileWAM, fpos_t &filepos) {
566  try {
567  int nvars = 0, Tipovar = 0;
568 
569  FILE *fich = fopen(FileWAM, "r");
570  fsetpos(fich, &filepos);
571 
572  FResMediosMotor.ParNeto = false;
573  FResMediosMotor.ParNetoSUM = 0.;
574  FResMediosMotor.ParNetoMED = 0.;
575  FResMediosMotor.PMN = false;
576  FResMediosMotor.PMNMED = 0.;
577  FResMediosMotor.ParEfectivo = false;
578  FResMediosMotor.ParEfectivoSUM = 0.;
579  FResMediosMotor.ParEfectivoMED = 0.;
580  FResMediosMotor.ParEfectivoCiclo = false;
581  FResMediosMotor.ParEfectivoCicloMED = 0.;
582  FResMediosMotor.PME = false;
583  FResMediosMotor.PMEMED = 0.;
584  FResMediosMotor.Potencia = false;
585  FResMediosMotor.PotenciaMED = 0.;
586  FResMediosMotor.PotenciaCiclo = false;
587  FResMediosMotor.PotenciaCicloMED = 0.;
588  FResMediosMotor.MasaAdmision = false;
589  FResMediosMotor.MasaAdmisionMED = 0.;
590  FResMediosMotor.MasaAdmisionSUM = 0.;
591  FResMediosMotor.MasaFuel = false;
592  FResMediosMotor.MasaFuelMED = 0.;
593  FResMediosMotor.MasaFuelSUM = 0.;
594  FResMediosMotor.RegimenGiro = false;
595  FResMediosMotor.RegimenGiroSUM = 0.;
596  FResMediosMotor.RegimenGiroMED = 0.;
597  FResMediosMotor.RendimientoVolumetrico = false;
598  FResMediosMotor.RendimientoVolumetricoMED = 0.;
599  FResMediosMotor.RendimientoVolumetricoAtm = false;
600  FResMediosMotor.RendimientoVolumetricoAtmMED = 0.;
601  FResMediosMotor.ParPerdidasMecanicas = false;
602  FResMediosMotor.ParPerdidasMecanicasSUM = 0.;
603  FResMediosMotor.ParPerdidasMecanicasMED = 0.;
604  FResMediosMotor.ParResistente = false;
605  FResMediosMotor.ParResistenteSUM = 0.;
606  FResMediosMotor.ParResistenteMED = 0.;
607  FResMediosMotor.VelocidadVehiculo = false;
608  FResMediosMotor.VelocidadVehiculoSUM = 0.;
609  FResMediosMotor.VelocidadVehiculoMED = 0.;
610  FResMediosMotor.DensidadReferenciaSUM = 0.;
611  FResMediosMotor.DensidadReferenciaMED = 0.;
612  FResMediosMotor.MasaTuboReferenciaSUM = 0.;
613  FResMediosMotor.MasaTuboReferenciaMED = 0.;
614  FResMediosMotor.GastoTuboReferenciaSUM = 0.;
615  FResMediosMotor.GastoTuboReferenciaMED = 0.;
616  FResMediosMotor.MasaAtrapada = false;
617  FResMediosMotor.MasaAtrapadaMED = 0.;
618  FResMediosMotor.TrabajoNeto = false;
619  FResMediosMotor.TrabajoNetoSUM = 0.;
620  FResMediosMotor.TrabajoNetoMED = 0.;
621  FResMediosMotor.TrabajoBombeo = false;
622  FResMediosMotor.TrabajoBombeoSUM = 0.;
623  FResMediosMotor.TrabajoBombeoMED = 0.;
624  FResMediosMotor.PMNCiclo = false;
625  FResMediosMotor.PMNCicloMED = 0.;
626  FResMediosMotor.PME = false;
627  FResMediosMotor.PMECicloMED = 0.;
628  FResMediosMotor.PMBCiclo = false;
629  FResMediosMotor.PMBCicloMED = 0.;
630  FResMediosMotor.PMICiclo = false;
631  FResMediosMotor.PMICicloMED = 0.;
632  FResMediosMotor.RendEfectivo = false;
633  FResMediosMotor.RendEfectivoMED = 0.;
634  FResMediosMotor.RendIndicado = false;
635  FResMediosMotor.RendIndicadoMED = 0.;
636  FResMediosMotor.ConsumoEspecifico = false;
637  FResMediosMotor.ConsumoEspecificoMED = 0.;
638  FResMediosMotor.Dosado = false;
639  FResMediosMotor.DosadoMED = 0.;
640  FResMediosMotor.AFR = false;
641  FResMediosMotor.AFRMED = 0.;
642  FResMediosMotor.Swirl = false;
643  FResMediosMotor.SwirlMED = 0.;
644 
645  FResMediosMotor.TiempoSUM = 0.;
646  FResMediosMotor.Tiempo0 = 0.;
647 
648  fscanf(fich, "%d ", &nvars);
649  for(int i = 0; i < nvars; i++) {
650  fscanf(fich, "%d ", &Tipovar);
651  switch(Tipovar) {
652  case 0:
653  FResMediosMotor.ParNeto = true;
654  break;
655  case 1:
656  FResMediosMotor.ParEfectivo = true;
657  break;
658  case 2:
659  FResMediosMotor.ParEfectivoCiclo = true;
660  break;
661  case 3:
662  FResMediosMotor.ParPerdidasMecanicas = true;
663  break;
664  case 4:
665  FResMediosMotor.TrabajoNeto = true;
666  break;
667  case 5:
668  FResMediosMotor.TrabajoBombeo = true;
669  break;
670  case 6:
671  FResMediosMotor.PMN = true;
672  break;
673  case 7:
674  FResMediosMotor.PME = true;
675  break;
676  case 8:
677  FResMediosMotor.PMNCiclo = true;
678  break;
679  case 9:
680  FResMediosMotor.PMECiclo = true;
681  break;
682  case 10:
683  FResMediosMotor.PMICiclo = true;
684  break;
685  case 11:
686  FResMediosMotor.PMBCiclo = true;
687  break;
688  case 12:
689  FResMediosMotor.Potencia = true;
690  break;
691  case 13:
692  FResMediosMotor.PotenciaCiclo = true;
693  break;
694  case 14:
695  FResMediosMotor.MasaAdmision = true;
696  break;
697  case 15:
698  FResMediosMotor.MasaFuel = true;
699  break;
700  case 16:
701  FResMediosMotor.MasaAtrapada = true;
702  break;
703  case 17:
704  FResMediosMotor.RegimenGiro = true;
705  break;
706  case 18:
707  FResMediosMotor.RendimientoVolumetrico = true;
708  break;
709  case 19:
710  FResMediosMotor.RendimientoVolumetricoAtm = true;
711  break;
712  case 20:
713  FResMediosMotor.RendEfectivo = true;
714  break;
715  case 21:
716  FResMediosMotor.RendIndicado = true;
717  break;
718  case 22:
719  FResMediosMotor.ConsumoEspecifico = true;
720  break;
721  case 23:
722  FResMediosMotor.ParResistente = true;
723  break;
724  case 24:
725  FResMediosMotor.VelocidadVehiculo = true;
726  break;
727  case 25:
728  FResMediosMotor.Dosado = true;
729  break;
730  case 26:
731  FResMediosMotor.AFR = true;
732  break;
733  case 27:
734  FResMediosMotor.Swirl = true;
735  break;
736  default:
737  std::cout << "Resultados medios en el motor (" << Tipovar << ")no definido" << std::endl;
738  }
739  }
740 
741  fgetpos(fich, &filepos);
742  fclose(fich);
743 
744  } catch(exception & N) {
745  std::cout << "ERROR: TBloqueMotor::ReadAverageResults en el Bloque Engine. " << std::endl;
746  std::cout << "Tipo de error: " << N.what() << std::endl;
747  throw Exception(N.what());
748  }
749 }
750 
751 // ---------------------------------------------------------------------------
752 // ---------------------------------------------------------------------------
753 
754 void TBloqueMotor::HeaderAverageResultsBloqueMotor(stringstream& medoutput) {
755  try {
756  // FILE *fich=fopen(FileSALIDA,"a");
757  std::string Label;
758 
759  if(FResMediosMotor.ParNeto) {
760  Label = "\t" + PutLabel(601);
761  medoutput << Label.c_str();
762  }
763  if(FResMediosMotor.ParEfectivo) {
764  Label = "\t" + PutLabel(602);
765  medoutput << Label.c_str();
766  }
767  if(FResMediosMotor.ParEfectivoCiclo) {
768  Label = "\t" + PutLabel(603);
769  medoutput << Label.c_str();
770  }
771  if(FResMediosMotor.ParPerdidasMecanicas) {
772  Label = "\t" + PutLabel(604);
773  medoutput << Label.c_str();
774  }
775  if(FResMediosMotor.TrabajoNeto) {
776  Label = "\t" + PutLabel(605);
777  medoutput << Label.c_str();
778  }
779  if(FResMediosMotor.TrabajoBombeo) {
780  Label = "\t" + PutLabel(606);
781  medoutput << Label.c_str();
782  }
783  if(FResMediosMotor.PMN) {
784  Label = "\t" + PutLabel(607);
785  medoutput << Label.c_str();
786  }
787  if(FResMediosMotor.PME) {
788  Label = "\t" + PutLabel(608);
789  medoutput << Label.c_str();
790  }
791  if(FResMediosMotor.PMNCiclo) {
792  Label = "\t" + PutLabel(609);
793  medoutput << Label.c_str();
794  }
795  if(FResMediosMotor.PMECiclo) {
796  Label = "\t" + PutLabel(610);
797  medoutput << Label.c_str();
798  }
799  if(FResMediosMotor.PMICiclo) {
800  Label = "\t" + PutLabel(611);
801  medoutput << Label.c_str();
802  }
803  if(FResMediosMotor.PMBCiclo) {
804  Label = "\t" + PutLabel(612);
805  medoutput << Label.c_str();
806  }
807  if(FResMediosMotor.Potencia) {
808  Label = "\t" + PutLabel(613);
809  medoutput << Label.c_str();
810  }
811  if(FResMediosMotor.PotenciaCiclo) {
812  Label = "\t" + PutLabel(614);
813  medoutput << Label.c_str();
814  }
815  if(FResMediosMotor.MasaAdmision) {
816  Label = "\t" + PutLabel(615);
817  medoutput << Label.c_str();
818  }
819  if(FResMediosMotor.MasaFuel) {
820  Label = "\t" + PutLabel(616);
821  medoutput << Label.c_str();
822  }
823  if(FResMediosMotor.MasaAtrapada) {
824  Label = "\t" + PutLabel(617);
825  medoutput << Label.c_str();
826  }
827  if(FResMediosMotor.RegimenGiro) {
828  Label = "\t" + PutLabel(618);
829  medoutput << Label.c_str();
830  }
831  if(FResMediosMotor.RendimientoVolumetrico) {
832  Label = "\t" + PutLabel(619);
833  medoutput << Label.c_str();
834  }
835  if(FResMediosMotor.RendimientoVolumetricoAtm) {
836  Label = "\t" + PutLabel(620);
837  medoutput << Label.c_str();
838  }
839  if(FResMediosMotor.RendEfectivo) {
840  Label = "\t" + PutLabel(621);
841  medoutput << Label.c_str();
842  }
843  if(FResMediosMotor.RendIndicado) {
844  Label = "\t" + PutLabel(622);
845  medoutput << Label.c_str();
846  }
847  if(FResMediosMotor.ConsumoEspecifico) {
848  Label = "\t" + PutLabel(623);
849  medoutput << Label.c_str();
850  }
851  if(FResMediosMotor.ParResistente) {
852  Label = "\t" + PutLabel(624);
853  medoutput << Label.c_str();
854  }
855  if(FResMediosMotor.VelocidadVehiculo) {
856  Label = "\t" + PutLabel(625);
857  medoutput << Label.c_str();
858  }
859  if(FResMediosMotor.Dosado) {
860  Label = "\t" + PutLabel(626);
861  medoutput << Label.c_str();
862  }
863  if(FResMediosMotor.AFR) {
864  Label = "\t" + PutLabel(627);
865  medoutput << Label.c_str();
866  }
867  if(FResMediosMotor.Swirl) {
868  Label = "\t" + PutLabel(628);
869  medoutput << Label.c_str();
870  }
871 
872  // fclose(fich);
873  } catch(exception & N) {
874  std::cout << "ERROR: TBloqueMotor::HeaderAverageResults en el Bloque Engine. " << std::endl;
875  std::cout << "Tipo de error: " << N.what() << std::endl;
876  throw Exception(N.what());
877  }
878 }
879 
880 // ---------------------------------------------------------------------------
881 // ---------------------------------------------------------------------------
882 
883 void TBloqueMotor::ImprimeResultadosMediosBloqueMotor(stringstream& medoutput) {
884  try {
885  // FILE *fich=fopen(FileSALIDA,"a");
886 
887  if(FResMediosMotor.ParNeto)
888  medoutput << "\t" << FResMediosMotor.ParNetoMED;
889  if(FResMediosMotor.ParEfectivo)
890  medoutput << "\t" << FResMediosMotor.ParEfectivoMED;
891  if(FResMediosMotor.ParEfectivoCiclo)
892  medoutput << "\t" << FResMediosMotor.ParEfectivoCicloMED;
893  if(FResMediosMotor.ParPerdidasMecanicas)
894  medoutput << "\t" << FResMediosMotor.ParPerdidasMecanicasMED;
895  if(FResMediosMotor.TrabajoNeto)
896  medoutput << "\t" << FResMediosMotor.TrabajoNetoMED;
897  if(FResMediosMotor.TrabajoBombeo)
898  medoutput << "\t" << FResMediosMotor.TrabajoBombeoMED;
899  if(FResMediosMotor.PMN)
900  medoutput << "\t" << FResMediosMotor.PMNMED;
901  if(FResMediosMotor.PME)
902  medoutput << "\t" << FResMediosMotor.PMEMED;
903  if(FResMediosMotor.PMNCiclo)
904  medoutput << "\t" << FResMediosMotor.PMNCicloMED;
905  if(FResMediosMotor.PMECiclo)
906  medoutput << "\t" << FResMediosMotor.PMECicloMED;
907  if(FResMediosMotor.PMICiclo)
908  medoutput << "\t" << FResMediosMotor.PMICicloMED;
909  if(FResMediosMotor.PMBCiclo)
910  medoutput << "\t" << FResMediosMotor.PMBCicloMED;
911  if(FResMediosMotor.Potencia)
912  medoutput << "\t" << FResMediosMotor.PotenciaMED;
913  if(FResMediosMotor.PotenciaCiclo)
914  medoutput << "\t" << FResMediosMotor.PotenciaCicloMED;
915  if(FResMediosMotor.MasaAdmision)
916  medoutput << "\t" << FResMediosMotor.MasaAdmisionMED;
917  if(FResMediosMotor.MasaFuel)
918  medoutput << "\t" << FResMediosMotor.MasaFuelMED;
919  if(FResMediosMotor.MasaAtrapada)
920  medoutput << "\t" << FResMediosMotor.MasaAtrapadaMED;
921  if(FResMediosMotor.RegimenGiro)
922  medoutput << "\t" << FResMediosMotor.RegimenGiroMED;
923  if(FResMediosMotor.RendimientoVolumetrico)
924  medoutput << "\t" << FResMediosMotor.RendimientoVolumetricoMED;
925  if(FResMediosMotor.RendimientoVolumetricoAtm)
926  medoutput << "\t" << FResMediosMotor.RendimientoVolumetricoAtmMED;
927  if(FResMediosMotor.RendEfectivo)
928  medoutput << "\t" << FResMediosMotor.RendEfectivoMED;
929  if(FResMediosMotor.RendIndicado)
930  medoutput << "\t" << FResMediosMotor.RendIndicadoMED;
931  if(FResMediosMotor.ConsumoEspecifico)
932  medoutput << "\t" << FResMediosMotor.ConsumoEspecificoMED;
933  if(FResMediosMotor.ParResistente)
934  medoutput << "\t" << FResMediosMotor.ParResistenteMED;
935  if(FResMediosMotor.VelocidadVehiculo)
936  medoutput << "\t" << FResMediosMotor.VelocidadVehiculoMED;
937  if(FResMediosMotor.Dosado)
938  medoutput << "\t" << FResMediosMotor.DosadoMED;
939  if(FResMediosMotor.AFR)
940  medoutput << "\t" << FResMediosMotor.AFRMED;
941  if(FResMediosMotor.Swirl)
942  medoutput << "\t" << FResMediosMotor.SwirlMED;
943 
944  // fclose(fich);
945  } catch(exception & N) {
946  std::cout << "ERROR: TBloqueMotor::ImprimeResultadosMediosBloqueMotor " << std::endl;
947  std::cout << "Tipo de error: " << N.what() << std::endl;
948  throw Exception(N.what());
949  }
950 }
951 
952 // ---------------------------------------------------------------------------
953 // ---------------------------------------------------------------------------
954 
955 void TBloqueMotor::ResultadosMediosBloqueMotor() {
956  try {
957  double DensidadAtm = 0.;
958  double MasaAtrapadaSUM = 0.;
959  double FraccionAireFrescoSUM = 0., AFRSUM = 0.;
960  double swirltotal = 0.;
961 
962  if(FResMediosMotor.RegimenGiro || FResMediosMotor.Potencia || FResMediosMotor.RendimientoVolumetricoAtm
963  || FResMediosMotor.RendimientoVolumetrico) {
964  FResMediosMotor.RegimenGiroMED = FResMediosMotor.RegimenGiroSUM / FResMediosMotor.TiempoSUM;
965  FResMediosMotor.RegimenGiroSUM = 0.;
966  }
967  if(FResMediosMotor.ParNeto || FResMediosMotor.PMN) {
968  FResMediosMotor.ParNetoMED = FResMediosMotor.ParNetoSUM / FResMediosMotor.TiempoSUM;
969  FResMediosMotor.ParNetoSUM = 0.;
970  }
971  if(FResMediosMotor.PMN) {
972  FResMediosMotor.PMNMED = FResMediosMotor.ParNetoMED * 16. / (FGeom.NCilin * pow2(FGeom.Diametro) * FGeom.Carrera) /
973  100000.;
974  }
975  if(FResMediosMotor.ParEfectivo || FResMediosMotor.PME || FResMediosMotor.Potencia) {
976  FResMediosMotor.ParEfectivoMED = FResMediosMotor.ParEfectivoSUM / FResMediosMotor.TiempoSUM;
977  FResMediosMotor.ParEfectivoSUM = 0.;
978  }
979  if(FResMediosMotor.PME) {
980  FResMediosMotor.PMEMED = FResMediosMotor.ParEfectivoMED * 16. / (FGeom.NCilin * pow2(
981  FGeom.Diametro) * FGeom.Carrera) / 100000.;
982  }
983  if(FResMediosMotor.Potencia) {
984  FResMediosMotor.PotenciaMED = __units::To_kilo(FResMediosMotor.ParEfectivoMED * __cons::Pi_x_2 * __units::RPMToRPS(
985  FResMediosMotor.RegimenGiroMED));
986  }
987  if(FResMediosMotor.MasaAdmision) {
988  for(int i = 0; i < FGeom.NCilin; i++) {
989  FResMediosMotor.MasaAdmisionSUM += FCilindro[i]->getMasaPorAdmision();
990  }
991  FResMediosMotor.MasaAdmisionMED = FResMediosMotor.MasaAdmisionSUM / FGeom.NCilin;
992  FResMediosMotor.MasaAdmisionSUM = 0.;
993  }
994 
995  FResMediosMotor.MasaFuelMED = FResMediosMotor.MasaFuelSUM / FGeom.NCilin;
996  FResMediosMotor.MasaFuelSUM = 0.;
997  FPrimeravezAcumulaFuel = true;
998 
999  if(FResMediosMotor.MasaAtrapada || FResMediosMotor.RendimientoVolumetrico || FResMediosMotor.RendimientoVolumetricoAtm
1000  || FResMediosMotor.AFR) {
1001  for(int i = 0; i < FGeom.NCilin; i++) {
1002  MasaAtrapadaSUM += FCilindro[i]->getMasaAtrapada();
1003  FraccionAireFrescoSUM += FCilindro[i]->getFraccionAireFresco();
1004  }
1005  FResMediosMotor.MasaAtrapadaMED = MasaAtrapadaSUM / FGeom.NCilin;
1006  FResMediosMotor.FraccionAireFrescoMED = FraccionAireFrescoSUM / FGeom.NCilin;
1007  }
1008  if(FResMediosMotor.RendimientoVolumetrico || FResMediosMotor.RendimientoVolumetricoAtm) {
1009  FResMediosMotor.GastoTuboReferenciaMED = FResMediosMotor.GastoTuboReferenciaSUM / FResMediosMotor.TiempoSUM;
1010  FResMediosMotor.GastoTuboReferenciaSUM = 0.;
1011  }
1012  if(FResMediosMotor.RendimientoVolumetrico) {
1013  FResMediosMotor.DensidadReferenciaMED = FResMediosMotor.DensidadReferenciaSUM / FResMediosMotor.TiempoSUM;
1014  FResMediosMotor.RendimientoVolumetricoMED = fabs(FResMediosMotor.GastoTuboReferenciaMED) /
1015  FResMediosMotor.DensidadReferenciaMED / FGeom.CilindradaTotal / (FResMediosMotor.RegimenGiroMED / 60. *
1016  (360. / FAngTotalCiclo));
1017  FResMediosMotor.DensidadReferenciaSUM = 0;
1018  }
1019  if(FResMediosMotor.ParPerdidasMecanicas) {
1020  FResMediosMotor.ParPerdidasMecanicasMED = FResMediosMotor.ParPerdidasMecanicasSUM / FResMediosMotor.TiempoSUM;
1021  FResMediosMotor.ParPerdidasMecanicasSUM = 0.;
1022  }
1023  if(FResMediosMotor.ParResistente) {
1024  FResMediosMotor.ParResistenteMED = FResMediosMotor.ParResistenteSUM / FResMediosMotor.TiempoSUM;
1025  FResMediosMotor.ParResistenteSUM = 0.;
1026  }
1027  if(FResMediosMotor.VelocidadVehiculo) {
1028  FResMediosMotor.VelocidadVehiculoMED = FResMediosMotor.VelocidadVehiculoSUM / FResMediosMotor.TiempoSUM;
1029  FResMediosMotor.VelocidadVehiculoSUM = 0.;
1030  }
1031  if(FResMediosMotor.RendimientoVolumetricoAtm) {
1032  DensidadAtm = __units::BarToPa(FPresionAmbiente) / (__R::Air * FTemperaturaAmbiente);
1033  FResMediosMotor.RendimientoVolumetricoAtmMED = fabs(FResMediosMotor.GastoTuboReferenciaMED) / DensidadAtm /
1034  FGeom.CilindradaTotal / (FResMediosMotor.RegimenGiroMED / 120.);
1035  }
1036  if(FResMediosMotor.Dosado) {
1037  FResMediosMotor.MasaTuboReferenciaMED = FResMediosMotor.MasaTuboReferenciaSUM / FResMediosMotor.TiempoSUM;
1038  FResMediosMotor.DosadoMED = FResMediosMotor.MasaFuelMED / fabs(FResMediosMotor.MasaTuboReferenciaMED);
1039  FResMediosMotor.MasaTuboReferenciaSUM = 0.;
1040  }
1041  if(FResMediosMotor.AFR) {
1042  for(int i = 0; i < FGeom.NCilin; i++) {
1043  AFRSUM += FCilindro[i]->getAFR();
1044  }
1045  FResMediosMotor.AFRMED = AFRSUM / FGeom.NCilin;
1046  AFRSUM = 0.;
1047  // FResMediosMotor.AFRMED=FResMediosMotor.MasaAtrapadaMED*FResMediosMotor.FraccionAireFrescoMED/FResMediosMotor.MasaFuelMED;
1048  }
1049  if(FResMediosMotor.Swirl) {
1050  for(int i = 0; i < FGeom.NCilin; i++) {
1051  swirltotal += FCilindro[i]->getSwirlSUM() / FResMediosMotor.TiempoSUM;
1052  /* Valor medio de Swirl para el cilindro i */
1053  }
1054  FResMediosMotor.SwirlMED = swirltotal / FGeom.NCilin;
1055  }
1056 
1057  FResMediosMotor.TrabajoNetoMED = FResMediosMotor.TrabajoNetoSUM;
1058  FResMediosMotor.TrabajoNetoSUM = 0.;
1059 
1060  /* for(int i=0;i<FGeom.NCilin;i++){
1061  FResMediosMotor.TrabajoBombeoSUM+=FCilindro[i]->getTrabajoBombeo();
1062  } */
1063 
1064  FResMediosMotor.TrabajoBombeoMED = FResMediosMotor.TrabajoBombeoSUM;
1065  FResMediosMotor.TrabajoBombeoSUM = 0.;
1066 
1067  FResMediosMotor.PMNCicloMED = __units::PaToBar(FResMediosMotor.TrabajoNetoMED / FGeom.CilindradaTotal);
1068 
1069  FResMediosMotor.PMBCicloMED = __units::PaToBar(FResMediosMotor.TrabajoBombeoMED / FGeom.CilindradaTotal);
1070 
1071  FResMediosMotor.PMICicloMED = FResMediosMotor.PMNCicloMED - FResMediosMotor.PMBCicloMED;
1072 
1073  FPMPMMotor = FPerMec.Coef0 + FPerMec.Coef1 * FResMediosMotor.RegimenGiroMED / 60. - FPerMec.Coef2 *
1074  FResMediosMotor.RegimenGiroMED * FResMediosMotor.RegimenGiroMED / 3600 + FPerMec.Coef3 * FResMediosMotor.PMICicloMED;
1075  FResMediosMotor.PMECicloMED = FResMediosMotor.PMNCicloMED - FPMPMMotor;
1076 
1077  FResMediosMotor.ParEfectivoCicloMED = __units::BarToPa(FResMediosMotor.PMECicloMED) * FGeom.CilindradaTotal /
1078  (__units::DegToRad(FAngTotalCiclo));
1079 
1080  FResMediosMotor.PotenciaCicloMED = __units::To_kilo(__cons::Pi_x_2 * FResMediosMotor.ParEfectivoCicloMED *
1081  __units::RPMToRPS(FResMediosMotor.RegimenGiroMED));
1082 
1083  if(FResMediosMotor.MasaFuelMED == 0) {
1084  FResMediosMotor.RendIndicadoMED = 0.;
1085  FResMediosMotor.RendEfectivoMED = 0.;
1086  FResMediosMotor.ConsumoEspecificoMED = 0.;
1087  } else {
1088  FResMediosMotor.RendIndicadoMED = (FResMediosMotor.TrabajoNetoMED - FResMediosMotor.TrabajoBombeoMED) /
1089  (FGeom.NCilin * FResMediosMotor.MasaFuelMED * FPoderCalorifico);
1090  FResMediosMotor.RendEfectivoMED = __units::BarToPa(FResMediosMotor.PMECicloMED) * FGeom.CilindradaTotal /
1091  (FGeom.NCilin * FResMediosMotor.MasaFuelMED * FPoderCalorifico);
1092  FResMediosMotor.ConsumoEspecificoMED = 3.6e9 / (FResMediosMotor.RendEfectivoMED * FPoderCalorifico);
1093  }
1094 
1095  FResMediosMotor.TiempoSUM = 0;
1096  } catch(exception & N) {
1097  std::cout << "ERROR: TBloqueMotor::ResultadosMediosBloqueMotor " << std::endl;
1098  std::cout << "Tipo de error: " << N.what() << std::endl;
1099  throw Exception(N.what());
1100  }
1101 }
1102 
1103 // ---------------------------------------------------------------------------
1104 // ---------------------------------------------------------------------------
1105 
1106 void TBloqueMotor::AcumulaResultadosMediosBloqueMotor(double TActual, int CilindroActual) {
1107  try {
1108  double partotalins = 0.;
1109 
1110  double DeltaT = TActual - FResMediosMotor.Tiempo0;
1111  // double DeltaAngulo=360.*FRegimen/60.*DeltaT;
1112 
1113  if(FResMediosMotor.ParNeto || FResMediosMotor.PMN || FResMediosMotor.ParEfectivo || FResMediosMotor.PME
1114  || FResMediosMotor.Potencia) {
1115  for(int i = 0; i < FGeom.NCilin; i++) {
1116  partotalins += FCilindro[i]->getParInstantaneo() * DeltaT;
1117  }
1118  FResMediosMotor.ParNetoSUM += partotalins;
1119  }
1120 
1121  if(FResMediosMotor.ParEfectivo || FResMediosMotor.PME || FResMediosMotor.Potencia) {
1122  FResMediosMotor.ParEfectivoSUM += partotalins - FParPerdidasMecanicas * DeltaT;
1123  }
1124 
1125  if(FCilindro[0]->getAnguloActual() > FCilindro[0]->getDistribucion().CA
1126  && FCilindro[0]->getAnguloActual() <= FCilindro[0]->getDistribucion().CA + (FCilindro[0]->getAnguloActual() -
1127  FCilindro[0]->getAnguloAnterior())) {
1128  if(FPrimeravezAcumulaFuel) {
1129  for(int i = 0; i < FGeom.NCilin; i++) {
1130  FResMediosMotor.MasaFuelSUM += FCilindro[i]->getMasaFuel();
1131  }
1132  FPrimeravezAcumulaFuel = false;
1133  }
1134  }
1135 
1136  if(FResMediosMotor.RendimientoVolumetrico || FResMediosMotor.Dosado) {
1137  FResMediosMotor.DensidadReferenciaSUM += FTuboRendVol->GetDensidad(FNodoMedio) * DeltaT;
1138  FResMediosMotor.GastoTuboReferenciaSUM += (FTuboRendVol->GetVelocidad(FNodoMedio) * __cons::ARef *
1139  FTuboRendVol->GetArea(FNodoMedio) * FTuboRendVol->GetDensidad(FNodoMedio)) * DeltaT;
1140 
1141  }
1142 
1143  if(FResMediosMotor.RendimientoVolumetrico || FResMediosMotor.Potencia || FResMediosMotor.RendimientoVolumetricoAtm) {
1144  FResMediosMotor.RegimenGiroSUM += FRegimen * DeltaT;
1145  }
1146 
1147  if(FResMediosMotor.ParPerdidasMecanicas) {
1148  FResMediosMotor.ParPerdidasMecanicasSUM += FParPerdidasMecanicas * DeltaT;
1149  }
1150  if(FResMediosMotor.ParResistente) {
1151  FResMediosMotor.ParResistenteSUM += FParResistente * DeltaT;
1152  }
1153  if(FResMediosMotor.VelocidadVehiculo) {
1154  FResMediosMotor.VelocidadVehiculoSUM += FVelocidadVehiculo * DeltaT;
1155  }
1156  if(FResMediosMotor.Dosado) {
1157  FResMediosMotor.MasaTuboReferenciaSUM += (FTuboRendVol->GetVelocidad(FNodoMedio) * __cons::ARef * FTuboRendVol->GetArea(
1158  FNodoMedio) * FTuboRendVol->GetDensidad(FNodoMedio)) / FGeom.NCilin / (FRegimen / 120) * DeltaT;
1159  }
1160 
1161  /* for(int i=0;i<FGeom.NCilin;i++){
1162  FResMediosMotor.TrabajoNetoSUM+=FCilindro[i]->getPreMed()*1e5*(FCilindro[i]->getVolumen()-FCilindro[i]->getVolumen0());
1163  if(FCilindro[i]->getAnguloActual()>180. && FCilindro[i]->getAnguloActual()<540.){
1164  FResMediosMotor.TrabajoBombeoSUM+=FCilindro[i]->getPreMed()*1e5*(FCilindro[i]->getVolumen()-FCilindro[i]->getVolumen0());
1165  }
1166  } */
1167  FResMediosMotor.TrabajoNetoSUM += __units::BarToPa(FCilindro[CilindroActual - 1]->getPreMed()) *
1168  (FCilindro[CilindroActual - 1]->getVolumen() - FCilindro[CilindroActual - 1]->getVolumen0());
1169  if(FCilindro[CilindroActual - 1]->getAnguloActual() > 180. && FCilindro[CilindroActual - 1]->getAnguloActual() < 540.) {
1170  FResMediosMotor.TrabajoBombeoSUM += __units::BarToPa(FCilindro[CilindroActual - 1]->getPreMed()) *
1171  (FCilindro[CilindroActual - 1]->getVolumen() - FCilindro[CilindroActual - 1]->getVolumen0());
1172  }
1173 
1174  FResMediosMotor.TiempoSUM += DeltaT;
1175  FResMediosMotor.Tiempo0 = TActual;
1176  } catch(exception & N) {
1177  std::cout << "ERROR: TBloqueMotor::AcumulaResultadosMediosBloqueMotor " << std::endl;
1178  std::cout << "Tipo de error: " << N.what() << std::endl;
1179  throw Exception(N.what());
1180  }
1181 }
1182 
1183 // ---------------------------------------------------------------------------
1184 // ---------------------------------------------------------------------------
1185 
1186 void TBloqueMotor::PrestacionesMotor() {
1187  try {
1188 
1189  printf("\n \n \n");
1190  std::cout << "INFO:----------------------------------------------" << std::endl;
1191  std::cout << "INFO: ENGINE PERFORMANCE" << std::endl;
1192  std::cout << "INFO:----------------------------------------------" << std::endl;
1193  if(FResMediosMotor.ParNeto)
1194  std::cout << "INFO: Net torque: " << FResMediosMotor.ParNetoMED << " (Nm)" << std::endl;
1195  if(FResMediosMotor.ParEfectivo)
1196  std::cout << "INFO: Effective torque: " << FResMediosMotor.ParEfectivoMED << " (Nm)" << std::endl;
1197  if(FResMediosMotor.ParEfectivoCiclo)
1198  std::cout << "INFO: Effective torque cycle: " << FResMediosMotor.ParEfectivoCicloMED << " (Nm)" <<
1199  std::endl;
1200  if(FResMediosMotor.ParPerdidasMecanicas)
1201  std::cout << "INFO: Torque of mechanical losses: " << FResMediosMotor.ParPerdidasMecanicasMED << " (Nm)" <<
1202  std::endl;
1203  if(FResMediosMotor.TrabajoNeto)
1204  std::cout << "INFO: Net work: " << FResMediosMotor.TrabajoNetoMED << " (J)" << std::endl;
1205  if(FResMediosMotor.TrabajoBombeo)
1206  std::cout << "INFO: Pumping work: " << FResMediosMotor.TrabajoBombeoMED << " (J)" <<
1207  std::endl;
1208  if(FResMediosMotor.PMN)
1209  std::cout << "INFO: NMEP (Mechanism): " << FResMediosMotor.PMNMED << " (bar)" << std::endl;
1210  if(FResMediosMotor.PME)
1211  std::cout << "INFO: BMEP (Mechanism): " << FResMediosMotor.PMEMED << " (bar)" << std::endl;
1212  if(FResMediosMotor.PMNCiclo)
1213  std::cout << "INFO: NMEP (Cycle): " << FResMediosMotor.PMNCicloMED << " (bar)" << std::endl;
1214  if(FResMediosMotor.PMECiclo)
1215  std::cout << "INFO: BMEP (Cycle): " << FResMediosMotor.PMECicloMED << " (bar)" << std::endl;
1216  if(FResMediosMotor.PMICiclo)
1217  std::cout << "INFO: IMEP (Cycle): " << FResMediosMotor.PMICicloMED << " (bar)" << std::endl;
1218  if(FResMediosMotor.PMBCiclo)
1219  std::cout << "INFO: PMEP (Cycle): " << FResMediosMotor.PMBCicloMED << " (bar)" << std::endl;
1220  if(FResMediosMotor.Potencia)
1221  std::cout << "INFO: Effective Power (Mechanism): " << FResMediosMotor.PotenciaMED << " (kW)" << std::endl;
1222  if(FResMediosMotor.PotenciaCiclo)
1223  std::cout << "INFO: Effective Power (Cycle): " << FResMediosMotor.PotenciaCicloMED << " (kW)" <<
1224  std::endl;
1225  if(FResMediosMotor.MasaAdmision)
1226  std::cout << "INFO: Intake Mass: " << FResMediosMotor.MasaAdmisionMED << " (kg/cc)" <<
1227  std::endl;
1228  if(FResMediosMotor.MasaFuel)
1229  std::cout << "INFO: Fuel Mass: " << FResMediosMotor.MasaFuelMED << " (kg/cc)" << std::endl;
1230  if(FResMediosMotor.MasaAtrapada)
1231  std::cout << "INFO: Trapped Mass: " << FResMediosMotor.MasaAtrapadaMED << " (kg/cc)" <<
1232  std::endl;
1233  if(FResMediosMotor.RegimenGiro)
1234  std::cout << "INFO: Engine Speed: " << FResMediosMotor.RegimenGiroMED << " (rpm)" <<
1235  std::endl;
1236  if(FResMediosMotor.RendimientoVolumetrico)
1237  std::cout << "INFO: Volumetric Efficiency (refered pipe n. " << FTuboRendVol->getNumeroTubo() << "): " <<
1238  FResMediosMotor.RendimientoVolumetricoMED << " (-)" << std::endl;
1239  if(FResMediosMotor.RendimientoVolumetricoAtm)
1240  std::cout << "INFO: Volumetric Efficiency (Ambient Condic): " << FResMediosMotor.RendimientoVolumetricoAtmMED << " (-)"
1241  << std::endl;
1242  if(FResMediosMotor.RendEfectivo)
1243  std::cout << "INFO: Effective Efficiency: " << FResMediosMotor.RendEfectivoMED << " (-)" << std::endl;
1244  if(FResMediosMotor.RendIndicado)
1245  std::cout << "INFO: Indicated Efficiency: " << FResMediosMotor.RendIndicadoMED << " (-)" << std::endl;
1246  if(FResMediosMotor.ConsumoEspecifico)
1247  std::cout << "INFO: BSFC: " << FResMediosMotor.ConsumoEspecificoMED << " (g/kWh)" <<
1248  std::endl;
1249  if(FResMediosMotor.ParResistente)
1250  std::cout << "INFO: Resistant Torque: " << FResMediosMotor.ParResistenteMED << " (Nm)" <<
1251  std::endl;
1252  if(FResMediosMotor.VelocidadVehiculo)
1253  std::cout << "INFO: Vehicle Speed: " << FResMediosMotor.VelocidadVehiculoMED << " (Nm)" <<
1254  std::endl;
1255  if(FResMediosMotor.Dosado)
1256  std::cout << "INFO: Fuel-to-air ratio:(refered pipe n. " << FTuboRendVol->getNumeroTubo() << "): " <<
1257  FResMediosMotor.DosadoMED << " (-)" << std::endl;
1258  if(FResMediosMotor.AFR)
1259  std::cout << "INFO: AFR: " << FResMediosMotor.AFRMED << " (-)" << std::endl;
1260  if(FResMediosMotor.Swirl)
1261  std::cout << "INFO: Swirl at T.D.C.: " << FResMediosMotor.SwirlMED << " (-)" << std::endl;
1262  std::cout << "INFO:----------------------------------------------" << std::endl;
1263 
1264  } catch(exception & N) {
1265  std::cout << "ERROR: TBloqueMotor::PrestacionesMotor en el Bloque Engine. " << std::endl;
1266  std::cout << "Tipo de error: " << N.what() << std::endl;
1267  throw Exception(N.what());
1268  }
1269 }
1270 
1271 // ---------------------------------------------------------------------------
1272 // ---------------------------------------------------------------------------
1273 
1274 void TBloqueMotor::ModeloDeVehiculo(double Time) {
1275  try {
1276 
1277  double DeltaT = Time - FTime;
1278  FTime = Time;
1279  // Calculo de par proporcionado por el motor
1280  double ParNeto = 0;
1281  double W = 0.;
1282  for(int i = 0; i < FGeom.NCilin; i++) {
1283  ParNeto += FCilindro[i]->getParInstantaneo();
1284  }
1285  FParPerdidasMecanicas = __units::BarToPa(FPMPMMotor) * FGeom.CilindradaTotal / (__units::DegToRad(FAngTotalCiclo));
1286  FParMotor = ParNeto - FParPerdidasMecanicas;
1287 
1288  if(FMfControlled) {
1289  FMasaFuel = FMfController->Output(FTime);
1290  }
1291 
1292  if(FRPMControlled) {
1293  FRegimen = FRPMController->Output(FTime);
1294  } else {
1295 
1296  if(FTipoModelado == nmTransitorioRegimen) {
1297  // Regimen de motor en rad/s
1298  W = __units::RPMToRad_s(FRegimen);
1299 
1300  // Resistencia de la carretera
1301  FRoadLoad = FCoefRoadLoad.A0 + (FCoefRoadLoad.B0 * W * FRadioRueda) / (FRelCajaCambios * FRelTrasmision) +
1302  FCoefRoadLoad.C0 * pow(W * FRadioRueda / (FRelCajaCambios * FRelTrasmision),
1303  FCoefRoadLoad.n) + (FCoefRoadLoad.cd * FCoefRoadLoad.rho * FCoefRoadLoad.A * pow2(W * FRadioRueda) / (2 * pow2(
1304  FRelCajaCambios * FRelTrasmision)));
1305 
1306  // Par resistente total
1307  FParResistente = FRadioRueda * (FRoadLoad + FPendiente) / (FRendCajaCambios * FRelCajaCambios * FRelTrasmision);
1308  if(FTheta < 7200) {
1309  FRegimen = __units::Rad_sToRPM(((FParMotor - FParResistente) * FCoeficienteInercias * DeltaT + W));
1310  }
1311  FVelocidadVehiculo = __units::m_sTokm_h((__units::RPMToRad_s(FRegimen) * FRadioRueda) /
1312  (FRelCajaCambios * FRelTrasmision));
1313  }
1314  }
1315 
1316  } catch(exception & N) {
1317  std::cout << "ERROR: TBloqueMotor::ModeloDeVehiculo en el Bloque Engine. " << std::endl;
1318  std::cout << "Tipo de error: " << N.what() << std::endl;
1319  throw Exception(N.what());
1320  }
1321 }
1322 
1323 // ---------------------------------------------------------------------------
1324 // ---------------------------------------------------------------------------
1325 
1326 TCilindro* TBloqueMotor::GetCilindro(int i) {
1327  try {
1328  return FCilindro[i];
1329  } catch(exception & N) {
1330  std::cout << "ERROR: TBloqueMotor::GetCilindro en el EngineBlock. " << std::endl;
1331  std::cout << "Tipo de error: " << N.what() << std::endl;
1332  throw Exception(N.what());
1333  }
1334 }
1335 
1336 // ---------------------------------------------------------------------------
1337 // ---------------------------------------------------------------------------
1338 
1339 double TBloqueMotor::GetDesfase(int i) {
1340  try {
1341  return FDesfase[i];
1342  } catch(exception & N) {
1343  std::cout << "ERROR: TBloqueMotor::GetCilindro en el EngineBlock. " << std::endl;
1344  std::cout << "Tipo de error: " << N.what() << std::endl;
1345  throw Exception(N.what());
1346  }
1347 }
1348 
1349 // ---------------------------------------------------------------------------
1350 // ---------------------------------------------------------------------------
1351 
1352 // void TBloqueMotor::PutTheta(double valor) {
1353 // try {
1354 // FTheta = valor;
1355 // }
1356 // catch(Exception & N) {
1357 // std::cout << "ERROR: TBloqueMotor::PutTheta en el EngineBlock. " << std::endl;
1358 // std::cout << "Tipo de error: " << N.what() << std::endl;
1359 // throw Exception(N.what());
1360 // }
1361 // }
1362 
1363 // ---------------------------------------------------------------------------
1364 // ---------------------------------------------------------------------------
1365 
1366 void TBloqueMotor::PutATCAdm(double valor) {
1367  try {
1368 
1369  FAjusteTranCalAdm = valor;
1370 
1371  } catch(exception & N) {
1372  std::cout << "ERROR: TBloqueMotor::PutATCAdm en el EngineBlock. " << std::endl;
1373  std::cout << "Tipo de error: " << N.what() << std::endl;
1374  throw Exception(N.what());
1375  }
1376 }
1377 
1378 // ---------------------------------------------------------------------------
1379 // ---------------------------------------------------------------------------
1380 
1381 void TBloqueMotor::PutATCEsc(double valor) {
1382  try {
1383 
1384  FAjusteTranCalEsc = valor;
1385 
1386  } catch(exception & N) {
1387  std::cout << "ERROR: TBloqueMotor::PutATCEsc en el EngineBlock. " << std::endl;
1388  std::cout << "Tipo de error: " << N.what() << std::endl;
1389  throw Exception(N.what());
1390  }
1391 }
1392 
1393 // ---------------------------------------------------------------------------
1394 // ---------------------------------------------------------------------------
1395 
1396 // void TBloqueMotor::PutRegimen(double valor) {
1397 // try {
1398 //
1399 // FRegimen = valor;
1400 //
1401 // }
1402 // catch(Exception & N) {
1403 // std::cout << "ERROR: TBloqueMotor::PutRegimen en el EngineBlock. " << std::endl;
1404 // std::cout << "Tipo de error: " << N.what() << std::endl;
1405 // throw Exception(N.what());
1406 // }
1407 // }
1408 
1409 // ---------------------------------------------------------------------------
1410 // ---------------------------------------------------------------------------
1411 
1412 // void TBloqueMotor::PutCiclo(int valor) {
1413 // try {
1414 //
1415 // FCiclo = valor;
1416 //
1417 // }
1418 // catch(Exception & N) {
1419 // std::cout << "ERROR: TBloqueMotor::PutCiclo en el EngineBlock. " << std::endl;
1420 // std::cout << "Tipo de error: " << N.what() << std::endl;
1421 // throw Exception(N.what());
1422 // }
1423 // }
1424 
1425 // ---------------------------------------------------------------------------
1426 // ---------------------------------------------------------------------------
1427 
1428 void TBloqueMotor::IniciaVarCilindro() {
1429  try {
1430 
1431  for(int i = 0; i < FGeom.NCilin; i++) {
1432  FCilindro[i]->IniciaVariables();
1433  }
1434 
1435  } catch(exception & N) {
1436  std::cout << "ERROR: TBloqueMotor::IniciaVarCilindro en el EngineBlock. " << std::endl;
1437  std::cout << "Tipo de error: " << N.what() << std::endl;
1438  throw Exception(N.what());
1439  }
1440 }
1441 
1442 // ---------------------------------------------------------------------------
1443 // ---------------------------------------------------------------------------
1444 
1445 double TBloqueMotor::GetComposicionInicial(int i) {
1446  try {
1447 
1448  return FComposicionInicial[i];
1449 
1450  } catch(exception & N) {
1451  std::cout << "ERROR: TBloqueMotor::GetComposicionInicial en el EngineBlock. " << std::endl;
1452  std::cout << "Tipo de error: " << N.what() << std::endl;
1453  throw Exception(N.what());
1454  }
1455 }
1456 
1457 // ---------------------------------------------------------------------------
1458 // ---------------------------------------------------------------------------
1459 
1460 double TBloqueMotor::GetComposicionAtmosfera(int i) {
1461  try {
1462 
1463  return FComposicionAtmosfera[i];
1464 
1465  } catch(exception & N) {
1466  std::cout << "ERROR: TBloqueMotor::GetComposicionAtmosfera en el EngineBlock. " << std::endl;
1467  std::cout << "Tipo de error: " << N.what() << std::endl;
1468  throw Exception(N.what());
1469  }
1470 }
1471 
1472 // ---------------------------------------------------------------------------
1473 // ---------------------------------------------------------------------------
1474 
1475 void TBloqueMotor::AsignRPMController(TController **Controller) {
1476  if(FRPMControlled)
1477  FRPMController = Controller[FRPMControllerID - 1];
1478 }
1479 
1480 void TBloqueMotor::AsignMfController(TController **Controller) {
1481  for(int i = 0; i < FGeom.NCilin; i++) {
1482  FCilindro[i]->AsignMfController(Controller);
1483  }
1484  // if (FMfControlled)
1485  // FMfController = Controller[FMfControllerID - 1];
1486  if(FACT) {
1487  for(int i = 0; i < FInjectionSys.NumPulsos; ++i) {
1488  if(FInjecPulse[i].CtrAngd)
1489  FInjecPulse[i].CtrAng = Controller[FInjecPulse[i].CtrAngID - 1];
1490  if(FInjecPulse[i].CtrMasd)
1491  FInjecPulse[i].CtrMas = Controller[FInjecPulse[i].CtrMasID - 1];
1492  }
1493  if(FInjectionSys.InjectPCtrd)
1494  FInjectionSys.InjectPCtr = Controller[FInjectionSys.InjectPCtrID - 1];
1495  }
1496 }
1497 
1498 // ---------------------------------------------------------------------------
1499 // ---------------------------------------------------------------------------
1500 
1501 void TBloqueMotor::NewInjectionData(double Time) {
1502  vector<stInjecPulse>::size_type i;
1503  for(i = 0; i < FInjecPulse.size(); i++) {
1504  if(FInjecPulse[i].CtrAngd)
1505  FInjecPulse[i].Angulo = FInjecPulse[i].CtrAng->Output(Time);
1506  if(FInjecPulse[i].CtrMasd)
1507  FInjecPulse[i].Masa = FInjecPulse[i].CtrMas->Output(Time);
1508  }
1509  if(FInjectionSys.InjectPCtrd)
1510  FInjectionSys.InjectPressure = FInjectionSys.InjectPCtr->Output(Time);
1511 }
1512 
1513 double TBloqueMotor::TasaInyInterp(double Angle) {
1514 
1515  fOutput = fDatosTasa->interp(Angle);
1516 
1517  return fOutput;
1518 }
1519 
1520 #pragma package(smart_init)
TTubo
a Finite differences pipe.
Definition: TTubo.h:116
stInjecPulse
Definition: Globales.h:1019
TCilindro4T
Definition: TCilindro4T.h:39
TController
Definition: TController.h:37
TCilindro
Definition: TCilindro.h:59
Step_interp
Definition: Math_wam.h:325
Hermite_interp
Definition: Math_wam.h:311
TTubo::GetVelocidad
double GetVelocidad(int i) const
Gets the fluid speed.
Definition: TTubo.cpp:5505
stWiebe
Definition: Globales.h:1043
Linear_interp
Definition: Math_wam.h:301
PutLabel
std::string PutLabel(int idx)
Returns an integer.
Definition: labels.cpp:475
Exception
Custom exception class.
Definition: Exception.hpp:39
TCilindro2T
Definition: TCilindro2T.h:39
stLeyQuemadoBD
Definition: Globales.h:1055
TTubo.h
pow2
T pow2(T x)
Returns x to the power of 2.
Definition: Math_wam.h:88
TTubo::GetDensidad
double GetDensidad(int i) const
Gets the density.
Definition: TTubo.cpp:5432
TController::Output
virtual double Output(double Time)=0
TTubo::getNumeroTubo
int getNumeroTubo() const
Gets the pipe id.
Definition: TTubo.cpp:5464
TTubo::GetArea
double GetArea(int i) const
Gets the cross section at a given cell.
Definition: TTubo.cpp:5408