diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PCCSegmentPreprocessor.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PCCSegmentPreprocessor.cs index 4dd9f0f4c87c67d0d40d18673b988a8e4ac925c1..329de2f500c317242c43f53f784b7f3d1181fa7c 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PCCSegmentPreprocessor.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PCCSegmentPreprocessor.cs @@ -37,15 +37,16 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var runData = Container.RunData; // average drag of all electric engines (if present) - var electricEngineDrag = runData.ElectricMachinesData?.Average(e => - e.Item2.EfficiencyData.VoltageLevels[0].DragCurve.Entries.Average(x => - (x.MotorSpeed * x.DragTorque).Value())).SI<Watt>() - ?? 0.SI<Watt>(); + var electricEngineDrag = !runData.ElectricMachinesData.Any() + ? 0.SI<Watt>() + : runData.ElectricMachinesData.Average(e => + e.Item2.EfficiencyData.VoltageLevels[0].DragCurve.Entries.Average(x => + (x.MotorSpeed * x.DragTorque).Value())).SI<Watt>(); - // average drag for the combustion engine (if present). + // average drag for the combustion engine (if present) var combustionEngineDrag = runData.EngineData?.FullLoadCurves[0].FullLoadEntries.Average(x => - (x.EngineSpeed * x.TorqueDrag).Value()).SI<Watt>() - ?? 0.SI<Watt>(); + (x.EngineSpeed * x.TorqueDrag).Value()).SI<Watt>() + ?? 0.SI<Watt>(); var engineDrag = electricEngineDrag + combustionEngineDrag; var slopeEngineDrag = 0.0;