OpenWAM
TAjusteTransCalorCil.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 "TAjusteTransCalorCil.h"
32 
33 //---------------------------------------------------------------------------
34 //---------------------------------------------------------------------------
35 
36 TAjusteTransCalorCil::TAjusteTransCalorCil() {
37 
38 }
39 
40 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
42 
43 TAjusteTransCalorCil::~TAjusteTransCalorCil() {
44 
45  if(FCiclo != NULL)
46  delete[] FCiclo;
47  if(FCadmision != NULL)
48  delete[] FCadmision;
49  if(FCescape != NULL)
50  delete[] FCescape;
51 
52 }
53 
54 //---------------------------------------------------------------------------
55 //---------------------------------------------------------------------------
56 
57 void TAjusteTransCalorCil::CalculaTCC(double TiempoActual, double Regimen) {
58  try {
59  int jmax = 0, j = 0;
60  double deltaT = 0., t = 0.;
61  jmax = FCiclo[FNumeroTramos - 1];
62 
63  if(TiempoActual < FCiclo[1] * 120 / Regimen) {
64  FCaqAdm = FCadmision[0];
65  FCaqEsc = FCescape[0];
66  }
67 
68  j = 1;
69  while(TiempoActual > FCiclo[j] * 120 / Regimen && j < jmax) {
70  j++;
71  }
72  if(j == jmax) {
73  FCaqAdm = FCadmision[jmax];
74  FCaqEsc = FCescape[jmax];
75  } else {
76  deltaT = (FCiclo[j] - FCiclo[j - 1]) * 120 / Regimen;
77  t = TiempoActual - FCiclo[j - 1] * 120 / Regimen;
78  FCaqAdm = xit_(FCadmision[j - 1], FCadmision[j], deltaT, t);
79  FCaqEsc = xit_(FCescape[j - 1], FCescape[j], deltaT, t);
80  }
81  /*
82  if(TiempoActual>FCicloCambioTC*120/Regimen && TiempoActual<FCicloCambioTC2*120/Regimen){
83  FCaqAdm=FCaqAdm2;
84  }else if(TiempoActual>FCicloCambioTC2*120/Regimen){
85  FCaqAdm=FCaqAdm3;
86  } */
87  } catch(exception &N) {
88  std::cout << "ERROR: TTransCalorCil::CalculaTCC (DLL)" << std::endl;
89  std::cout << "Tipo de error: " << N.what() << std::endl;
90  throw Exception(N.what());
91  }
92 }
93 
94 //---------------------------------------------------------------------------
95 //---------------------------------------------------------------------------
96 
97 void TAjusteTransCalorCil::IniciaTCC(int NumeroTramos, int *Ciclo, double *CoefTCAdm, double *CoefTCEsc) {
98  try {
99  FCiclo = new int[NumeroTramos];
100  FCadmision = new double[NumeroTramos];
101  FCescape = new double[NumeroTramos];
102  FNumeroTramos = NumeroTramos;
103  for(int i = 0; i < NumeroTramos; i++) {
104  FCiclo[i] = Ciclo[i];
105  FCadmision[i] = CoefTCAdm[i];
106  FCescape[i] = CoefTCEsc[i];
107  }
108 
109  FCaqAdm = FCadmision[0];
110  FCaqEsc = FCescape[0];
111 
112  } catch(exception &N) {
113  std::cout << "ERROR: TTransCalorCil::CalculaCD (DLL)" << std::endl;
114  std::cout << "Tipo de error: " << N.what() << std::endl;
115  throw Exception(N.what());
116  }
117 }
118 
119 //---------------------------------------------------------------------------
120 //---------------------------------------------------------------------------
121 
122 double TAjusteTransCalorCil::xit_(double vizq, double vder, double axid, double xif) {
123  try {
124  double xx = 0., yy = 0.;
125  double ret_val = 0.;
126 
127  xx = vder - vizq;
128  if(axid != 0.) {
129  yy = xx / axid * xif;
130  ret_val = vizq + yy;
131  } else {
132  printf("ERROR: valores entrada xit\n");
133  throw Exception("");
134  }
135  return ret_val;
136  } catch(exception &N) {
137  std::cout << "ERROR: TAjusteTransCalorCil::xit_" << std::endl;
138  std::cout << "Tipo de error: " << N.what() << std::endl;
139  throw Exception(N.what());
140  }
141 }
142 
143 //---------------------------------------------------------------------------
144 //---------------------------------------------------------------------------
145 
146 #pragma package(smart_init)
Exception
Custom exception class.
Definition: Exception.hpp:39