Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Select Git revision
  • 9fa10d30cfad0db7a265c0130c25136f70cf16a6
  • development default
  • bugfix/EDELIVERY-14172-domismp-accepts-requests-with-wrong-domain-header-value
  • EDELIVERY-15372-upgrade-libraries-and-plugins-and-update-httpclient-to-httpclient5
  • EDELIVERY-15377-migrate-to-angular-20
  • feature/EDELIVERY-15382-rest-api-jwt-authentication-for-dynamic-discovery-client
  • bugfix/EDELIVERY-14196-select-domain-select-resource-dropdown-should-be-order-alphabetically
  • feature/EDELIVERY-12753-sml-integration-migration-to-different-smp
  • feature/EDELIVERY-13757-extend-session-dialog-should-have-an-active-counter
  • EDELIVERY-15144-sql-update
  • bugfix/EDELIVERY-14326-ui-edit-resource-filters
  • feature/EDELIVERY-15144-domismp-system-notification-generalize-time-expiration-alerts
  • bugfix/EDELIVERY-15102-alert-is-not-appearing-when-adding-duplicated-certificate
  • bugfix/EDELIVERY-15203-small-left-grid-shows-no-data-found-for-1-2-seconds-before-loading-the-data
  • EDELIVERY-15219-search-filter-with-understore-char-does-not-work
  • bugfix/EDELIVERY-15226-certificates-error-when-trying-to-delete-certificates
  • bugfix/EDELIVERY-15224-error-when-trying-to-update-info-from-profile-page
  • bugfix/EDELIVERY-15225-emails-are-not-sent-in-domismp
  • release/5.1.x
  • feature/EDELIVERY-12746-external-secret-sharing-services-as-vaults
  • EDELIVERY-15229-upgrade-libraries-and-plugins
  • 5.1.1
  • 5.1
  • 5.1-TEST
  • 5.1-RC1
  • 5.0.1
  • 5.0
  • 5.0-RC1
  • 4.2
  • 4.2-RC1
  • 4.1.2
  • 4.1.1
  • 4.1.0
  • 4.1.0-RC1
  • 4.0.0
  • 4.0.0-RC1
  • 3.0.2
  • 3.0.1
  • 3.0.0
39 results

DObject.java

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    PwheelModeTests.cs 7.05 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.IO;
    using System.Text;
    using System.Data;
    using System.Linq;
    using TUGraz.VectoCore.Utils;
    using System.Collections.Generic;
    using TUGraz.VectoCore.OutputData;
    using TUGraz.VectoCore.Tests.Utils;
    using TUGraz.VectoCore.InputData.Reader;
    using TUGraz.VectoCore.OutputData.FileIO;
    using TUGraz.VectoCore.InputData.FileIO.JSON;
    using TUGraz.VectoCore.Models.Simulation.Impl;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using TUGraz.VectoCore.Models.Simulation.Data;
    using TUGraz.VectoCore.Models.SimulationComponent.Data;
    using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine;
    using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
    using TUGraz.VectoCore.Models.SimulationComponent.Impl;
    
    namespace TUGraz.VectoCore.Tests.Models.Simulation
    {
    	[TestClass]
    	public class PwheelModeTests
    	{
    		/// <summary>
    		/// Test if the cycle file can be read.
    		/// </summary>
    		/// <remarks>VECTO-177</remarks>
    		[TestMethod]
    		public void Pwheel_ReadCycle_Test()
    		{
    			var container = new VehicleContainer();
    			var inputData = @"<t>,<Pwheel>,<gear>,<n>,<Padd>
                                   1,89,2,1748,1.300
                                   2,120,2,1400,0.4";
    
    			var cycleFile = new MemoryStream(Encoding.UTF8.GetBytes(inputData));
    			var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycleFile, CycleType.PWheel);
    
    			var gearbox = new CycleGearbox(container,
    				new GearboxData {
    					Gears = new Dictionary<uint, GearData> { { 1, new GearData { Ratio = 2.0 } }, { 2, new GearData { Ratio = 3.5 } } }
    				});
    
    			var cycle = new PWheelCycle(container, drivingCycle, 2.3,
    				gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio));
    
    			Assert.AreEqual(container.CycleData.LeftSample.Time, 1.SI<Second>());
    			Assert.AreEqual(container.CycleData.RightSample.Time, 2.SI<Second>());
    
    			Assert.AreEqual(1748.RPMtoRad() / (2.3 * 3.5), container.CycleData.LeftSample.WheelAngularVelocity);
    			Assert.AreEqual(1400.RPMtoRad() / (2.3 * 3.5), container.CycleData.RightSample.WheelAngularVelocity);
    
    			Assert.AreEqual(89.SI().Kilo.Watt, container.CycleData.LeftSample.PWheel);
    			Assert.AreEqual(120.SI().Kilo.Watt, container.CycleData.RightSample.PWheel);
    
    			Assert.AreEqual(2u, container.CycleData.LeftSample.Gear);
    			Assert.AreEqual(2u, container.CycleData.RightSample.Gear);
    
    			Assert.AreEqual(1300.SI<Watt>(), container.CycleData.LeftSample.AdditionalAuxPowerDemand);
    			Assert.AreEqual(400.SI<Watt>(), container.CycleData.RightSample.AdditionalAuxPowerDemand);
    
    			Assert.AreEqual(89.SI().Kilo.Watt / (1748.RPMtoRad() / (2.3 * 3.5)), container.CycleData.LeftSample.Torque);
    			Assert.AreEqual(120.SI().Kilo.Watt / (1400.RPMtoRad() / (2.3 * 3.5)), container.CycleData.RightSample.Torque);
    		}
    
    		/// <summary>
    		/// Tests if the powertrain can be created in P_wheel_in mode.
    		/// </summary>
    		/// <remarks>VECTO-177</remarks>
    		[TestMethod]
    		public void Pwheel_CreatePowertrain_Test()
    		{
    			// prepare input data
    			var inputData = @"<t>,<Pwheel>,<gear>,<n>,  <Padd>
                                   1,  89,      2,     1748, 1.3
                                   2,  120,     2,     1400, 0.4";
    
    			var cycleFile = new MemoryStream(Encoding.UTF8.GetBytes(inputData));
    			var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycleFile, CycleType.PWheel);
    
    			var fuelConsumption = new DataTable();
    			fuelConsumption.Columns.Add("");
    			fuelConsumption.Columns.Add("");
    			fuelConsumption.Columns.Add("");
    			fuelConsumption.Rows.Add("1", "1", "1");
    			fuelConsumption.Rows.Add("2", "2", "2");
    			fuelConsumption.Rows.Add("3", "3", "3");
    
    			var fullLoad = new DataTable();
    			fullLoad.Columns.Add("Engine speed");
    			fullLoad.Columns.Add("max torque");
    			fullLoad.Columns.Add("drag torque");
    			fullLoad.Columns.Add("PT1");
    			fullLoad.Rows.Add("0", "5000", "-5000", "0");
    			fullLoad.Rows.Add("3000", "5000", "-5000", "0");
    
    			var fullLoadCurve = EngineFullLoadCurve.Create(fullLoad);
    			var data = new VectoRunData {
    				Cycle = drivingCycle,
    				AxleGearData = new AxleGearData { AxleGear = new GearData { Ratio = 2.3 } },
    				EngineData = new CombustionEngineData { IdleSpeed = 560.RPMtoRad(), FullLoadCurve = fullLoadCurve },
    				GearboxData = new GearboxData { Gears = new Dictionary<uint, GearData> { { 2, new GearData { Ratio = 3.5 } } } },
    				Retarder = new RetarderData()
    			};
    
    			// call builder (actual test)
    			var builder = new PowertrainBuilder(null);
    			var jobContainer = builder.Build(data);
    		}
    
    		/// <summary>
    		/// Tests if the simulation works and the modfile and sumfile are correct in P_wheel_in mode.
    		/// </summary>
    		/// <remarks>VECTO-177</remarks>
    		[TestMethod]
    		public void Pwheel_Run_Test()
    		{
    			var jobFile = @"TestData\Pwheel\Pwheel.vecto";
    			var fileWriter = new FileOutputWriter(jobFile);
    			var sumWriter = new SummaryDataContainer(fileWriter);
    			var jobContainer = new JobContainer(sumWriter);
    
    			var inputData = JSONInputDataFactory.ReadJsonJob(jobFile);
    			var runsFactory = new SimulatorFactory(ExecutionMode.Engineering, inputData, fileWriter);
    
    			jobContainer.AddRuns(runsFactory);
    			jobContainer.Execute();
    
    			jobContainer.WaitFinished();
    
    			Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException)));
    
    			ResultFileHelper.TestSumFile(@"TestData\Pwheel\Results\Atego_ges.v2.vsum", @"TestData\Jobs\Pwheel.vsum");
    
    			ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\Atego_ges_Gear2_pt1_rep1_actual.vmod",
    				@"TestData\Pwheel\Pwheel_Gear2_pt1_rep1_actual.vmod");
    		}
    
    		/// <summary>
    		/// Tests if the simulation works and the modfile and sumfile are correct in P_wheel_in mode.
    		/// </summary>
    		/// <remarks>VECTO-177</remarks>
    		[TestMethod]
    		public void Pwheel_ultimate_Run_Test()
    		{
    			var jobFile = @"TestData\Pwheel\Pwheel_ultimate.vecto";
    			var fileWriter = new FileOutputWriter(jobFile);
    			var sumWriter = new SummaryDataContainer(fileWriter);
    			var jobContainer = new JobContainer(sumWriter);
    
    			var inputData = JSONInputDataFactory.ReadJsonJob(jobFile);
    			var runsFactory = new SimulatorFactory(ExecutionMode.Engineering, inputData, fileWriter);
    
    			jobContainer.AddRuns(runsFactory);
    			jobContainer.Execute();
    
    			jobContainer.WaitFinished();
    
    			Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException)));
    
    			ResultFileHelper.TestModFile(@"TestData\Pwheel\Results\Atego_HDVCO2_RD_#1_AuxStd.vmod",
    				@"TestData\Pwheel\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod", testRowCount: false);
    		}
    	}
    }