36 #include "TCompresor.h"
41 TCompresor::TCompresor(
int i, nmTipoCalculoEspecies SpeciesModel,
int numeroespecies, nmCalculoGamma GammaCalculation,
43 FNumeroCompresor = i + 1;
44 FMedias.GraficaMedias =
false;
45 FMedias.GraficaTrabajo =
false;
46 FMedias.GraficaRendimiento =
false;
47 FMedias.GraficaRelacionCompresion =
false;
48 FMedias.GraficaGasto =
false;
49 FMedias.GraficaGastoCorregido =
false;
50 FMedias.GraficaRegimenCorregido =
false;
51 FInstant.GraficaInstantaneas =
false;
52 FInstant.GraficaPotencia =
false;
53 FInstant.GraficaRendimiento =
false;
54 FInstant.GraficaRelacionCompresion =
false;
55 FInstant.GraficaGasto =
false;
56 FInstant.GraficaGastoCorregido =
false;
57 FInstant.GraficaRegimenCorregido =
false;
58 FInstant.GraficaGamma =
false;
66 FCalculoEspecies = SpeciesModel;
67 FNumeroEspecies = numeroespecies;
68 FCalculoGamma = GammaCalculation;
69 FFraccionMasicaEspecie = NULL;
83 TCompresor::~TCompresor() {
88 if(FFraccionMasicaEspecie != NULL)
89 delete[] FFraccionMasicaEspecie;
95 void TCompresor::InterpolaValoresMapa(
double rtc) {
99 if(FModeloCompresor == nmCompPipes) {
100 Mapa2T->InterpolaMapa(FRegimen, FTemperatura10);
102 Mapa->InterpolaMapa(FRegimen, FTemperatura10);
105 }
catch(exception &N) {
106 std::cout <<
"ERROR: InterpolaValoresMapa en el compresor: " << FNumeroCompresor << std::endl;
107 std::cout <<
"Tipo de error: " << N.what() << std::endl;
108 throw Exception(
"ERROR: InterpolaValoresMapa en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
115 void TCompresor::AcumulaMedias(
double Tiempo) {
118 DeltaT = Tiempo - FMedias.Tiempo0;
119 FMedias.TiempoSUM += DeltaT;
120 FMedias.RelacionCompresionSUM += FRelacionCompresion * DeltaT;
121 FMedias.GastoSUM += FGastoCompresor * DeltaT;
122 FMedias.RendimientoSUM += FRendimiento * DeltaT;
123 FMedias.GastoCorregidoSUM += FGastoCorregido * DeltaT;
124 FMedias.RegimenCorregidoSUM += FRegimenCorregido * DeltaT;
125 FMedias.TrabajoSUM += FPotencia * DeltaT;
126 FMedias.Tiempo0 = Tiempo;
127 }
catch(exception &N) {
128 std::cout <<
"ERROR: AcumulaMedias en el compresor: " << FNumeroCompresor << std::endl;
129 std::cout <<
"Tipo de error: " << N.what() << std::endl;
130 throw Exception(
"ERROR: AcumulaMedias en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
137 void TCompresor::IniciaMedias() {
140 FMedias.TiempoSUM = 0.;
141 FMedias.RelacionCompresionSUM = 0.;
142 FMedias.GastoSUM = 0.;
143 FMedias.RendimientoSUM = 0.;
144 FMedias.GastoCorregidoSUM = 0.;
145 FMedias.RegimenCorregidoSUM = 0.;
146 FMedias.TrabajoSUM = 0.;
147 FMedias.Tiempo0 = 0.;
149 }
catch(exception &N) {
150 std::cout <<
"ERROR: IniciaMedias en el compresor: " << FNumeroCompresor << std::endl;
151 std::cout <<
"Tipo de error: " << N.what() << std::endl;
152 throw Exception(
"ERROR: IniciaMedias en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
159 void TCompresor::CalculoPotenciaPaso() {
162 FPotenciaPaso = FTrabajoPaso / FDeltaTPaso;
166 }
catch(exception &N) {
167 std::cout <<
"ERROR: TCompresor::CalculoPotenciaPaso en el compresor: " << FNumeroCompresor << std::endl;
168 std::cout <<
"Tipo de error: " << N.what() << std::endl;
169 throw Exception(
"ERROR: TCompresor::CalculoPotenciaPaso en el compresor: " + std::to_string(
170 FNumeroCompresor) + N.what());
176 void TCompresor::CalculaMedias() {
179 FMedias.RelacionCompresion = FMedias.RelacionCompresionSUM / FMedias.TiempoSUM;
180 FMedias.Massflow = FMedias.GastoSUM / FMedias.TiempoSUM;
181 FMedias.Rendimiento = FMedias.RendimientoSUM / FMedias.TiempoSUM;
182 FMedias.Trabajo = FMedias.TrabajoSUM;
183 FMedias.GastoCorregido = FMedias.GastoCorregidoSUM / FMedias.TiempoSUM;
184 FMedias.RegimenCorregido = FMedias.RegimenCorregidoSUM / FMedias.TiempoSUM;
186 FMedias.TiempoSUM = 0.;
187 FMedias.RelacionCompresionSUM = 0.;
188 FMedias.GastoSUM = 0.;
189 FMedias.RendimientoSUM = 0.;
190 FMedias.TrabajoSUM = 0.;
191 FMedias.GastoCorregidoSUM = 0.;
192 FMedias.RegimenCorregidoSUM = 0.;
194 }
catch(exception &N) {
195 std::cout <<
"ERROR: CalculaMedias en el compresor: " << FNumeroCompresor << std::endl;
196 std::cout <<
"Tipo de error: " << N.what() << std::endl;
197 throw Exception(
"ERROR: CalculaMedias en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
204 void TCompresor::CalculaInstantaneos() {
206 FInstant.RelacionCompresion = FRelacionCompresion;
207 FInstant.Massflow = FGastoCompresor;
208 FInstant.Rendimiento = FRendimiento;
209 FInstant.Potencia = FPotencia;
210 FInstant.GastoCorregido = FGastoCorregido;
211 FInstant.RegimenCorregido = FRegimenCorregido;
212 FInstant.Gamma = FGamma;
213 }
catch(exception &N) {
214 std::cout <<
"ERROR: CalculaInstantaneos en el compresor: " << FNumeroCompresor << std::endl;
215 std::cout <<
"Tipo de error: " << N.what() << std::endl;
216 throw Exception(
"ERROR: CalculaInstantaneos en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
223 void TCompresor::LeeDatosGraficasMedias(
const char *FileWAM, fpos_t &filepos) {
224 int NMagnitudes = 0, Magnitud = 0;
226 FILE *fich = fopen(FileWAM,
"r");
227 fsetpos(fich, &filepos);
229 FMedias.GraficaMedias =
true;
230 fscanf(fich,
"%d", &NMagnitudes);
231 for(
int i = 0; i < NMagnitudes; i++) {
232 fscanf(fich,
"%d", &Magnitud);
235 FMedias.GraficaTrabajo =
true;
238 FMedias.GraficaRendimiento =
true;
241 FMedias.GraficaRelacionCompresion =
true;
244 FMedias.GraficaGasto =
true;
247 FMedias.GraficaGastoCorregido =
true;
250 FMedias.GraficaRegimenCorregido =
true;
254 fgetpos(fich, &filepos);
256 }
catch(exception &N) {
257 std::cout <<
"ERROR: LeeDatosGraficasMedias en el compresor: " << FNumeroCompresor << std::endl;
258 std::cout <<
"Tipo de error: " << N.what() << std::endl;
259 throw Exception(
"ERROR: LeeDatosGraficasMedias en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
266 void TCompresor::CabeceraGraficasMedias(stringstream& medoutput) {
270 if(FMedias.GraficaMedias) {
271 if(FMedias.GraficaTrabajo) {
272 Label =
"\t" +
PutLabel(28) + std::to_string(FNumeroCompresor) +
PutLabel(907);
273 medoutput << Label.c_str();
275 if(FMedias.GraficaRendimiento) {
276 Label =
"\t" +
PutLabel(22) + std::to_string(FNumeroCompresor) +
PutLabel(901);
277 medoutput << Label.c_str();
279 if(FMedias.GraficaRelacionCompresion) {
280 Label =
"\t" +
PutLabel(23) + std::to_string(FNumeroCompresor) +
PutLabel(901);
281 medoutput << Label.c_str();
283 if(FMedias.GraficaGasto) {
284 Label =
"\t" +
PutLabel(24) + std::to_string(FNumeroCompresor) +
PutLabel(904);
285 medoutput << Label.c_str();
287 if(FMedias.GraficaGastoCorregido) {
288 Label =
"\t" +
PutLabel(25) + std::to_string(FNumeroCompresor) +
PutLabel(905);
289 medoutput << Label.c_str();
291 if(FMedias.GraficaRegimenCorregido) {
292 Label =
"\t" +
PutLabel(26) + std::to_string(FNumeroCompresor) +
PutLabel(906);
293 medoutput << Label.c_str();
297 }
catch(exception &N) {
298 std::cout <<
"ERROR: CabeceraGraficasMedias en el compresor: " << FNumeroCompresor << std::endl;
299 std::cout <<
"Tipo de error: " << N.what() << std::endl;
300 throw Exception(
"ERROR: CabeceraGraficasMedias en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
307 void TCompresor::ImprimeGraficasMedias(stringstream& medoutput) {
310 if(FMedias.GraficaMedias) {
311 if(FMedias.GraficaTrabajo)
312 medoutput <<
"\t" << FMedias.Trabajo;
313 if(FMedias.GraficaRendimiento)
314 medoutput <<
"\t" << FMedias.Rendimiento;
315 if(FMedias.GraficaRelacionCompresion)
316 medoutput <<
"\t" << FMedias.RelacionCompresion;
317 if(FMedias.GraficaGasto)
318 medoutput <<
"\t" << FMedias.Massflow;
319 if(FMedias.GraficaGastoCorregido)
320 medoutput <<
"\t" << FMedias.GastoCorregido;
321 if(FMedias.GraficaRegimenCorregido)
322 medoutput <<
"\t" << FMedias.RegimenCorregido;
325 }
catch(exception &N) {
326 std::cout <<
"ERROR: ImprimeGraficasMedias en el compresor: " << FNumeroCompresor << std::endl;
327 std::cout <<
"Tipo de error: " << N.what() << std::endl;
328 throw Exception(
"ERROR: ImprimeGraficasMedias en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
335 void TCompresor::LeeDatosGraficasInstantaneas(
const char *FileWAM, fpos_t &filepos) {
336 int NMagnitudes = 0, Magnitud = 0;
338 FILE *fich = fopen(FileWAM,
"r");
339 fsetpos(fich, &filepos);
341 FInstant.GraficaInstantaneas =
true;
342 fscanf(fich,
"%d", &NMagnitudes);
343 for(
int i = 0; i < NMagnitudes; i++) {
344 fscanf(fich,
"%d", &Magnitud);
347 FInstant.GraficaRelacionCompresion =
true;
350 FInstant.GraficaRendimiento =
true;
353 FInstant.GraficaPotencia =
true;
356 FInstant.GraficaGasto =
true;
359 FInstant.GraficaGastoCorregido =
true;
362 FInstant.GraficaRegimenCorregido =
true;
365 FInstant.GraficaGamma =
true;
369 fgetpos(fich, &filepos);
371 }
catch(exception &N) {
372 std::cout <<
"ERROR: LeeDatosGraficasMedias en el compresor: " << FNumeroCompresor << std::endl;
373 std::cout <<
"Tipo de error: " << N.what() << std::endl;
374 throw Exception(
"ERROR: LeeDatosGraficasMedias en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
381 void TCompresor::CabeceraGraficasInstantaneas(stringstream& insoutput) {
386 if(FInstant.GraficaInstantaneas) {
387 if(FInstant.GraficaPotencia) {
388 Label =
"\t" +
PutLabel(21) + std::to_string(FNumeroCompresor) +
PutLabel(903);
389 insoutput << Label.c_str();
391 if(FInstant.GraficaRendimiento) {
392 Label =
"\t" +
PutLabel(22) + std::to_string(FNumeroCompresor) +
PutLabel(901);
393 insoutput << Label.c_str();
395 if(FInstant.GraficaRelacionCompresion) {
396 Label =
"\t" +
PutLabel(23) + std::to_string(FNumeroCompresor) +
PutLabel(901);
397 insoutput << Label.c_str();
399 if(FInstant.GraficaGasto) {
400 Label =
"\t" +
PutLabel(24) + std::to_string(FNumeroCompresor) +
PutLabel(904);
401 insoutput << Label.c_str();
403 if(FInstant.GraficaGastoCorregido) {
404 Label =
"\t" +
PutLabel(25) + std::to_string(FNumeroCompresor) +
PutLabel(905);
405 insoutput << Label.c_str();
407 if(FInstant.GraficaRegimenCorregido) {
408 Label =
"\t" +
PutLabel(26) + std::to_string(FNumeroCompresor) +
PutLabel(906);
409 insoutput << Label.c_str();
411 if(FInstant.GraficaGamma) {
412 Label =
"\t" +
PutLabel(27) + std::to_string(FNumeroCompresor) +
PutLabel(901);
413 insoutput << Label.c_str();
417 }
catch(exception &N) {
418 std::cout <<
"ERROR: CabeceraGraficasInstantaneas en el compresor: " << FNumeroCompresor << std::endl;
419 std::cout <<
"Tipo de error: " << N.what() << std::endl;
420 throw Exception(
"ERROR: CabeceraGraficasInstantaneas en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
427 void TCompresor::ImprimeGraficasInstantaneas(stringstream& insoutput) {
430 if(FInstant.GraficaInstantaneas) {
431 if(FInstant.GraficaPotencia)
432 insoutput <<
"\t" << FInstant.Potencia;
433 if(FInstant.GraficaRendimiento)
434 insoutput <<
"\t" << FInstant.Rendimiento;
435 if(FInstant.GraficaRelacionCompresion)
436 insoutput <<
"\t" << FInstant.RelacionCompresion;
437 if(FInstant.GraficaGasto)
438 insoutput <<
"\t" << FInstant.Massflow;
439 if(FInstant.GraficaGastoCorregido)
440 insoutput <<
"\t" << FInstant.GastoCorregido;
441 if(FInstant.GraficaRegimenCorregido)
442 insoutput <<
"\t" << FInstant.RegimenCorregido;
443 if(FInstant.GraficaGamma)
444 insoutput <<
"\t" << FInstant.Gamma;
447 }
catch(exception &N) {
448 std::cout <<
"ERROR: ImprimeGraficasInstantaneas en el compresor: " << FNumeroCompresor << std::endl;
449 std::cout <<
"Tipo de error: " << N.what() << std::endl;
450 throw Exception(
"ERROR: ImprimeGraficasInstantaneas en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
457 double TCompresor::GetASonidoComp() {
459 if(FModeloCompresor == nmCompPipes) {
460 printf(
"ERROR:El compresor de tubos no puede estar unido a un deposito\n");
463 return FASonidoSalida;
464 }
catch(exception &N) {
465 std::cout <<
"ERROR: TCompresor::GetASonidoComp en el compresor: " << FNumeroCompresor << std::endl;
466 std::cout <<
"Tipo de error: " << N.what() << std::endl;
467 throw Exception(
"ERROR: ImprimeGraficasInstantaneas en el compresor: " + std::to_string(FNumeroCompresor) + N.what());
474 double TCompresor::GetFraccionMasicaEspecie(
int i) {
476 return FFraccionMasicaEspecie[i];
477 }
catch(exception &N) {
478 std::cout <<
"ERROR: TCompresor::GetFraccionMasicaEspecie en el compresor: " << FNumeroCompresor << std::endl;
479 std::cout <<
"Tipo de error: " << N.what() << std::endl;
487 void TCompresor::AsignAcousticElements(
TTubo **Pipe,
TDeposito **Volume) {
489 FAcComp->AsignInPipe(Pipe);
490 FAcComp->AsignOutPipe(Pipe);
491 FAcComp->AsignVolute(Pipe);
492 FAcComp->AsignRotorVol(Volume);
493 FAcComp->AsignStatorVol(Volume);
497 #pragma package(smart_init)