From ff308a9bae1c81fb4d873193fe4f6fa8ff9b9700 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Wed, 30 Sep 2015 09:55:22 +0200 Subject: [PATCH] output of modal results --- .../SimulationComponent/Impl/AxleGear.cs | 7 ++- .../SimulationComponent/Impl/Vehicle.cs | 63 +++++++++++++++---- .../Models/SimulationComponent/Impl/Wheels.cs | 8 ++- 3 files changed, 64 insertions(+), 14 deletions(-) diff --git a/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs b/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs index 242d55f8d6..fa7b4d1130 100644 --- a/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs +++ b/VectoCore/Models/SimulationComponent/Impl/AxleGear.cs @@ -11,6 +11,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected ITnOutPort NextComponent; private readonly GearData _gearData; + protected Watt Loss; + public AxleGear(VehicleContainer container, GearData gearData) : base(container) { _gearData = gearData; @@ -41,6 +43,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ? 0.SI<NewtonMeter>() : _gearData.LossMap.GearboxInTorque(inAngularVelocity, torque); + Loss = inTorque * inAngularVelocity - torque * angularVelocity; + var retVal = NextComponent.Request(absTime, dt, inTorque, inAngularVelocity, dryRun); retVal.AxlegearPowerRequest = torque * angularVelocity; @@ -57,11 +61,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override void DoWriteModalResults(IModalDataWriter writer) { - // nothing to write + writer[ModalResultField.PlossDiff] = Loss; } protected override void DoCommitSimulationStep() { + Loss = null; // nothing to commit } } diff --git a/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs b/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs index 8db5eeff4e..6b676356b3 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Vehicle.cs @@ -73,11 +73,28 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Initialize(MeterPerSecond vehicleSpeed, Radian roadGradient) { - _previousState = new VehicleState { Distance = 0.SI<Meter>(), Velocity = vehicleSpeed }; - _currentState = new VehicleState { Distance = 0.SI<Meter>(), Velocity = vehicleSpeed }; - - var vehicleAccelerationForce = RollingResistance(roadGradient) + AirDragResistance() + SlopeResistance(roadGradient); - return NextComponent.Initialize(vehicleAccelerationForce, vehicleSpeed); + _previousState = new VehicleState { + Distance = 0.SI<Meter>(), + Velocity = vehicleSpeed, + AirDragResistance = AirDragResistance(), + RollingResistance = RollingResistance(roadGradient), + SlopeResistance = SlopeResistance(roadGradient) + }; + _previousState.VehicleAccelerationForce = _previousState.RollingResistance + + _previousState.AirDragResistance + + _previousState.SlopeResistance; + + _currentState = new VehicleState { + Distance = 0.SI<Meter>(), + Velocity = vehicleSpeed, + AirDragResistance = _previousState.AirDragResistance, + RollingResistance = _previousState.RollingResistance, + SlopeResistance = _previousState.SlopeResistance, + VehicleAccelerationForce = _previousState.VehicleAccelerationForce, + }; + + + return NextComponent.Initialize(_currentState.VehicleAccelerationForce, vehicleSpeed); } public IResponse Initialize(MeterPerSecond vehicleSpeed, MeterPerSquareSecond startAcceleration, Radian roadGradient) @@ -95,19 +112,37 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _currentState.Velocity = _previousState.Velocity + accelleration * dt; _currentState.Distance = _previousState.Distance + dt * (_previousState.Velocity + _currentState.Velocity) / 2; + _currentState.DriverAcceleration = DriverAcceleration(accelleration); + _currentState.RollingResistance = RollingResistance(gradient); + _currentState.AirDragResistance = AirDragResistance(); + _currentState.SlopeResistance = SlopeResistance(gradient); + // DriverAcceleration = vehicleAccelerationForce - RollingResistance - AirDragResistance - SlopeResistance - var vehicleAccelerationForce = DriverAcceleration(accelleration) - + RollingResistance(gradient) - + AirDragResistance() - + SlopeResistance(gradient); + _currentState.VehicleAccelerationForce = _currentState.DriverAcceleration + + _currentState.RollingResistance + + _currentState.AirDragResistance + + _currentState.SlopeResistance; - var retval = NextComponent.Request(absTime, dt, vehicleAccelerationForce, _currentState.Velocity, dryRun); + var retval = NextComponent.Request(absTime, dt, _currentState.VehicleAccelerationForce, _currentState.Velocity, + dryRun); return retval; } protected override void DoWriteModalResults(IModalDataWriter writer) { - writer[ModalResultField.v_act] = (_previousState.Velocity + _currentState.Velocity) / 2; + var averageVelocity = (_previousState.Velocity + _currentState.Velocity) / 2; + + writer[ModalResultField.v_act] = averageVelocity; + writer[ModalResultField.PaVeh] = (_previousState.VehicleAccelerationForce * _previousState.Velocity + + _currentState.VehicleAccelerationForce * _currentState.Velocity) / 2; + writer[ModalResultField.Pgrad] = (_previousState.SlopeResistance * _previousState.Velocity + + _currentState.SlopeResistance * _currentState.Velocity) / 2; + writer[ModalResultField.Proll] = (_previousState.RollingResistance * _previousState.Velocity + + _currentState.RollingResistance * _currentState.Velocity) / 2; + // TODO: comptuation of AirResistancePower is wrong! + writer[ModalResultField.Pair] = (_previousState.AirDragResistance * _previousState.Velocity + + _currentState.AirDragResistance * _currentState.Velocity) / 2; + // sanity check: is the vehicle in step with the cycle? if (writer[ModalResultField.dist] == DBNull.Value) { @@ -251,6 +286,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public MeterPerSecond Velocity; public Second dt; public Meter Distance; + + public Newton VehicleAccelerationForce; + public Newton DriverAcceleration; + public Newton SlopeResistance; + public Newton AirDragResistance; + public Newton RollingResistance; } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Impl/Wheels.cs b/VectoCore/Models/SimulationComponent/Impl/Wheels.cs index 928e35c04d..3f3f598399 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Wheels.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Wheels.cs @@ -11,6 +11,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected ITnOutPort NextComponent; private readonly Meter _dynamicWheelRadius; + protected Watt WheelsPowerRequest { get; set; } + public Wheels(IVehicleContainer cockpit, Meter rdyn) : base(cockpit) { @@ -42,11 +44,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("request: force: {0}, velocity: {1}", force, velocity); var torque = force * _dynamicWheelRadius; var angularVelocity = velocity / _dynamicWheelRadius; + WheelsPowerRequest = torque * angularVelocity; var retVal = NextComponent.Request(absTime, dt, torque, angularVelocity, dryRun); - retVal.WheelsPowerRequest = torque * angularVelocity; + retVal.WheelsPowerRequest = WheelsPowerRequest; return retVal; } + public IResponse Initialize(Newton force, MeterPerSecond velocity) { var torque = force * _dynamicWheelRadius; @@ -70,7 +74,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected override void DoWriteModalResults(IModalDataWriter writer) { - // noting to write... + writer[ModalResultField.Pwheel] = WheelsPowerRequest; } protected override void DoCommitSimulationStep() -- GitLab