OpenWAM
TCCExternalConnectionVol.cpp
1 // ---------------------------------------------------------------------------
2 
3 #pragma hdrstop
4 
5 #include "TCCExternalConnectionVol.h"
6 #include "TTubo.h"
7 
8 // ---------------------------------------------------------------------------
9 
10 TCCExternalConnectionVol::TCCExternalConnectionVol(nmTypeBC TipoCC, int numCC, nmTipoCalculoEspecies SpeciesModel,
11  int numeroespecies, nmCalculoGamma GammaCalculation, bool ThereIsEGR) :
12  TCondicionContorno(TipoCC, numCC, SpeciesModel, numeroespecies, GammaCalculation, ThereIsEGR) {
13 
14  FTuboExtremo = NULL;
15  FTime0 = 0;
16 
17  FTimeSum = 0;
18 
19  FT_BoundarySum = 0;
20  FU_BoundarySum = 0;
21  FP_BoundarySum = 0;
22 
23  // FComposicion = NULL;
24 
25 }
26 
27 TCCExternalConnectionVol::~TCCExternalConnectionVol() {
28 }
29 
30 void TCCExternalConnectionVol::UpdateCurrentExternalProperties(double U0, double T0, double P0, double t) {
31 
32  FUExt = U0;
33  FTExt = T0;
34  FPExt = P0;
35 
36  FCurrentTime = t;
37 }
38 
39 void TCCExternalConnectionVol::AsignGeometricalData(double D0, double deltaX) {
40 
41  FDExt = D0;
42  FAExt = __geom::Circle_area(D0);
43 
44  FDeltaX = deltaX;
45 }
46 
47 void TCCExternalConnectionVol::ExternalCharacteristics(double Time) {
48 
49  // Calculo Entropia
50  double x = 0., Px = 0., Tx = 0., Ux = 0., Ax = 0.;
51  // double Deltat = Time - FTime0;
52 
53  double g = __Gamma::G;
54  double gg = __Gamma::G_5;
55 
56  double A0 = sqrt(g * __R::Air * FTExt);
57 
58  FA_AExt = A0 / pow(__units::PaToBar(FPExt), gg) / __cons::ARef;
59 
60  FK_CExt = (A0 + (g - 1) / 2 * FUExt) / __cons::ARef;
61 
62 }
63 
64 void TCCExternalConnectionVol::CalculaCondicionContorno(double Time) {
65 
66  double flujo = 0.;
67 
68  ExternalCharacteristics(Time);
69 
70  flujo = (FK_CExt / FA_AExt) / (*FCC / FTuboExtremo[0].Entropia);
71 
72  if(flujo < 0.999995) {
73 
74  double A = FTuboExtremo[0].Entropia / (FTuboExtremo[0].Entropia + FA_AExt) * (*FCC + FK_CExt);
75  FT_Boundary = pow2(A * __cons::ARef) / __R::Air / __Gamma::G;
76  FU_Boundary = (A - *FCC) / __Gamma::G_3;
77  *FCD = A + __Gamma::G_3 * FU_Boundary;
78  FU_Boundary *= __cons::ARef;
79  FP_Boundary = pow(A / FTuboExtremo[0].Entropia, __Gamma::G_4);
80  } else if(flujo > 1.000005) {
81  double A = FA_AExt / (FTuboExtremo[0].Entropia + FA_AExt) * (*FCC + FK_CExt);
82  FT_Boundary = pow2(A * __cons::ARef) / __R::Air / __Gamma::G;
83  FU_Boundary = (FK_CExt - A) / __Gamma::G_3;
84  *FCD = A + __Gamma::G_3 * FU_Boundary;
85  *FCC = A - __Gamma::G_3 * FU_Boundary;
86  FTuboExtremo[0].Entropia = FA_AExt;
87  FU_Boundary *= __cons::ARef;
88  FP_Boundary = pow(A / FTuboExtremo[0].Entropia, __Gamma::G_4);
89 
90  } else {
91  double A = *FCC;
92  FT_Boundary = pow2(A * __cons::ARef) / __R::Air / __Gamma::G;
93  FU_Boundary = 0;
94  *FCD = *FCC;
95  FP_Boundary = pow(A / FTuboExtremo[0].Entropia, __Gamma::G_4);
96  }
97  double deltat = Time - FTime0;
98 
99  FT_BoundarySum = FT_Boundary * deltat;
100  FU_BoundarySum = FU_Boundary * deltat;
101  FP_BoundarySum = FP_Boundary * deltat;
102 
103  FTimeSum = deltat;
104 
105  FTime0 = Time;
106 
107 }
108 
109 void TCCExternalConnectionVol::ReadBoundaryData(const char *FileWAM, fpos_t &filepos, int NumberOfPipes, TTubo **Pipe,
110  int nDPF, TDPF **DPF) {
111 
112  int i = 0;
113 
114  FTuboExtremo = new stTuboExtremo[1];
115  FTuboExtremo[0].Pipe = NULL;
116 
117  while(FNumeroTubosCC < 1 && i < NumberOfPipes) {
118  if(Pipe[i]->getNodoIzq() == FNumeroCC) {
119  FTuboExtremo[FNumeroTubosCC].Pipe = Pipe[i];
120  FTuboExtremo[FNumeroTubosCC].TipoExtremo = nmLeft;
121  FCC = &(FTuboExtremo[FNumeroTubosCC].Beta);
122  FCD = &(FTuboExtremo[FNumeroTubosCC].Landa);
123  FNodoFin = 0;
124  FIndiceCC = 0;
125  FNumeroTubosCC++;
126  }
127  if(Pipe[i]->getNodoDer() == FNumeroCC) {
128  FTuboExtremo[FNumeroTubosCC].Pipe = Pipe[i];
129  FTuboExtremo[FNumeroTubosCC].TipoExtremo = nmRight;
130  FCC = &(FTuboExtremo[FNumeroTubosCC].Landa);
131  FCD = &(FTuboExtremo[FNumeroTubosCC].Beta);
132  FNodoFin = FTuboExtremo[FNumeroTubosCC].Pipe->getNin() - 1;
133  FIndiceCC = 1;
134  FNumeroTubosCC++;
135  }
136  i++;
137  }
138 
139  // Inicializacion del transporte de especies quimicas.
140  FFraccionMasicaEspecie = new double[FNumeroEspecies - FIntEGR];
141  for(int i = 0; i < FNumeroEspecies - FIntEGR; i++) {
142  FFraccionMasicaEspecie[i] = FTuboExtremo[0].Pipe->GetFraccionMasicaInicial(i);
143  }
144 
145  FILE *fich = fopen(FileWAM, "r");
146  fsetpos(fich, &filepos);
147 
148  fscanf(fich, "%d ", &FID);
149 
150  fgetpos(fich, &filepos);
151  fclose(fich);
152 
153 }
154 
155 void TCCExternalConnectionVol::LoadNewData(double* p, double* T, double* u) {
156 
157  if(FTimeSum > 0) {
158  *p = FP_BoundarySum / FTimeSum;
159  *T = FT_BoundarySum / FTimeSum;
160  *u = FU_BoundarySum / FTimeSum;
161  } else {
162  *p = FP_Boundary;
163  *T = FT_Boundary;
164  *u = FU_Boundary;
165  }
166 
167  FT_BoundarySum = 0;
168  FU_BoundarySum = 0;
169  FP_BoundarySum = 0;
170 
171  FTimeSum = 0;
172 }
173 
174 #pragma package(smart_init)
TTubo
a Finite differences pipe.
Definition: TTubo.h:116
stTuboExtremo
Definition: Globales.h:730
TDPF
Definition: TDPF.h:45
TTubo::GetFraccionMasicaInicial
double GetFraccionMasicaInicial(int i) const
Gets the initial mass fraction of species i.
Definition: TTubo.cpp:5440
TCondicionContorno
Definition: TCondicionContorno.h:54
TTubo.h
pow2
T pow2(T x)
Returns x to the power of 2.
Definition: Math_wam.h:88