31 #include "TCCPreVble.h" 36 #include "TEntradaPulso.h" 41 TCCPreVble::TCCPreVble(nmTypeBC TipoCC,
int numCC, nmTipoCalculoEspecies SpeciesModel,
int numeroespecies,
42 nmCalculoGamma GammaCalculation,
bool ThereIsEGR) :
43 TCondicionContorno(TipoCC, numCC, SpeciesModel, numeroespecies, GammaCalculation, ThereIsEGR) {
54 TCCPreVble::~TCCPreVble() {
56 delete[] FTuboExtremo;
61 if(FComposicion != NULL)
62 delete[] FComposicion;
69 void TCCPreVble::ReadBoundaryData(
const char *FileWAM, fpos_t &filepos,
int NumberOfPipes,
TTubo **Pipe,
int nDPF,
73 double fracciontotal = 0.;
76 FTuboExtremo[0].Pipe = NULL;
81 while(FNumeroTubosCC < 1 && i < NumberOfPipes) {
82 if(Pipe[i]->getNodoIzq() == FNumeroCC) {
83 FTuboExtremo[FNumeroTubosCC].Pipe = Pipe[i];
84 FTuboExtremo[FNumeroTubosCC].TipoExtremo = nmLeft;
85 FCC = &(FTuboExtremo[FNumeroTubosCC].Beta);
86 FCD = &(FTuboExtremo[FNumeroTubosCC].Landa);
91 if(Pipe[i]->getNodoDer() == FNumeroCC) {
92 FTuboExtremo[FNumeroTubosCC].Pipe = Pipe[i];
93 FTuboExtremo[FNumeroTubosCC].TipoExtremo = nmRight;
94 FCC = &(FTuboExtremo[FNumeroTubosCC].Landa);
95 FCD = &(FTuboExtremo[FNumeroTubosCC].Beta);
96 FNodoFin = FTuboExtremo[FNumeroTubosCC].Pipe->getNin() - 1;
103 FILE *fich = fopen(FileWAM,
"r");
104 fsetpos(fich, &filepos);
107 FPulso->LeeEntradaPulso(fich);
110 FFraccionMasicaEspecie =
new double[FNumeroEspecies - FIntEGR];
111 FComposicion =
new double[FNumeroEspecies - FIntEGR];
112 for(
int i = 0; i < FNumeroEspecies - 1; i++) {
113 fscanf(fich,
"%lf ", &FComposicion[i]);
115 fracciontotal += FComposicion[i];
119 if(FCalculoEspecies == nmCalculoCompleto) {
120 if(FComposicion[0] > 0.2)
121 FComposicion[FNumeroEspecies - 1] = 0.;
123 FComposicion[FNumeroEspecies - 1] = 1.;
125 if(FComposicion[0] > 0.5)
126 FComposicion[FNumeroEspecies - 1] = 1.;
128 FComposicion[FNumeroEspecies - 1] = 0.;
132 if(fracciontotal != 1.) {
134 "ERROR: La fraccion masica total no puede ser distinta de 1. Repasa la lectura en la condicion de contorno " <<
135 FNumeroCC << std::endl;
139 fgetpos(fich, &filepos);
144 catch(exception & N) {
145 std::cout <<
"ERROR: TCCPreVble::LecturaPulso en la condicion de contorno: " << FNumeroCC << std::endl;
146 std::cout <<
"Tipo de error: " << N.what() << std::endl;
154 void TCCPreVble::CalculaCondicionContorno(
double Time) {
156 double Pressure, Temp, Ason, FraccionMasicaAcum = 0.;
158 FGamma = FTuboExtremo[0].Pipe->
GetGamma(FNodoFin);
159 double Gamma3 = (FGamma - 1) / 2;
160 double R = FTuboExtremo[0].Pipe->
GetRMezcla(FNodoFin);
162 FTiempo = FTuboExtremo[0].Pipe->
getTime1();
163 FPulso->BusquedaInstante(FTiempo);
165 Pressure = FPulso->InterpolaPresion();
166 Temp = FPulso->InterpolaEntropia();
168 double rel_CCon_entropia = *FCC / FTuboExtremo[0].Entropia;
169 double yyy = pow(Pressure / FPref, __Gamma::G5(FGamma));
171 if(rel_CCon_entropia / yyy < 1.0) {
173 Ason = sqrt(FGamma * R * __units::degCToK(Temp)) / __cons::ARef;
174 double AA = Ason / pow(Pressure, __Gamma::G5(FGamma));
175 double U = (*FCC - Ason * FTuboExtremo[0].Entropia / AA) / Gamma3;
176 *FCC = Ason + Gamma3 * U;
177 *FCD = Ason - Gamma3 * U;
178 FTuboExtremo[0].Entropia = Ason / pow(Pressure, __Gamma::G5(FGamma));
180 Ason = FTuboExtremo[0].Entropia * pow(Pressure, __Gamma::G5(FGamma));
181 *FCD = 2 * Ason - *FCC;
190 for(
int j = 0; j < FNumeroEspecies - 2; j++) {
192 FraccionMasicaAcum += FFraccionMasicaEspecie[j];
194 FFraccionMasicaEspecie[FNumeroEspecies - 2] = 1. - FraccionMasicaAcum;
196 FFraccionMasicaEspecie[FNumeroEspecies - 1] = FTuboExtremo[0].Pipe->
GetFraccionMasicaCC(FIndiceCC, FNumeroEspecies - 1);
197 }
else if(*FCD > *FCC) {
198 for(
int j = 0; j < FNumeroEspecies - FIntEGR; j++) {
199 FFraccionMasicaEspecie[j] = FComposicion[j];
205 }
catch(exception & N) {
206 std::cout <<
"ERROR: TCCPreVble::CalculaCondicionesContorno en la condicion de contorno: " << FNumeroCC << std::endl;
207 std::cout <<
"Tipo de error: " << N.what() << std::endl;
215 #pragma package(smart_init) double getTime1() const
Gets the time at the following time-step.
double GetGamma(int i) const
Gets the specific heat capacities ratio at a given cell.
double GetFraccionMasicaCC(int j, int i)
double GetFraccionMasicaInicial(int i) const
Gets the initial mass fraction of species i.
double GetRMezcla(int i) const
Gets the gas constant of the mixture at a given cell.
a Finite differences pipe.