Eclipse SUMO - Simulation of Urban MObility
EngineParameters.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 /****************************************************************************/
19 
20 #include <config.h>
21 
22 #include <cmath>
23 #include <utils/geom/GeomHelper.h> // for M_PI
24 #include "EngineParameters.h"
25 
26 
27 EngineParameters::EngineParameters() : nGears(5), differentialRatio(3.714), wheelDiameter_m(0.94),
28  mass_kg(1300), cAir(0.3), a_m2(2.7), rho_kgpm3(1.2), cr1(0.0136), cr2(5.18e-7),
29  slope(0.), tiresFrictionCoefficient(0.7), engineEfficiency(0.8),
30  massFactor(1.089), cylinders(4), dt(0.01), minRpm(1000), maxRpm(7000),
31  brakesTau_s(0.2), tauEx_s(0.1), tauBurn_s(-1), fixedTauBurn(false) {
32  id = "";
33  //set default gear ratios
34  gearRatios = new double[nGears];
35  gearRatios[0] = 3.909;//4.5;
36  gearRatios[1] = 2.238;//3.5;//2.6;
37  gearRatios[2] = 1.520;//2.5;//1.5;
38  gearRatios[3] = 1.156;//1.5;//1.0;
39  gearRatios[4] = 0.971;//1.0;//0.8;
40  //default engine mapping
42  engineMapping.x[0] = -7.50084;
43  engineMapping.x[1] = 0.02045;
44  //default shifting rule
45  shiftingRule.rpm = 6000;
46  shiftingRule.deltaRpm = 100;
47  //initialize precomputed coefficients
49 
50 }
51 
53  nGears(other.nGears), differentialRatio(other.differentialRatio), wheelDiameter_m(other.wheelDiameter_m),
54  mass_kg(other.mass_kg), cAir(other.cAir), a_m2(other.a_m2), rho_kgpm3(other.rho_kgpm3), cr1(other.cr1), cr2(other.cr2),
55  slope(other.slope), tiresFrictionCoefficient(other.tiresFrictionCoefficient), engineEfficiency(other.engineEfficiency),
56  massFactor(other.massFactor), cylinders(other.cylinders), dt(other.dt), minRpm(other.minRpm), maxRpm(other.maxRpm),
57  brakesTau_s(other.brakesTau_s), tauEx_s(other.tauEx_s), tauBurn_s(other.tauBurn_s), fixedTauBurn(other.fixedTauBurn) {
58  id = other.id;
59  gearRatios = new double[nGears];
60  for (int i = 0; i < nGears; i++) {
61  gearRatios[i] = other.gearRatios[i];
62  }
64  for (int i = 0; i < engineMapping.degree; i++) {
65  engineMapping.x[i] = other.engineMapping.x[i];
66  }
70 }
72  id = other.id;
73  nGears = other.nGears;
76  mass_kg = other.mass_kg;
77  cAir = other.cAir;
78  a_m2 = other.a_m2;
79  rho_kgpm3 = other.rho_kgpm3;
80  cr1 = other.cr1;
81  cr2 = other.cr2;
82  slope = other.slope;
85  massFactor = other.massFactor;
86  cylinders = other.cylinders;
87  dt = other.dt;
88  minRpm = other.minRpm;
89  maxRpm = other.maxRpm;
90  delete [] gearRatios;
91  gearRatios = new double[nGears];
92  for (int i = 0; i < nGears; i++) {
93  gearRatios[i] = other.gearRatios[i];
94  }
96  for (int i = 0; i < engineMapping.degree; i++) {
97  engineMapping.x[i] = other.engineMapping.x[i];
98  }
101  brakesTau_s = other.brakesTau_s;
102  tauBurn_s = other.tauBurn_s;
103  tauEx_s = other.tauEx_s;
104  fixedTauBurn = other.fixedTauBurn;
106  return *this;
107 }
108 
110  delete [] gearRatios;
111 }
112 
117  __gravity = mass_kg * massFactor * GRAVITY_MPS2 * sin(slope / 180 * M_PI);
123  __brakesAlpha = dt / (brakesTau_s + dt);
125  __engineTau1 = (420.0 * cylinders - 240.0) / (2.0 * cylinders);
126  __engineTau2 = (120.0 * cylinders - 120.0) / cylinders;
128 }
129 
130 void EngineParameters::dumpParameters(std::ostream& out) {
131  out << "ID: " << id.c_str() << std::endl;
132 
133  out << "Gearbox:\n";
134  out << "\tGears number: " << (int)nGears << std::endl;
135  for (int i = 0; i < nGears; i++) {
136  out << std::setprecision(4) << "\tRatio of gear " << (i + 1) << ": " << gearRatios[i] << std::endl;
137  }
138  out << std::setprecision(4) << "\tFinal drive ratio: " << differentialRatio << std::endl;
139 
140  out << "Wheels:\n";
141  out << std::setprecision(3) << "\tDiameter: " << wheelDiameter_m << " m\n";
142  out << std::setprecision(3) << "\tFriction coefficient: " << tiresFrictionCoefficient << std::endl;
143  out << std::setprecision(10) << "\tcr1: " << cr1 << std::endl;
144  out << std::setprecision(10) << "\tcr2: " << cr2 << std::endl;
145 
146  out << "Mass:\n";
147  out << std::setprecision(2) << "\tMass: " << mass_kg << " kg\n";
148  out << std::setprecision(4) << "\tMass factor: " << massFactor << std::endl;
149 
150  out << "Air drag:\n";
151  out << std::setprecision(4) << "\tDrag coefficient: " << cAir << std::endl;
152  out << std::setprecision(3) << "\tMax section: " << a_m2 << " m^2\n";
153 
154  out << "Engine:\n";
155  out << "\tEfficiency: " << engineEfficiency << std::endl;
156  out << "\tCylinders: " << cylinders << std::endl;
157  out << "\tMinimum rpm: " << minRpm << std::endl;
158  out << "\tMaximum rpm: " << maxRpm << std::endl;
159  out << "\tMapping (rpm to hp) degree: " << engineMapping.degree << std::endl;
160  for (int i = 0; i < engineMapping.degree; i++) {
161  out << "\t\tMapping coefficient x" << i << ": " << engineMapping.x[i] << std::endl;
162  }
163  out << "\tShifting rpm: " << shiftingRule.rpm << std::endl;
164  out << "\tShifting delta: " << shiftingRule.deltaRpm << std::endl;
165 
166  out << "Brakes:\n";
167  out << "\tTime constant (s): " << brakesTau_s << std::endl;
168 
169  out << "Vehicle unrelated parameters:\n";
170  out << std::setprecision(4) << "\tAir density: " << rho_kgpm3 << " kg/m^3\n";
171  out << "\tRoad slope: " << slope << " degrees\n";
172  out << std::setprecision(3) << "\tSimulation sampling time: " << dt << " s\n";
173 }
#define GRAVITY_MPS2
#define HP_TO_W
double __airFrictionCoefficient
struct PolynomialEngineModelRpmToHp engineMapping
void dumpParameters(std::ostream &out)
EngineParameters & operator=(const EngineParameters &other)
double __speedToRpmCoefficient
double tiresFrictionCoefficient
double __speedToThrustCoefficient
struct GearShiftingRules shiftingRule
double __maxNoSlipAcceleration
double __rpmToSpeedCoefficient
double __maxAccelerationCoefficient
#define M_PI
Definition: odrSpiral.cpp:45