31 #include "TWasteGate.h"
33 #include "TDeposito.h"
38 TWasteGate::TWasteGate() :
45 TWasteGate::~TWasteGate() {
51 TWasteGate::TWasteGate(
TWasteGate *Origen,
int Valvula) :
54 FTuboControl = Origen->FTuboControl;
55 FDistancia = Origen->FDistancia;
56 FPresCapMando = Origen->FPresCapMando;
57 FCoefC1 = Origen->FCoefC1;
58 FCoefC2 = Origen->FCoefC2;
59 FMasa = Origen->FMasa;
60 FAmortiguamiento = Origen->FAmortiguamiento;
61 FRigidez = Origen->FRigidez;
62 FPrecarga = Origen->FPrecarga;
63 FAreaDiaf = Origen->FAreaDiaf;
64 FAreaPlato = Origen->FAreaPlato;
65 FDiametroRef = Origen->FDiametroRef;
66 FSentidoWG = Origen->FSentidoWG;
68 FNumeroOrden = Origen->FNumeroOrden;
72 FDiamRef = FDiametroRef;
84 void TWasteGate::LeeDatosIniciales(
const char *FileWAM, fpos_t &filepos,
int norden,
bool HayMotor,
89 FNumeroOrden = norden;
91 FILE *fich = fopen(FileWAM,
"r");
92 fsetpos(fich, &filepos);
94 fscanf(fich,
"%d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %d", &FTuboControl, &FDistancia, &FPresCapMando, &FCoefC1,
95 &FCoefC2, &FMasa, &FAmortiguamiento, &FRigidez, &FPrecarga, &FAreaDiaf,
96 &FAreaPlato, &FDiametroRef, &modo);
106 fgetpos(fich, &filepos);
108 }
catch(exception &N) {
109 std::cout <<
"ERROR: LeeDatosIniciales WasteGate" << std::endl;
119 void TWasteGate::CalculoNodoAdm(
TTubo **Pipe) {
122 FTuboAdm = Pipe[FTuboControl - 1];
124 FNodoAdm = floor(FDistancia / Pipe[FTuboControl - 1]->getXRef());
125 if(FNodoAdm >= Pipe[FTuboControl - 1]->getNin() - 1) {
126 FNodoAdm = FNodoAdm - 1;
129 FDist = FDistancia / Pipe[FTuboControl - 1]->getXRef() - FNodoAdm;
131 }
catch(exception &N) {
132 std::cout <<
"ERROR: TWasteGate::CalculoNodoAdm " << std::endl;
142 void TWasteGate::CalculaCD(
double Padm,
double PTubo,
double PDeposito,
double deltaT) {
144 FFuerza = (Padm - FPresCapMando) * FAreaDiaf + FSentidoWG * (PDeposito - PTubo) * FAreaPlato - FPrecarga;
146 FddX = (FFuerza - FRigidez * FX - FAmortiguamiento * FdX) / FMasa;
147 FX = FX + FdX * deltaT + FddX * deltaT * deltaT / 2.;
148 FdX = FdX + FddX * deltaT;
159 FCDTubVol = FCoefC1 * (pow((FX / FDiametroRef), FCoefC2));
160 FCDVolTub = FCoefC1 * (pow((FX / FDiametroRef), FCoefC2));
162 }
catch(exception &N) {
163 std::cout <<
"ERROR: LeeDatosIniciales WasteGate" << std::endl;
170 void TWasteGate::GetCDin(
double Time) {
172 double deltaT = Time - FTime0;
174 double p2 = FTuboAdm->
GetPresion(FNodoAdm + 1);
175 double Padm = Interpola(p1, p2, 1.0, FDist);
176 double PDeposito = FPlenum->getPressure();
178 FFuerza = (Padm - FPresCapMando) * FAreaDiaf + FSentidoWG * (PDeposito - PTubo) * FAreaPlato - FPrecarga;
180 FddX = (FFuerza - FRigidez * FX - FAmortiguamiento * FdX) / FMasa;
181 FX = FX + FdX * deltaT + FddX * deltaT * deltaT / 2.;
182 FdX = FdX + FddX * deltaT;
193 FCDTubVol = FCoefC1 * (pow((FX / FDiametroRef), FCoefC2));
197 void TWasteGate::GetCDout(
double Time) {
199 double deltaT = Time - FTime0;
201 double p2 = FTuboAdm->
GetPresion(FNodoAdm + 1);
202 double Padm = Interpola(p1, p2, 1.0, FDist);
203 double PDeposito = FPlenum->getPressure();
205 FFuerza = (Padm - FPresCapMando) * FAreaDiaf + FSentidoWG * (PDeposito - PTubo) * FAreaPlato - FPrecarga;
207 FddX = (FFuerza - FRigidez * FX - FAmortiguamiento * FdX) / FMasa;
208 FX = FX + FdX * deltaT + FddX * deltaT * deltaT / 2.;
209 FdX = FdX + FddX * deltaT;
220 FCDVolTub = FCoefC1 * (pow((FX / FDiametroRef), FCoefC2));
227 void TWasteGate::LeeDatosGraficas(
const char *FileWAM, fpos_t &filepos) {
229 int ndv = 0, var = 0;
230 FILE *fich = fopen(FileWAM,
"r");
231 fsetpos(fich, &filepos);
234 fscanf(fich,
" %d", &ndv);
235 for(
int i = 0; i < ndv; i++) {
236 fscanf(fich,
" %d", &var);
243 fgetpos(fich, &filepos);
245 }
catch(exception &N) {
246 std::cout <<
"ERROR: LeeDatosGraficas WasteGate" << std::endl;
256 void TWasteGate::CabeceraGraficaINS(stringstream& insoutput,
int lam) {
264 insoutput << Label.c_str();
268 }
catch(exception &N) {
269 std::cout <<
"ERROR: CabeceraGrafica WasteGate" << std::endl;
279 void TWasteGate::ImprimeGraficaINS(stringstream& insoutput) {
284 insoutput <<
"\t" << FX;
287 }
catch(exception &N) {
288 std::cout <<
"ERROR: ImprimeGrafica WasteGate" << std::endl;
298 #pragma package(smart_init)