LCOV - code coverage report
Current view: top level - src/foreign/PHEMlight/V5/cpp - CEP.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 10 10
Test Date: 2024-12-21 15:45:41 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2016-2024 German Aerospace Center (DLR) and others.
       4              : // PHEMlight module
       5              : // Copyright (C) 2016-2023 Technische Universitaet Graz, https://www.tugraz.at/
       6              : // This program and the accompanying materials are made available under the
       7              : // terms of the Eclipse Public License 2.0 which is available at
       8              : // https://www.eclipse.org/legal/epl-2.0/
       9              : // This Source Code may also be made available under the following Secondary
      10              : // Licenses when the conditions for such availability set forth in the Eclipse
      11              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      12              : // or later which is available at
      13              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      14              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      15              : /****************************************************************************/
      16              : /// @file    CEP.h
      17              : /// @author  Martin Dippold
      18              : /// @author  Michael Behrisch
      19              : /// @date    July 2016
      20              : ///
      21              : //
      22              : /****************************************************************************/
      23              : #pragma once
      24              : 
      25              : #define _USE_MATH_DEFINES
      26              : #include <string>
      27              : #include <map>
      28              : #include <vector>
      29              : #include <cmath>
      30              : #include <utility>
      31              : #include "CEPHandler.h"
      32              : 
      33              : //C# TO C++ CONVERTER NOTE: Forward class declarations:
      34              : namespace PHEMlightdllV5 { class VEHPHEMLightJSON; }
      35              : namespace PHEMlightdllV5 { class VEH; }
      36              : namespace PHEMlightdllV5 { class Helpers; }
      37              : 
      38              : #define FLEET
      39              : 
      40              : namespace PHEMlightdllV5 {
      41              :     class CEP {
      42              :     public:
      43              :         enum eNormalizingType {
      44              :             eNormalizingType_RatedPower,
      45              :             eNormalizingType_DrivingPower
      46              :         };
      47              : 
      48              :     private:
      49              :         bool privateHeavyVehicle;
      50              :         std::string privateFuelType;
      51              :         std::string privateCalcType;
      52              :         double privateRatedPower;
      53              : 
      54              :     public:
      55              :         CEP(VEHPHEMLightJSON::VEH* Vehicle, std::vector<std::string>& headerLineFCvalues, std::vector<std::vector<double> >& matrixFCvalues, std::vector<std::string>& headerLinePollutants, std::vector<std::vector<double> >& matrixPollutants, std::vector<double>& idlingFCvalues, std::vector<double>& idlingPollutants);
      56              : 
      57              : 
      58              :         const bool&  getHeavyVehicle() const;
      59              :         const std::string&  getFuelType() const;
      60              :         void setFuelType(const std::string& value);
      61              :         const std::string&  getCalcType() const;
      62              :         void setCalcType(const std::string& value);
      63              : 
      64              :     public:
      65              :         const double&  getRatedPower() const;
      66              :         void setRatedPower(const double&  value);
      67              :         double getAuxPower() const {
      68       203307 :             return _auxPower * getRatedPower();
      69              :         }
      70              :         double getVehicleMass() const {
      71       349355 :             return _massVehicle;
      72              :         }
      73              :         double getVehicleLoading() const {
      74       349355 :             return _vehicleLoading;
      75              :         }
      76              :         double getVehicleMassRot() const {
      77       263712 :             return _vehicleMassRot;
      78              :         }
      79              :         double getCrossSectionalArea() const {
      80       288950 :             return _crossSectionalArea;
      81              :         }
      82              :         double getCWValue() const {
      83       288950 :             return _cWValue;
      84              :         }
      85              :         double getWheelRadius() const {
      86        85643 :             return _effectiveWheelDiameter / 2.;
      87              :         }
      88              :         double getResistanceF0() const {
      89       288950 :             return _resistanceF0;
      90              :         }
      91       288950 :         double getResistance(const double speed, const double f0) const {
      92       288950 :             return f0 + _resistanceF1 * speed + _resistanceF2 * std::pow(speed, 2) + _resistanceF3 * std::pow(speed, 3) + _resistanceF4 * std::pow(speed, 4);
      93              :         }
      94              :         double getFMot(const double speed, const double ratedPower, const double wheelRadius);
      95              : 
      96              :     protected:
      97              :         double _massVehicle;
      98              :         double _vehicleLoading;
      99              :         double _vehicleMassRot;
     100              :         double _crossSectionalArea;
     101              :         double _cWValue;
     102              :         double _resistanceF0;
     103              :         double _resistanceF1;
     104              :         double _resistanceF2;
     105              :         double _resistanceF3;
     106              :         double _resistanceF4;
     107              :         double _axleRatio;
     108              :         double _auxPower;
     109              :         double _pNormV0;
     110              :         double _pNormP0;
     111              :         double _pNormV1;
     112              :         double _pNormP1;
     113              : 
     114              :         double _engineRatedSpeed;
     115              :         double _engineIdlingSpeed;
     116              :         double _effectiveWheelDiameter;
     117              : 
     118              :         std::vector<double> _speedPatternRotational;
     119              :         std::vector<double> _normalizedPowerPatternFCvalues;
     120              :         std::vector<double> _normalizedPowerPatternPollutants;
     121              : 
     122              :         std::map<std::string, std::vector<double> > _normedCepCurveFCvalues;
     123              :         std::vector<double> _gearTransmissionCurve;
     124              :         std::vector<double> _speedCurveRotational;
     125              :         std::map<std::string, std::vector<double> > _cepNormalizedCurvePollutants;
     126              :         std::map<std::string, double> _FleetMix;
     127              :         std::map<std::string, double> _idlingValueFCvalues;
     128              :         std::map<std::string, double> _idlingValuesPollutants;
     129              : 
     130              :         std::vector<double> _nNormTable;
     131              :         std::vector<double> _dragNormTable;
     132              : 
     133              :     public:
     134              :         double CalcEngPower(double power, const double ratedPower);
     135              : 
     136              :         double GetEmission(const std::string& pollutant, double power, double speed, Helpers* VehicleClass, const double drivingPower, const double ratedPower);
     137              : 
     138              :         double GetCO2Emission(double _FC, double _CO, double _HC, Helpers* VehicleClass);
     139              : 
     140              :         //Calculate the weighted fuel factor values for Fleetmix
     141              :     private:
     142              :         bool CalcfCValMix(double& _fCBr, double& _fCHC, double& _fCCO, double& _fCCO2, Helpers* VehicleClass);
     143              : 
     144              :         // Get the fuel factor values
     145              :         bool GetfcVals(const std::string& _fuelTypex, double& _fCBr, double& _fCHC, double& _fCCO, double& _fCCO2, Helpers* VehicleClass);
     146              : 
     147              :     public:
     148              :         double GetRotationalCoeffecient(double speed);
     149              : 
     150              : 
     151              :     private:
     152              :         void FindLowerUpperInPattern(int& lowerIndex, int& upperIndex, const std::vector<double>& pattern, double value, double scale=1.);
     153              : 
     154              :         double Interpolate(double px, double p1, double p2, double e1, double e2);
     155              : 
     156              :     public:
     157              :         double GetPMaxNorm(double speed);
     158              : 
     159              :         //--------------------------------------------------------------------------------------------------
     160              :         // Operators for fleetmix
     161              :         //--------------------------------------------------------------------------------------------------
     162              : 
     163              : 
     164              :     private:
     165              :         void InitializeInstanceFields();
     166              :     };
     167              : }
        

Generated by: LCOV version 2.0-1