OpenWAM
TOutputResults.cpp
1 // ---------------------------------------------------------------------------
2 
3 #pragma hdrstop
4 
5 #include "TOutputResults.h"
6 
7 TOutputResults::TOutputResults() {
8 
9  FAvgOutput.str("");
10  AvgEngine = NULL;
11  FInsOutput.str("");
12  FPlotThisCycle = true;
13  FFirstTime = true;
14  InsHeaderCreated = false;
15  FWriteSpaceTime = false;
16  FFileCountI = 1;
17  WriteInsHeader = false;
18 }
19 
20 TOutputResults::~TOutputResults() {
21 
22 }
23 
24 void TOutputResults::ReadAverageResults(const char* FileWAM, fpos_t& filepos, TTubo** Pipe, bool EngineBlock,
25  TBloqueMotor** Engine, TDeposito **Plenum, TEjeTurbogrupo** Axis, TCompresor** Compressor, TTurbina** Turbine,
26  TCondicionContorno** BC, TDPF** DPF, TCCCompresorVolumetrico** Root, TVenturi** Venturi, TSensor** Sensor,
27  TController** Controller, int TotalCycles, char* ModelName) {
28 
29  GetName(ModelName, FAvgFilename, "AVG.DAT");
30 
31  FILE *FileInput = fopen(FileWAM, "r");
32  fsetpos(FileInput, &filepos);
33 
34  // fpos_t filepos;
35 
36  int intAuxiliar = 0;
37  fscanf(FileInput, "%d ", &intAuxiliar);
38  switch(intAuxiliar) {
39  case 0:
40  FTypeOfInsResults = nmLastCyle;
41  FMultipleFiles = false;
42  break;
43  case 1:
44  FTypeOfInsResults = nmAllCyclesIndependent;
45  FMultipleFiles = true;
46  FCharacters = int(log10((float) TotalCycles));
47  break;
48  case 2:
49  FTypeOfInsResults = nmAllCyclesConcatenated;
50  FMultipleFiles = false;
51  break;
52  case 3:
53  FTypeOfInsResults = nmEveryNCycles;
54  FMultipleFiles = true;
55  fscanf(FileInput, "%d ", &FCyclePeriod);
56  FCharacters = int(log10(float(TotalCycles) / FCyclePeriod));
57  break;
58  }
59 
60  // ! Read average results in pipes
61  int NumPipesAvg = 0;
62  int PipeID = 0;
63  fscanf(FileInput, "%d ", &NumPipesAvg);
64  fscanf(FileInput, "%d ", &intAuxiliar);
65  for(int i = 0; i < NumPipesAvg; i++) {
66  fscanf(FileInput, "%d ", &PipeID);
67  AvgPipe.push_back(Pipe[PipeID - 1]);
68  fgetpos(FileInput, &filepos);
69  fclose(FileInput);
70  AvgPipe[i]->ReadAverageResultsTubo(FileWAM, filepos, EngineBlock);
71  FileInput = fopen(FileWAM, "r");
72  fsetpos(FileInput, &filepos);
73  }
74 
75  // ! Read average results in cylinders
76  int NumCylindersAvg = 0;
77  int CylinderID = 0;
78  fscanf(FileInput, "%d ", &NumCylindersAvg);
79  for(int i = 0; i < NumCylindersAvg; i++) {
80  fscanf(FileInput, "%d ", &CylinderID);
81  AvgCylinder.push_back(Engine[0]->GetCilindro(CylinderID - 1));
82  fgetpos(FileInput, &filepos);
83  fclose(FileInput);
84  AvgCylinder[i]->ReadAverageResultsCilindro(FileWAM, filepos);
85  FileInput = fopen(FileWAM, "r");
86  fsetpos(FileInput, &filepos);
87  }
88 
89  // ! Read average results in the engine
90  int NumEnginesAvg = 0;
91  int EngineID = 0;
92  fscanf(FileInput, "%d ", &NumEnginesAvg);
93  if(NumEnginesAvg > 0) {
94  AvgEngine = Engine[0];
95  fgetpos(FileInput, &filepos);
96  fclose(FileInput);
97  AvgEngine->ReadAverageResultsBloqueMotor(FileWAM, filepos);
98  FileInput = fopen(FileWAM, "r");
99  fsetpos(FileInput, &filepos);
100  }
101 
102  // !Read average results in plenums
103  int NumPlenumsAvg = 0;
104  int PlenumID = 0;
105  fscanf(FileInput, "%d ", &NumPlenumsAvg);
106  for(int i = 0; i < NumPlenumsAvg; i++) {
107  fscanf(FileInput, "%d ", &PlenumID);
108  AvgPlenum.push_back(Plenum[PlenumID - 1]);
109  fgetpos(FileInput, &filepos);
110  fclose(FileInput);
111  AvgPlenum[i]->ReadAverageResultsDep(FileWAM, filepos);
112  FileInput = fopen(FileWAM, "r");
113  fsetpos(FileInput, &filepos);
114  }
115 
116  // !Read average results in turbocharger axis
117  int NumAxisAvg = 0;
118  int AxisID = 0;
119  fscanf(FileInput, "%d ", &NumAxisAvg);
120  for(int i = 0; i < NumAxisAvg; i++) {
121  fscanf(FileInput, "%d ", &AxisID);
122  AvgAxis.push_back(Axis[AxisID - 1]);
123  fgetpos(FileInput, &filepos);
124  fclose(FileInput);
125  AvgAxis[i]->ReadAverageResultsEje(FileWAM, filepos);
126  FileInput = fopen(FileWAM, "r");
127  fsetpos(FileInput, &filepos);
128  }
129 
130  // !Read average results in compressors
131  int NumCompressorAvg = 0;
132  int CompressorID = 0;
133  fscanf(FileInput, "%d ", &NumCompressorAvg);
134  for(int i = 0; i < NumCompressorAvg; i++) {
135  fscanf(FileInput, "%d ", &CompressorID);
136  AvgCompressor.push_back(Compressor[CompressorID - 1]);
137  fgetpos(FileInput, &filepos);
138  fclose(FileInput);
139  AvgCompressor[i]->LeeDatosGraficasMedias(FileWAM, filepos);
140  FileInput = fopen(FileWAM, "r");
141  fsetpos(FileInput, &filepos);
142  }
143 
144  // !Read average results in turbines
145  int NumTurbineAvg = 0;
146  int TurbineID = 0;
147  fscanf(FileInput, "%d ", &NumTurbineAvg);
148  for(int i = 0; i < NumTurbineAvg; i++) {
149  fscanf(FileInput, "%d ", &TurbineID);
150  AvgTurbine.push_back(Turbine[TurbineID - 1]);
151  fgetpos(FileInput, &filepos);
152  fclose(FileInput);
153  AvgTurbine[i]->ReadAverageResultsTurb(FileWAM, filepos);
154  FileInput = fopen(FileWAM, "r");
155  fsetpos(FileInput, &filepos);
156  }
157 
158  // !Read average results in valves
159  int NumValvesAvg = 0;
160  int ValveID = 0;
161  fscanf(FileInput, "%d ", &NumValvesAvg);
162  for(int i = 0; i < NumValvesAvg; i++) {
163  fscanf(FileInput, "%d ", &ValveID);
164  if(BC[ValveID - 1]->getTipoCC() == nmIntakeValve || BC[ValveID - 1]->getTipoCC() == nmExhaustValve) {
165  AvgValve.push_back(dynamic_cast<TCCCilindro*>(BC[ValveID - 1])->getValvula());
166  } else if(BC[ValveID - 1]->getTipoCC() == nmPipeToPlenumConnection) {
167  AvgValve.push_back(dynamic_cast<TCCDeposito*>(BC[ValveID - 1])->getValvula());
168  } else if(BC[ValveID - 1]->getTipoCC() == nmUnionEntreDepositos) {
169  AvgValve.push_back(dynamic_cast<TCCUnionEntreDepositos*>(BC[ValveID - 1])->getValvula());
170  } else
171  printf("ERROR: There is no valves asigned in the connection number %d\n", ValveID);
172  AvgValveNode.push_back(ValveID);
173  fgetpos(FileInput, &filepos);
174  fclose(FileInput);
175  AvgValve[i]->LeeDatosGraficasMED(FileWAM, filepos);
176  FileInput = fopen(FileWAM, "r");
177  fsetpos(FileInput, &filepos);
178 
179  }
180 
181  // !Read average results in root compressors
182  int NumRootsAvg = 0;
183  int RootID = 0;
184  fscanf(FileInput, "%d ", &NumRootsAvg);
185 
186  for(int i = 0; i < NumRootsAvg; ++i) {
187  fscanf(FileInput, "%d ", &RootID);
188  AvgRoot.push_back(Root[RootID - 1]);
189  fgetpos(FileInput, &filepos);
190  fclose(FileInput);
191  AvgRoot[i]->ReadAverageResultsCV(FileWAM, filepos);
192  FileInput = fopen(FileWAM, "r");
193  fsetpos(FileInput, &filepos);
194  }
195 
196  // !Read average results in venturis
197  int NumVenturisAvg = 0;
198  int VenturiID = 0;
199  fscanf(FileInput, "%d ", &NumVenturisAvg);
200 
201  for(int i = 0; i < NumVenturisAvg; ++i) {
202  fscanf(FileInput, "%d ", &VenturiID);
203  AvgVenturi.push_back(Venturi[VenturiID - 1]);
204  fgetpos(FileInput, &filepos);
205  fclose(FileInput);
206  AvgVenturi[i]->ReadAverageResultsVenturi(FileWAM, filepos);
207  FileInput = fopen(FileWAM, "r");
208  fsetpos(FileInput, &filepos);
209  }
210 
211  // !Read average results in connections between plenums
212  int NumConnectionsAvg = 0;
213  int ConnectionID = 0;
214  fscanf(FileInput, "%d ", &NumConnectionsAvg);
215 
216  for(int i = 0; i < NumConnectionsAvg; ++i) {
217  fscanf(FileInput, "%d ", &ConnectionID);
218  if(BC[ConnectionID - 1]->getTipoCC() == nmUnionEntreDepositos) {
219  AvgConnection.push_back(dynamic_cast<TCCUnionEntreDepositos*>(BC[ConnectionID - 1]));
220  } else {
221  printf("ERROR: Connection %d\n does not connect two plenums", ConnectionID);
222  }
223  fgetpos(FileInput, &filepos);
224  fclose(FileInput);
225  AvgConnection[i]->ReadAverageResultsUED(FileWAM, filepos);
226  FileInput = fopen(FileWAM, "r");
227  fsetpos(FileInput, &filepos);
228  }
229 
230  // !Read average results in DPF
231 #ifdef ParticulateFilter
232  int NumDPFAvg = 0;
233  int DPFID = 0;
234  fscanf(FileInput, "%d ", &NumDPFAvg);
235  for(int i = 0; i < NumDPFAvg; i++) {
236  fscanf(FileInput, "%d ", &DPFID);
237  AvgDPF.push_back(DPF[DPFID - 1]);
238  fgetpos(FileInput, &filepos);
239  fclose(FileInput);
240  AvgDPF[i]->LeeResultadosMediosDPF(FileWAM, filepos);
241  FileInput = fopen(FileWAM, "r");
242  fsetpos(FileInput, &filepos);
243  }
244 #endif
245 
246  // !Read average results in sensors
247  int NumSensorAvg = 0;
248  int SensorID = 0;
249  fscanf(FileInput, "%d ", &NumSensorAvg);
250  for(int i = 0; i < NumSensorAvg; ++i) {
251  fscanf(FileInput, "%d ", &SensorID);
252  AvgSensor.push_back(Sensor[SensorID - 1]);
253  fgetpos(FileInput, &filepos);
254  fclose(FileInput);
255  AvgSensor[i]->LeeResultadosMedSensor(FileWAM, filepos);
256  FileInput = fopen(FileWAM, "r");
257  fsetpos(FileInput, &filepos);
258  }
259 
260  // !Read average results in controllers
261  int NumControllersAvg = 0;
262  int ControllerID = 0;
263  fscanf(FileInput, "%d ", &NumControllersAvg);
264 
265  for(int i = 0; i < NumControllersAvg; ++i) {
266  fscanf(FileInput, "%d ", &ControllerID);
267  AvgController.push_back(Controller[ControllerID - 1]);
268  fgetpos(FileInput, &filepos);
269  fclose(FileInput);
270  AvgController[i]->LeeResultadosMedControlador(FileWAM, filepos);
271  FileInput = fopen(FileWAM, "r");
272  fsetpos(FileInput, &filepos);
273  }
274  fgetpos(FileInput, &filepos);
275  fclose(FileInput);
276 
277 }
278 
279 void TOutputResults::HeaderAverageResults(stEspecies *SpeciesName, TCalculoExtern* EXTERN, bool ThereIsDLL) {
280 
281  FAvgOutput << PutLabel(704);
282  FAvgOutput << "\t" << PutLabel(701);
283 
284  // ! Header average results in cylinders.
285 
286  for(Uint i = 0; i < AvgCylinder.size(); ++i) {
287  AvgCylinder[i]->HeaderAverageResultsCilindro(FAvgOutput, SpeciesName);
288  }
289 
290  // ! Header average results in the engine.
291  if(AvgEngine != NULL) {
292  AvgEngine->HeaderAverageResultsBloqueMotor(FAvgOutput);
293  }
294 
295  // ! Header average results in plenums
296  for(Uint i = 0; i < AvgPlenum.size(); ++i) {
297  AvgPlenum[i]->HeaderAverageResultsDep(FAvgOutput, SpeciesName);
298  }
299 
300  // ! Header average results in pipes
301  for(Uint i = 0; i < AvgPipe.size(); i++) {
302  AvgPipe[i]->HeaderAverageResults(FAvgOutput, SpeciesName);
303  }
304 
305  // ! Header average results in valves
306  for(Uint i = 0; i < AvgValve.size(); i++) {
307  AvgValve[i]->CabeceraGraficaMED(FAvgOutput, AvgValveNode[i]);
308  }
309 
310  // ! Header average results in venturis
311  for(Uint i = 0; i < AvgVenturi.size(); i++) {
312  AvgVenturi[i]->HeaderAverageResultsVenturi(FAvgOutput);
313  }
314 
315  // ! Header average results in turbocharger.
316  for(Uint i = 0; i < AvgAxis.size(); ++i) {
317  AvgAxis[i]->CabeceraResultadosMedEje(FAvgOutput);
318  }
319 
320  // ! Header averge results in compressors.
321  for(Uint i = 0; i < AvgCompressor.size(); ++i) {
322  AvgCompressor[i]->CabeceraGraficasMedias(FAvgOutput);
323  }
324 
325  // ! Header average results in turbines
326 
327  for(Uint i = 0; i < AvgTurbine.size(); i++) {
328  AvgTurbine[i]->CabeceraResultadosMedTurb(FAvgOutput);
329  }
330 
331  // ! Header average results in root compressors
332  for(Uint i = 0; i < AvgRoot.size(); i++) {
333  AvgRoot[i]->CabeceraResultadosMedCV(FAvgOutput);
334  }
335 
336  // ! Header average results in connections between plenums
337  for(Uint i = 0; i < AvgConnection.size(); i++) {
338  AvgConnection[i]->HeaderAverageResultsUED(FAvgOutput);
339  }
340 
341  // ! Header average results in connections between DPF.
342 #ifdef ParticulateFilter
343  for(Uint i = 0; i < AvgDPF.size(); i++) {
344  AvgDPF[i]->CabeceraResultadosMedios(FAvgOutput, SpeciesName);
345  }
346 #endif
347 
348  // ! Header average results in sensors
349  for(Uint i = 0; i < AvgSensor.size(); i++) {
350  AvgSensor[i]->CabeceraResultadosMedSensor(FAvgOutput);
351  }
352 
353  // ! Header average results in controllers
354  for(Uint i = 0; i < AvgController.size(); i++) {
355  AvgController[i]->CabeceraResultadosMedControlador(FAvgOutput);
356  }
357 
358  // ! Average results in external calculations
359  if(ThereIsDLL) {
360  EXTERN->ImprimeCabeceraMedias(FAvgOutput);
361  }
362 }
363 
364 void TOutputResults::OutputAverageResults(double AcumulatedTime, TCalculoExtern* EXTERN, bool ThereIsDLL) {
365 
366  float pasafloat;
367 
368  pasafloat = (float)(AcumulatedTime);
369 
370  FAvgOutput << std::endl;
371  FAvgOutput << AvgEngine->getCiclo();
372  FAvgOutput << "\t";
373  FAvgOutput << pasafloat;
374 
375  // ! Average results in cylinders
376 
377  for(Uint i = 0; i < AvgCylinder.size(); ++i) {
378  AvgCylinder[i]->CalculaResultadosMediosCilindro();
379  AvgCylinder[i]->ImprimeResultadosMediosCilindro(FAvgOutput);
380  }
381 
382  // ! Average results in the engine
383  if(AvgEngine != NULL) {
384  AvgEngine->ResultadosMediosBloqueMotor();
385  AvgEngine->ImprimeResultadosMediosBloqueMotor(FAvgOutput);
386  }
387 
388  // ! Average results in plenums
389 
390  for(Uint i = 0; i < AvgPlenum.size(); ++i) {
391  AvgPlenum[i]->ResultadosMediosDep();
392  AvgPlenum[i]->ImprimeResultadosMediosDep(FAvgOutput);
393  }
394 
395  // ! Average results in pipes
396  for(Uint i = 0; i < AvgPipe.size(); ++i) {
397  AvgPipe[i]->ImprimeResultadosMedios(FAvgOutput);
398  }
399 
400  // ! Average results in valves.
401  for(Uint i = 0; i < AvgValve.size(); i++) {
402  AvgValve[i]->ImprimeGraficaMED(FAvgOutput);
403  }
404 
405  // ! Average results in venturis
406  for(Uint i = 0; i < AvgVenturi.size(); i++) {
407  AvgVenturi[i]->ResultadosMediosVenturi();
408  AvgVenturi[i]->ImprimeResultadosMediosVenturi(FAvgOutput);
409  }
410 
411  // ! Average results in turbocharger axis
412  for(Uint i = 0; i < AvgAxis.size(); ++i) {
413  AvgAxis[i]->ResultadosMediosEje();
414  AvgAxis[i]->ImprimeResultadosMedEje(FAvgOutput);
415  }
416 
417  // ! Average results in compressors.
418  for(Uint i = 0; i < AvgCompressor.size(); ++i) {
419  AvgCompressor[i]->ImprimeGraficasMedias(FAvgOutput);
420  }
421 
422  // ! Average results in turbines.
423  for(Uint i = 0; i < AvgTurbine.size(); i++) {
424  AvgTurbine[i]->CalculaResultadosMediosTurb();
425  AvgTurbine[i]->ImprimeResultadosMedTurb(FAvgOutput);
426  }
427 
428  // ! Average results in root compressors.
429  for(Uint i = 0; i < AvgRoot.size(); i++) {
430  AvgRoot[i]->ResultadosMediosCV();
431  AvgRoot[i]->ImprimeResultadosMedCV(FAvgOutput);
432  }
433 
434  // ! Average results in connections.
435  for(Uint i = 0; i < AvgConnection.size(); i++) {
436  AvgConnection[i]->ResultadosMediosUED();
437  AvgConnection[i]->ImprimeResultadosMediosUED(FAvgOutput);
438  }
439 
440  // ! Average results in DPF.
441 #ifdef ParticulateFilter
442  for(int i = 0; i < AvgConnection.size(); i++) {
443  AvgDPF[i]->ImprimeResultadosMedios(FAvgOutput);
444  }
445 #endif
446 
447  // ! Average results in sensors.
448  for(Uint i = 0; i < AvgSensor.size(); i++) {
449  AvgSensor[i]->ResultadosMediosSensor();
450  AvgSensor[i]->ImprimeResultadosMedSensor(FAvgOutput);
451  }
452 
453  // ! Average results in controllers
454  for(Uint i = 0; i < AvgController.size(); i++) {
455  AvgController[i]->ResultadosMediosController();
456  AvgController[i]->ImprimeResultadosMedControlador(FAvgOutput);
457  }
458 
459  // ! Average results in external calculations.
460  if(ThereIsDLL) {
461  EXTERN->CalculaMedias();
462  EXTERN->ImprimeGraficosMedias(FAvgOutput);
463  }
464 
465 }
466 
467 void TOutputResults::CopyAverageResultsToFile(int mode) {
468 
469  if(mode == 0) { // ! Create new file o rewrite if it exists
470  FFileAvg.open(FAvgFilename, fstream::out);
471  } else { // ! Create new file or append if it exists
472  FFileAvg.open(FAvgFilename, fstream::out | fstream::app);
473  }
474 
475  FFileAvg << FAvgOutput.str();
476 
477  FFileAvg.close();
478 
479  FAvgOutput.str("");
480 }
481 
482 void TOutputResults::CopyInstananeousResultsToFile(int mode) {
483 
484  if(FInsOutput.str() != "" && (WriteInsHeader || mode == 1)) {
485 
486  char FileName[300];
487 
488  if(FMultipleFiles) {
489  ConvertCharacter(FFileCountI, FFileCountC, FCharacters);
490 
491  strcat(FFileCountC, ".DAT");
492  GetName(FInsFilename, FileName, FFileCountC);
493  } else {
494  GetName(FInsFilename, FileName, ".DAT");
495  }
496 
497  if(WriteInsHeader) {
498  FFileIns.open(FileName, fstream::out);
499  } else {
500 #ifdef WriteINS
501  FFileIns.open(FileName, fstream::out | fstream::app);
502 #endif
503 #ifndef WriteINS
504  FFileIns.open(FileName, fstream::out);
505 #endif
506  }
507  if(!FFileIns.is_open()) {
508  cout << "WARNING: The file " << FileName << " in in use" << endl;
509  cout << "Please close the file, insert any character and press enter to continue" << endl;
510  string key;
511  cin >> key;
512  }
513 
514  FFileIns << FInsOutput.str();
515 
516  FFileIns.close();
517 
518  FInsOutput.str("");
519 
520  FFileCountI++;
521  }
522 }
523 
524 void TOutputResults::ReadInstantaneousResults(const char* FileWAM, fpos_t &filepos, TBloqueMotor** Engine,
525  TDeposito** Plenum, TTubo** Pipe, TVenturi** Venturi, TCondicionContorno** BC, TDPF** DPF, TEjeTurbogrupo** Turbo,
526  TCompresor** Compressor, TTurbina** Turbine, TCCCompresorVolumetrico** Root, TCondicionContorno** BCWasteGate,
527  int NumberOfWasteGates, TCondicionContorno** BCReedValve, int NumberOfReedValves, TSensor** Sensor,
528  TController** Controller, char* ModelName) {
529 
530  GetName(ModelName, FInsFilename, "INS.DAT");
531 
532  int err = remove(FInsFilename);
533 
534  FILE *FileInput = fopen(FileWAM, "r");
535  fsetpos(FileInput, &filepos);
536 
537  // ! Instantaneous results in cylinders
538  int NumCylindersIns = 0;
539  int CylinderID = 0;
540  fscanf(FileInput, "%d ", &NumCylindersIns);
541  for(int i = 0; i < NumCylindersIns; ++i) {
542  fscanf(FileInput, "%d ", &CylinderID);
543  InsCylinder.push_back(Engine[0]->GetCilindro(CylinderID - 1));
544  fgetpos(FileInput, &filepos);
545  fclose(FileInput);
546  InsCylinder[i]->ReadInstantaneousResultsCilindro(FileWAM, filepos);
547  FileInput = fopen(FileWAM, "r");
548  fsetpos(FileInput, &filepos);
549  }
550 
551  // ! Instantaneous results in plenums
552  int NumPlenumsIns = 0;
553  int PlenumID = 0;
554  fscanf(FileInput, "%d ", &NumPlenumsIns);
555  for(int i = 0; i < NumPlenumsIns; i++) {
556  fscanf(FileInput, "%d ", &PlenumID);
557  InsPlenum.push_back(Plenum[PlenumID - 1]);
558  fgetpos(FileInput, &filepos);
559  fclose(FileInput);
560  InsPlenum[i]->ReadInstantaneousResultsDep(FileWAM, filepos);
561  FileInput = fopen(FileWAM, "r");
562  fsetpos(FileInput, &filepos);
563  }
564 
565  // ! Instantaneous results in pipes
566  int NumPipesIns = 0;
567  int PipeID = 0;
568  fscanf(FileInput, "%d ", &NumPipesIns);
569  /* Dato para WAMer. Numero de resultados instantaneos en tubos */
570  int numeroparawamer = 0;
571  fscanf(FileInput, "%d ", &numeroparawamer);
572  for(int i = 0; i < NumPipesIns; i++) {
573  fscanf(FileInput, "%d ", &PipeID);
574  InsPipe.push_back(Pipe[PipeID - 1]);
575  fgetpos(FileInput, &filepos);
576  fclose(FileInput);
577  InsPipe[i]->ReadInstantaneousResultsTubo(FileWAM, filepos, Engine);
578  FileInput = fopen(FileWAM, "r");
579  fsetpos(FileInput, &filepos);
580  }
581 
582  // ! Instantaneous results in venturis
583  int NumVenturisIns = 0;
584  int VenturiID = 0;
585  fscanf(FileInput, "%d ", &NumVenturisIns);
586  for(int i = 0; i < NumVenturisIns; i++) {
587  fscanf(FileInput, "%d ", &VenturiID);
588  InsVenturi.push_back(Venturi[VenturiID - 1]);
589  fgetpos(FileInput, &filepos);
590  fclose(FileInput);
591  InsVenturi[i]->LeeResultadosInstantVenturi(FileWAM, filepos);
592  FileInput = fopen(FileWAM, "r");
593  fsetpos(FileInput, &filepos);
594  }
595 
596  // ! Instantaneous results in connections
597  int NumValvesIns = 0;
598  int ValveID = 0;
599  fscanf(FileInput, "%d", &NumValvesIns);
600  for(int i = 0; i < NumValvesIns; i++) {
601  fscanf(FileInput, "%d ", &ValveID);
602  if(BC[ValveID - 1]->getTipoCC() == nmIntakeValve || BC[ValveID - 1]->getTipoCC() == nmExhaustValve) {
603  InsValve.push_back(dynamic_cast<TCCCilindro*>(BC[ValveID - 1])->getValvula());
604  } else if(BC[ValveID - 1]->getTipoCC() == nmPipeToPlenumConnection) {
605  InsValve.push_back(dynamic_cast<TCCDeposito*>(BC[ValveID - 1])->getValvula());
606  } else if(BC[ValveID - 1]->getTipoCC() == nmUnionEntreDepositos) {
607  InsValve.push_back(dynamic_cast<TCCUnionEntreDepositos*>(BC[ValveID - 1])->getValvula());
608  } else
609  printf("ERROR: There is no valves asigned in the connection number %d\n", ValveID);
610  InsValveNode.push_back(ValveID);
611  fgetpos(FileInput, &filepos);
612  fclose(FileInput);
613  InsValve[i]->LeeDatosGraficasINS(FileWAM, filepos);
614  FileInput = fopen(FileWAM, "r");
615  fsetpos(FileInput, &filepos);
616  }
617 
618  // ! Instantaneous results turbochargers.
619  int NumTurboIns = 0;
620  int TurboID = 0;
621  fscanf(FileInput, "%d", &NumTurboIns);
622  for(int i = 0; i < NumTurboIns; i++) {
623  fscanf(FileInput, "%d", &TurboID);
624  InsTurbo.push_back(Turbo[TurboID - 1]);
625  fgetpos(FileInput, &filepos);
626  fclose(FileInput);
627  InsTurbo[i]->ReadInstantaneousResultsEje(FileWAM, filepos);
628  FileInput = fopen(FileWAM, "r");
629  fsetpos(FileInput, &filepos);
630  }
631 
632  int NumCompressorIns = 0;
633  int CompressorID = 0;
634  fscanf(FileInput, "%d ", &NumCompressorIns);
635  for(int i = 0; i < NumCompressorIns; i++) {
636  fscanf(FileInput, "%d ", &CompressorID);
637  InsCompressor.push_back(Compressor[CompressorID - 1]);
638  fgetpos(FileInput, &filepos);
639  fclose(FileInput);
640  InsCompressor[i]->LeeDatosGraficasInstantaneas(FileWAM, filepos);
641  FileInput = fopen(FileWAM, "r");
642  fsetpos(FileInput, &filepos);
643  }
644 
645  int NumTurbineIns = 0;
646  int TurbineID = 0;
647  fscanf(FileInput, "%d ", &NumTurbineIns);
648  for(int i = 0; i < NumTurbineIns; i++) {
649  fscanf(FileInput, "%d ", &TurbineID);
650  InsTurbine.push_back(Turbine[TurbineID - 1]);
651  fgetpos(FileInput, &filepos);
652  fclose(FileInput);
653  InsTurbine[i]->LeeResultadosInstantTurb(FileWAM, filepos);
654  FileInput = fopen(FileWAM, "r");
655  fsetpos(FileInput, &filepos);
656  }
657 
658  int NumRootsIns = 0;
659  int RootID = 0;
660  fscanf(FileInput, "%d ", &NumRootsIns);
661  for(int i = 0; i < NumRootsIns; ++i) {
662  fscanf(FileInput, "%d ", &RootID);
663  InsRoot.push_back(Root[RootID - 1]);
664  fgetpos(FileInput, &filepos);
665  fclose(FileInput);
666  InsRoot[i]->LeeResultadosInstantCV(FileWAM, filepos);
667  FileInput = fopen(FileWAM, "r");
668  fsetpos(FileInput, &filepos);
669  }
670 
671  // !Read instantaneous results in connections between plenums
672  int NumConnectionsIns = 0;
673  int ConnectionID = 0;
674  fscanf(FileInput, "%d ", &NumConnectionsIns);
675  for(int i = 0; i < NumConnectionsIns; ++i) {
676  fscanf(FileInput, "%d ", &ConnectionID);
677  if(BC[ConnectionID - 1]->getTipoCC() == nmUnionEntreDepositos) {
678  InsConnection.push_back(dynamic_cast<TCCUnionEntreDepositos*>(BC[ConnectionID - 1]));
679  } else {
680  printf("ERROR: Connection %d\n does not connect two plenums", ConnectionID);
681  }
682  fgetpos(FileInput, &filepos);
683  fclose(FileInput);
684  InsConnection[i]->LeeResultadosInstantUED(FileWAM, filepos);
685  FileInput = fopen(FileWAM, "r");
686  fsetpos(FileInput, &filepos);
687  }
688 
689  //
690  // // RESULTADOS INSTANTANEOS WASTE-GATE.
691 
692  int NumWasteGateIns = 0;
693  int WasteGateID = 0;
694  bool valido = false;
695  fscanf(FileInput, "%d ", &NumWasteGateIns);
696  for(int i = 0; i < NumWasteGateIns; i++) {
697  fscanf(FileInput, "%d ", &WasteGateID);
698  for(int j = 0; j < NumberOfWasteGates; j++) {
699  if(BCWasteGate[j]->getNumeroCC() == WasteGateID) {
700  valido = true;
701  fgetpos(FileInput, &filepos);
702  fclose(FileInput);
703  if(BCWasteGate[j]->getTipoCC() == nmPipeToPlenumConnection) {
704  InsWasteGate.push_back(dynamic_cast<TWasteGate*>(dynamic_cast<TCCDeposito*>(BCWasteGate[j])->getValvula()));
705  } else if(BCWasteGate[j]->getTipoCC() == nmUnionEntreDepositos) {
706  InsWasteGate.push_back(dynamic_cast<TWasteGate*>(dynamic_cast<TCCUnionEntreDepositos*>(BCWasteGate[j])->getValvula()));
707  }
708  InsWasteGate[i]->LeeDatosGraficasINS(FileWAM, filepos);
709  FileInput = fopen(FileWAM, "r");
710  fsetpos(FileInput, &filepos);
711  }
712  }
713  if(!valido)
714  printf("ERROR: A WasteGate does not exist in connection number %d\n", WasteGateID);
715  valido = false;
716  }
717  //
718  // // RESULTADOS INSTANTANEOS LAMINA.
719  int NumReedIns = 0;
720  int ReedID = 0;
721  fscanf(FileInput, "%d ", &NumReedIns);
722  for(int i = 0; i < NumReedIns; i++) {
723  fscanf(FileInput, "%d ", &ReedID);
724  for(int j = 0; j < NumberOfReedValves; j++) {
725  if(BCReedValve[j]->getNumeroCC() == ReedID) {
726  valido = true;
727  fgetpos(FileInput, &filepos);
728  fclose(FileInput);
729  if(BCReedValve[j]->getTipoCC() == nmPipeToPlenumConnection) {
730  InsReedValve.push_back(dynamic_cast<TLamina*>(dynamic_cast<TCCDeposito*>(BCReedValve[j])->getValvula()));
731  } else if(BCReedValve[j]->getTipoCC() == nmUnionEntreDepositos) {
732  InsReedValve.push_back(dynamic_cast<TLamina*>(dynamic_cast<TCCUnionEntreDepositos*>(BCReedValve[j])->getValvula()));
733  }
734  InsReedValve[i]->LeeDatosGraficasINS(FileWAM, filepos);
735  FileInput = fopen(FileWAM, "r");
736  fsetpos(FileInput, &filepos);
737  }
738  }
739  if(!valido)
740  printf("ERROR: A reed valve does not exist in connection number %d\n", ReedID);
741  valido = false;
742 
743  }
744 
745  // !Read instantaneous results in DPF.
746 #ifdef ParticulateFilter
747  int NumDPFIns = 0;
748  int DPFID = 0;
749  fscanf(FileInput, "%d ", &NumDPFIns);
750  for(int i = 0; i < NumDPFIns; ++i) {
751  fscanf(FileInput, "%d ", &DPFID);
752  InsDPF.push_back(DPF[DPFID - 1]);
753  fgetpos(FileInput, &filepos);
754  fclose(FileInput);
755  InsDPF[i]->LeeResultadosInstantaneosDPF(FileWAM, filepos);
756  FileInput = fopen(FileWAM, "r");
757  fsetpos(FileInput, &filepos);
758  }
759 #endif
760 
761  // !Read instantaneous results in sensors
762  int NumSensorIns = 0;
763  int SensorID = 0;
764  fscanf(FileInput, "%d ", &NumSensorIns);
765  for(int i = 0; i < NumSensorIns; ++i) {
766  fscanf(FileInput, "%d ", &SensorID);
767  InsSensor.push_back(Sensor[SensorID - 1]);
768  fgetpos(FileInput, &filepos);
769  fclose(FileInput);
770  InsSensor[i]->LeeResultadosInsSensor(FileWAM, filepos);
771  FileInput = fopen(FileWAM, "r");
772  fsetpos(FileInput, &filepos);
773  }
774 
775  // !Read instantaneous results in controllers
776 
777  int NumControllersIns = 0;
778  int ControllerID = 0;
779  fscanf(FileInput, "%d ", &NumControllersIns);
780 
781  for(int i = 0; i < NumControllersIns; ++i) {
782  fscanf(FileInput, "%d ", &ControllerID);
783  InsController.push_back(Controller[ControllerID - 1]);
784  fgetpos(FileInput, &filepos);
785  fclose(FileInput);
786  InsController[i]->LeeResultadosInsControlador(FileWAM, filepos);
787  FileInput = fopen(FileWAM, "r");
788  fsetpos(FileInput, &filepos);
789  }
790 
791  fgetpos(FileInput, &filepos);
792  fclose(FileInput);
793 
794 }
795 
796 void TOutputResults::ReadSpaceTimeResults(const char* FileWAM, fpos_t &filepos, TTubo** Pipe, TBloqueMotor** Engine,
797  TDeposito **Plenum) {
798 
799  // Numero de elementos en los que se grafica
800  int FNumMagnitudesEspTemp = 0;
801  int NumCilEspTemp = 0;
802  int NumDepEspTemp = 0;
803  int NumTubEspTemp = 0;
804 
805  FILE *FileInput = fopen(FileWAM, "r");
806  fsetpos(FileInput, &filepos);
807 
808  fscanf(FileInput, "%d ", &FNumMagnitudesEspTemp);
809  if(FNumMagnitudesEspTemp != 0) {
810  fscanf(FileInput, "%d %d %d ", &NumCilEspTemp, &NumDepEspTemp, &NumTubEspTemp);
811 
812  int CylinderID = 0;
813  for(int i = 0; i < NumCilEspTemp; ++i) {
814  fscanf(FileInput, "%d ", &CylinderID);
815  STCylinder.push_back(Engine[0]->GetCilindro(CylinderID - 1));
816  }
817 
818  int PlenumID = 0;
819  for(int i = 0; i < NumDepEspTemp; ++i) {
820  fscanf(FileInput, "%d ", &PlenumID);
821  STPlenum.push_back(Plenum[PlenumID - 1]);
822  }
823 
824  int PipeID = 0;
825  for(int i = 0; i < NumTubEspTemp; ++i) {
826  fscanf(FileInput, "%d ", &PipeID);
827  STPipe.push_back(Pipe[PipeID - 1]);
828  }
829 
830  // Magnitudes que se grafican
831  int ParameterID = 0;
832  for(int i = 0; i < FNumMagnitudesEspTemp; ++i) {
833  fscanf(FileInput, "%d ", &ParameterID);
834  FParameterSpaceTime.push_back(ParameterID);
835  }
836  }
837 
838  fgetpos(FileInput, &filepos);
839  fclose(FileInput);
840 
841 }
842 
843 void TOutputResults::DoSpaceTimeFiles(int SpeciesNumber) {
844 
845  if(FParameterSpaceTime.size() > 0) {
846  int k = 0;
847  if(SpeciesNumber == 3) {
848  for(int j = 0; j <= 299; ++j) {
849  salpre[j] = '\0';
850  saltem[j] = '\0';
851  salvel[j] = '\0';
852  salair[j] = '\0';
853  salYAireFresco[j] = '\0';
854  salYGasQuemado[j] = '\0';
855  salGastoAireFresco[j] = '\0';
856  salGastoGasQuemado[j] = '\0';
857  }
858  } else if(SpeciesNumber == 4) {
859  for(int j = 0; j <= 299; ++j) {
860  salpre[j] = '\0';
861  saltem[j] = '\0';
862  salvel[j] = '\0';
863  salair[j] = '\0';
864  salYCombustible[j] = '\0';
865  salYAireFresco[j] = '\0';
866  salYGasQuemado[j] = '\0';
867  salGastoCombustible[j] = '\0';
868  salGastoAireFresco[j] = '\0';
869  salGastoGasQuemado[j] = '\0';
870  }
871  } else if(SpeciesNumber == 9) {
872  for(int j = 0; j <= 299; ++j) {
873  salpre[j] = '\0';
874  saltem[j] = '\0';
875  salvel[j] = '\0';
876  salair[j] = '\0';
877  salYO2[j] = '\0';
878  salYN2[j] = '\0';
879  salYCO2[j] = '\0';
880  salYH2O[j] = '\0';
881  salYCO[j] = '\0';
882  salYHC[j] = '\0';
883  salYSoot[j] = '\0';
884  salYNOx[j] = '\0';
885  salGastoO2[j] = '\0';
886  salGastoN2[j] = '\0';
887  salGastoCO2[j] = '\0';
888  salGastoH2O[j] = '\0';
889  salGastoCO[j] = '\0';
890  salGastoHC[j] = '\0';
891  salGastoSoot[j] = '\0';
892  salGastoNOx[j] = '\0';
893  }
894  } else if(SpeciesNumber == 10) {
895  for(int j = 0; j <= 299; ++j) {
896  salpre[j] = '\0';
897  saltem[j] = '\0';
898  salvel[j] = '\0';
899  salair[j] = '\0';
900  salYO2[j] = '\0';
901  salYN2[j] = '\0';
902  salYCO2[j] = '\0';
903  salYH2O[j] = '\0';
904  salYCO[j] = '\0';
905  salYHC[j] = '\0';
906  salYSoot[j] = '\0';
907  salYCombustible[j] = '\0';
908  salYNOx[j] = '\0';
909  salGastoO2[j] = '\0';
910  salGastoN2[j] = '\0';
911  salGastoCO2[j] = '\0';
912  salGastoH2O[j] = '\0';
913  salGastoCO[j] = '\0';
914  salGastoHC[j] = '\0';
915  salGastoSoot[j] = '\0';
916  salGastoCombustible[j] = '\0';
917  salGastoNOx[j] = '\0';
918  }
919  }
920 
921  for(unsigned int i = 0; i < FParameterSpaceTime.size(); ++i) {
922  switch(FParameterSpaceTime[i]) {
923  case 0:
924  k = 0;
925  while(FInsFilename[k] != '.') {
926  salpre[k] = FInsFilename[k];
927  ++k;
928  }
929  strcat(salpre, "_pre.DAT");
930  FileOutPressure = fopen(salpre, "w");
931  break;
932  case 1:
933  k = 0;
934  while(FInsFilename[k] != '.') {
935  saltem[k] = FInsFilename[k];
936  ++k;
937  }
938  strcat(saltem, "_tem.DAT");
939  FileOutTemp = fopen(saltem, "w");
940  break;
941  case 2:
942  k = 0;
943  while(FInsFilename[k] != '.') {
944  salvel[k] = FInsFilename[k];
945  ++k;
946  }
947  strcat(salvel, "_vel.DAT");
948  FileOutVel = fopen(salvel, "w");
949  break;
950  case 3:
951  k = 0;
952  while(FInsFilename[k] != '.') {
953  salair[k] = FInsFilename[k];
954  ++k;
955  }
956  strcat(salair, "_air.DAT");
957  FileOutFlow = fopen(salair, "w");
958  break;
959  case 4:
960  k = 0;
961  if(SpeciesNumber == 3) {
962  while(FInsFilename[k] != '.') {
963  salYGasQuemado[k] = FInsFilename[k];
964  salYAireFresco[k] = FInsFilename[k];
965  ++k;
966  }
967  strcat(salYGasQuemado, "_YGQ.DAT");
968  strcat(salYAireFresco, "_YAF.DAT");
969  FOutYBurntGas = fopen(salYGasQuemado, "w");
970  FOutYFreshAir = fopen(salYAireFresco, "w");
971 
972  } else if(SpeciesNumber == 4) {
973  while(FInsFilename[k] != '.') {
974  salYGasQuemado[k] = FInsFilename[k];
975  salYCombustible[k] = FInsFilename[k];
976  salYAireFresco[k] = FInsFilename[k];
977  ++k;
978  }
979  strcat(salYGasQuemado, "_YGQ.DAT");
980  strcat(salYCombustible, "_Ycomb.DAT");
981  strcat(salYAireFresco, "_YAF.DAT");
982  FOutYBurntGas = fopen(salYGasQuemado, "w");
983  FOutYFuel = fopen(salYCombustible, "w");
984  FOutYFreshAir = fopen(salYAireFresco, "w");
985 
986  } else if(SpeciesNumber == 9) {
987  while(FInsFilename[k] != '.') {
988  salYO2[k] = FInsFilename[k];
989  salYCO2[k] = FInsFilename[k];
990  salYH2O[k] = FInsFilename[k];
991  salYHC[k] = FInsFilename[k];
992  salYSoot[k] = FInsFilename[k];
993  salYNOx[k] = FInsFilename[k];
994  salYCO[k] = FInsFilename[k];
995  salYN2[k] = FInsFilename[k];
996  ++k;
997  }
998  strcat(salYO2, "_YO2.DAT");
999  strcat(salYCO2, "_YCO2.DAT");
1000  strcat(salYH2O, "_YH2O.DAT");
1001  strcat(salYHC, "_YHC.DAT");
1002  strcat(salYSoot, "_YSoot.DAT");
1003  strcat(salYNOx, "_YNOx.DAT");
1004  strcat(salYCO, "_YCO.DAT");
1005  strcat(salYN2, "_YN2.DAT");
1006  FOutYO2 = fopen(salYO2, "w");
1007  FOutYCO2 = fopen(salYCO2, "w");
1008  FOutYH2O = fopen(salYH2O, "w");
1009  FOutYHC = fopen(salYHC, "w");
1010  FOutYSoot = fopen(salYSoot, "w");
1011  FOutYNOx = fopen(salYNOx, "w");
1012  FOutYCO = fopen(salYCO, "w");
1013  FOutYN2 = fopen(salYN2, "w");
1014 
1015  } else if(SpeciesNumber == 10) {
1016  while(FInsFilename[k] != '.') {
1017  salYO2[k] = FInsFilename[k];
1018  salYCO2[k] = FInsFilename[k];
1019  salYH2O[k] = FInsFilename[k];
1020  salYHC[k] = FInsFilename[k];
1021  salYSoot[k] = FInsFilename[k];
1022  salYNOx[k] = FInsFilename[k];
1023  salYCO[k] = FInsFilename[k];
1024  salYCombustible[k] = FInsFilename[k];
1025  salYN2[k] = FInsFilename[k];
1026  ++k;
1027  }
1028  strcat(salYO2, "_YO2.DAT");
1029  strcat(salYCO2, "_YCO2.DAT");
1030  strcat(salYH2O, "_YH2O.DAT");
1031  strcat(salYHC, "_YHC.DAT");
1032  strcat(salYSoot, "_YSoot.DAT");
1033  strcat(salYNOx, "_YNOx.DAT");
1034  strcat(salYCO, "_YCO.DAT");
1035  strcat(salYCombustible, "_YComb.DAT");
1036  strcat(salYN2, "_YN2.DAT");
1037  FOutYO2 = fopen(salYO2, "w");
1038  FOutYCO2 = fopen(salYCO2, "w");
1039  FOutYH2O = fopen(salYH2O, "w");
1040  FOutYHC = fopen(salYHC, "w");
1041  FOutYSoot = fopen(salYSoot, "w");
1042  FOutYNOx = fopen(salYNOx, "w");
1043  FOutYCO = fopen(salYCO, "w");
1044  FOutYFuel = fopen(salYCombustible, "w");
1045  FOutYN2 = fopen(salYN2, "w");
1046  }
1047  break;
1048  case 5:
1049  k = 0;
1050  if(SpeciesNumber == 3) {
1051  while(FInsFilename[k] != '.') {
1052  salGastoGasQuemado[k] = FInsFilename[k];
1053  salGastoAireFresco[k] = FInsFilename[k];
1054  ++k;
1055  }
1056  strcat(salGastoGasQuemado, "_GastoGQ.DAT");
1057  strcat(salGastoAireFresco, "_GastoAF.DAT");
1058  FOutFlowBurntGas = fopen(salGastoGasQuemado, "w");
1059  FOutFlowFreshAir = fopen(salGastoAireFresco, "w");
1060 
1061  } else if(SpeciesNumber == 4) {
1062  while(FInsFilename[k] != '.') {
1063  salGastoGasQuemado[k] = FInsFilename[k];
1064  salGastoCombustible[k] = FInsFilename[k];
1065  salGastoAireFresco[k] = FInsFilename[k];
1066  ++k;
1067  }
1068  strcat(salGastoGasQuemado, "_GastoGQ.DAT");
1069  strcat(salGastoCombustible, "_Gastocomb.DAT");
1070  strcat(salGastoAireFresco, "_GastoAF.DAT");
1071  FOutFlowBurntGas = fopen(salGastoGasQuemado, "w");
1072  FOutFlowFuel = fopen(salGastoCombustible, "w");
1073  FOutFlowFreshAir = fopen(salGastoAireFresco, "w");
1074 
1075  } else if(SpeciesNumber == 9) {
1076  while(FInsFilename[k] != '.') {
1077  salGastoO2[k] = FInsFilename[k];
1078  salGastoCO2[k] = FInsFilename[k];
1079  salGastoH2O[k] = FInsFilename[k];
1080  salGastoHC[k] = FInsFilename[k];
1081  salGastoSoot[k] = FInsFilename[k];
1082  salGastoNOx[k] = FInsFilename[k];
1083  salGastoCO[k] = FInsFilename[k];
1084  salGastoN2[k] = FInsFilename[k];
1085  ++k;
1086  }
1087  strcat(salGastoO2, "_GastoO2.DAT");
1088  strcat(salGastoCO2, "_GastoCO2.DAT");
1089  strcat(salGastoH2O, "_GastoH2O.DAT");
1090  strcat(salGastoHC, "_GastoHC.DAT");
1091  strcat(salGastoSoot, "_GastoSoot.DAT");
1092  strcat(salGastoNOx, "_GastoNOx.DAT");
1093  strcat(salGastoCO, "_GastoCO.DAT");
1094  strcat(salGastoN2, "_GastoN2.DAT");
1095  FOutFlowO2 = fopen(salGastoO2, "w");
1096  FOutFlowCO2 = fopen(salGastoCO2, "w");
1097  FOutFlowH2O = fopen(salGastoH2O, "w");
1098  FOutFlowHC = fopen(salGastoHC, "w");
1099  FOutFlowSoot = fopen(salGastoSoot, "w");
1100  FOutFlowNOx = fopen(salGastoNOx, "w");
1101  FOutFlowCO = fopen(salGastoCO, "w");
1102  FOutFlowN2 = fopen(salGastoN2, "w");
1103 
1104  } else if(SpeciesNumber == 10) {
1105  while(FInsFilename[k] != '.') {
1106  salGastoO2[k] = FInsFilename[k];
1107  salGastoCO2[k] = FInsFilename[k];
1108  salGastoH2O[k] = FInsFilename[k];
1109  salGastoHC[k] = FInsFilename[k];
1110  salGastoSoot[k] = FInsFilename[k];
1111  salGastoNOx[k] = FInsFilename[k];
1112  salGastoCO[k] = FInsFilename[k];
1113  salGastoCombustible[k] = FInsFilename[k];
1114  salGastoN2[k] = FInsFilename[k];
1115  ++k;
1116  }
1117  strcat(salGastoO2, "_GastoO2.DAT");
1118  strcat(salGastoCO2, "_GastoCO2.DAT");
1119  strcat(salGastoH2O, "_GastoH2O.DAT");
1120  strcat(salGastoHC, "_GastoHC.DAT");
1121  strcat(salGastoSoot, "_GastoSoot.DAT");
1122  strcat(salGastoNOx, "_GastoNOx.DAT");
1123  strcat(salGastoCO, "_GastoCO.DAT");
1124  strcat(salGastoCombustible, "_GastoComb.DAT");
1125  strcat(salGastoN2, "_GastoN2.DAT");
1126  FOutFlowO2 = fopen(salGastoO2, "w");
1127  FOutFlowCO2 = fopen(salGastoCO2, "w");
1128  FOutFlowH2O = fopen(salGastoH2O, "w");
1129  FOutFlowHC = fopen(salGastoHC, "w");
1130  FOutFlowSoot = fopen(salGastoSoot, "w");
1131  FOutFlowNOx = fopen(salGastoNOx, "w");
1132  FOutFlowCO = fopen(salGastoCO, "w");
1133  FOutFlowFuel = fopen(salGastoCombustible, "w");
1134  FOutFlowN2 = fopen(salGastoN2, "w");
1135  }
1136  break;
1137  }
1138 
1139  }
1140  }
1141 }
1142 
1143 void TOutputResults::HeaderSpaceTimeResults(double thmax, double grmax, double agincr, int SpeciesNumber)
1144 
1145 {
1146 
1147  for(unsigned int i = 0; i < FParameterSpaceTime.size(); ++i) {
1148  switch(FParameterSpaceTime[i]) {
1149  case 0: // PRESION
1150  fprintf(FileOutPressure, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1151  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1152  fprintf(FileOutPressure, "%d ", STCylinder[j]->getNumeroCilindro());
1153  }
1154  fprintf(FileOutPressure, "\n");
1155  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1156  fprintf(FileOutPressure, "%d ", STPlenum[j]->getNumeroDeposito());
1157  }
1158  fprintf(FileOutPressure, "\n");
1159  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1160  fprintf(FileOutPressure, "%d ", STPipe[j]->getNumeroTubo());
1161  }
1162  fprintf(FileOutPressure, "\n");
1163  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1164  fprintf(FileOutPressure, "%d ", STPipe[j]->getNin());
1165  }
1166  fprintf(FileOutPressure, "\n%d", (int)((thmax - grmax) / agincr));
1167  break;
1168  case 1: // TEMPERATURA
1169  fprintf(FileOutTemp, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1170  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1171  fprintf(FileOutTemp, "%d ", STCylinder[j]->getNumeroCilindro());
1172  }
1173  fprintf(FileOutTemp, "\n");
1174  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1175  fprintf(FileOutTemp, "%d ", STPlenum[j]->getNumeroDeposito());
1176  }
1177  fprintf(FileOutTemp, "\n");
1178  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1179  fprintf(FileOutTemp, "%d ", STPipe[j]->getNumeroTubo());
1180  }
1181  fprintf(FileOutTemp, "\n");
1182  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1183  fprintf(FileOutTemp, "%d ", STPipe[j]->getNin());
1184  }
1185  fprintf(FileOutTemp, "\n%d", (int)((thmax - grmax) / agincr));
1186  break;
1187  case 2: // VELOCIDAD
1188  fprintf(FileOutVel, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1189  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1190  fprintf(FileOutVel, "%d ", STCylinder[j]->getNumeroCilindro());
1191  }
1192  fprintf(FileOutVel, "\n");
1193  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1194  fprintf(FileOutVel, "%d ", STPlenum[j]->getNumeroDeposito());
1195  }
1196  fprintf(FileOutVel, "\n");
1197  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1198  fprintf(FileOutVel, "%d ", STPipe[j]->getNumeroTubo());
1199  }
1200  fprintf(FileOutVel, "\n");
1201  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1202  fprintf(FileOutVel, "%d ", STPipe[j]->getNin());
1203  }
1204  fprintf(FileOutVel, "\n%d", (int)((thmax - grmax) / agincr));
1205  break;
1206  case 3: // GASTO
1207  fprintf(FileOutFlow, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1208  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1209  fprintf(FileOutFlow, "%d ", STCylinder[j]->getNumeroCilindro());
1210  }
1211  fprintf(FileOutFlow, "\n");
1212  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1213  fprintf(FileOutFlow, "%d ", STPlenum[j]->getNumeroDeposito());
1214  }
1215  fprintf(FileOutFlow, "\n");
1216  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1217  fprintf(FileOutFlow, "%d ", STPipe[j]->getNumeroTubo());
1218  }
1219  fprintf(FileOutFlow, "\n");
1220  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1221  fprintf(FileOutFlow, "%d ", STPipe[j]->getNin());
1222  }
1223  fprintf(FileOutFlow, "\n%d", (int)((thmax - grmax) / agincr));
1224  break;
1225  case 4: // FRACCION MASICA DE ESPECIES
1226  if(SpeciesNumber == 3) {
1227  fprintf(FOutYBurntGas, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1228  fprintf(FOutYFreshAir, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1229  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1230  fprintf(FOutYBurntGas, "%d ", STCylinder[j]->getNumeroCilindro());
1231  fprintf(FOutYFreshAir, "%d ", STCylinder[j]->getNumeroCilindro());
1232  }
1233  fprintf(FOutYBurntGas, "\n");
1234  fprintf(FOutYFreshAir, "\n");
1235  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1236  fprintf(FOutYBurntGas, "%d ", STPlenum[j]->getNumeroDeposito());
1237  fprintf(FOutYFreshAir, "%d ", STPlenum[j]->getNumeroDeposito());
1238  }
1239  fprintf(FOutYBurntGas, "\n");
1240  fprintf(FOutYFreshAir, "\n");
1241  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1242  fprintf(FOutYBurntGas, "%d ", STPipe[j]->getNumeroTubo());
1243  fprintf(FOutYFreshAir, "%d ", STPipe[j]->getNumeroTubo());
1244  }
1245  fprintf(FOutYBurntGas, "\n");
1246  fprintf(FOutYFreshAir, "\n");
1247  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1248  fprintf(FOutYBurntGas, "%d ", STPipe[j]->getNin());
1249  fprintf(FOutYFreshAir, "%d ", STPipe[j]->getNin());
1250  }
1251  fprintf(FOutYBurntGas, "\n%d", (int)((thmax - grmax) / agincr));
1252  fprintf(FOutYFreshAir, "\n%d", (int)((thmax - grmax) / agincr));
1253 
1254  } else if(SpeciesNumber == 4) {
1255  fprintf(FOutYBurntGas, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1256  fprintf(FOutYFuel, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1257  fprintf(FOutYFreshAir, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1258  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1259  fprintf(FOutYBurntGas, "%d ", STCylinder[j]->getNumeroCilindro());
1260  fprintf(FOutYFuel, "%d ", STCylinder[j]->getNumeroCilindro());
1261  fprintf(FOutYFreshAir, "%d ", STCylinder[j]->getNumeroCilindro());
1262  }
1263  fprintf(FOutYBurntGas, "\n");
1264  fprintf(FOutYFuel, "\n");
1265  fprintf(FOutYFreshAir, "\n");
1266  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1267  fprintf(FOutYBurntGas, "%d ", STPlenum[j]->getNumeroDeposito());
1268  fprintf(FOutYFuel, "%d ", STPlenum[j]->getNumeroDeposito());
1269  fprintf(FOutYFreshAir, "%d ", STPlenum[j]->getNumeroDeposito());
1270  }
1271  fprintf(FOutYBurntGas, "\n");
1272  fprintf(FOutYFuel, "\n");
1273  fprintf(FOutYFreshAir, "\n");
1274  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1275  fprintf(FOutYBurntGas, "%d ", STPipe[j]->getNumeroTubo());
1276  fprintf(FOutYFuel, "%d ", STPipe[j]->getNumeroTubo());
1277  fprintf(FOutYFreshAir, "%d ", STPipe[j]->getNumeroTubo());
1278  }
1279  fprintf(FOutYBurntGas, "\n");
1280  fprintf(FOutYFuel, "\n");
1281  fprintf(FOutYFreshAir, "\n");
1282  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1283  fprintf(FOutYBurntGas, "%d ", STPipe[j]->getNin());
1284  fprintf(FOutYFuel, "%d ", STPipe[j]->getNin());
1285  fprintf(FOutYFreshAir, "%d ", STPipe[j]->getNin());
1286  }
1287  fprintf(FOutYBurntGas, "\n%d", (int)((thmax - grmax) / agincr));
1288  fprintf(FOutYFuel, "\n%d", (int)((thmax - grmax) / agincr));
1289  fprintf(FOutYFreshAir, "\n%d", (int)((thmax - grmax) / agincr));
1290 
1291  } else if(SpeciesNumber == 9) {
1292  fprintf(FOutYO2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1293  fprintf(FOutYCO2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1294  fprintf(FOutYH2O, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1295  fprintf(FOutYHC, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1296  fprintf(FOutYSoot, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1297  fprintf(FOutYNOx, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1298  fprintf(FOutYCO, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1299  fprintf(FOutYN2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1300  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1301  fprintf(FOutYO2, "%d ", STCylinder[j]->getNumeroCilindro());
1302  fprintf(FOutYCO2, "%d ", STCylinder[j]->getNumeroCilindro());
1303  fprintf(FOutYH2O, "%d ", STCylinder[j]->getNumeroCilindro());
1304  fprintf(FOutYHC, "%d ", STCylinder[j]->getNumeroCilindro());
1305  fprintf(FOutYSoot, "%d ", STCylinder[j]->getNumeroCilindro());
1306  fprintf(FOutYNOx, "%d ", STCylinder[j]->getNumeroCilindro());
1307  fprintf(FOutYCO, "%d ", STCylinder[j]->getNumeroCilindro());
1308  fprintf(FOutYN2, "%d ", STCylinder[j]->getNumeroCilindro());
1309  }
1310  fprintf(FOutYO2, "\n");
1311  fprintf(FOutYCO2, "\n");
1312  fprintf(FOutYH2O, "\n");
1313  fprintf(FOutYHC, "\n");
1314  fprintf(FOutYSoot, "\n");
1315  fprintf(FOutYNOx, "\n");
1316  fprintf(FOutYCO, "\n");
1317  fprintf(FOutYN2, "\n");
1318  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1319  fprintf(FOutYO2, "%d ", STPlenum[j]->getNumeroDeposito());
1320  fprintf(FOutYCO2, "%d ", STPlenum[j]->getNumeroDeposito());
1321  fprintf(FOutYH2O, "%d ", STPlenum[j]->getNumeroDeposito());
1322  fprintf(FOutYHC, "%d ", STPlenum[j]->getNumeroDeposito());
1323  fprintf(FOutYSoot, "%d ", STPlenum[j]->getNumeroDeposito());
1324  fprintf(FOutYNOx, "%d ", STPlenum[j]->getNumeroDeposito());
1325  fprintf(FOutYCO, "%d ", STPlenum[j]->getNumeroDeposito());
1326  fprintf(FOutYN2, "%d ", STPlenum[j]->getNumeroDeposito());
1327  }
1328  fprintf(FOutYO2, "\n");
1329  fprintf(FOutYCO2, "\n");
1330  fprintf(FOutYH2O, "\n");
1331  fprintf(FOutYHC, "\n");
1332  fprintf(FOutYSoot, "\n");
1333  fprintf(FOutYNOx, "\n");
1334  fprintf(FOutYCO, "\n");
1335  fprintf(FOutYN2, "\n");
1336  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1337  fprintf(FOutYO2, "%d ", STPipe[j]->getNumeroTubo());
1338  fprintf(FOutYCO2, "%d ", STPipe[j]->getNumeroTubo());
1339  fprintf(FOutYH2O, "%d ", STPipe[j]->getNumeroTubo());
1340  fprintf(FOutYHC, "%d ", STPipe[j]->getNumeroTubo());
1341  fprintf(FOutYSoot, "%d ", STPipe[j]->getNumeroTubo());
1342  fprintf(FOutYNOx, "%d ", STPipe[j]->getNumeroTubo());
1343  fprintf(FOutYCO, "%d ", STPipe[j]->getNumeroTubo());
1344  fprintf(FOutYN2, "%d ", STPipe[j]->getNumeroTubo());
1345  }
1346  fprintf(FOutYO2, "\n");
1347  fprintf(FOutYCO2, "\n");
1348  fprintf(FOutYH2O, "\n");
1349  fprintf(FOutYHC, "\n");
1350  fprintf(FOutYSoot, "\n");
1351  fprintf(FOutYNOx, "\n");
1352  fprintf(FOutYCO, "\n");
1353  fprintf(FOutYN2, "\n");
1354  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1355  fprintf(FOutYO2, "%d ", STPipe[j]->getNin());
1356  fprintf(FOutYCO2, "%d ", STPipe[j]->getNin());
1357  fprintf(FOutYH2O, "%d ", STPipe[j]->getNin());
1358  fprintf(FOutYHC, "%d ", STPipe[j]->getNin());
1359  fprintf(FOutYSoot, "%d ", STPipe[j]->getNin());
1360  fprintf(FOutYNOx, "%d ", STPipe[j]->getNin());
1361  fprintf(FOutYCO, "%d ", STPipe[j]->getNin());
1362  fprintf(FOutYN2, "%d ", STPipe[j]->getNin());
1363  }
1364  fprintf(FOutYO2, "\n%d", (int)((thmax - grmax) / agincr));
1365  fprintf(FOutYCO2, "\n%d", (int)((thmax - grmax) / agincr));
1366  fprintf(FOutYH2O, "\n%d", (int)((thmax - grmax) / agincr));
1367  fprintf(FOutYHC, "\n%d", (int)((thmax - grmax) / agincr));
1368  fprintf(FOutYSoot, "\n%d", (int)((thmax - grmax) / agincr));
1369  fprintf(FOutYNOx, "\n%d", (int)((thmax - grmax) / agincr));
1370  fprintf(FOutYCO, "\n%d", (int)((thmax - grmax) / agincr));
1371  fprintf(FOutYN2, "\n%d", (int)((thmax - grmax) / agincr));
1372 
1373  } else if(SpeciesNumber == 10) {
1374  fprintf(FOutYO2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1375  fprintf(FOutYCO2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1376  fprintf(FOutYH2O, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1377  fprintf(FOutYHC, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1378  fprintf(FOutYSoot, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1379  fprintf(FOutYNOx, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1380  fprintf(FOutYCO, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1381  fprintf(FOutYFuel, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1382  fprintf(FOutYN2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1383  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1384  fprintf(FOutYO2, "%d ", STCylinder[j]->getNumeroCilindro());
1385  fprintf(FOutYCO2, "%d ", STCylinder[j]->getNumeroCilindro());
1386  fprintf(FOutYH2O, "%d ", STCylinder[j]->getNumeroCilindro());
1387  fprintf(FOutYHC, "%d ", STCylinder[j]->getNumeroCilindro());
1388  fprintf(FOutYSoot, "%d ", STCylinder[j]->getNumeroCilindro());
1389  fprintf(FOutYNOx, "%d ", STCylinder[j]->getNumeroCilindro());
1390  fprintf(FOutYCO, "%d ", STCylinder[j]->getNumeroCilindro());
1391  fprintf(FOutYFuel, "%d ", STCylinder[j]->getNumeroCilindro());
1392  fprintf(FOutYN2, "%d ", STCylinder[j]->getNumeroCilindro());
1393  }
1394  fprintf(FOutYO2, "\n");
1395  fprintf(FOutYCO2, "\n");
1396  fprintf(FOutYH2O, "\n");
1397  fprintf(FOutYHC, "\n");
1398  fprintf(FOutYSoot, "\n");
1399  fprintf(FOutYNOx, "\n");
1400  fprintf(FOutYCO, "\n");
1401  fprintf(FOutYFuel, "\n");
1402  fprintf(FOutYN2, "\n");
1403  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1404  fprintf(FOutYO2, "%d ", STPlenum[j]->getNumeroDeposito());
1405  fprintf(FOutYCO2, "%d ", STPlenum[j]->getNumeroDeposito());
1406  fprintf(FOutYH2O, "%d ", STPlenum[j]->getNumeroDeposito());
1407  fprintf(FOutYHC, "%d ", STPlenum[j]->getNumeroDeposito());
1408  fprintf(FOutYSoot, "%d ", STPlenum[j]->getNumeroDeposito());
1409  fprintf(FOutYNOx, "%d ", STPlenum[j]->getNumeroDeposito());
1410  fprintf(FOutYCO, "%d ", STPlenum[j]->getNumeroDeposito());
1411  fprintf(FOutYFuel, "%d ", STPlenum[j]->getNumeroDeposito());
1412  fprintf(FOutYN2, "%d ", STPlenum[j]->getNumeroDeposito());
1413  }
1414  fprintf(FOutYO2, "\n");
1415  fprintf(FOutYCO2, "\n");
1416  fprintf(FOutYH2O, "\n");
1417  fprintf(FOutYHC, "\n");
1418  fprintf(FOutYSoot, "\n");
1419  fprintf(FOutYNOx, "\n");
1420  fprintf(FOutYCO, "\n");
1421  fprintf(FOutYFuel, "\n");
1422  fprintf(FOutYN2, "\n");
1423  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1424  fprintf(FOutYO2, "%d ", STPipe[j]->getNumeroTubo());
1425  fprintf(FOutYCO2, "%d ", STPipe[j]->getNumeroTubo());
1426  fprintf(FOutYH2O, "%d ", STPipe[j]->getNumeroTubo());
1427  fprintf(FOutYHC, "%d ", STPipe[j]->getNumeroTubo());
1428  fprintf(FOutYSoot, "%d ", STPipe[j]->getNumeroTubo());
1429  fprintf(FOutYNOx, "%d ", STPipe[j]->getNumeroTubo());
1430  fprintf(FOutYCO, "%d ", STPipe[j]->getNumeroTubo());
1431  fprintf(FOutYFuel, "%d ", STPipe[j]->getNumeroTubo());
1432  fprintf(FOutYN2, "%d ", STPipe[j]->getNumeroTubo());
1433  }
1434  fprintf(FOutYO2, "\n");
1435  fprintf(FOutYCO2, "\n");
1436  fprintf(FOutYH2O, "\n");
1437  fprintf(FOutYHC, "\n");
1438  fprintf(FOutYSoot, "\n");
1439  fprintf(FOutYNOx, "\n");
1440  fprintf(FOutYCO, "\n");
1441  fprintf(FOutYFuel, "\n");
1442  fprintf(FOutYN2, "\n");
1443  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1444  fprintf(FOutYO2, "%d ", STPipe[j]->getNin());
1445  fprintf(FOutYCO2, "%d ", STPipe[j]->getNin());
1446  fprintf(FOutYH2O, "%d ", STPipe[j]->getNin());
1447  fprintf(FOutYHC, "%d ", STPipe[j]->getNin());
1448  fprintf(FOutYSoot, "%d ", STPipe[j]->getNin());
1449  fprintf(FOutYNOx, "%d ", STPipe[j]->getNin());
1450  fprintf(FOutYCO, "%d ", STPipe[j]->getNin());
1451  fprintf(FOutYFuel, "%d ", STPipe[j]->getNin());
1452  fprintf(FOutYN2, "%d ", STPipe[j]->getNin());
1453  }
1454  fprintf(FOutYO2, "\n%d", (int)((thmax - grmax) / agincr));
1455  fprintf(FOutYCO2, "\n%d", (int)((thmax - grmax) / agincr));
1456  fprintf(FOutYH2O, "\n%d", (int)((thmax - grmax) / agincr));
1457  fprintf(FOutYHC, "\n%d", (int)((thmax - grmax) / agincr));
1458  fprintf(FOutYSoot, "\n%d", (int)((thmax - grmax) / agincr));
1459  fprintf(FOutYNOx, "\n%d", (int)((thmax - grmax) / agincr));
1460  fprintf(FOutYCO, "\n%d", (int)((thmax - grmax) / agincr));
1461  fprintf(FOutYFuel, "\n%d", (int)((thmax - grmax) / agincr));
1462  fprintf(FOutYN2, "\n%d", (int)((thmax - grmax) / agincr));
1463  }
1464  break;
1465  case 5: // GASTO MASICO DE ESPECIES
1466  if(SpeciesNumber == 3) {
1467  fprintf(FOutFlowBurntGas, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1468  fprintf(FOutFlowFreshAir, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1469  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1470  fprintf(FOutFlowBurntGas, "%d ", STCylinder[j]->getNumeroCilindro());
1471  fprintf(FOutFlowFreshAir, "%d ", STCylinder[j]->getNumeroCilindro());
1472  }
1473  fprintf(FOutFlowBurntGas, "\n");
1474  fprintf(FOutFlowFreshAir, "\n");
1475  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1476  fprintf(FOutFlowBurntGas, "%d ", STPlenum[j]->getNumeroDeposito());
1477  fprintf(FOutFlowFreshAir, "%d ", STPlenum[j]->getNumeroDeposito());
1478  }
1479  fprintf(FOutFlowBurntGas, "\n");
1480  fprintf(FOutFlowFreshAir, "\n");
1481  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1482  fprintf(FOutFlowBurntGas, "%d ", STPipe[j]->getNumeroTubo());
1483  fprintf(FOutFlowFreshAir, "%d ", STPipe[j]->getNumeroTubo());
1484  }
1485  fprintf(FOutFlowBurntGas, "\n");
1486  fprintf(FOutFlowFreshAir, "\n");
1487  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1488  fprintf(FOutFlowBurntGas, "%d ", STPipe[j]->getNin());
1489  fprintf(FOutFlowFreshAir, "%d ", STPipe[j]->getNin());
1490  }
1491  fprintf(FOutFlowBurntGas, "\n%d", (int)((thmax - grmax) / agincr));
1492  fprintf(FOutFlowFreshAir, "\n%d", (int)((thmax - grmax) / agincr));
1493 
1494  } else if(SpeciesNumber == 4) {
1495  fprintf(FOutFlowBurntGas, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1496  fprintf(FOutFlowFuel, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1497  fprintf(FOutFlowFreshAir, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1498  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1499  fprintf(FOutFlowBurntGas, "%d ", STCylinder[j]->getNumeroCilindro());
1500  fprintf(FOutFlowFuel, "%d ", STCylinder[j]->getNumeroCilindro());
1501  fprintf(FOutFlowFreshAir, "%d ", STCylinder[j]->getNumeroCilindro());
1502  }
1503  fprintf(FOutFlowBurntGas, "\n");
1504  fprintf(FOutFlowFuel, "\n");
1505  fprintf(FOutFlowFreshAir, "\n");
1506  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1507  fprintf(FOutFlowBurntGas, "%d ", STPlenum[j]->getNumeroDeposito());
1508  fprintf(FOutFlowFuel, "%d ", STPlenum[j]->getNumeroDeposito());
1509  fprintf(FOutFlowFreshAir, "%d ", STPlenum[j]->getNumeroDeposito());
1510  }
1511  fprintf(FOutFlowBurntGas, "\n");
1512  fprintf(FOutFlowFuel, "\n");
1513  fprintf(FOutFlowFreshAir, "\n");
1514  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1515  fprintf(FOutFlowBurntGas, "%d ", STPipe[j]->getNumeroTubo());
1516  fprintf(FOutFlowFuel, "%d ", STPipe[j]->getNumeroTubo());
1517  fprintf(FOutFlowFreshAir, "%d ", STPipe[j]->getNumeroTubo());
1518  }
1519  fprintf(FOutFlowBurntGas, "\n");
1520  fprintf(FOutFlowFuel, "\n");
1521  fprintf(FOutFlowFreshAir, "\n");
1522  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1523  fprintf(FOutFlowBurntGas, "%d ", STPipe[j]->getNin());
1524  fprintf(FOutFlowFuel, "%d ", STPipe[j]->getNin());
1525  fprintf(FOutFlowFreshAir, "%d ", STPipe[j]->getNin());
1526  }
1527  fprintf(FOutFlowBurntGas, "\n%d", (int)((thmax - grmax) / agincr));
1528  fprintf(FOutFlowFuel, "\n%d", (int)((thmax - grmax) / agincr));
1529  fprintf(FOutFlowFreshAir, "\n%d", (int)((thmax - grmax) / agincr));
1530 
1531  } else if(SpeciesNumber == 9) {
1532  fprintf(FOutFlowO2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1533  fprintf(FOutFlowCO2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1534  fprintf(FOutFlowH2O, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1535  fprintf(FOutFlowHC, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1536  fprintf(FOutFlowSoot, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1537  fprintf(FOutFlowNOx, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1538  fprintf(FOutFlowCO, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1539  fprintf(FOutFlowN2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1540  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1541  fprintf(FOutFlowO2, "%d ", STCylinder[j]->getNumeroCilindro());
1542  fprintf(FOutFlowCO2, "%d ", STCylinder[j]->getNumeroCilindro());
1543  fprintf(FOutFlowH2O, "%d ", STCylinder[j]->getNumeroCilindro());
1544  fprintf(FOutFlowHC, "%d ", STCylinder[j]->getNumeroCilindro());
1545  fprintf(FOutFlowSoot, "%d ", STCylinder[j]->getNumeroCilindro());
1546  fprintf(FOutFlowNOx, "%d ", STCylinder[j]->getNumeroCilindro());
1547  fprintf(FOutFlowCO, "%d ", STCylinder[j]->getNumeroCilindro());
1548  fprintf(FOutFlowN2, "%d ", STCylinder[j]->getNumeroCilindro());
1549  }
1550  fprintf(FOutFlowO2, "\n");
1551  fprintf(FOutFlowCO2, "\n");
1552  fprintf(FOutFlowH2O, "\n");
1553  fprintf(FOutFlowHC, "\n");
1554  fprintf(FOutFlowSoot, "\n");
1555  fprintf(FOutFlowNOx, "\n");
1556  fprintf(FOutFlowCO, "\n");
1557  fprintf(FOutFlowN2, "\n");
1558  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1559  fprintf(FOutFlowO2, "%d ", STPlenum[j]->getNumeroDeposito());
1560  fprintf(FOutFlowCO2, "%d ", STPlenum[j]->getNumeroDeposito());
1561  fprintf(FOutFlowH2O, "%d ", STPlenum[j]->getNumeroDeposito());
1562  fprintf(FOutFlowHC, "%d ", STPlenum[j]->getNumeroDeposito());
1563  fprintf(FOutFlowSoot, "%d ", STPlenum[j]->getNumeroDeposito());
1564  fprintf(FOutFlowNOx, "%d ", STPlenum[j]->getNumeroDeposito());
1565  fprintf(FOutFlowCO, "%d ", STPlenum[j]->getNumeroDeposito());
1566  fprintf(FOutFlowN2, "%d ", STPlenum[j]->getNumeroDeposito());
1567  }
1568  fprintf(FOutFlowO2, "\n");
1569  fprintf(FOutFlowCO2, "\n");
1570  fprintf(FOutFlowH2O, "\n");
1571  fprintf(FOutFlowHC, "\n");
1572  fprintf(FOutFlowSoot, "\n");
1573  fprintf(FOutFlowNOx, "\n");
1574  fprintf(FOutFlowCO, "\n");
1575  fprintf(FOutFlowN2, "\n");
1576  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1577  fprintf(FOutFlowO2, "%d ", STPipe[j]->getNumeroTubo());
1578  fprintf(FOutFlowCO2, "%d ", STPipe[j]->getNumeroTubo());
1579  fprintf(FOutFlowH2O, "%d ", STPipe[j]->getNumeroTubo());
1580  fprintf(FOutFlowHC, "%d ", STPipe[j]->getNumeroTubo());
1581  fprintf(FOutFlowSoot, "%d ", STPipe[j]->getNumeroTubo());
1582  fprintf(FOutFlowNOx, "%d ", STPipe[j]->getNumeroTubo());
1583  fprintf(FOutFlowCO, "%d ", STPipe[j]->getNumeroTubo());
1584  fprintf(FOutFlowN2, "%d ", STPipe[j]->getNumeroTubo());
1585  }
1586  fprintf(FOutFlowO2, "\n");
1587  fprintf(FOutFlowCO2, "\n");
1588  fprintf(FOutFlowH2O, "\n");
1589  fprintf(FOutFlowHC, "\n");
1590  fprintf(FOutFlowSoot, "\n");
1591  fprintf(FOutFlowNOx, "\n");
1592  fprintf(FOutFlowCO, "\n");
1593  fprintf(FOutFlowN2, "\n");
1594  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1595  fprintf(FOutFlowO2, "%d ", STPipe[j]->getNin());
1596  fprintf(FOutFlowCO2, "%d ", STPipe[j]->getNin());
1597  fprintf(FOutFlowH2O, "%d ", STPipe[j]->getNin());
1598  fprintf(FOutFlowHC, "%d ", STPipe[j]->getNin());
1599  fprintf(FOutFlowSoot, "%d ", STPipe[j]->getNin());
1600  fprintf(FOutFlowNOx, "%d ", STPipe[j]->getNin());
1601  fprintf(FOutFlowCO, "%d ", STPipe[j]->getNin());
1602  fprintf(FOutFlowN2, "%d ", STPipe[j]->getNin());
1603  }
1604  fprintf(FOutFlowO2, "\n%d", (int)((thmax - grmax) / agincr));
1605  fprintf(FOutFlowCO2, "\n%d", (int)((thmax - grmax) / agincr));
1606  fprintf(FOutFlowH2O, "\n%d", (int)((thmax - grmax) / agincr));
1607  fprintf(FOutFlowHC, "\n%d", (int)((thmax - grmax) / agincr));
1608  fprintf(FOutFlowSoot, "\n%d", (int)((thmax - grmax) / agincr));
1609  fprintf(FOutFlowNOx, "\n%d", (int)((thmax - grmax) / agincr));
1610  fprintf(FOutFlowCO, "\n%d", (int)((thmax - grmax) / agincr));
1611  fprintf(FOutFlowN2, "\n%d", (int)((thmax - grmax) / agincr));
1612 
1613  } else if(SpeciesNumber == 10) {
1614  fprintf(FOutFlowO2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1615  fprintf(FOutFlowCO2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1616  fprintf(FOutFlowH2O, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1617  fprintf(FOutFlowHC, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1618  fprintf(FOutFlowSoot, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1619  fprintf(FOutFlowNOx, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1620  fprintf(FOutFlowCO, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1621  fprintf(FOutFlowFuel, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1622  fprintf(FOutFlowN2, "%d %d %d\n", STCylinder.size(), STPlenum.size(), STPipe.size());
1623  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1624  fprintf(FOutFlowO2, "%d ", STCylinder[j]->getNumeroCilindro());
1625  fprintf(FOutFlowCO2, "%d ", STCylinder[j]->getNumeroCilindro());
1626  fprintf(FOutFlowH2O, "%d ", STCylinder[j]->getNumeroCilindro());
1627  fprintf(FOutFlowHC, "%d ", STCylinder[j]->getNumeroCilindro());
1628  fprintf(FOutFlowSoot, "%d ", STCylinder[j]->getNumeroCilindro());
1629  fprintf(FOutFlowNOx, "%d ", STCylinder[j]->getNumeroCilindro());
1630  fprintf(FOutFlowCO, "%d ", STCylinder[j]->getNumeroCilindro());
1631  fprintf(FOutFlowFuel, "%d ", STCylinder[j]->getNumeroCilindro());
1632  fprintf(FOutFlowN2, "%d ", STCylinder[j]->getNumeroCilindro());
1633  }
1634  fprintf(FOutFlowO2, "\n");
1635  fprintf(FOutFlowCO2, "\n");
1636  fprintf(FOutFlowH2O, "\n");
1637  fprintf(FOutFlowHC, "\n");
1638  fprintf(FOutFlowSoot, "\n");
1639  fprintf(FOutFlowNOx, "\n");
1640  fprintf(FOutFlowCO, "\n");
1641  fprintf(FOutFlowFuel, "\n");
1642  fprintf(FOutFlowN2, "\n");
1643  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1644  fprintf(FOutFlowO2, "%d ", STPlenum[j]->getNumeroDeposito());
1645  fprintf(FOutFlowCO2, "%d ", STPlenum[j]->getNumeroDeposito());
1646  fprintf(FOutFlowH2O, "%d ", STPlenum[j]->getNumeroDeposito());
1647  fprintf(FOutFlowHC, "%d ", STPlenum[j]->getNumeroDeposito());
1648  fprintf(FOutFlowSoot, "%d ", STPlenum[j]->getNumeroDeposito());
1649  fprintf(FOutFlowNOx, "%d ", STPlenum[j]->getNumeroDeposito());
1650  fprintf(FOutFlowCO, "%d ", STPlenum[j]->getNumeroDeposito());
1651  fprintf(FOutFlowFuel, "%d ", STPlenum[j]->getNumeroDeposito());
1652  fprintf(FOutFlowN2, "%d ", STPlenum[j]->getNumeroDeposito());
1653  }
1654  fprintf(FOutFlowO2, "\n");
1655  fprintf(FOutFlowCO2, "\n");
1656  fprintf(FOutFlowH2O, "\n");
1657  fprintf(FOutFlowHC, "\n");
1658  fprintf(FOutFlowSoot, "\n");
1659  fprintf(FOutFlowNOx, "\n");
1660  fprintf(FOutFlowCO, "\n");
1661  fprintf(FOutFlowFuel, "\n");
1662  fprintf(FOutFlowN2, "\n");
1663  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1664  fprintf(FOutFlowO2, "%d ", STPipe[j]->getNumeroTubo());
1665  fprintf(FOutFlowCO2, "%d ", STPipe[j]->getNumeroTubo());
1666  fprintf(FOutFlowH2O, "%d ", STPipe[j]->getNumeroTubo());
1667  fprintf(FOutFlowHC, "%d ", STPipe[j]->getNumeroTubo());
1668  fprintf(FOutFlowSoot, "%d ", STPipe[j]->getNumeroTubo());
1669  fprintf(FOutFlowNOx, "%d ", STPipe[j]->getNumeroTubo());
1670  fprintf(FOutFlowCO, "%d ", STPipe[j]->getNumeroTubo());
1671  fprintf(FOutFlowFuel, "%d ", STPipe[j]->getNumeroTubo());
1672  fprintf(FOutFlowN2, "%d ", STPipe[j]->getNumeroTubo());
1673  }
1674  fprintf(FOutFlowO2, "\n");
1675  fprintf(FOutFlowCO2, "\n");
1676  fprintf(FOutFlowH2O, "\n");
1677  fprintf(FOutFlowHC, "\n");
1678  fprintf(FOutFlowSoot, "\n");
1679  fprintf(FOutFlowNOx, "\n");
1680  fprintf(FOutFlowCO, "\n");
1681  fprintf(FOutFlowFuel, "\n");
1682  fprintf(FOutFlowN2, "\n");
1683  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1684  fprintf(FOutFlowO2, "%d ", STPipe[j]->getNin());
1685  fprintf(FOutFlowCO2, "%d ", STPipe[j]->getNin());
1686  fprintf(FOutFlowH2O, "%d ", STPipe[j]->getNin());
1687  fprintf(FOutFlowHC, "%d ", STPipe[j]->getNin());
1688  fprintf(FOutFlowSoot, "%d ", STPipe[j]->getNin());
1689  fprintf(FOutFlowNOx, "%d ", STPipe[j]->getNin());
1690  fprintf(FOutFlowCO, "%d ", STPipe[j]->getNin());
1691  fprintf(FOutFlowFuel, "%d ", STPipe[j]->getNin());
1692  fprintf(FOutFlowN2, "%d ", STPipe[j]->getNin());
1693  }
1694  fprintf(FOutFlowO2, "\n%d", (int)((thmax - grmax) / agincr));
1695  fprintf(FOutFlowCO2, "\n%d", (int)((thmax - grmax) / agincr));
1696  fprintf(FOutFlowH2O, "\n%d", (int)((thmax - grmax) / agincr));
1697  fprintf(FOutFlowHC, "\n%d", (int)((thmax - grmax) / agincr));
1698  fprintf(FOutFlowSoot, "\n%d", (int)((thmax - grmax) / agincr));
1699  fprintf(FOutFlowNOx, "\n%d", (int)((thmax - grmax) / agincr));
1700  fprintf(FOutFlowCO, "\n%d", (int)((thmax - grmax) / agincr));
1701  fprintf(FOutFlowFuel, "\n%d", (int)((thmax - grmax) / agincr));
1702  fprintf(FOutFlowN2, "\n%d", (int)((thmax - grmax) / agincr));
1703  }
1704  break;
1705  }
1706  }
1707 }
1708 
1709 void TOutputResults::PrintSpaceTimeResults(bool EngineBlock, double Theta, double SimulationDuration,
1710  TBloqueMotor **Engine, int SpeciesNumber)
1711 
1712 {
1713 
1714  if(FWriteSpaceTime) {
1715  float pasafloat = 0.;
1716  double m = 0., RegimenFicticio = 0.;
1717 
1718  if(EngineBlock) {
1719  m = floor(Theta / Engine[0]->getAngTotalCiclo());
1720  pasafloat = (float)(Theta - (m * Engine[0]->getAngTotalCiclo()));
1721  } else {
1722  RegimenFicticio = 720. / 6. / SimulationDuration;
1723  m = floor(Theta / 720.);
1724  pasafloat = (float)(Theta - (m * 720.));
1725  pasafloat = pasafloat / 6. / RegimenFicticio;
1726  }
1727  for(unsigned int i = 0; i < FParameterSpaceTime.size(); ++i) {
1728  switch(FParameterSpaceTime[i]) {
1729  case 0:
1730  fprintf(FileOutPressure, "\n%g", pasafloat);
1731  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1732  fprintf(FileOutPressure, " %g", STCylinder[j]->getPressure());
1733  }
1734  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1735  fprintf(FileOutPressure, " %g", STPlenum[j]->getPressure());
1736  }
1737  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1738  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1739  fprintf(FileOutPressure, " %g", STPipe[j]->GetPresion(k));
1740  }
1741  }
1742  break;
1743  case 1:
1744  fprintf(FileOutTemp, "\n%g", pasafloat);
1745  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1746  fprintf(FileOutTemp, " %g", STCylinder[j]->getTemperature());
1747  }
1748  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1749  fprintf(FileOutTemp, " %g", STPlenum[j]->getTemperature());
1750  }
1751  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1752  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1753  double temp = __units::KTodegC(pow2(STPipe[j]->GetAsonido(k) * __cons::ARef) / (STPipe[j]->GetGamma(
1754  k) * STPipe[j]->GetRMezcla(k)));
1755  fprintf(FileOutTemp, " %g", temp);
1756  }
1757  }
1758  break;
1759  case 2:
1760  fprintf(FileOutVel, "\n%g", pasafloat);
1761  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1762  fprintf(FileOutVel, " %g", 0.0);
1763  }
1764  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1765  fprintf(FileOutVel, " %g", 0.0);
1766  }
1767  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1768  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1769  double vel = STPipe[j]->GetVelocidad(k) * __cons::ARef;
1770  fprintf(FileOutVel, " %g", vel);
1771  }
1772  }
1773  break;
1774  case 3:
1775  fprintf(FileOutFlow, "\n%g", pasafloat);
1776  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1777  fprintf(FileOutFlow, " %g", 0.0);
1778  }
1779  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1780  fprintf(FileOutFlow, " %g", 0.0);
1781  }
1782  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1783  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1784  if(STPipe[j]->getFormulacionLeyes() == nmConArea) {
1785  fprintf(FileOutFlow, " %g", STPipe[j]->GetU0(1, k));
1786  } else {
1787  double massflow = __units::BarToPa(STPipe[j]->GetPresion(k)) / pow2(STPipe[j]->GetAsonido(
1788  k) * __cons::ARef) * STPipe[j]->GetGamma(k) * STPipe[j]->GetVelocidad(k) * __cons::ARef * __geom::Circle_area(
1789  STPipe[j]->GetDiametro(k));
1790  fprintf(FileOutFlow, " %g", massflow);
1791  }
1792  }
1793  }
1794  break;
1795  case 4:
1796  if(SpeciesNumber == 3) {
1797  fprintf(FOutYBurntGas, "\n%g", pasafloat);
1798  fprintf(FOutYFreshAir, "\n%g", pasafloat);
1799  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1800  fprintf(FOutYBurntGas, " %g", STCylinder[j]->GetFraccionMasicaEspecie(0));
1801  fprintf(FOutYFreshAir, " %g", STCylinder[j]->GetFraccionMasicaEspecie(1));
1802  }
1803  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1804  fprintf(FOutYBurntGas, " %g", STPlenum[j]->GetFraccionMasicaEspecie(0));
1805  fprintf(FOutYFreshAir, " %g", STPlenum[j]->GetFraccionMasicaEspecie(1));
1806  }
1807  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1808  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1809  fprintf(FOutYBurntGas, " %g", STPipe[j]->GetFraccionMasica(k, 0));
1810  fprintf(FOutYFreshAir, " %g", STPipe[j]->GetFraccionMasica(k, 1));
1811  }
1812  }
1813 
1814  } else if(SpeciesNumber == 4) {
1815  fprintf(FOutYBurntGas, "\n%g", pasafloat);
1816  fprintf(FOutYFuel, "\n%g", pasafloat);
1817  fprintf(FOutYFreshAir, "\n%g", pasafloat);
1818  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1819  fprintf(FOutYBurntGas, " %g", STCylinder[j]->GetFraccionMasicaEspecie(0));
1820  fprintf(FOutYFuel, " %g", STCylinder[j]->GetFraccionMasicaEspecie(1));
1821  fprintf(FOutYFreshAir, " %g", STCylinder[j]->GetFraccionMasicaEspecie(2));
1822  }
1823  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1824  fprintf(FOutYBurntGas, " %g", STPlenum[j]->GetFraccionMasicaEspecie(0));
1825  fprintf(FOutYFuel, " %g", STPlenum[j]->GetFraccionMasicaEspecie(1));
1826  fprintf(FOutYFreshAir, " %g", STPlenum[j]->GetFraccionMasicaEspecie(2));
1827  }
1828  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1829  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1830  fprintf(FOutYBurntGas, " %g", STPipe[j]->GetFraccionMasica(k, 0));
1831  fprintf(FOutYFuel, " %g", STPipe[j]->GetFraccionMasica(k, 1));
1832  fprintf(FOutYFreshAir, " %g", STPipe[j]->GetFraccionMasica(k, 2));
1833  }
1834  }
1835 
1836  } else if(SpeciesNumber == 9) {
1837  fprintf(FOutYO2, "\n%g", pasafloat);
1838  fprintf(FOutYCO2, "\n%g", pasafloat);
1839  fprintf(FOutYH2O, "\n%g", pasafloat);
1840  fprintf(FOutYHC, "\n%g", pasafloat);
1841  fprintf(FOutYSoot, "\n%g", pasafloat);
1842  fprintf(FOutYNOx, "\n%g", pasafloat);
1843  fprintf(FOutYCO, "\n%g", pasafloat);
1844  fprintf(FOutYN2, "\n%g", pasafloat);
1845  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1846  fprintf(FOutYO2, " %g", STCylinder[j]->GetFraccionMasicaEspecie(0));
1847  fprintf(FOutYCO2, " %g", STCylinder[j]->GetFraccionMasicaEspecie(1));
1848  fprintf(FOutYH2O, " %g", STCylinder[j]->GetFraccionMasicaEspecie(2));
1849  fprintf(FOutYHC, " %g", STCylinder[j]->GetFraccionMasicaEspecie(3));
1850  fprintf(FOutYSoot, " %g", STCylinder[j]->GetFraccionMasicaEspecie(4));
1851  fprintf(FOutYNOx, " %g", STCylinder[j]->GetFraccionMasicaEspecie(5));
1852  fprintf(FOutYCO, " %g", STCylinder[j]->GetFraccionMasicaEspecie(6));
1853  fprintf(FOutYN2, " %g", STCylinder[j]->GetFraccionMasicaEspecie(7));
1854  }
1855  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1856  fprintf(FOutYO2, " %g", STPlenum[j]->GetFraccionMasicaEspecie(0));
1857  fprintf(FOutYCO2, " %g", STPlenum[j]->GetFraccionMasicaEspecie(1));
1858  fprintf(FOutYH2O, " %g", STPlenum[j]->GetFraccionMasicaEspecie(2));
1859  fprintf(FOutYHC, " %g", STPlenum[j]->GetFraccionMasicaEspecie(3));
1860  fprintf(FOutYSoot, " %g", STPlenum[j]->GetFraccionMasicaEspecie(4));
1861  fprintf(FOutYNOx, " %g", STPlenum[j]->GetFraccionMasicaEspecie(5));
1862  fprintf(FOutYCO, " %g", STPlenum[j]->GetFraccionMasicaEspecie(6));
1863  fprintf(FOutYN2, " %g", STPlenum[j]->GetFraccionMasicaEspecie(7));
1864  }
1865  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1866  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1867  fprintf(FOutYO2, " %g", STPipe[j]->GetFraccionMasica(k, 0));
1868  fprintf(FOutYCO2, " %g", STPipe[j]->GetFraccionMasica(k, 1));
1869  fprintf(FOutYH2O, " %g", STPipe[j]->GetFraccionMasica(k, 2));
1870  fprintf(FOutYHC, " %g", STPipe[j]->GetFraccionMasica(k, 3));
1871  fprintf(FOutYSoot, " %g", STPipe[j]->GetFraccionMasica(k, 4));
1872  fprintf(FOutYNOx, " %g", STPipe[j]->GetFraccionMasica(k, 5));
1873  fprintf(FOutYCO, " %g", STPipe[j]->GetFraccionMasica(k, 6));
1874  fprintf(FOutYN2, " %g", STPipe[j]->GetFraccionMasica(k, 7));
1875  }
1876  }
1877 
1878  } else if(SpeciesNumber == 10) {
1879  fprintf(FOutYO2, "\n%g", pasafloat);
1880  fprintf(FOutYCO2, "\n%g", pasafloat);
1881  fprintf(FOutYH2O, "\n%g", pasafloat);
1882  fprintf(FOutYHC, "\n%g", pasafloat);
1883  fprintf(FOutYSoot, "\n%g", pasafloat);
1884  fprintf(FOutYNOx, "\n%g", pasafloat);
1885  fprintf(FOutYCO, "\n%g", pasafloat);
1886  fprintf(FOutYFuel, "\n%g", pasafloat);
1887  fprintf(FOutYN2, "\n%g", pasafloat);
1888  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1889  fprintf(FOutYO2, " %g", STCylinder[j]->GetFraccionMasicaEspecie(0));
1890  fprintf(FOutYCO2, " %g", STCylinder[j]->GetFraccionMasicaEspecie(1));
1891  fprintf(FOutYH2O, " %g", STCylinder[j]->GetFraccionMasicaEspecie(2));
1892  fprintf(FOutYHC, " %g", STCylinder[j]->GetFraccionMasicaEspecie(3));
1893  fprintf(FOutYSoot, " %g", STCylinder[j]->GetFraccionMasicaEspecie(4));
1894  fprintf(FOutYNOx, " %g", STCylinder[j]->GetFraccionMasicaEspecie(5));
1895  fprintf(FOutYCO, " %g", STCylinder[j]->GetFraccionMasicaEspecie(6));
1896  fprintf(FOutYFuel, " %g", STCylinder[j]->GetFraccionMasicaEspecie(7));
1897  fprintf(FOutYN2, " %g", STCylinder[j]->GetFraccionMasicaEspecie(8));
1898  }
1899  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1900  fprintf(FOutYO2, " %g", STPlenum[j]->GetFraccionMasicaEspecie(0));
1901  fprintf(FOutYCO2, " %g", STPlenum[j]->GetFraccionMasicaEspecie(1));
1902  fprintf(FOutYH2O, " %g", STPlenum[j]->GetFraccionMasicaEspecie(2));
1903  fprintf(FOutYHC, " %g", STPlenum[j]->GetFraccionMasicaEspecie(3));
1904  fprintf(FOutYSoot, " %g", STPlenum[j]->GetFraccionMasicaEspecie(4));
1905  fprintf(FOutYNOx, " %g", STPlenum[j]->GetFraccionMasicaEspecie(5));
1906  fprintf(FOutYCO, " %g", STPlenum[j]->GetFraccionMasicaEspecie(6));
1907  fprintf(FOutYFuel, " %g", STPlenum[j]->GetFraccionMasicaEspecie(7));
1908  fprintf(FOutYN2, " %g", STPlenum[j]->GetFraccionMasicaEspecie(8));
1909  }
1910  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1911  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1912  fprintf(FOutYO2, " %g", STPipe[j]->GetFraccionMasica(k, 0));
1913  fprintf(FOutYCO2, " %g", STPipe[j]->GetFraccionMasica(k, 1));
1914  fprintf(FOutYH2O, " %g", STPipe[j]->GetFraccionMasica(k, 2));
1915  fprintf(FOutYHC, " %g", STPipe[j]->GetFraccionMasica(k, 3));
1916  fprintf(FOutYSoot, " %g", STPipe[j]->GetFraccionMasica(k, 4));
1917  fprintf(FOutYNOx, " %g", STPipe[j]->GetFraccionMasica(k, 5));
1918  fprintf(FOutYCO, " %g", STPipe[j]->GetFraccionMasica(k, 6));
1919  fprintf(FOutYFuel, " %g", STPipe[j]->GetFraccionMasica(k, 7));
1920  fprintf(FOutYN2, " %g", STPipe[j]->GetFraccionMasica(k, 8));
1921  }
1922  }
1923  }
1924  break;
1925  case 5:
1926  double massflow = 0.;
1927  if(SpeciesNumber == 3) {
1928  fprintf(FOutFlowBurntGas, "\n%g", pasafloat);
1929  fprintf(FOutFlowFreshAir, "\n%g", pasafloat);
1930  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1931  fprintf(FOutFlowBurntGas, " %g", 0.0);
1932  fprintf(FOutFlowFreshAir, " %g", 0.0);
1933  }
1934  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1935  fprintf(FOutFlowBurntGas, " %g", 0.0);
1936  fprintf(FOutFlowFreshAir, " %g", 0.0);
1937  }
1938  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1939  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1940  if(STPipe[j]->getFormulacionLeyes() == nmConArea) {
1941  massflow = STPipe[j]->GetU0(1, k);
1942  } else {
1943  massflow = __units::BarToPa(STPipe[j]->GetPresion(k)) / pow2(STPipe[j]->GetAsonido(k) * __cons::ARef) *
1944  STPipe[j]->GetGamma(k) * STPipe[j]->GetVelocidad(k) * __cons::ARef * __geom::Circle_area(
1945  STPipe[j]->GetDiametro(k));
1946  }
1947  fprintf(FOutFlowBurntGas, " %g", STPipe[j]->GetFraccionMasica(k, 0) * massflow);
1948  fprintf(FOutFlowFreshAir, " %g", STPipe[j]->GetFraccionMasica(k, 1) * massflow);
1949  }
1950  }
1951 
1952  } else if(SpeciesNumber == 4) {
1953  fprintf(FOutFlowBurntGas, "\n%g", pasafloat);
1954  fprintf(FOutFlowFuel, "\n%g", pasafloat);
1955  fprintf(FOutFlowFreshAir, "\n%g", pasafloat);
1956  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1957  fprintf(FOutFlowBurntGas, " %g", 0.0);
1958  fprintf(FOutFlowFuel, " %g", 0.0);
1959  fprintf(FOutFlowFreshAir, " %g", 0.0);
1960  }
1961  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
1962  fprintf(FOutFlowBurntGas, " %g", 0.0);
1963  fprintf(FOutFlowFuel, " %g", 0.0);
1964  fprintf(FOutFlowFreshAir, " %g", 0.0);
1965  }
1966  for(unsigned int j = 0; j < STPipe.size(); ++j) {
1967  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
1968  if(STPipe[j]->getFormulacionLeyes() == nmConArea) {
1969  massflow = STPipe[j]->GetU0(1, k);
1970  } else {
1971  massflow = __units::BarToPa(STPipe[j]->GetPresion(k)) / pow2(STPipe[j]->GetAsonido(k) * __cons::ARef) *
1972  STPipe[j]->GetGamma(k) * STPipe[j]->GetVelocidad(k) * __cons::ARef * __geom::Circle_area(
1973  STPipe[j]->GetDiametro(k));
1974  }
1975  fprintf(FOutFlowBurntGas, " %g", STPipe[j]->GetFraccionMasica(k, 0) * massflow);
1976  fprintf(FOutFlowFuel, " %g", STPipe[j]->GetFraccionMasica(k, 1) * massflow);
1977  fprintf(FOutFlowFreshAir, " %g", STPipe[j]->GetFraccionMasica(k, 2) * massflow);
1978  }
1979  }
1980 
1981  } else if(SpeciesNumber == 9) {
1982  fprintf(FOutFlowO2, "\n%g", pasafloat);
1983  fprintf(FOutFlowCO2, "\n%g", pasafloat);
1984  fprintf(FOutFlowH2O, "\n%g", pasafloat);
1985  fprintf(FOutFlowHC, "\n%g", pasafloat);
1986  fprintf(FOutFlowSoot, "\n%g", pasafloat);
1987  fprintf(FOutFlowNOx, "\n%g", pasafloat);
1988  fprintf(FOutFlowCO, "\n%g", pasafloat);
1989  fprintf(FOutFlowN2, "\n%g", pasafloat);
1990  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
1991  fprintf(FOutFlowO2, " %g", 0.0);
1992  fprintf(FOutFlowCO2, " %g", 0.0);
1993  fprintf(FOutFlowH2O, " %g", 0.0);
1994  fprintf(FOutFlowHC, " %g", 0.0);
1995  fprintf(FOutFlowSoot, " %g", 0.0);
1996  fprintf(FOutFlowNOx, " %g", 0.0);
1997  fprintf(FOutFlowCO, " %g", 0.0);
1998  fprintf(FOutFlowN2, " %g", 0.0);
1999  }
2000  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
2001  fprintf(FOutFlowO2, " %g", 0.0);
2002  fprintf(FOutFlowCO2, " %g", 0.0);
2003  fprintf(FOutFlowH2O, " %g", 0.0);
2004  fprintf(FOutFlowHC, " %g", 0.0);
2005  fprintf(FOutFlowSoot, " %g", 0.0);
2006  fprintf(FOutFlowNOx, " %g", 0.0);
2007  fprintf(FOutFlowCO, " %g", 0.0);
2008  fprintf(FOutFlowN2, " %g", 0.0);
2009  }
2010  for(unsigned int j = 0; j < STPipe.size(); ++j) {
2011  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
2012  if(STPipe[j]->getFormulacionLeyes() == nmConArea) {
2013  massflow = STPipe[j]->GetU0(1, k);
2014  } else {
2015  massflow = __units::BarToPa(STPipe[j]->GetPresion(k)) / pow2(STPipe[j]->GetAsonido(k) * __cons::ARef) *
2016  STPipe[j]->GetGamma(k) * STPipe[j]->GetVelocidad(k) * __cons::ARef * __geom::Circle_area(
2017  STPipe[j]->GetDiametro(k));
2018  }
2019  fprintf(FOutFlowO2, " %g", STPipe[j]->GetFraccionMasica(k, 0) * massflow);
2020  fprintf(FOutFlowCO2, " %g", STPipe[j]->GetFraccionMasica(k, 1) * massflow);
2021  fprintf(FOutFlowH2O, " %g", STPipe[j]->GetFraccionMasica(k, 2) * massflow);
2022  fprintf(FOutFlowHC, " %g", STPipe[j]->GetFraccionMasica(k, 3) * massflow);
2023  fprintf(FOutFlowSoot, " %g", STPipe[j]->GetFraccionMasica(k, 4) * massflow);
2024  fprintf(FOutFlowNOx, " %g", STPipe[j]->GetFraccionMasica(k, 5) * massflow);
2025  fprintf(FOutFlowCO, " %g", STPipe[j]->GetFraccionMasica(k, 6) * massflow);
2026  fprintf(FOutFlowN2, " %g", STPipe[j]->GetFraccionMasica(k, 7) * massflow);
2027  }
2028  }
2029 
2030  } else if(SpeciesNumber == 10) {
2031  fprintf(FOutFlowO2, "\n%g", pasafloat);
2032  fprintf(FOutFlowCO2, "\n%g", pasafloat);
2033  fprintf(FOutFlowH2O, "\n%g", pasafloat);
2034  fprintf(FOutFlowHC, "\n%g", pasafloat);
2035  fprintf(FOutFlowSoot, "\n%g", pasafloat);
2036  fprintf(FOutFlowNOx, "\n%g", pasafloat);
2037  fprintf(FOutFlowCO, "\n%g", pasafloat);
2038  fprintf(FOutFlowFuel, "\n%g", pasafloat);
2039  fprintf(FOutFlowN2, "\n%g", pasafloat);
2040  for(unsigned int j = 0; j < STCylinder.size(); ++j) {
2041  fprintf(FOutFlowO2, " %g", 0.0);
2042  fprintf(FOutFlowCO2, " %g", 0.0);
2043  fprintf(FOutFlowH2O, " %g", 0.0);
2044  fprintf(FOutFlowHC, " %g", 0.0);
2045  fprintf(FOutFlowSoot, " %g", 0.0);
2046  fprintf(FOutFlowNOx, " %g", 0.0);
2047  fprintf(FOutFlowCO, " %g", 0.0);
2048  fprintf(FOutFlowFuel, " %g", 0.0);
2049  fprintf(FOutFlowN2, " %g", 0.0);
2050  }
2051  for(unsigned int j = 0; j < STPlenum.size(); ++j) {
2052  fprintf(FOutFlowO2, " %g", 0.0);
2053  fprintf(FOutFlowCO2, " %g", 0.0);
2054  fprintf(FOutFlowH2O, " %g", 0.0);
2055  fprintf(FOutFlowHC, " %g", 0.0);
2056  fprintf(FOutFlowSoot, " %g", 0.0);
2057  fprintf(FOutFlowNOx, " %g", 0.0);
2058  fprintf(FOutFlowCO, " %g", 0.0);
2059  fprintf(FOutFlowFuel, " %g", 0.0);
2060  fprintf(FOutFlowN2, " %g", 0.0);
2061  }
2062  for(unsigned int j = 0; j < STPipe.size(); ++j) {
2063  for(int k = 0; k < STPipe[j]->getNin(); ++k) {
2064  if(STPipe[j]->getFormulacionLeyes() == nmConArea) {
2065  massflow = STPipe[j]->GetU0(1, k);
2066  } else {
2067  massflow = __units::BarToPa(STPipe[j]->GetPresion(k)) / pow2(STPipe[j]->GetAsonido(k) * __cons::ARef) *
2068  STPipe[j]->GetGamma(k) * STPipe[j]->GetVelocidad(k) * __cons::ARef * __geom::Circle_area(
2069  STPipe[j]->GetDiametro(k));
2070  }
2071  fprintf(FOutFlowO2, " %g", STPipe[j]->GetFraccionMasica(k, 0) * massflow);
2072  fprintf(FOutFlowCO2, " %g", STPipe[j]->GetFraccionMasica(k, 1) * massflow);
2073  fprintf(FOutFlowH2O, " %g", STPipe[j]->GetFraccionMasica(k, 2) * massflow);
2074  fprintf(FOutFlowHC, " %g", STPipe[j]->GetFraccionMasica(k, 3) * massflow);
2075  fprintf(FOutFlowSoot, " %g", STPipe[j]->GetFraccionMasica(k, 4) * massflow);
2076  fprintf(FOutFlowNOx, " %g", STPipe[j]->GetFraccionMasica(k, 5) * massflow);
2077  fprintf(FOutFlowCO, " %g", STPipe[j]->GetFraccionMasica(k, 6) * massflow);
2078  fprintf(FOutFlowFuel, " %g", STPipe[j]->GetFraccionMasica(k, 7) * massflow);
2079  fprintf(FOutFlowN2, " %g", STPipe[j]->GetFraccionMasica(k, 8) * massflow);
2080  }
2081  }
2082  }
2083  break;
2084  }
2085  }
2086 
2087  }
2088 }
2089 
2090 void TOutputResults::HeaderInstantaneousResults(TCalculoExtern *EXTERN, bool ThereIsDLL, bool EngineBlock,
2091  stEspecies *SpeciesName) {
2092 
2093  if(WriteInsHeader) {
2094 
2095  std::string Label;
2096 
2097  FInsOutput << "Time";
2098 
2099  if(EngineBlock) {
2100  Label = PutLabel(702);
2101  FInsOutput << "\t" << Label.c_str();
2102  }
2103 
2104  // std::cout << (*FInsOutput).str() << std::endl;
2105 
2106  // fflush(fg);
2107  // fclose(fg);
2108 
2109  // CABECERA RESULTADOS INSTANTANEOS CILINDROS.
2110  for(unsigned int i = 0; i < InsCylinder.size(); ++i) {
2111  InsCylinder[i]->HeaderInstantaneousResultsCilindro(FInsOutput, SpeciesName);
2112  }
2113 
2114  // CABECERA RESULTADOS INSTANTANEOS DEPOSITOS.
2115  for(unsigned int i = 0; i < InsPlenum.size(); ++i) {
2116  InsPlenum[i]->HeaderInstantaneousResultsDep(FInsOutput, SpeciesName);
2117  }
2118 
2119  // CABECERA RESULTADOS INSTANTANEOS TUBOS.
2120 
2121  for(unsigned int i = 0; i < InsPipe.size(); i++) {
2122  InsPipe[i]->HeaderInstantaneousResults(FInsOutput, SpeciesName);
2123  }
2124 
2125  // CABECERA RESULTADOS INSTANTANEOS DPF.
2126 #ifdef ParticulateFilter
2127  for(unsigned int i = 0; i < InsDPF.size(); i++) {
2128  InsDPF[i]->CabeceraResultadosInstantaneos(FInsOutput, SpeciesName);
2129  }
2130 #endif
2131 
2132  // CABECERA RESULTADOS INSTANTANEOS VENTURIS.
2133 
2134  for(unsigned int i = 0; i < InsVenturi.size(); i++) {
2135  InsVenturi[i]->CabeceraResultadosInstantVenturi(FInsOutput);
2136  }
2137 
2138  // CABECERA RESULTADOS INSTANTANEOS EJES.
2139 
2140  for(unsigned int i = 0; i < InsTurbo.size(); ++i) {
2141  InsTurbo[i]->HeaderInstantaneousResultsEje(FInsOutput);
2142  }
2143 
2144  // CABECERA RESULTADOS INSTANTANEOS TURBINAS.
2145  for(unsigned int i = 0; i < InsTurbine.size(); i++) {
2146  InsTurbine[i]->CabeceraResultadosInstantTurb(FInsOutput);
2147  }
2148 
2149  // CABECERA RESULTADOS INSTANTANEOS COMPRESOR.
2150  for(unsigned int i = 0; i < InsCompressor.size(); ++i) {
2151  InsCompressor[i]->CabeceraGraficasInstantaneas(FInsOutput);
2152  }
2153 
2154  // CABECERA RESULTADOS INSTANTANEOS VALVULAS.
2155 
2156  for(unsigned int i = 0; i < InsValve.size(); i++) {
2157  InsValve[i]->CabeceraGraficaINS(FInsOutput, InsValveNode[i]);
2158  }
2159 
2160  // CABECERA RESULTADOS INSTANTANEOS WASTE-GATES.
2161  for(unsigned int i = 0; i < InsWasteGate.size(); i++) {
2162  InsWasteGate[i]->CabeceraGraficaINS(FInsOutput, i);
2163  }
2164 
2165  // CABECERA RESULTADOS INSTANTANEOS LAMINAS.
2166  for(unsigned int i = 0; i < InsReedValve.size(); i++) {
2167  InsReedValve[i]->CabeceraGraficaINS(FInsOutput, i);
2168  }
2169 
2170  // CABECERA RESULTADOS INSTANTANEOS COMPRESOR VOLUMETRICO (TORNILLO).
2171  for(unsigned int i = 0; i < InsRoot.size(); i++) {
2172  InsRoot[i]->CabeceraResultadosInstantCV(FInsOutput);
2173  }
2174 
2175  // CABECERA RESULTADOS INSTANTANEOS UNION ENTRE DEPOSITOS.
2176  for(unsigned int i = 0; i < InsConnection.size(); i++) {
2177  InsConnection[i]->CabeceraResultadosInstantUED(FInsOutput);
2178  }
2179 
2180  // CABECERA RESULTADOS INSTANTANEOS SENSOR.
2181  for(unsigned int i = 0; i < InsSensor.size(); i++) {
2182  InsSensor[i]->CabeceraResultadosInsSensor(FInsOutput);
2183  }
2184 
2185  // CABECERA RESULTADOS INSTANTANEOS CONTROLADOR.
2186  for(unsigned int i = 0; i < InsController.size(); i++) {
2187  InsController[i]->CabeceraResultadosInsControlador(FInsOutput);
2188  }
2189 
2190  // CABECERA RESULTADOS INSTANTANEOS CALCULOS EXTERNOS.
2191  if(ThereIsDLL) {
2192  EXTERN->ImprimeCabeceraInstantaneas(FInsOutput);
2193  }
2194  }
2195 
2196 }
2197 
2198 void TOutputResults::ConvertCharacter(int confile, char confile1[], int Characters) {
2199  try {
2200  int i, j = 0;
2201 
2202  i = 0;
2203  do {
2204  confile1[Characters - i] = (char)(confile % 10) + '0';
2205  ++i;
2206  } while((confile /= 10) > 0);
2207  confile1[Characters + 1] = '\0';
2208 
2209  if(i < Characters + 1) {
2210  for(j = 0; j <= (Characters - i); j++) {
2211  confile1[j] = '0';
2212  }
2213  }
2214  } catch(exception & N) {
2215  std::cout << "ERROR: ConvertCharacter" << std::endl;
2216  std::cout << "Tipo de error: " << N.what() << std::endl;
2217  throw Exception(N.what());
2218  }
2219 }
2220 
2221 void TOutputResults::PlotThisCycle(TBloqueMotor* Engine, int TotalCycles) {
2222 
2223  switch(FTypeOfInsResults) {
2224  case nmLastCyle:
2225  if((Engine->getCiclo() + 1) == TotalCycles - 1) {
2226  FPlotThisCycle = true;
2227  } else {
2228  FPlotThisCycle = false;
2229  }
2230  break;
2231  case nmEveryNCycles:
2232  if((Engine->getCiclo() + 1) % FCyclePeriod == 0) {
2233  FPlotThisCycle = true;
2234  } else {
2235  FPlotThisCycle = false;
2236  }
2237  default:
2238  FPlotThisCycle = true;
2239  }
2240 }
2241 
2242 void TOutputResults::PlotControl(double Theta0, double Theta, double CycleDuration) {
2243 
2244  int n1 = 0, n0 = 0;
2245 
2246  if(FFirstTime) {
2247  FFirstTime = false;
2248  FControlAngle1 = 0;
2249  while(FControlAngle1 <= Theta) {
2250  FControlAngle1 += FInsPeriod;
2251  }
2252  if(FControlAngle1 > Theta + 10) {
2253  FControlAngle1 = Theta + 10;
2254  }
2255  FControlAngle0 = FControlAngle1 - FInsPeriod;
2256  }
2257  while(FControlAngle1 < Theta0) {
2258  FControlAngle1 = FControlAngle1 + FInsPeriod;
2259  FControlAngle0 = FControlAngle1 - FInsPeriod;
2260  }
2261  if(FControlAngle1 > Theta0 && FControlAngle1 <= Theta) {
2262  FControlAngle0 = FControlAngle1;
2263  FControlAngle1 += FInsPeriod;
2264  if(fmod(FControlAngle1, CycleDuration) < FInsPeriod) {
2265  FControlAngle1 -= fmod(FControlAngle1, CycleDuration);
2266  }
2267  if(FPlotThisCycle)
2268  FPlotIns = true;
2269  else
2270  FPlotIns = false;
2271  } else {
2272  FPlotIns = false;
2273  }
2274 }
2275 
2276 void TOutputResults::OutputInstantaneousResults(TCalculoExtern *EXTERN, bool ThereIsDLL, bool EngineBlock, double Theta,
2277  TBloqueMotor* Engine, double Time) {
2278 
2279  if(FPlotIns) {
2280  float pasafloat, m;
2281  double RegimenFicticio = 0.;
2282 
2283  FInsOutput << std::endl;
2284  FInsOutput << Time;
2285 
2286  if(EngineBlock) {
2287  m = int(Theta / Engine->getAngTotalCiclo());
2288  pasafloat = (float)(Theta - (m * Engine->getAngTotalCiclo()));
2289  FInsOutput << "\t" << pasafloat;
2290  }
2291 
2292  // IMPRIME RESULTADOS INSTANTANEOS CILINDROS.
2293  for(unsigned int i = 0; i < InsCylinder.size(); ++i) {
2294  InsCylinder[i]->CalculaResultadosInstantaneosCilindro();
2295  InsCylinder[i]->ImprimeResultadosInstantaneosCilindro(FInsOutput);
2296  }
2297 
2298  // IMPRIME RESULTADOS INSTANTANEOS DEPOSITOS.
2299  for(unsigned int i = 0; i < InsPlenum.size(); ++i) {
2300  InsPlenum[i]->ResultadosInstantaneosDep();
2301  InsPlenum[i]->ImprimeResultadosInstantaneosDep(FInsOutput);
2302  }
2303 
2304  // IMPRIME RESULTADOS INSTANTANEOS TUBOS.
2305 
2306  for(unsigned int i = 0; i < InsPipe.size(); i++) {
2307  InsPipe[i]->CalculaResultadosInstantaneos();
2308  InsPipe[i]->ImprimeResultadosInstantaneos(FInsOutput);
2309  }
2310 
2311  // IMPRIME RESULTADOS INSTANTANEOS VENTURIS.
2312 
2313  for(unsigned int i = 0; i < InsVenturi.size(); i++) {
2314  InsVenturi[i]->CalculaResultadosVenturi();
2315  InsVenturi[i]->ImprimeResultadosInstantVenturi(FInsOutput);
2316  }
2317 
2318  // IMPRIME RESULTADOS INSTANTANEOS EJES.
2319 
2320  for(unsigned int i = 0; i < InsTurbo.size(); ++i) {
2321  InsTurbo[i]->ResultadosInstantEje();
2322  InsTurbo[i]->ImprimeResultadosInstantaneosEje(FInsOutput);
2323  }
2324 
2325  // IMPRIME RESULTADOS INSTANTANEOS TURBINAS.
2326  for(unsigned int i = 0; i < InsTurbine.size(); i++) {
2327  InsTurbine[i]->ResultadosInstantTurb();
2328  InsTurbine[i]->ImprimeResultadosInstantTurb(FInsOutput);
2329  }
2330 
2331  // IMPRIME RESULTADOS INSTANTANEOS COMPRESOR.
2332  for(unsigned int i = 0; i < InsCompressor.size(); ++i) {
2333  InsCompressor[i]->CalculaInstantaneos();
2334  InsCompressor[i]->ImprimeGraficasInstantaneas(FInsOutput);
2335  }
2336 
2337  // RESULTADOS INSTANTANEOS EN DPF.
2338 #ifdef ParticulateFilter
2339  for(int i = 0; i < InsDPF.size(); i++) {
2340  InsDPF[i]->CalculaResultadosInstantaneos();
2341  InsDPF[i]->ImprimeResultadosInstantaneos(FInsOutput);
2342  }
2343 #endif
2344 
2345  // IMPRIME RESULTADOS INSTANTANEOS VALVULAS.
2346 
2347  for(unsigned int i = 0; i < InsValve.size(); i++) {
2348  InsValve[i]->ImprimeGraficaINS(FInsOutput);
2349  }
2350 
2351  // IMPRIME RESULTADOS INSTANTANEOS WASTE-GATES.
2352  for(unsigned int i = 0; i < InsWasteGate.size(); i++) {
2353  InsWasteGate[i]->ImprimeGraficaINS(FInsOutput);
2354  }
2355 
2356  // IMPRIME RESULTADOS INSTANTANEOS LAMINAS.
2357  for(unsigned int i = 0; i < InsReedValve.size(); i++) {
2358  InsReedValve[i]->ImprimeGraficaINS(FInsOutput);
2359  }
2360 
2361  // IMPRIME RESULTADOS INSTANTANEOS COMPRESOR VOLUMETRICO (TORNILLO).
2362  for(unsigned int i = 0; i < InsRoot.size(); i++) {
2363  InsRoot[i]->ResultadosInstantCV();
2364  InsRoot[i]->ImprimeResultadosInstantCV(FInsOutput);
2365  }
2366 
2367  // IMPRIME RESULTADOS INSTANTANEOS UNION ENTRE DEPOSITOS.
2368  for(unsigned int i = 0; i < InsConnection.size(); i++) {
2369  InsConnection[i]->ResultadosInstantUED();
2370  InsConnection[i]->ImprimeResultadosInstantUED(FInsOutput);
2371  }
2372 
2373  // IMPRIME RESULTADOS INSTANTANEOS SENSOR.
2374  for(unsigned int i = 0; i < InsSensor.size(); i++) {
2375  InsSensor[i]->ResultadosInstantSensor();
2376  InsSensor[i]->ImprimeResultadosInsSensor(FInsOutput);
2377  }
2378 
2379  // IMPRIME RESULTADOS INSTANTANEOS CONTROLADOR.
2380  for(unsigned int i = 0; i < InsController.size(); i++) {
2381  InsController[i]->ResultadosInstantController();
2382  InsController[i]->ImprimeResultadosInsControlador(FInsOutput);
2383  }
2384 
2385  // IMPRIME RESULTADOS INSTANTANEOS CALCULOS EXTERNOS.
2386  if(ThereIsDLL) {
2387  EXTERN->ImprimeGraficosInstantaneas(FInsOutput);
2388  }
2389 #ifdef WriteINS
2390  CopyInstananeousResultsToFile(1);
2391 #endif
2392  }
2393 
2394 }
2395 
2396 void TOutputResults::WriteInstantaneous(bool EngineBlock, double Angle, double AngStep, TBloqueMotor* Engine,
2397  int TotalCycles) {
2398 
2399  if(EngineBlock) {
2400  switch(FTypeOfInsResults) {
2401  case nmLastCyle:
2402  if((Engine->getCiclo() + 1) == TotalCycles - 1) {
2403  FPlotThisCycle = true;
2404  if(Angle - AngStep < 0)
2405  WriteInsHeader = true;
2406  else
2407  WriteInsHeader = false;
2408  } else {
2409  FPlotThisCycle = false;
2410  WriteInsHeader = false;
2411  }
2412 
2413  break;
2414  case nmAllCyclesIndependent:
2415  FPlotThisCycle = true;
2416  if(Angle - AngStep < 0)
2417  WriteInsHeader = true;
2418  else
2419  WriteInsHeader = false;
2420  break;
2421  case nmAllCyclesConcatenated:
2422  FPlotThisCycle = true;
2423  if(InsHeaderCreated) {
2424  WriteInsHeader = false;
2425  } else {
2426  WriteInsHeader = true;
2427  InsHeaderCreated = true;
2428  }
2429  break;
2430  case nmEveryNCycles:
2431 
2432  if((Engine->getCiclo() + 1) % FCyclePeriod == 0 && Engine->getCiclo() > 0) {
2433  FPlotThisCycle = true;
2434  if(Angle - AngStep < 0) {
2435  WriteInsHeader = true;
2436  } else {
2437  WriteInsHeader = false;
2438  }
2439  } else {
2440  FPlotThisCycle = false;
2441  }
2442  }
2443  } else {
2444  if(InsHeaderCreated) {
2445  WriteInsHeader = false;
2446  } else {
2447  WriteInsHeader = true;
2448  InsHeaderCreated = true;
2449  }
2450  }
2451 
2452 }
2453 
2454 void TOutputResults::WriteSpaceTime(bool EngineBlock, TBloqueMotor* Engine, int TotalCycles) {
2455  if(EngineBlock) {
2456  if((Engine->getCiclo() + 1) == TotalCycles - 1) {
2457  FWriteSpaceTime = true;
2458  }
2459  } else {
2460  FWriteSpaceTime = true;
2461  }
2462 }
2463 
2464 // ---------------------------------------------------------------------------
2465 
2466 #pragma package(smart_init)
stEspecies
Definition: Globales.h:297
TEjeTurbogrupo
Definition: TEjeTurbogrupo.h:47
TTubo
a Finite differences pipe.
Definition: TTubo.h:116
Uint
unsigned int Uint
Unsigned integer.
Definition: Math_wam.h:69
TController
Definition: TController.h:37
TTurbina
Definition: TTurbina.h:41
TCCCompresorVolumetrico
Definition: TCCCompresorVolumetrico.h:37
TDPF
Definition: TDPF.h:45
TCCUnionEntreDepositos
Definition: TCCUnionEntreDepositos.h:41
TCalculoExtern
Definition: TCalculoExtern.h:190
TWasteGate
Definition: TWasteGate.h:47
TLamina
Definition: TLamina.h:50
TCompresor
Definition: TCompresor.h:47
TCondicionContorno
Definition: TCondicionContorno.h:54
TDeposito
Definition: TDeposito.h:44
PutLabel
std::string PutLabel(int idx)
Returns an integer.
Definition: labels.cpp:475
Exception
Custom exception class.
Definition: Exception.hpp:39
TCCCilindro
Foo.
Definition: TCCCilindro.h:46
TVenturi
Definition: TVenturi.h:33
TBloqueMotor
Definition: TBloqueMotor.h:43
TCCDeposito
Definition: TCCDeposito.h:40
pow2
T pow2(T x)
Returns x to the power of 2.
Definition: Math_wam.h:88
TSensor
Definition: TSensor.h:42