OpenWAM
TEjeTurbogrupo.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 "TEjeTurbogrupo.h"
32 
33 //#include <cmath>
34 #ifdef __BORLANDC__
35 #include <vcl.h>
36 #endif
37 #include "TCompresor.h"
38 #include "TCompTubDep.h"
39 #include "TTurbina.h"
40 #include "fluids.h"
41 
42 // ---------------------------------------------------------------------------
43 // ---------------------------------------------------------------------------
44 
45 TEjeTurbogrupo::TEjeTurbogrupo(int i, int ncilin) {
46 
47  FNumeroEje = i + 1;
48  FNumeroCompresor = NULL;
49  FCompresor = NULL;
50  FNumeroTurbina = NULL;
51  FTurbina = NULL;
52  FNumCilindros = ncilin;
53 
54  FResMediosEje.Regimen = false;
55  FNumCiclo = 0;
56 
57  FRPMControlled = false;
58  FTime = 0;
59 
60  FThereIsHTM = false;
61 
62  FHTM = NULL;
63 
64  FMechLosses = NULL;
65  FMechPower = 0;
66 }
67 
68 // ---------------------------------------------------------------------------
69 // ---------------------------------------------------------------------------
70 
71 TEjeTurbogrupo::~TEjeTurbogrupo() {
72 
73  if(FNumeroCompresor != NULL)
74  delete[] FNumeroCompresor;
75  if(FCompresor != NULL)
76  delete[] FCompresor;
77 
78  if(FNumeroTurbina != NULL)
79  delete[] FNumeroTurbina;
80  if(FTurbina != NULL)
81  delete[] FTurbina;
82 
83 #ifdef tchtm
84  if(FHTM != NULL)
85  delete FHTM;
86 
87  if(FMechLosses != NULL)
88  delete FMechLosses;
89 #endif
90 
91 }
92 
93 // ---------------------------------------------------------------------------
94 // ---------------------------------------------------------------------------
95 
96 void TEjeTurbogrupo::ReadTurbochargerAxis(const char *FileWAM, fpos_t &filepos, TCompresor **Compressor,
97  TTurbina **Turbine) {
98  try {
99  int variacion = 0, htm = 0;
100 
101  FILE *fich = fopen(FileWAM, "r");
102  fsetpos(fich, &filepos);
103 
104  // Lectura del regimen inicial y si se mantiene constante durante el calculo.
105  fscanf(fich, "%lf %d", &FRegimenEje, &variacion);
106  switch(variacion) {
107  case 0:
108  FVariacionRegimen = nmVariable;
109  break;
110  case 1:
111  FVariacionRegimen = nmFixed;
112  break;
113  default:
114  std::cout << "ERROR: Reading turbocharger speed variation in axis: " << FNumeroEje << std::endl;
115  throw Exception("");
116  }
117  if(FVariacionRegimen == nmVariable) {
118  fscanf(fich, "%lf ", &FMomentoInercia);
119  }
120 
121  fscanf(fich, "%d ", &FNumCompresoresAcoplados);
122  FCompresor = new TCompresor*[FNumCompresoresAcoplados];
123  FNumeroCompresor = new int[FNumCompresoresAcoplados];
124  for(int i = 0; i < FNumCompresoresAcoplados; ++i) {
125  // Identifica que compresores estan acoplados a este eje.
126  fscanf(fich, "%d ", &FNumeroCompresor[i]);
127  FCompresor[i] = Compressor[FNumeroCompresor[i] - 1];
128  FCompresor[i]->IniciaMedias();
129  }
130 
131  fscanf(fich, "%d ", &FNumTurbinasAcopladas);
132  FTurbina = new TTurbina*[FNumTurbinasAcopladas];
133  FNumeroTurbina = new int[FNumTurbinasAcopladas];
134  for(int i = 0; i < FNumTurbinasAcopladas; ++i) {
135  // Identifica que turbinas estan acopladas a este eje.
136  fscanf(fich, "%d ", &FNumeroTurbina[i]);
137  // numidturbina es un numero que necesita WAMer y que a nosotros no nos interesa.
138  FTurbina[i] = Turbine[FNumeroTurbina[i] - 1];
139  FTurbina[i]->PutRegimen(FRegimenEje);
140  }
141 
142  fscanf(fich, "%d ", &FControllerID);
143  if(FControllerID > 0)
144  FRPMControlled = true;
145 
146  // basura para wamer
147  int numide = 0;
148  fscanf(fich, "%d ", &numide);
149 
150 #ifdef tchtm
151  fscanf(fich, "%d ", &htm);
152  if(htm == 1) {
153 
154  if(FNumTurbinasAcopladas != 1 || FNumCompresoresAcoplados != 1) {
155  std::cout <<
156  "ERROR: Turbocharger heat trasfer model is not adapted for more than one turbine" << std::endl;
157  std::cout <<
158  " or more than one compressor in the same turbocharger"
159  << std::endl;
160  }
161  FThereIsHTM = true;
162  // Geometrical parameters journal bearing
163  fscanf(fich, "%lf %lf %lf ", &FDShaft, &FJournalBLengh, &FHD);
164  // Geometrical parameters thrust bearing
165  fscanf(fich, "%lf %lf", &FTthrustBRmin, &FTthrustBRmax);
166  // Geometrical parameters inlet ports
167  fscanf(fich, "%lf %lf", &FDoil, &FDwater);
168  // Fitting coefficients
169  fscanf(fich, "%lf %lf %lf %lf %lf", &FJournalB_K, &Fk_m, &Fk_tb,
170  &FCAC, &FCAT);
171  // Wheel areas
172  fscanf(fich, "%lf %lf", &FCWArea, &FTWArea);
173  double DT = 0., LT = 0.;
174  fscanf(fich, "%lf %lf", &DT, &LT);
175  double DC = 0., LC = 0.;
176  fscanf(fich, "%lf %lf", &DC, &LC);
177  double DH = 0., LH = 0.;
178  fscanf(fich, "%lf %lf", &DH, &LH);
179 
180  // Oil properties.
181  fscanf(fich, "%lf %lf %lf ", &FMoil, &FToil, &FPoil);
182  double K1 = 0., K2 = 0., K3 = 0.;
183  // Oil Voeguel parameters.
184  fscanf(fich, "%lf %lf %lf ", &K1, &K2, &K3);
185  FOil = new stHTMoil();
186  FOil->mu_c1 = K1;
187  FOil->mu_c2 = K2;
188  FOil->mu_c3 = K3;
189 
190  // Water properties in turbocharger.
191  fscanf(fich, "%lf %lf ", &FTwater, &FMwater);
192  FWater = new stHTMwater();
193 
194  FHTM = new TTC_HTM(FOil);
195 
196  FMechLosses = new TurboBearings(FOil, FJournalBLengh, FDShaft / 2,
197  FHD, FJournalB_K, FCAC, FCAT, FCWArea, FTWArea, Fk_m,
198  FTthrustBRmin, FTthrustBRmax, Fk_tb);
199 
200  FHTM->Read_HTM(fich);
201 
202  FHTM->TurbochargerData(FDShaft, FHD, FDoil, FDwater, DT, LT, DC,
203  LC, DH, LH);
204 
205  }
206 #endif
207  fgetpos(fich, &filepos);
208  fclose(fich);
209 
210  } catch(exception & N) {
211  std::cout << "ERROR: TEjeTurbogrupo::ReadTurbochargerAxis in the boundary condition: " << FNumeroEje << std::endl;
212  std::cout << "Tipo de error: " << N.what() << std::endl;
213  throw Exception(N.what());
214  }
215 }
216 
217 // ---------------------------------------------------------------------------
218 // ---------------------------------------------------------------------------
219 
220 void TEjeTurbogrupo::InterpolaValoresMapa() {
221  try {
222 
223  for(int i = 0; i < FNumCompresoresAcoplados; ++i) {
224 
225  FCompresor[i]->InterpolaValoresMapa(FRegimenEje);
226 
227  }
228 
229  } catch(exception & N) {
230  std::cout << "ERROR: TEjeTurbogrupo::InterpolaValoresMapa in the boundary condition: " << FNumeroEje << std::endl;
231  std::cout << "Tipo de error: " << N.what() << std::endl;
232  throw Exception(N.what());
233  }
234 }
235 
236 // ---------------------------------------------------------------------------
237 // ---------------------------------------------------------------------------
238 
239 void TEjeTurbogrupo::CalculaEjesTurbogrupo(double Theta, nmTipoModelado SimulationType, double Time,
240  double CrankAngle) {
241  try {
242 
243  // Calculo del nuevo regimen del turbogrupo.
244 
245  double MechWork = 0;
246  // HAY QUE PASAR EL VALOR DE TAMB
247  double DeltaTime = Time - FTime;
248  FTime = Time;
249 
250  if(FRPMControlled) {
251  FRegimenEje = FController->Output(FTime);
252  } else {
253 #ifdef tchtm
254 
255  double p1 = FCompresor[0]->AcousticC()->P1() * 1e5;
256  double p2 = FCompresor[0]->AcousticC()->P2() * 1e5;
257  double p3 = FTurbina[0]->AcousticT()->P3() * 1e5;
258  double p4 = FTurbina[0]->AcousticT()->P4() * 1e5;
259  FMechPower = FMechLosses->P_oil(__units::degCToK(FToil),
260  Pi * FRegimenEje / 30, p1, p2, p3, p4, FMoil);
261  MechWork = FMechPower * DeltaTime;
262  if(FSumTrabajoTurbinas > MechWork) {
263  FMechEff = 1 - MechWork / FSumTrabajoTurbinas;
264  } else {
265  FMechEff = 0;
266  }
267  double T1 = FCompresor[0]->AcousticC()->T1();
268  double T2 = FCompresor[0]->AcousticC()->T2();
269  double cr = FCompresor[0]->AcousticC()->CompRatio();
270  double efc = FCompresor[0]->getEfficiency();
271 
272  FHTM->CompressorWorkingPoint(0, FCompresor[0]->getMassflow(),
273  __units::KTodegC(T1), p1, cr, efc);
274 
275  double T3 = FTurbina[0]->AcousticT()->T3();
276  double er = FTurbina[0]->AcousticT()->ExpRatio();
277  double eft = FTurbina[0]->GetEfficiency();
278 
279  FHTM->TurbineWorkingPoint(0, 0, FTurbina[0]->AcousticT()->MassIn(),
280  __units::KTodegC(T3), p3 / 1e5, er, eft);
281 
282  FHTM->TurbochargerWorkingPoint(FRegimenEje, FMechEff, FMoil, FToil,
283  FPoil, FTwater, FMwater);
284 
285  FHTM->SolveNodeTemperaturesTransient(T3, T2, T1, __units::degCToK(FToil),
286  FMoil, FMechPower, __units::degCToK(FTwater), __units::degCToK(FTamb), Time);
287  FHTM->SolveDeltaTempTr();
288  FHTM->SolveHeatFlowMatix();
289 
290  FCompresor[0]->AcousticC()->PutHeatPower(FHTM->Comp_Heat_Flow());
291  FCompresor[0]->AcousticC()->PutHeatPowerIn
292  (FHTM->Comp_Heat_Flow_In());
293 
294 #endif
295  if(FVariacionRegimen == nmVariable) {
296  if((Theta > 2880. && SimulationType != nmEstacionario) || (SimulationType == nmEstacionario && Theta > 50.
297  && FNumCilindros == 0) || (SimulationType == nmEstacionario && Theta > 2880 && FNumCilindros != 0)) {
298 
299  FSumTrabajoCompresores = 0.;
300  FSumTrabajoTurbinas = 0.;
301 
302  for(int i = 0; i < FNumCompresoresAcoplados; i++) {
303  FCompresor[i]->CalculoPotenciaPaso();
304  FSumTrabajoCompresores += (FCompresor[i]->getPotenciaPaso() * DeltaTime);
305  }
306 
307  for(int i = 0; i < FNumTurbinasAcopladas; i++) {
308  FTurbina[i]->CalculoPotenciaPaso();
309  FSumTrabajoTurbinas += (FTurbina[i]->getPotenciaPaso() * DeltaTime);
310  }
311 
312  FDeltaReg = __units::Rad_sToRPM(FSumTrabajoTurbinas - FSumTrabajoCompresores - MechWork) /
313  (FMomentoInercia * FRegimenEje);
314  FRegimenEje += FDeltaReg;
315 
316  if(FRegimenEje < 10000)
317  FRegimenEje = 10000;
318  }
319  }
320  }
321 
322  // Actualizacion del regimen de los compresores acoplados al eje y su interpolacion.
323  for(int i = 0; i < FNumCompresoresAcoplados; ++i) {
324  if(FCompresor[i]->getModeloCompresor() == nmCompPlenums || FCompresor[i]->getModeloCompresor() == nmCompPipes) {
325  FCompresor[i]->InterpolaValoresMapa(FRegimenEje);
326  } else if(FCompresor[i]->getModeloCompresor() == nmCompOriginal) {
327  if(FVariacionRegimen == nmVariable
328  || (dynamic_cast<TCompTubDep*>(FCompresor[i]))->getEntradaCompresor() != nmAtmosphere) {
329  FCompresor[i]->InterpolaValoresMapa(FRegimenEje);
330  }
331  }
332  }
333  // Actualizacion del regimen de las turbinas acopladas al eje.
334  for(int j = 0; j < FNumTurbinasAcopladas; ++j) {
335  FTurbina[j]->PutRegimen(FRegimenEje);
336  }
337 
338  // Acumulacion de valores medios.
339 
340  if(FResMediosEje.Regimen) {
341  FResMediosEje.RegimenSUM += FRegimenEje * DeltaTime;
342  }
343  FResMediosEje.TiempoSUM += DeltaTime;
344 
345  // printf("%lf \n",FRegimenEje);
346 
347  // Salida de resultados por pantalla.
348  // printf("%lf %lf\n",CrankAngle,Theta);
349 
350  if(CrankAngle - FAngle0 <= 0. && Theta >= 750.) {
351  FNumCiclo++;
352  printf("\n");
353  printf("*****************************************************\n");
354  printf("***TURBOCHARGER AVERAGE VALUES %3d **CYCLE N. %3d ***\n", FNumeroEje, FNumCiclo);
355  printf("*****************************************************\n");
356  printf("\n");
357  for(int j = 0; j < FNumTurbinasAcopladas; ++j) {
358  FTurbina[j]->ImprimeResultadosMediosPantalla();
359  }
360  for(int j = 0; j < FNumCompresoresAcoplados; ++j) {
361  FCompresor[j]->CalculaMedias();
362  printf("COMPRESSOR WORK %d = %6.3lf Julios \n", FNumeroCompresor[j], FCompresor[j]->getTrabCiclo());
363  printf("COMPRESSOR EFFICIENCY %d = %6.3lf \n", FNumeroCompresor[j], FCompresor[j]->getRendMed());
364  printf("COMPRESSOR MASS FLOW %d = %6.3lf g/s\n", FNumeroCompresor[j], FCompresor[j]->getGastoMed() * 1000);
365  printf("COMPRESSOR RATIO %d = %6.3lf \n", FNumeroCompresor[j], FCompresor[j]->getRCMed());
366  }
367  printf("TURBOCHARGER SPEED = %6.3lf r.p.m.\n", FResMediosEje.RegimenSUM / FResMediosEje.TiempoSUM);
368  printf("*****************************************************\n\n");
369  }
370  FAngle0 = CrankAngle;
371 
372  } catch(exception & N) {
373  std::cout << "ERROR: TEjeTurbogrupo::CalculaEjesTurbogrupo in the boundary condition: " << FNumeroEje << std::endl;
374  std::cout << "Tipo de error: " << N.what() << std::endl;
375  throw Exception(N.what());
376  }
377 }
378 
379 // ---------------------------------------------------------------------------
380 // ---------------------------------------------------------------------------
381 
382 void TEjeTurbogrupo::ReadAverageResultsEje(const char* FileWAM, fpos_t & filepos) {
383  try {
384  int nvars = 0, var = 0;
385 
386  FILE *fich = fopen(FileWAM, "r");
387  fsetpos(fich, &filepos);
388 
389  fscanf(fich, "%d ", &nvars);
390  for(int i = 0; i < nvars; i++) {
391  fscanf(fich, "%d ", &var);
392  switch(var) {
393  case 0:
394  FResMediosEje.Regimen = true;
395  break;
396  default:
397  std::cout << "Resultados medios en Axis " << FNumeroEje << " no implementados " << std::endl;
398  }
399  }
400 
401  fgetpos(fich, &filepos);
402  fclose(fich);
403  } catch(exception & N) {
404  std::cout << "ERROR: TEjeTurbogrupo::ReadAverageResultsEje en el eje " << FNumeroEje << std::endl;
405  std::cout << "Tipo de error: " << N.what() << std::endl;
406  throw Exception(N.what());
407  }
408 }
409 
410 // ---------------------------------------------------------------------------
411 // ---------------------------------------------------------------------------
412 
413 void TEjeTurbogrupo::CabeceraResultadosMedEje(stringstream & medoutput) {
414  try {
415  // FILE *fich=fopen(FileSALIDA,"a");
416  std::string Label;
417 
418  if(FResMediosEje.Regimen) {
419  Label = "\t" + PutLabel(703) + std::to_string(FNumeroEje) + PutLabel(918);
420  medoutput << Label.c_str();
421  }
422 
423  // fclose(fich);
424  } catch(exception & N) {
425  std::cout << "ERROR: TEjeTurbogrupo::CabeceraResultadosMedEje en el eje " << FNumeroEje << std::endl;
426  std::cout << "Tipo de error: " << N.what() << std::endl;
427  throw Exception(N.what());
428  }
429 }
430 
431 // ---------------------------------------------------------------------------
432 // ---------------------------------------------------------------------------
433 
434 void TEjeTurbogrupo::ImprimeResultadosMedEje(stringstream & medoutput) {
435  try {
436  // FILE *fich=fopen(FileSALIDA,"a");
437 
438  if(FResMediosEje.Regimen)
439  medoutput << "\t" << FResMediosEje.RegimenMED;
440 
441  // fclose(fich);
442  } catch(exception & N) {
443  std::cout << "ERROR: TEjeTurbogrupo::ImprimeResultadosMedEje en el eje " << FNumeroEje << std::endl;
444  std::cout << "Tipo de error: " << N.what() << std::endl;
445  throw Exception(N.what());
446  }
447 }
448 
449 // ---------------------------------------------------------------------------
450 // ---------------------------------------------------------------------------
451 
452 void TEjeTurbogrupo::IniciaMedias() {
453  try {
454 
455  FResMediosEje.RegimenSUM = 0.;
456  FResMediosEje.TiempoSUM = 0.;
457  FResMediosEje.Tiempo0 = 0.;
458 
459  } catch(exception & N) {
460  std::cout << "ERROR: TEjeTurbogrupo::IniciaMedias en el eje: " << FNumeroEje << std::endl;
461  // std::cout << "Tipo de error: " << N.what() << std::endl;
462  throw Exception(N.what());
463  }
464 }
465 
466 // ---------------------------------------------------------------------------
467 // ---------------------------------------------------------------------------
468 
469 void TEjeTurbogrupo::ResultadosMediosEje() {
470  try {
471 
472  if(FResMediosEje.Regimen) {
473  FResMediosEje.RegimenMED = FResMediosEje.RegimenSUM / FResMediosEje.TiempoSUM;
474  FResMediosEje.RegimenSUM = 0.;
475  }
476  FResMediosEje.TiempoSUM = 0;
477 
478  } catch(exception & N) {
479  std::cout << "ERROR: TEjeTurbogrupo::ResultadosMediosEje en el eje: " << FNumeroEje << std::endl;
480  // std::cout << "Tipo de error: " << N.what() << std::endl;
481  throw Exception(N.what());
482  }
483 }
484 
485 // ---------------------------------------------------------------------------
486 // ---------------------------------------------------------------------------
487 
488 void TEjeTurbogrupo::AcumulaResultadosMediosEje(double Actual) {
489  try {
490  /* Lo que se hace en esta funcion se realiza dentro del calculo del eje, para asi poder
491  llevar a cabo la salida de resultados medios por pantalla. */
492  double Delta = Actual - FResMediosEje.Tiempo0;
493 
494  if(FResMediosEje.Regimen) {
495  FResMediosEje.RegimenSUM += FRegimenEje * Delta;
496  }
497  FResMediosEje.TiempoSUM += Delta;
498  FResMediosEje.Tiempo0 = Delta;
499 
500  } catch(exception & N) {
501  std::cout << "ERROR: TEjeTurbogrupo::AcumulaResultadosMediosEje en el eje: " << FNumeroEje << std::endl;
502  // std::cout << "Tipo de error: " << N.what() << std::endl;
503  throw Exception(N.what());
504  }
505 }
506 
507 // ---------------------------------------------------------------------------
508 // ---------------------------------------------------------------------------
509 
510 void TEjeTurbogrupo::ReadInstantaneousResultsEje(const char* FileWAM, fpos_t & filepos) {
511  try {
512  int nvars = 0, var = 0;
513 
514  FILE *fich = fopen(FileWAM, "r");
515  fsetpos(fich, &filepos);
516 
517  FResInstantEje.Regimen = false;
518  FResInstantEje.MechPower = false;
519  FResInstantEje.MechEff = false;
520  FResInstantEje.NodeTemp = false;
521  FResInstantEje.HeatFlow = false;
522 
523  fscanf(fich, "%d ", &nvars);
524  for(int i = 0; i < nvars; i++) {
525  fscanf(fich, "%d ", &var);
526  switch(var) {
527  case 0:
528  FResInstantEje.Regimen = true;
529  break;
530  case 1:
531  FResInstantEje.MechPower = true;
532  break;
533  case 2:
534  FResInstantEje.MechEff = true;
535  break;
536  case 3:
537  FResInstantEje.NodeTemp = true;
538  break;
539  case 4:
540  FResInstantEje.HeatFlow = true;
541  break;
542  default:
543  std::cout << "Instantaneous results in axis " << FNumeroEje << " are not implemented " << std::endl;
544  }
545  }
546 
547  fgetpos(fich, &filepos);
548  fclose(fich);
549  } catch(exception & N) {
550  std::cout << "ERROR: TEjeTurbogrupo::ReadInstantaneousResultsEje en el eje " << FNumeroEje << std::endl;
551  std::cout << "Tipo de error: " << N.what() << std::endl;
552  throw Exception(N.what());
553  }
554 }
555 
556 // ---------------------------------------------------------------------------
557 // ---------------------------------------------------------------------------
558 
559 void TEjeTurbogrupo::HeaderInstantaneousResultsEje(stringstream & insoutput) {
560  try {
561  // FILE *fich=fopen(FileSALIDA,"a");
562 
563  std::string Label;
564 
565  if(FResInstantEje.Regimen) {
566  Label = "\t" + PutLabel(703) + std::to_string(FNumeroEje) + PutLabel(918);
567  insoutput << Label.c_str();
568  }
569  if(FResInstantEje.MechPower) {
570  Label = "\t" + PutLabel(713) + std::to_string(FNumeroEje) + PutLabel(903);
571  insoutput << Label.c_str();
572  }
573  if(FResInstantEje.MechEff) {
574  Label = "\t" + PutLabel(714) + std::to_string(FNumeroEje) + PutLabel(901);
575  insoutput << Label.c_str();
576  }
577 #ifdef tchtm
578  if(FResInstantEje.NodeTemp) {
579  FHTM->HeaderInsTemperatures(insoutput);
580  }
581  if(FResInstantEje.HeatFlow) {
582  FHTM->HeaderInsHeatFlow(insoutput);
583  }
584 #endif
585 
586  // fclose(fich);
587  } catch(exception & N) {
588  std::cout << "ERROR: TEjeTurbogrupo::HeaderInstantaneousResultsEje en el eje " << FNumeroEje << std::endl;
589  std::cout << "Tipo de error: " << N.what() << std::endl;
590  throw Exception(N.what());
591  }
592 }
593 
594 // ---------------------------------------------------------------------------
595 // ---------------------------------------------------------------------------
596 
597 void TEjeTurbogrupo::ImprimeResultadosInstantaneosEje(stringstream & insoutput) {
598  try {
599  // FILE *fich=fopen(FileSALIDA,"a");
600 
601  if(FResInstantEje.Regimen)
602  insoutput << "\t" << FResInstantEje.RegimenINS;
603  if(FResInstantEje.MechPower)
604  insoutput << "\t" << FResInstantEje.MechPowerINS;
605  if(FResInstantEje.MechEff)
606  insoutput << "\t" << FResInstantEje.MechEffINS;
607 #ifdef tchtm
608  if(FResInstantEje.NodeTemp) {
609  FHTM->PrintInsTemperatures(insoutput);
610  }
611  if(FResInstantEje.HeatFlow) {
612  FHTM->PrintInsHeatFlow(insoutput);
613  }
614 #endif
615 
616  // fclose(fich);
617  } catch(exception & N) {
618  std::cout << "ERROR: TEjeTurbogrupo::ImprimeResultadosInstantaneosEje en el eje " << FNumeroEje << std::endl;
619  std::cout << "Tipo de error: " << N.what() << std::endl;
620  throw Exception(N.what());
621  }
622 }
623 
624 // ---------------------------------------------------------------------------
625 // ---------------------------------------------------------------------------
626 
627 void TEjeTurbogrupo::ResultadosInstantEje() {
628  try {
629  if(FResInstantEje.Regimen)
630  FResInstantEje.RegimenINS = FRegimenEje;
631  if(FResInstantEje.MechPower)
632  FResInstantEje.MechPowerINS = FMechPower;
633  if(FResInstantEje.MechEff)
634  FResInstantEje.MechEffINS = FMechEff;
635 
636  } catch(exception & N) {
637  std::cout << "ERROR: TEjeTurbogrupo::ResultadosInstantEje en el eje " << FNumeroEje << std::endl;
638  std::cout << "Tipo de error: " << N.what() << std::endl;
639  throw Exception(N.what());
640  }
641 }
642 
643 // ---------------------------------------------------------------------------
644 // ---------------------------------------------------------------------------
645 
646 int TEjeTurbogrupo::GetNumeroCompresor(int i) {
647 
648  return FNumeroCompresor[i];
649 
650 }
651 
652 // ---------------------------------------------------------------------------
653 // ---------------------------------------------------------------------------
654 
655 void TEjeTurbogrupo::AsignaRPMController(TController * *Controller) {
656  if(FRPMControlled)
657  FController = Controller[FControllerID - 1];
658 }
659 
660 void TEjeTurbogrupo::InitizlizeHTM(double Tamb) {
661 #ifdef tchtm
662 
663  FTamb = Tamb;
664 
665  double T1 = FCompresor[0]->AcousticC()->T1();
666  double T2 = FCompresor[0]->AcousticC()->T2();
667  double T3 = FTurbina[0]->AcousticT()->T3();
668 
669  FHTM->AsignTCMechLosses(FMechLosses);
670 
671  FHTM->TurbochargerWorkingPoint(FRegimenEje, 0.9, FMoil, FToil, FPoil,
672  FTwater, FMwater);
673  FHTM->CompressorData(FCompresor[0]->GetMap()->getPresionRef(),
674  FCompresor[0]->GetMap()->getTempRef(),
675  FCompresor[0]->GetMap()->getTempMeasure(),
676  FCompresor[0]->AcousticC()->Din());
677  FHTM->TurbineData(1, 300, FTurbina[0]->getMap()->getTempMeasure(),
678  FTurbina[0]->AcousticT()->DIn());
679 
680  FTurbina[0]->AsignTCHTM(FHTM);
681  FTurbina[0]->CalculateAdiabaticMap(FCompresor[0]->GetMap()->getTempMeasure()
682  );
683 
684  FCompresor[0]->AsignTCHTM(FHTM);
685  FCompresor[0]->GetMap()->CalculateAdiabaticEfficiency(FHTM,
686  FTurbina[0]->getMap()->getTempMeasure());
687 
688  // TEMPERATURA AMBIENTE
689  FHTM->InitializeTemp(T3, T2, T1, FToil, FTwater, Tamb);
690 
691 #endif
692 }
693 
694 // ---------------------------------------------------------------------------
695 // ---------------------------------------------------------------------------
696 
697 #pragma package(smart_init)
TController
Definition: TController.h:37
stHTMwater
Definition: THTM_Fluids.h:249
TTurbina
Definition: TTurbina.h:41
TTC_HTM
Definition: TTC_HTM.h:307
stHTMoil
Definition: THTM_Fluids.h:176
TCompTubDep
Definition: TCompTubDep.h:40
TCompresor
Definition: TCompresor.h:47
TurboBearings
The TurboBearings class represent the bearing system in a turbocharger.
Definition: turbo_bearings.hpp:44
PutLabel
std::string PutLabel(int idx)
Returns an integer.
Definition: labels.cpp:475
Exception
Custom exception class.
Definition: Exception.hpp:39
TAcousticCompressor::T2
double T2()
Compute the temperature at compressor outlet.
Definition: TAcousticCompressor.cpp:106
TController::Output
virtual double Output(double Time)=0
TurboBearings::P_oil
double P_oil(double T1, double n, double p1, double p2, double p3, double p4, double m)
Compute the power losses in the bearings.
TAcousticCompressor::P2
double P2()
Compute the pressure at compressor outlet.
Definition: TAcousticCompressor.cpp:84