forked from bobsayshilol/engine-sim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpiston.cpp
More file actions
52 lines (43 loc) · 1.22 KB
/
piston.cpp
File metadata and controls
52 lines (43 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "../include/piston.h"
#include "../include/connecting_rod.h"
#include "../include/crankshaft.h"
#include "../include/cylinder_bank.h"
#include <cmath>
Piston::Piston() {
m_rod = nullptr;
m_bank = nullptr;
m_cylinderConstraint = nullptr;
m_cylinderIndex = -1;
m_compressionHeight = 0.0;
m_displacement = 0.0;
m_wristPinLocation = 0.0;
m_mass = 0.0;
m_blowby_k = 0.0;
}
Piston::~Piston() {
/* void */
}
void Piston::initialize(const Parameters ¶ms) {
m_rod = params.Rod;
m_bank = params.Bank;
m_cylinderIndex = params.CylinderIndex;
m_compressionHeight = params.CompressionHeight;
m_displacement = params.Displacement;
m_wristPinLocation = params.WristPinPosition;
m_mass = params.Mass;
m_blowby_k = params.BlowbyFlowCoefficient;
}
void Piston::destroy() {
/* void */
}
double Piston::relativeX() const {
return m_body.p_x - m_bank->getX();
}
double Piston::relativeY() const {
return m_body.p_y - m_bank->getY();
}
double Piston::calculateCylinderWallForce() const {
return std::sqrt(
m_cylinderConstraint->F_x[0][0] * m_cylinderConstraint->F_x[0][0]
+ m_cylinderConstraint->F_y[0][0] * m_cylinderConstraint->F_y[0][0]);
}