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
  • 975e556fdeba168fd2678f4e19451707ee2c475e
  • 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

JsonTest.cs

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.
    TorqueConverter.cs 1.88 KiB
    using System;
    using System.Data;
    using TUGraz.VectoCore.Utils;
    
    namespace TUGraz.VectoCore.Models.Declaration
    {
    	public class TorqueConverter : LookupData<double, TorqueConverter.TorqueConverterEntry>
    	{
    		protected const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.DefaultTC.vtcc";
    
    
    		public TorqueConverter()
    		{
    			ParseData(ReadCsvResource(ResourceId));
    		}
    
    
    		[Obsolete("Default Lookup not availabel. Use LookupMu or LookupTorque instead.", true)]
    		protected new TorqueConverterEntry Lookup(double key)
    		{
    			throw new InvalidOperationException(
    				"Default Lookup not available. Use TorqueConverter.LookupMu() or TorqueConverter.LookupTorque() instead.");
    		}
    
    
    		public NewtonMeter LookupTorque(double nu, PerSecond angularSpeedIn, PerSecond referenceSpeed)
    		{
    			var sec = Data.GetSamples(kv => kv.Key < nu);
    
    			if (nu < sec.Item1.Key || sec.Item2.Key < nu) {
    				Log.Warn(string.Format("TCextrapol: nu = {0} [n_out/n_in]", nu));
    			}
    
    			var torque = VectoMath.Interpolate(sec.Item1.Key, sec.Item2.Key, sec.Item1.Value.Torque, sec.Item2.Value.Torque, nu);
    			return torque * Math.Pow((angularSpeedIn / referenceSpeed).Scalar(), 2);
    		}
    
    		public double LookupMu(double nu)
    		{
    			var sec = Data.GetSamples(kv => kv.Key < nu);
    
    			if (nu < sec.Item1.Key || sec.Item2.Key < nu) {
    				Log.Warn(string.Format("TCextrapol: nu = {0} [n_out/n_in]", nu));
    			}
    
    			return VectoMath.Interpolate(sec.Item1.Key, sec.Item2.Key, sec.Item1.Value.Mu, sec.Item2.Value.Mu, nu);
    		}
    
    
    		protected override void ParseData(DataTable table)
    		{
    			Data.Clear();
    			foreach (DataRow row in table.Rows) {
    				Data[row.ParseDouble("nue")] = new TorqueConverterEntry {
    					Mu = row.ParseDouble("mue"),
    					Torque = row.ParseDouble("MP1000 (1000/rpm)^2*Nm").SI<NewtonMeter>()
    				};
    			}
    		}
    
    		public class TorqueConverterEntry
    		{
    			public double Mu { get; set; }
    			public NewtonMeter Torque { get; set; }
    		}
    	}
    }