42 FVector_Mf_mapa = NULL;
43 FVector_TipoControl_Regimen_mapa = NULL;
44 FVector_Regimen_mapa = NULL;
46 FMapa_TipoControl = NULL;
47 FMapa_MasaAire = NULL;
65 void TEGRV::LeeDatosEntrada(
char *Ruta, FILE *fich) {
71 for(
int i = 0; i <= (int) strlen(Ruta); i++) {
72 DatosEGR[i] = Ruta[i];
75 fscanf(fich,
"%s ", &FileEGR);
76 strcat(DatosEGR, FileEGR);
78 FichEGRV = fopen(DatosEGR,
"r");
79 if((FichEGRV = fopen(DatosEGR,
"r")) == NULL) {
80 std::cout <<
"ERROR: Fichero de EGR no cargado";
82 fscanf(FichEGRV,
"%lf %lf %lf ", &FKc, &FKi, &FKd);
83 fscanf(FichEGRV,
"%d %d %d ", &FNumeroDatos_TipoControl_Regimen, &FNumeroDatos_Mf, &FNumeroDatos_Regimen);
85 FVector_Mf_mapa =
new double[FNumeroDatos_Mf];
86 FVector_TipoControl_Regimen_mapa =
new double[FNumeroDatos_TipoControl_Regimen];
87 FVector_Regimen_mapa =
new double[FNumeroDatos_Regimen];
89 FMapa_TipoControl =
new double[FNumeroDatos_TipoControl_Regimen];
90 FMapa_MasaAire =
new double*[FNumeroDatos_Mf];
91 for(
int i = 0; i < FNumeroDatos_Mf; i++) {
92 FMapa_MasaAire[i] =
new double[FNumeroDatos_Regimen];
95 for(
int i = 0; i < FNumeroDatos_TipoControl_Regimen; i++) {
96 fscanf(FichEGRV,
"%lf ", &FVector_TipoControl_Regimen_mapa[i]);
98 for(
int i = 0; i < FNumeroDatos_Regimen; i++) {
99 fscanf(FichEGRV,
"%lf ", &FVector_Regimen_mapa[i]);
101 for(
int i = 0; i < FNumeroDatos_Mf; i++) {
102 fscanf(FichEGRV,
"%lf ", &FVector_Mf_mapa[i]);
104 for(
int i = 0; i < FNumeroDatos_TipoControl_Regimen; i++) {
105 fscanf(FichEGRV,
"%lf ", &FMapa_TipoControl[i]);
107 for(
int i = 0; i < FNumeroDatos_Mf; i++) {
108 for(
int j = 0; j < FNumeroDatos_Regimen; j++) {
109 fscanf(FichEGRV,
"%lf ", &FMapa_MasaAire[i][j]);
115 }
catch(exception &N) {
116 std::cout <<
"ERROR: TEGRV::LeeDatosEntrada (DLL)" << std::endl;
117 std::cout <<
"Tipo de error: " << N.what() << std::endl;
174 double TEGRV::xit_(
double vizq,
double vder,
double axid,
double xif) {
176 double xx = 0., yy = 0.;
181 yy = xx / axid * xif;
184 printf(
"ERROR: valores entrada xit\n");
188 }
catch(exception &N) {
189 std::cout <<
"ERROR: xit_" << std::endl;
190 std::cout <<
"Tipo de error: " << N.what() << std::endl;
197 nmTipoControl TEGRV::DeterminacionTipoControl(
double Regimen,
double MasaFuel) {
199 double MasaFuel_mapadecisor = 0.;
201 MasaFuel_mapadecisor = Interp1(Regimen, FVector_TipoControl_Regimen_mapa, FMapa_TipoControl,
202 FNumeroDatos_TipoControl_Regimen);
204 if(MasaFuel * 1e6 < MasaFuel_mapadecisor) {
205 FTipoControl = nmControlMasaAire;
207 FTipoControl = nmControlPadm;
212 }
catch(exception &N) {
213 std::cout <<
"ERROR: TEGRV::DeterminacionTipoControl (DLL)" << std::endl;
214 std::cout <<
"Tipo de error: " << N.what() << std::endl;
222 void TEGRV::CalculaEGRV(
double MasaFuel,
double Regimen,
double MasaAireAdmitida,
double TiempoActual) {
226 if(FTipoControl == nmControlPadm) {
227 if(TiempoActual < 13 * 120 / Regimen) {
228 FCDEntrante = FCDEntrante / 2;
232 }
else if(FTipoControl == nmControlMasaAire) {
233 MasaFuel = MasaFuel * 1e6;
234 FMasaAireAdmitidaConsigna = Interpolacion_bidimensional(Regimen, MasaFuel, FVector_Mf_mapa, FVector_Regimen_mapa,
235 FMapa_MasaAire, FNumeroDatos_Regimen, FNumeroDatos_Mf);
238 FError = (MasaAireAdmitida - FMasaAireAdmitidaConsigna) / FMasaAireAdmitidaConsigna;
239 FErrorI = FErrorI + FError;
243 FI = FKi * (FErrorI);
244 FD = FKd * (FError - FError_ant);
245 FCDEntrante = FCDEntrante + FP + FI + FD;
247 if(FCDEntrante > 1.0) {
249 }
else if(FCDEntrante < 0.0) {
253 FCDSaliente = FCDEntrante;
256 }
catch(exception &N) {
257 std::cout <<
"ERROR: TEGRV::CalculaEGRV (DLL)" << std::endl;
258 std::cout <<
"Tipo de error: " << N.what() << std::endl;
266 void TEGRV::IniciaEGRV(
double cdEGR,
int CicloCerrado) {
272 FCicloCerrado = CicloCerrado;
274 }
catch(exception &N) {
275 std::cout <<
"ERROR: IniciaEGRV (DLL)" << std::endl;
276 std::cout <<
"Tipo de error: " << N.what() << std::endl;
284 #pragma package(smart_init)