Select Git revision
CoachPowerTrain.cs
Forked from
VECTO / VECTO Sim
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CoachPowerTrain.cs 7.15 KiB
/*
* Copyright 2015, 2016 Graz University of Technology,
* Institute of Internal Combustion Engines and Thermodynamics,
* Institute of Technical Informatics
*
* Licensed under the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.OutputData.FileIO;
using TUGraz.VectoCore.Tests.Utils;
using TUGraz.VectoCore.Utils;
using Wheels = TUGraz.VectoCore.Models.SimulationComponent.Impl.Wheels;
namespace TUGraz.VectoCore.Tests.Integration
{
public class CoachPowerTrain
{
public const string AccelerationFile = @"TestData\Components\Truck.vacc";
public const string EngineFile = @"TestData\Components\24t Coach.veng";
public const string AxleGearLossMap = @"TestData\Components\Axle.vtlm";
public const string GearboxIndirectLoss = @"TestData\Components\Indirect Gear.vtlm";
public const string GearboxDirectLoss = @"TestData\Components\Direct Gear.vtlm";
public const string GearboxShiftPolygonFile = @"TestData\Components\ShiftPolygons.vgbs";
public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld";
public static VectoRun CreateEngineeringRun(DrivingCycleData cycleData, string modFileName,
bool overspeed = false)
{
var container = CreatePowerTrain(cycleData, modFileName.Replace(".vmod", ""), overspeed);
return new DistanceRun(container);
}
public static VehicleContainer CreatePowerTrain(DrivingCycleData cycleData, string modFileName,
bool overspeed = false)
{
var fileWriter = new FileOutputWriter(modFileName, "");
var modData = new ModalDataContainer(modFileName, fileWriter);
var container = new VehicleContainer(modData, null, ExecutionMode.Engineering);
var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(EngineFile);
var axleGearData = CreateAxleGearData();
var gearboxData = CreateGearboxData();
var vehicleData = CreateVehicleData(3300.SI<Kilogram>());
//var retarder = new RetarderData { Type = RetarderData.RetarderType.None };
var driverData = CreateDriverData(AccelerationFile, overspeed);
var cycle = new DistanceBasedDrivingCycle(container, cycleData);
var engine = new CombustionEngine(container, engineData);
var clutch = new Clutch(container, engineData, engine.IdleController);
dynamic tmp = Port.AddComponent(cycle, new Driver(container, driverData, new DefaultDriverStrategy()));
tmp = Port.AddComponent(tmp, new Vehicle(container, vehicleData));
tmp = Port.AddComponent(tmp, new Wheels(container, vehicleData.DynamicTyreRadius, vehicleData.WheelsInertia));
tmp = Port.AddComponent(tmp, new Brakes(container));
tmp = Port.AddComponent(tmp, new AxleGear(container, axleGearData));
tmp = Port.AddComponent(tmp, new DummyRetarder(container));
tmp = Port.AddComponent(tmp,
new Gearbox(container, gearboxData, new AMTShiftStrategy(gearboxData, container)));
tmp = Port.AddComponent(tmp, clutch);
var aux = new EngineAuxiliary(container);
aux.AddConstant("", 0.SI<Watt>());
engine.Connect(aux.Port());
Port.AddComponent(tmp, engine);
engine.IdleController.RequestPort = clutch.IdleControlPort;
return container;
}
private static GearboxData CreateGearboxData()
{
var ratios = new[] { 6.38, 4.63, 3.44, 2.59, 1.86, 1.35, 1, 0.76 };
return new GearboxData {
Gears = ratios.Select((ratio, i) =>
Tuple.Create((uint)i,
new GearData {
FullLoadCurve = FullLoadCurve.ReadFromFile(GearboxFullLoadCurveFile),
LossMap = (ratio != 1.0)
? TransmissionLossMap.ReadFromFile(GearboxIndirectLoss, ratio,
string.Format("Gear {0}", i))
: TransmissionLossMap.ReadFromFile(GearboxDirectLoss, ratio,
string.Format("Gear {0}", i)),
Ratio = ratio,
ShiftPolygon = ShiftPolygon.ReadFromFile(GearboxShiftPolygonFile)
}))
.ToDictionary(k => k.Item1 + 1, v => v.Item2),
ShiftTime = 2.SI<Second>(),
Inertia = 0.SI<KilogramSquareMeter>(),
TractionInterruption = 1.SI<Second>(),
StartSpeed = 2.SI<MeterPerSecond>(),
StartAcceleration = 0.6.SI<MeterPerSquareSecond>(),
StartTorqueReserve = 0.2,
SkipGears = true,
TorqueReserve = 0.2
};
}
private static AxleGearData CreateAxleGearData()
{
const double ratio = 3.240355;
return new AxleGearData {
AxleGear = new GearData {
Ratio = ratio,
LossMap = TransmissionLossMap.ReadFromFile(AxleGearLossMap, ratio, "AxleGear")
}
};
}
private static VehicleData CreateVehicleData(Kilogram loading)
{
var axles = new List<Axle> {
new Axle {
AxleWeightShare = 0.4375,
Inertia = 21.66667.SI<KilogramSquareMeter>(),
RollResistanceCoefficient = 0.0055,
TwinTyres = false,
TyreTestLoad = 62538.75.SI<Newton>()
},
new Axle {
AxleWeightShare = 0.375,
Inertia = 10.83333.SI<KilogramSquareMeter>(),
RollResistanceCoefficient = 0.0065,
TwinTyres = true,
TyreTestLoad = 52532.55.SI<Newton>()
},
new Axle {
AxleWeightShare = 0.1875,
Inertia = 21.66667.SI<KilogramSquareMeter>(),
RollResistanceCoefficient = 0.0055,
TwinTyres = false,
TyreTestLoad = 62538.75.SI<Newton>()
}
};
return new VehicleData {
AxleConfiguration = AxleConfiguration.AxleConfig_6x2,
//AerodynamicDragAera = 3.2634.SI<SquareMeter>(),
//CrossWindCorrectionMode = CrossWindCorrectionMode.NoCorrection,
CrossWindCorrectionCurve = CrossWindCorrectionCurve.GetNoCorrectionCurve(3.2634.SI<SquareMeter>()),
CurbWeight = 15700.SI<Kilogram>(),
CurbWeigthExtra = 0.SI<Kilogram>(),
Loading = loading,
DynamicTyreRadius = 0.52.SI<Meter>(),
AxleData = axles,
SavedInDeclarationMode = false
};
}
private static DriverData CreateDriverData(string accelerationFile, bool overspeed = false)
{
return new DriverData {
AccelerationCurve = AccelerationCurveData.ReadFromFile(accelerationFile),
LookAheadCoasting = new DriverData.LACData {
Enabled = true,
MinSpeed = 50.KMPHtoMeterPerSecond(),
Deceleration = -0.5.SI<MeterPerSquareSecond>()
},
OverSpeedEcoRoll = overspeed
? new DriverData.OverSpeedEcoRollData {
Mode = DriverData.DriverMode.Overspeed,
MinSpeed = 50.KMPHtoMeterPerSecond(),
OverSpeed = 5.KMPHtoMeterPerSecond()
}
: new DriverData.OverSpeedEcoRollData {
Mode = DriverData.DriverMode.Off
},
StartStop = new VectoRunData.StartStopData {
Enabled = false
}
};
}
}
}