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
  • cb7809d3c5329bdba1cbca3109df76bb79e032f7
  • stable default
  • feat-fchv-bus
  • fix-h2-ice-bus
  • powertrains-multiple-axles
  • amdm3/develop
  • issue-1039
  • amdm3/main
  • test/nuget_publish
  • IEPC-experiments
  • amdm2/main
  • amdm2/develop
  • aptngearbox-not-auto
  • playground
  • official/main
  • official/develop
  • issue-templates
  • pdf-reports
  • HEV-timeruns-dev
  • timerun-empower-hybrids
  • timerun-pwheel-hybrids
  • Release/v5.0.3
  • Release/v5.0.1
  • Release/5.0.0-RC
  • Nuget/v0.11.4-DEV
  • Release/v0.11.4-DEV
  • Release/4.3.4-DEV
  • Release/4.3.3
  • Release/4.3.2-RC
  • Release/v4.3.0-DEV
  • Release/4.2.7
  • XMLConverterTool/4.2.6.0
  • Release/4.2.6-RC
  • Release/v4.2.5
  • Release/v4.2.3
  • Release/v4.2.2.3539-RC
  • Release/v4.2.1.3469
  • Release/v0.11.2.3456-DEV
  • Release/v4.2.0.3448-RC
  • Release/v4.1.3.3415
  • Release/v4.1.1.3413
41 results

VectoCoreTest.csproj

Blame
  • 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.
    ModDataTest.cs 6.37 KiB
    /*
    * This file is part of VECTO.
    *
    * Copyright © 2012-2016 European Union
    *
    * Developed by Graz University of Technology,
    *              Institute of Internal Combustion Engines and Thermodynamics,
    *              Institute of Technical Informatics
    *
    * VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved
    * by the European Commission - subsequent versions of the EUPL (the "Licence");
    * You may not use VECTO except in compliance with the Licence.
    * You may obtain a copy of the Licence at:
    *
    * https://joinup.ec.europa.eu/community/eupl/og_page/eupl
    *
    * Unless required by applicable law or agreed to in writing, VECTO
    * 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.
    *
    * Authors:
    *   Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology
    *   Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology
    *   Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology
    *   Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology
    *   Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology
    *   Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
    */
    
    using System.Data;
    using System.Linq;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using TUGraz.VectoCommon.Utils;
    using TUGraz.VectoCore.Models.Simulation.Data;
    using TUGraz.VectoCore.OutputData;
    using TUGraz.VectoCore.Tests.Integration;
    using TUGraz.VectoCore.Tests.Utils;
    
    namespace TUGraz.VectoCore.Tests.Reports
    {
    	[TestClass]
    	public class ModDataTest
    	{
    		[TestMethod]
    		public void ModDataIntegrityTest()
    		{
    			var cycleData = new[] {
    				// <s>,<v>,<grad>,<stop>
    				"  0,  20, 0,    0",
    				" 100, 60, 0,    0",
    				"1000, 60, 0,    0",
    				"1500, 40, 1,    0",
    				"2000, 50,-1,    0",
    				"2500,  0, 0,    2"
    			};
    			var cycle = SimpleDrivingCycles.CreateCycleData(cycleData);
    			var run = Truck40tPowerTrain.CreateEngineeringRun(cycle, "Truck_ModDataIntegrity.vmod");
    
    			var engineData = MockSimulationDataFactory.CreateEngineDataFromFile(Truck40tPowerTrain.EngineFile);
    
    			var modData = (ModalDataContainer)run.GetContainer().ModalData;
    
    			run.Run();
    			Assert.IsTrue(run.FinishedWithoutErrors);
    
    			var lastGear = 0u;
    			foreach (DataRow row in modData.Data.Rows) {
    				if (cycle.Entries.Last().Distance.IsEqual(((Meter)row[(int)ModalResultField.dist]))) {
    					continue;
    				}
    				var gear = (uint)row[(int)ModalResultField.Gear];
    				var time = (Second)row[(int)ModalResultField.time];
    
    				if ((lastGear == 0 && gear != 0) || (lastGear != 0 && gear == 0)) {
    					//skipNext = (uint)row[(int)ModalResultField.Gear] == 0;
    					lastGear = gear;
    					continue;
    				}
    				var distance = (Meter)row[(int)ModalResultField.dist];
    				var tqEngFcmap = (NewtonMeter)row[(int)ModalResultField.T_eng_fcmap];
    				var nEngFcMap = (PerSecond)row[(int)ModalResultField.n_eng_avg];
    
    				// check fuel consumption interpolation
    				var fuelConsumption = (SI)row[(int)ModalResultField.FCMap];
    				Assert.AreEqual(fuelConsumption.Value(),
    					engineData.ConsumptionMap.GetFuelConsumption(tqEngFcmap, nEngFcMap).Value(), 1E-3, "time: {0}  distance: {1}",
    					time, distance);
    
    				// check P_eng_FCmap = T_eng_fcmap * n_eng
    				var pEngFcmap = (SI)row[(int)ModalResultField.P_eng_fcmap];
    				Assert.AreEqual(pEngFcmap.Value(), (tqEngFcmap * nEngFcMap).Value(), 1E-3, "time: {0}  distance: {1}", time,
    					distance);
    
    				var pWheelIn = (Watt)row[(int)ModalResultField.P_wheel_in];
    				var pAir = (Watt)row[(int)ModalResultField.P_air];
    				var pRoll = (Watt)row[(int)ModalResultField.P_roll];
    				var pGrad = (Watt)row[(int)ModalResultField.P_slope];
    				var pVehInertia = (Watt)row[(int)ModalResultField.P_veh_inertia];
    				var pTrac = (Watt)row[(int)ModalResultField.P_trac];
    
    				// Pe_eng = P_wheel + P_lossgearbox + P_lossaxle + P_lossretarder + P_agbx + Pa_eng + P_aux - P_brake_loss
    				var pEngOut = (Watt)row[(int)ModalResultField.P_eng_out];
    				var pLossGbx = (Watt)row[(int)ModalResultField.P_gbx_loss];
    				var pGbxIn = (Watt)row[(int)ModalResultField.P_gbx_in];
    				var pLossAxle = (Watt)row[(int)ModalResultField.P_axle_loss];
    				var pAxleIn = (Watt)row[(int)ModalResultField.P_axle_in];
    				var pLossRet = (Watt)row[(int)ModalResultField.P_ret_loss];
    				var pRetIn = (Watt)row[(int)ModalResultField.P_retarder_in];
    				var pGbxInertia = (Watt)row[(int)ModalResultField.P_gbx_inertia];
    				var pEngInertia = (Watt)row[(int)ModalResultField.P_eng_inertia];
    				var pAux = (Watt)row[(int)ModalResultField.P_aux];
    				var pBrakeLoss = (Watt)row[(int)ModalResultField.P_brake_loss];
    				var pBrakeIn = (Watt)row[(int)ModalResultField.P_brake_in];
    				var pClutchLoss = (Watt)row[(int)ModalResultField.P_clutch_loss];
    				var pClutchOut = (Watt)row[(int)ModalResultField.P_clutch_out];
    				var pWheelInertia = (Watt)row[(int)ModalResultField.P_wheel_inertia];
    
    				// P_trac = P_veh_inertia + P_roll + P_air + P_slope
    				Assert.AreEqual(pTrac.Value(), (pAir + pRoll + pGrad + pVehInertia).Value(), 1E-3, "time: {0}  distance: {1}", time,
    					distance);
    
    				// P_wheel_in = P_trac + P_wheel_inertia
    				Assert.AreEqual(pWheelIn.Value(), (pTrac + pWheelInertia).Value(), 1E-3, "time: {0}  distance: {1}", time, distance);
    
    				Assert.AreEqual(pBrakeIn.Value(), (pWheelIn + pBrakeLoss).Value(), 1E-3, "time: {0}  distance: {1}", time, distance);
    
    				Assert.AreEqual(pAxleIn.Value(), (pBrakeIn + pLossAxle).Value(), 1E-3, "time: {0}  distance: {1}", time, distance);
    
    				Assert.AreEqual(pRetIn.Value(), (pAxleIn + pLossRet).Value(), 1E-3, "time: {0}  distance: {1}", time, distance);
    
    
    				Assert.AreEqual(pGbxIn.Value(), pClutchOut.Value(), 1E-3, "time: {0}  distance: {1}", time, distance);
    
    				Assert.AreEqual(pEngOut.Value(), (pClutchOut + pClutchLoss).Value(), 1E-3,
    					"time: {0}  distance: {1}", time, distance);
    
    				if (gear != 0) {
    					Assert.AreEqual(pGbxIn.Value(), (pRetIn + pLossGbx + pGbxInertia).Value(), gear != 0 ? 1E-3 : 0.5,
    						"time: {0}  distance: {1}", time,
    						distance);
    					Assert.AreEqual(pEngFcmap.Value(),
    						(pTrac + pWheelInertia + pBrakeLoss + pLossAxle + pLossRet + pLossGbx + pGbxInertia + pEngInertia + pAux +
    						pClutchLoss).Value(), 0.5, "time: {0}  distance: {1}", time, distance);
    				}
    				lastGear = gear;
    			}
    		}
    	}
    }