//******************* Parameters of Array or Single calculation ******************* //********************************* INPUT ****************************************** //*** DATATYP | UNIT | VARIBLE | Description *** //List<string> | [-] | DataFiles (VEH, FC, EMI)| Name of file (e.g. "PC_D_EU4" path neede if not in "Default Vehicles") or aggregated name (PC, HDV, BUS, TW) by FleetMix calculation //List<double> / double | [s] | Time | Time signal //List<double> / double | [m/s] | Velocity | Velocity signal //double | [m/s^2]| acc | Acceleration (ONLY NEDDED BY SINGLE CALCULATION) //List<double> / double | [%] | Gradient | Gradient of the route //out List<VehicleResult> | [-] | VehicleResultsOrg | Returned result list //bool | [-] | fleetMix = false | Optional parameter if fleetMix should be calculate //string | [-] | CommentPref = "c" | Optional parameter for comment prefix //********************************* OUPUT: VehicleResultsOrg ********************** //*** DATATYP | UNIT | VARIBLE | Description *** //string | [-] | vehicle | Name of the vehicle //string | [-] | cycle | Name of the cycle //double | [s] | time | Time //double | [m/s] | speed | Velocity //double | [kW] | power | Calculated power at the engine (ICE for conventional and HEV vehicles, electric engine for BEVs) including engine inertia and auxiliaries; not limited for engine fullload and braking limitations //double | [kW] | P_pos | Positive engine power limited with engine rated power //double | [-] | pNormRated | Engine power normalised with rated engine power and limited with the power range (fullload and drag) as specified in the characteristic curve for fuel consumption //double | [-] | pNormDrive | Engine power normalised with "P_drive" and limited with the power range (fullload and drag) as specified in the characteristic curve for emissions //double | [m/s^2]| acc | Caclulated/given acceleration //Dictionary<string, double>| [*] | Emissiondata | Calculated emissions for all components which are defined in the emission curves. Unit dependent of emission component #region calculate //Calculate data from array public bool CALC_Array(List <string> DataFiles, List <double> Time, List <double> Velocity, List <double> Gradient, out List <VehicleResult> VehicleResultsOrg, bool fleetMix = false, Correction DataCor = null, string CommentPref = "c") { //Declaration int i; double acc; List <VehicleResult> _VehicleResult = new List <VehicleResult>(); //Initialisation Helper.ErrMsg = null; //Borrow Helper.CommentPrefix = CommentPref; _DataPath = new List <string>(); //Set path by normal calculation (on given) and set path by fleetmix (on Default Vehicles) calculation for (i = 0; i < DataFiles.Count; i++) { if ((DataFiles[i].LastIndexOf(@"\")) >= 0) { _DataPath.Add(DataFiles[i]); } else { //_DataPath.Add(Assembly.GetExecutingAssembly().Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf(@"\")) + @"\Default Vehicles\" + Helper.PHEMDataV); _DataPath.Add(DataFiles[i + 1].Substring(0, DataFiles[i + 1].LastIndexOf(@"\"))); _DataPath.Add(DataFiles[i + 1].Substring(0, DataFiles[i + 1].LastIndexOf(@"\"))); _DataPath.Add(DataFiles[i + 1].Substring(0, DataFiles[i + 1].LastIndexOf(@"\"))); i += 1; } } //Read the vehicle and emission data #if FLEET if (fleetMix) { //Set the vehicle class Helper.gClass = _DataPath[0]; //Generate the class DataInput = new CEPHandler(); //Read the FleetShares if (!DataInput.ReadFleetShares(DataFiles[1], Helper)) { VehicleResultsOrg = null; return(false); } //Read the vehicle and emission data if (!DataInput.GetFleetCEP(_DataPath, DataFiles[0], Helper, DataCor)) { VehicleResultsOrg = null; return(false); } } else #endif { //Get vehicle string if (!Helper.setclass(DataFiles[0])) { VehicleResultsOrg = null; return(false); } //Generate the class DataInput = new CEPHandler(); //Read the vehicle and emission data if (!DataInput.GetCEP(_DataPath, Helper, DataCor)) { VehicleResultsOrg = null; return(false); } } //Calculate emissions per second for (i = 1; i <= Time.Count - 1; i++) { //Calculate the acceleration acc = (Velocity[i] - Velocity[i - 1]) / (Time[i] - Time[i - 1]); //Calculate and save the data in the List _VehicleResult.Add(PHEMLight.CreateVehicleStateData(Helper, DataInput.CEPS[Helper.gClass], Time[i - 1], Velocity[i - 1], acc, Gradient[i - 1])); if (Helper.ErrMsg != null) { VehicleResultsOrg = null; return(false); } } VehicleResultsOrg = _VehicleResult; return(true); }
static public VehicleResult CreateVehicleStateData(Helpers Helper, CEP currCep, double time, double inputSpeed, double inputAcc, double Gradient = 0, Correction DataCor = null) { //Declaration double speed = Math.Max(inputSpeed, 0); double acc; double P_pos; //Speed/Acceleration limitation if (speed == 0) { acc = 0; } else { acc = Math.Min(inputAcc, currCep.GetMaxAccel(speed, Gradient, (Helper.pClass == Constants.strBEV | Helper.uClass == Constants.strHybrid))); } //Calculate the power double power = currCep.CalcPower(speed, acc, Gradient, (Helper.pClass == Constants.strBEV | Helper.uClass == Constants.strHybrid)); double P_eng = currCep.CalcEngPower(power); double Pwheel = 0; if (Helper.uClass == Constants.strHybrid) { Pwheel = currCep.CalcWheelPower(speed, acc, Gradient); } //Power limitation if (P_eng >= 0) { P_pos = power; } else { P_pos = 0; } //Calculate the result values (BEV) if (Helper.pClass == Constants.strBEV) { return(new VehicleResult(Helper.gClass, "", time, speed, Gradient, P_eng, P_pos, P_eng / currCep.RatedPower, P_eng / currCep.DrivingPower, acc, currCep.GetAllEmission(P_eng, speed, Helper))); } //Calculate the decel costing double decelCoast = currCep.GetDecelCoast(speed, acc, Gradient); //Calculate the result values (Zero emissions by costing, Idling emissions by v <= 0.5m / s²) if (acc >= decelCoast || speed <= Constants.ZERO_SPEED_ACCURACY) { if (Helper.uClass == Constants.strHybrid) { return(new VehicleResult(Helper.gClass, "", time, speed, Gradient, P_eng, P_pos, P_eng / currCep.RatedPower, P_eng / currCep.DrivingPower, acc, currCep.GetAllEmission(Pwheel, speed, Helper))); } else { return(new VehicleResult(Helper.gClass, "", time, speed, Gradient, P_eng, P_pos, P_eng / currCep.RatedPower, P_eng / currCep.DrivingPower, acc, currCep.GetAllEmission(P_eng, speed, Helper))); } } else { if (Helper.uClass == Constants.strHybrid) { return(new VehicleResult(Helper.gClass, "", time, speed, Gradient, P_eng, P_pos, P_eng / currCep.RatedPower, P_eng / currCep.DrivingPower, acc, currCep.GetAllEmission(Pwheel, speed, Helper, true))); } else { return(new VehicleResult(Helper.gClass, "", time, speed, Gradient, P_eng, P_pos, P_eng / currCep.RatedPower, P_eng / currCep.DrivingPower, acc, currCep.GetAllEmission(P_eng, speed, Helper, true))); } } }
//Calculate single data public bool CALC_Single(List <string> DataFiles, double Time, double Velocity, double acc, double Gradient, out List <VehicleResult> VehicleResultsOrg, bool fleetMix = false, Correction DataCor = null, string CommentPref = "c") { //Declaration List <VehicleResult> _VehicleResult = new List <VehicleResult>(); VehicleResultsOrg = _VehicleResult; //Borrow Helper.CommentPrefix = CommentPref; _DataPath = new List <string>(); //Set path by normal calculation (on given) and set path by fleetmix (on Fleetshare file) calculation for (int i = 0; i < DataFiles.Count; i++) { if ((DataFiles[i].LastIndexOf(@"\")) >= 0) { _DataPath.Add(DataFiles[i]); } else { //_DataPath.Add(Assembly.GetExecutingAssembly().Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf(@"\")) + @"\Default Vehicles\" + Helper.PHEMDataV); _DataPath.Add(DataFiles[i + 1].Substring(0, DataFiles[i + 1].LastIndexOf(@"\"))); _DataPath.Add(DataFiles[i + 1].Substring(0, DataFiles[i + 1].LastIndexOf(@"\"))); _DataPath.Add(DataFiles[i + 1].Substring(0, DataFiles[i + 1].LastIndexOf(@"\"))); i += 1; } } //Read the vehicle and emission data #if FLEET if (fleetMix) { //Set the vehicle class Helper.gClass = "AggClass_" + DataFiles[0]; //Generate the class DataInput = new CEPHandler(); //Read the FleetShares if (!DataInput.ReadFleetShares(DataFiles[1], Helper)) { VehicleResultsOrg = null; return(false); } //Read the vehicle and emission data if (!DataInput.GetFleetCEP(_DataPath, DataFiles[0], Helper, DataCor)) { VehicleResultsOrg = null; return(false); } } else #endif { //Get vehicle string if (!Helper.setclass(DataFiles[0])) { VehicleResultsOrg = null; return(false); } //Generate the class DataInput = new CEPHandler(); //Read the vehicle and emission data if (!DataInput.GetCEP(_DataPath, Helper, DataCor)) { VehicleResultsOrg = null; return(false); } } //Calculate and save the data in the List _VehicleResult.Add(PHEMLight.CreateVehicleStateData(Helper, DataInput.CEPS[Helper.gClass], Time, Velocity, acc, Gradient)); VehicleResultsOrg = _VehicleResult; return(true); }