OpenWAM
TCondicionContorno.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 "TCondicionContorno.h"
32 //#include <cmath>
33 #ifdef __BORLANDC__
34 #include <vcl.h>
35 #endif
36 #include "TTubo.h"
37 
38 //---------------------------------------------------------------------------
39 
40 TCondicionContorno::TCondicionContorno(nmTypeBC TipoCC, int numCC, nmTipoCalculoEspecies SpeciesModel,
41  int numeroespecies, nmCalculoGamma GammaCalculation, bool ThereIsEGR) {
42 
43  FCalculoEspecies = SpeciesModel;
44  FNumeroEspecies = numeroespecies;
45  FCalculoGamma = GammaCalculation;
46  FFraccionMasicaEspecie = NULL;
47 
48 //FTuboExtremo=NULL;
49 
50  FTipoCC = TipoCC;
51  FNumeroCC = numCC + 1;
52  FNumeroTubosCC = 0;
53 
54  FHayEGR = ThereIsEGR;
55  if(FHayEGR)
56  FIntEGR = 0;
57  else
58  FIntEGR = 1;
59 
60  FUnionDPF = false;
61 
62 }
63 
64 //---------------------------------------------------------------------------
65 //---------------------------------------------------------------------------
66 
67 TCondicionContorno::~TCondicionContorno() {
68 
69  if(FFraccionMasicaEspecie != NULL)
70  delete[] FFraccionMasicaEspecie;
71 
72 }
73 
74 //---------------------------------------------------------------------------
75 //---------------------------------------------------------------------------
76 
77 stTuboExtremo TCondicionContorno::GetTuboExtremo(int i) {
78  return FTuboExtremo[i];
79 }
80 
81 //---------------------------------------------------------------------------
82 //---------------------------------------------------------------------------
83 
84 void TCondicionContorno::PutBeta(int i, double valor) {
85 
86  FTuboExtremo[i].Beta = valor;
87 
88 }
89 
90 //---------------------------------------------------------------------------
91 //---------------------------------------------------------------------------
92 
93 void TCondicionContorno::PutLanda(int i, double valor) {
94 
95  FTuboExtremo[i].Landa = valor;
96 
97 }
98 
99 //---------------------------------------------------------------------------
100 //---------------------------------------------------------------------------
101 
102 void TCondicionContorno::PutEntropia(int i, double valor) {
103 
104  FTuboExtremo[i].Entropia = valor;
105 
106 }
107 
108 //---------------------------------------------------------------------------
109 //---------------------------------------------------------------------------
110 //
112 //{
113 //FPosicionNodo=valor;
114 //}
115 
116 //---------------------------------------------------------------------------
117 //---------------------------------------------------------------------------
118 
119 double TCondicionContorno::GetFraccionMasicaEspecie(int i) {
120  try {
121  return FFraccionMasicaEspecie[i];
122  } catch(exception &N) {
123  std::cout << "ERROR: TCondicionContorno::GetConcentracionEspecie en la condicion de contorno: " << FNumeroCC <<
124  std::endl;
125  std::cout << "Tipo de error: " << N.what() << std::endl;
126  throw Exception(N.what());
127  }
128 }
129 
130 //---------------------------------------------------------------------------
131 //---------------------------------------------------------------------------
132 double TCondicionContorno::GetEntropia(int i) {
133 
134  return FTuboExtremo[i].Entropia;
135 
136 }
137 
138 //---------------------------------------------------------------------------
139 //---------------------------------------------------------------------------
140 
141 double TCondicionContorno::GetBeta(int i) {
142 
143  return FTuboExtremo[i].Beta;
144 
145 }
146 
147 //---------------------------------------------------------------------------
148 //---------------------------------------------------------------------------
149 
150 double TCondicionContorno::GetLanda(int i) {
151 
152  return FTuboExtremo[i].Landa;
153 
154 }
155 
156 //---------------------------------------------------------------------------
157 //---------------------------------------------------------------------------
158 
159 void TCondicionContorno::CalculaCaracteristicas(double Time) {
160 
161  for(int i = 0; i < FNumeroTubosCC; i++) {
162  double dt = Time - FTuboExtremo[i].Pipe->getTime0();
163  if(FTuboExtremo[i].TipoExtremo == nmRight) {
164  int nin = FTuboExtremo[i].Pipe->getNin() - 1;
165  if(FTuboExtremo[i].Pipe->GetVelocidad(nin) > 0) {
166  FTuboExtremo[i].Entropia = FTuboExtremo[i].Pipe->Interpola_Entropia(FTuboExtremo[i].TipoExtremo, dt);
167  }
168  FTuboExtremo[i].Landa = FTuboExtremo[i].Pipe->Interpola_Caracteristica(FTuboExtremo[i].Entropia, -1, nin, dt);
169  } else {
170  if(FTuboExtremo[i].Pipe->GetVelocidad(0) < 0) {
171  FTuboExtremo[i].Entropia = FTuboExtremo[i].Pipe->Interpola_Entropia(FTuboExtremo[i].TipoExtremo, dt);
172  }
173  FTuboExtremo[i].Beta = FTuboExtremo[i].Pipe->Interpola_Caracteristica(FTuboExtremo[i].Entropia, 1, 0, dt);
174  }
175  }
176 }
177 
178 //---------------------------------------------------------------------------
179 //---------------------------------------------------------------------------
180 
181 #pragma package(smart_init)
182 
stTuboExtremo
Definition: Globales.h:730
TTubo::Interpola_Caracteristica
double Interpola_Caracteristica(double entropia, int signo, int extremo, double DeltaTiempo)
Definition: TTubo.cpp:4584
Exception
Custom exception class.
Definition: Exception.hpp:39
TTubo::getTime0
double getTime0() const
Gets the current time.
Definition: TTubo.cpp:5488
TTubo.h
TTubo::Interpola_Entropia
double Interpola_Entropia(nmPipeEnd TipoExtremoTubo, double DeltaTiempo)
Definition: TTubo.cpp:4441