Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 6c76734f authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

more extensive tests of VAirBeta Crosswind correction

parent 60497932
No related branches found
No related tags found
No related merge requests found
......@@ -131,7 +131,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
averageAirDragPower = (Physics.AirDensity / 2.0 * CdA * vAverage * vAverage * vAverage).Cast<Watt>();
} else {
// compute the average force within the current simulation interval
// P(t) = k * CdA * v(t)^3 , v(t) = v0 + a * t // a != 0, P_avg = 1/dt * Integral P(t)
// P(t) = k * CdA * v(t)^3 , v(t) = v0 + a * t // a != 0, P_avg = 1/T * Integral P(t) dt
// => P_avg = (CdA * rho/2)/(4*a * dt) * (v2^4 - v1^4)
var acceleration = (v2 - v1) / dt;
averageAirDragPower =
......
......@@ -70,13 +70,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
var vAir = DataBus.CycleData.LeftSample.AirSpeedRelativeToVehicle;
var beta = DataBus.CycleData.LeftSample.WindYawAngle;
// F_air(t) = k * CdA_korr * v_air^2 // assumption: v_air = const for the current interval
// P(t) = F_air(t) * v(t) , v(t) = v1 + a * t
// P_avg = 1/T * Integral P(t) dt
// P_avg = k * CdA_korr * v_air^2 * (v1 + v2) / 2
var airDragForce = (AirDragArea + DeltaCdA(beta)) * Physics.AirDensity / 2.0 * vAir * vAir;
var vAverage = (v1 + v2) / 2;
if (v1.IsEqual(v2)) {
return (airDragForce * vAverage).Cast<Watt>();
}
var acceleration = (v2 - v1) / dt;
return (airDragForce * (v2 * v2 - v1 * v1) / (2 * acceleration * dt)).Cast<Watt>();
return (airDragForce * vAverage).Cast<Watt>();
}
protected SquareMeter DeltaCdA(double beta)
......
......@@ -381,9 +381,37 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
{
var tbl = VectoCSVFile.Read(@"TestData/MeasuredSpeed/VairBeta.vcdb");
var vairbeta = new VAirBetaCrosswindCorrection(1.SI<SquareMeter>(), tbl);
Assert.AreEqual(0, vairbeta.AverageAirDragPowerLoss(20.KMPHtoMeterPerSecond(), 20.KMPHtoMeterPerSecond(), 1.SI<Second>()) );
var dataBus = new MockVairVechicleContainer();
var vairbeta = new VAirBetaCrosswindCorrection(5.SI<SquareMeter>(), tbl);
vairbeta.SetDataBus(dataBus);
var cycleEntry = new DrivingCycleData.DrivingCycleEntry() {
AirSpeedRelativeToVehicle = 20.KMPHtoMeterPerSecond(),
WindYawAngle = 0
};
dataBus.CycleData = new CycleData() { LeftSample = cycleEntry };
var pAvg =
vairbeta.AverageAirDragPowerLoss(20.KMPHtoMeterPerSecond(), 20.KMPHtoMeterPerSecond(), 1.SI<Second>()).Value();
Assert.AreEqual(509.259, pAvg, 1e-3);
pAvg =
vairbeta.AverageAirDragPowerLoss(20.KMPHtoMeterPerSecond(), 21.KMPHtoMeterPerSecond(), 1.SI<Second>()).Value();
Assert.AreEqual(521.990, pAvg, 1e-3);
pAvg =
vairbeta.AverageAirDragPowerLoss(20.KMPHtoMeterPerSecond(), 30.KMPHtoMeterPerSecond(), 1.SI<Second>()).Value();
Assert.AreEqual(636.574, pAvg, 1e-3);
cycleEntry.WindYawAngle = 20;
pAvg =
vairbeta.AverageAirDragPowerLoss(20.KMPHtoMeterPerSecond(), 20.KMPHtoMeterPerSecond(), 1.SI<Second>()).Value();
Assert.AreEqual(638.611, pAvg, 1e-3);
pAvg =
vairbeta.AverageAirDragPowerLoss(20.KMPHtoMeterPerSecond(), 30.KMPHtoMeterPerSecond(), 1.SI<Second>()).Value();
Assert.AreEqual(798.263, pAvg, 1e-3);
}
}
}
\ No newline at end of file
using System.Collections.Generic;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.OutputData;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.Utils
{
public class MockVairVechicleContainer : IVehicleContainer
{
// only CycleData Lookup is set / accessed...
public uint Gear { get; private set; }
public MeterPerSecond StartSpeed { get; private set; }
public MeterPerSquareSecond StartAcceleration { get; private set; }
public FullLoadCurve GearFullLoadCurve { get; private set; }
public PerSecond EngineSpeed { get; private set; }
public Watt EngineStationaryFullPower(PerSecond angularSpeed)
{
throw new System.NotImplementedException();
}
public PerSecond EngineIdleSpeed { get; private set; }
public PerSecond EngineRatedSpeed { get; private set; }
public MeterPerSecond VehicleSpeed { get; private set; }
public Kilogram VehicleMass { get; private set; }
public Kilogram VehicleLoading { get; private set; }
public Kilogram TotalMass { get; private set; }
public Meter Distance { get; private set; }
public bool ClutchClosed(Second absTime)
{
throw new System.NotImplementedException();
}
public Watt BrakePower { get; set; }
public Meter CycleStartDistance { get; private set; }
public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Meter lookaheadDistance)
{
throw new System.NotImplementedException();
}
public IReadOnlyList<DrivingCycleData.DrivingCycleEntry> LookAhead(Second time)
{
throw new System.NotImplementedException();
}
public bool VehicleStopped { get; private set; }
public DrivingBehavior DrivingBehavior { get; private set; }
public CycleData CycleData { get; set; }
public ExecutionMode ExecutionMode { get; set; }
public IModalDataContainer ModalData { get; private set; }
public VectoRunData RunData { get; private set; }
public ISimulationOutPort GetCycleOutPort()
{
throw new System.NotImplementedException();
}
public VectoRun.Status RunStatus { get; set; }
public void AddComponent(VectoSimulationComponent component)
{
throw new System.NotImplementedException();
}
public void CommitSimulationStep(Second time, Second simulationInterval)
{
throw new System.NotImplementedException();
}
public void FinishSimulation()
{
throw new System.NotImplementedException();
}
}
}
\ No newline at end of file
......@@ -93,6 +93,7 @@
<Compile Include="Models\SimulationComponent\GearboxPowertrainTest.cs" />
<Compile Include="Utils\InputDataHelper.cs" />
<Compile Include="Utils\MockSimulationDataFactory.cs" />
<Compile Include="Utils\MockVairVechicleContainer.cs" />
<Compile Include="Utils\Port.cs" />
<Compile Include="Models\SimulationComponentData\AuxiliaryTypeHelperTest.cs" />
<Compile Include="Models\Simulation\AuxTests.cs" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment