OpenWAM
TMuelle.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 "TMuelle.h"
32 
33 //---------------------------------------------------------------------------
34 //---------------------------------------------------------------------------
35 
36 TMuelle::TMuelle() {
37 
38  /* Introduccion de los valores de rigidez, amortiguamiento y masa del muelle */
39 
40  FRigidez = 1;
41  FAmort = 1;
42  FMasa = 1;
43  Fx = 0;
44  Fdx = 0;
45 
46 }
47 
48 //---------------------------------------------------------------------------
49 //---------------------------------------------------------------------------
50 
51 TMuelle::~TMuelle() {
52 
53 }
54 
55 //---------------------------------------------------------------------------
56 //---------------------------------------------------------------------------
57 
58 void TMuelle::CalculaPosicion(double fuerza, double DeltaT) {
59  try {
60  double ddx = 0., xact = 0., dxact = 0.;
61 
62  ddx = (fuerza - FRigidez * Fx - FAmort * Fdx) / FMasa;
63 
64  xact = Fx + Fdx * DeltaT + DeltaT * DeltaT * ddx / 2.;
65 
66  dxact = Fdx + DeltaT * ddx;
67 
68  Fx = xact;
69 
70  Fdx = dxact;
71 
72  }
73 
74  catch(exception &N) {
75  std::cout << "ERROR: Calculo de la Posicion del Muelle(DLL)" << std::endl;
76  std::cout << "Tipo de error: " << N.what() << std::endl;
77  throw Exception(N.what());
78  }
79 }
80 
81 //---------------------------------------------------------------------------
82 
83 #pragma package(smart_init)
Exception
Custom exception class.
Definition: Exception.hpp:39