OpenWAM
TCDFijo.cpp
1 /*--------------------------------------------------------------------------------*\
2 ==========================|
3  \\ /\ /\ // O pen | OpenWAM: The Open Source 1D Gas-Dynamic Code
4  \\ | X | // W ave |
5  \\ \/_\/ // A ction | CMT-Motores Termicos / Universidad Politecnica Valencia
6  \\/ \// M odel |
7  ----------------------------------------------------------------------------------
8  License
9 
10  This file is part of OpenWAM.
11 
12  OpenWAM is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  OpenWAM is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with OpenWAM. If not, see <http://www.gnu.org/licenses/>.
24 
25 
26  \*--------------------------------------------------------------------------------*/
27 
28 //---------------------------------------------------------------------------
29 #pragma hdrstop
30 
31 #include "TCDFijo.h"
32 
33 //---------------------------------------------------------------------------
34 //---------------------------------------------------------------------------
35 TCDFijo::TCDFijo() :
36  TTipoValvula(nmCDFijo) {
37 
38 }
39 
40 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
42 
43 TCDFijo::~TCDFijo() {
44 
45 }
46 
47 //---------------------------------------------------------------------------
48 //---------------------------------------------------------------------------
49 
50 TCDFijo::TCDFijo(TCDFijo *Origen, int Valvula) :
51  TTipoValvula(nmCDFijo) {
52 
53  FCDEntrada = Origen->FCDEntrada;
54  FCDSalida = Origen->FCDSalida;
55  FActivaDiamRef = Origen->FActivaDiamRef;
56  FDiametroRef = Origen->FDiametroRef;
57  FNumeroOrden = Origen->FNumeroOrden;
58 
59 //Se utilizara el diametro del tubo
60  if(FActivaDiamRef) {
61  FDiamRef = FDiametroRef;
62  } else {
63  FDiamRef = -1;
64  }
65 
66  FCDTubVol = FCDEntrada;
67  FCDVolTub = FCDSalida;
68 
69  FValvula = Valvula;
70 }
71 
72 //---------------------------------------------------------------------------
73 //---------------------------------------------------------------------------
74 
75 void TCDFijo::LeeDatosIniciales(const char *FileWAM, fpos_t &filepos, int norden, bool HayMotor, TBloqueMotor *Engine) {
76  try {
77  int tmp = 0;
78  FActivaDiamRef = false;
79 
80  FILE *fich = fopen(FileWAM, "r");
81  fsetpos(fich, &filepos);
82 
83  FNumeroOrden = norden;
84 
85  fscanf(fich, "%lf %lf %d ", &FCDEntrada, &FCDSalida, &tmp);
86  if(tmp == 1) {
87  FActivaDiamRef = true;
88  fscanf(fich, "%lf ", &FDiametroRef);
89  }
90 
91  fgetpos(fich, &filepos);
92  fclose(fich);
93 
94  } catch(exception &N) {
95  std::cout << "ERROR: LeeDatosIniciales CDFijo" << std::endl;
96  //std::cout << "Tipo de error: " << N.what().scr() << std::endl;
97  throw Exception(N.what());
98 
99  }
100 }
101 
102 //---------------------------------------------------------------------------
103 //---------------------------------------------------------------------------
104 
105 void TCDFijo::CalculaCD() {
106  try {
107  if(FActivaDiamRef) {
108  FCDTubVol = FCDEntrada * FSectionRatio;
109  FCDVolTub = FCDSalida * FSectionRatio;
110  } else {
111  FCDTubVol = FCDEntrada;
112  FCDVolTub = FCDSalida;
113  }
114  } catch(exception &N) {
115  std::cout << "ERROR: TCDFijo::CalculaCD " << std::endl;
116  //std::cout << "Tipo de error: " << N.what().scr() << std::endl;
117  throw Exception(N.what());
118 
119  }
120 }
121 #pragma package(smart_init)
TTipoValvula
Definition: TTipoValvula.h:53
TCDFijo
Definition: TCDFijo.h:43
Exception
Custom exception class.
Definition: Exception.hpp:39
TBloqueMotor
Definition: TBloqueMotor.h:43