diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/DragCurve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/DragCurve.cs index 3e57c01aa3c8956f959184cdead8e99ffa652845..9bc05651174d7d941f1096b1214a9cda9f49e625 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/DragCurve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/DragCurve.cs @@ -47,5 +47,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { } + + public string[] SerializedEntries + { + get { return Entries.Select(x => $"{x.MotorSpeed.AsRPM} {x.DragTorque}").ToArray(); } + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/EfficiencyMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/EfficiencyMap.cs index 33787a226da223910ecf46af3101265e37531c69..21fde2ab14dcd5c305e1a4d81cb6db5c66cb17e8 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/EfficiencyMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/EfficiencyMap.cs @@ -1,4 +1,5 @@ -using TUGraz.VectoCommon.Utils; +using System.Linq; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { @@ -59,6 +60,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { }; } + public string[] SerializedEntries + { + get { return _efficiencyMapMech2El.Entries.Select( + entry => $"{entry.Y.SI<PerSecond>().AsRPM} [rpm], {entry.X.SI<NewtonMeter>()}, {entry.Z.SI<Watt>()}") + .ToArray(); + } + } + public class Entry { diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/ElectricFullLoadCurve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/ElectricFullLoadCurve.cs index e407734826add4829fcda0b5b2c16fa389c64d67..f88db2d6c8ac3a65b9c9e7ad2c1ad52ada001ba2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/ElectricFullLoadCurve.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricMotor/ElectricFullLoadCurve.cs @@ -62,5 +62,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data { public NewtonMeter FullGenerationTorque { get; set; } } + public string[] SerializedEntries + { + get { return FullLoadEntries.Select(x => $"{x.MotorSpeed.AsRPM} {x.FullDriveTorque} {x.FullGenerationTorque}").ToArray(); } + } + + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs index 7a3afca5ce8a3a66848564261b99246ac9f3f9fe..5b8d18338ce1820c3fe71860954240db8b7a6a97 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/ElectricMotor.cs @@ -88,7 +88,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var maxEmTorque = ModelData.FullLoadCurve.FullGenerationTorque(avgSpeed); var electricSystemResponse = ElectricPower.Request(absTime, dt, 0.SI<Watt>(), true); - var maxBatPower = electricSystemResponse.BatteryResponse.MaxBatteryLoadCharge; + var maxBatPower = electricSystemResponse.MaxPowerDrag; var maxBatRecuperationTorque = maxBatPower.IsEqual(0) ? 0.SI<NewtonMeter>() : ModelData.EfficiencyMap.LookupTorque(maxBatPower, avgSpeed, maxEmTorque); var maxTorqueRecuperate = VectoMath.Min(maxEmTorque, maxBatRecuperationTorque); @@ -99,7 +99,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var maxEmTorque = ModelData.FullLoadCurve.FullLoadDriveTorque(avgSpeed); var electricSystemResponse = ElectricPower.Request(absTime, dt, 0.SI<Watt>(), true); - var maxBatPower = electricSystemResponse.BatteryResponse.MaxBatteryLoadDischarge; + var maxBatPower = electricSystemResponse.MaxPowerDrive; var maxBatDriveTorque = maxBatPower.IsEqual(0) ? ModelData.DragCurve.Lookup(avgSpeed) : ModelData.EfficiencyMap.LookupTorque(maxBatPower, avgSpeed, maxEmTorque); var maxTorqueDrive = VectoMath.Max(maxEmTorque, maxBatDriveTorque); @@ -135,6 +135,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } var electricSystemResponse = ElectricPower.Request(absTime, dt, 0.SI<Watt>(), dryRun); if (!dryRun) { + if (!(electricSystemResponse is ElectricSystemResponseSuccess)) { + throw new VectoException("unexpected response from electric system: {0}", electricSystemResponse); + } SetState(inTorque, outAngularVelocity); } var retVal = NextComponent.Request(absTime, dt, outTorque, outAngularVelocity, dryRun); diff --git a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs index 8b75b6fdb0bea2575f7c855751e6d6e64b48bf88..8320df82ccf37ca1692472eac1778bb17ec99e0d 100644 --- a/VectoCore/VectoCore/OutputData/ModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/ModalDataContainer.cs @@ -443,7 +443,8 @@ namespace TUGraz.VectoCore.OutputData } dataColumns.AddRange( new[] { - ModalResultField.P_aux_mech + ModalResultField.P_aux_mech, + ModalResultField.P_aux_el }.Select(x => x.GetName())); if (!_writeEngineOnly) { diff --git a/VectoCore/VectoCore/Utils/DelaunayMap.cs b/VectoCore/VectoCore/Utils/DelaunayMap.cs index 19562944aa2ed5303116bdf362aba98fa3246f3a..e89bdc1be667353cef68b8c03208e909fbaf7c7d 100644 --- a/VectoCore/VectoCore/Utils/DelaunayMap.cs +++ b/VectoCore/VectoCore/Utils/DelaunayMap.cs @@ -37,6 +37,7 @@ using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Windows.Forms.DataVisualization.Charting; +using Newtonsoft.Json; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; diff --git a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs index 63443b9c1ac2458a79375241911452e770766f0f..50fe83e02f1fac233546970ed0f0083a3646e0b4 100644 --- a/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Hybrid/ParallelHybridTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Newtonsoft.Json; using NUnit.Framework; using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.InputData; @@ -140,23 +141,26 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid } [ - TestCase(30, 0.7, 0, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.7, level"), - TestCase(50, 0.7, 0, TestName = "P2 Hybrid ConstantSpeed 50km/h SoC: 0.7, level"), - TestCase(80, 0.7, 0, TestName = "P2 Hybrid ConstantSpeed 80km/h SoC: 0.7, level"), + TestCase(30, 0.7, 0, 0, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.7, level"), + TestCase(50, 0.7, 0, 0, TestName = "P2 Hybrid ConstantSpeed 50km/h SoC: 0.7, level"), + TestCase(80, 0.7, 0, 0, TestName = "P2 Hybrid ConstantSpeed 80km/h SoC: 0.7, level"), - TestCase(30, 0.2, 0, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.2, level"), - TestCase(50, 0.2, 0, TestName = "P2 Hybrid ConstantSpeed 50km/h SoC: 0.2, level"), + TestCase(30, 0.2, 0, 0, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.2, level"), + TestCase(50, 0.2, 0, 0, TestName = "P2 Hybrid ConstantSpeed 50km/h SoC: 0.2, level"), TestCase(80, 0.2, 0, TestName = "P2 Hybrid ConstantSpeed 80km/h SoC: 0.2, level"), - TestCase(30, 0.5, 5, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.5, UH 5%"), - TestCase(50, 0.5, 5, TestName = "P2 Hybrid ConstantSpeed 50km/h SoC: 0.5, UH 5%"), - TestCase(80, 0.5, 5, TestName = "P2 Hybrid ConstantSpeed 80km/h SoC: 0.5, UH 5%"), + TestCase(30, 0.5, 5, 0, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.5, UH 5%"), + TestCase(50, 0.5, 5, 0, TestName = "P2 Hybrid ConstantSpeed 50km/h SoC: 0.5, UH 5%"), + TestCase(80, 0.5, 5, 0, TestName = "P2 Hybrid ConstantSpeed 80km/h SoC: 0.5, UH 5%"), - TestCase(30, 0.5, -5, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.5, DH 5%"), - TestCase(50, 0.5, -5, TestName = "P2 Hybrid ConstantSpeed 50km/h SoC: 0.5, DH 5%"), - TestCase(80, 0.5, -5, TestName = "P2 Hybrid ConstantSpeed 80km/h SoC: 0.5, DH 5%"), + TestCase(30, 0.5, -5, 0, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.5, DH 5%"), + TestCase(50, 0.5, -5, 0, TestName = "P2 Hybrid ConstantSpeed 50km/h SoC: 0.5, DH 5%"), + TestCase(80, 0.5, -5, 0, TestName = "P2 Hybrid ConstantSpeed 80km/h SoC: 0.5, DH 5%"), + + TestCase(30, 0.2, 0, 1000, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.2, level P_auxEl: 1kW"), + TestCase(30, 0.2, 0, 5000, TestName = "P2 Hybrid ConstantSpeed 30km/h SoC: 0.2, level P_auxEl: 5kW"), ] - public void P2HybridConstantSpeed(double vmax, double initialSoC, double slope) + public void P2HybridConstantSpeed(double vmax, double initialSoC, double slope, double pAuxEl) { var cycleData = string.Format( @" 0, {0}, {1}, 0 @@ -165,22 +169,20 @@ namespace TUGraz.VectoCore.Tests.Integration.Hybrid const bool largeMotor = true; - var modFilename = string.Format("SimpleParallelHybrid_constant_{0}-{1}_{2}.vmod", vmax, initialSoC, slope); + var modFilename = string.Format("SimpleParallelHybrid_constant_{0}-{1}_{2}_{3}.vmod", vmax, initialSoC, slope, pAuxEl); const PowertrainPosition pos = PowertrainPosition.HybridP2; var run = CreateEngineeringRun( - cycle, modFilename, initialSoC, pos, largeMotor: true); + cycle, modFilename, initialSoC, pos, largeMotor: true, pAuxEl: pAuxEl); var hybridController = (HybridController)((VehicleContainer)run.GetContainer()).HybridController; Assert.NotNull(hybridController); - //var strategy = (DelegateParallelHybridStrategy)hybridController.Strategy; - //Assert.NotNull(strategy); - + var modData = ((ModalDataContainer)((VehicleContainer)run.GetContainer()).ModData).Data; - var nextState = new StrategyState(); - var currentState = new StrategyState(); - - + var data = run.GetContainer().RunData; + File.WriteAllText( + $"{modFilename}.json", + JsonConvert.SerializeObject(data, Formatting.Indented)); run.Run(); Assert.IsTrue(run.FinishedWithoutErrors);