diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs index ae2cf4d19212bba5f423c0ea61ab7eb5f134f31d..730be2a1e92d098eb9ab0fd14d27b80a9a55e911 100644 --- a/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/TorqueConverterDataReader.cs @@ -11,17 +11,17 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData { public class TorqueConverterDataReader { - public static TorqueConverterData ReadFromFile(string filename) + public static TorqueConverterData ReadFromFile(string filename, PerSecond referenceRpm) { - return Create(VectoCSVFile.Read(filename)); + return Create(VectoCSVFile.Read(filename), referenceRpm); } - public static TorqueConverterData ReadFromStream(Stream stream) + public static TorqueConverterData ReadFromStream(Stream stream, PerSecond referenceRpm) { - return Create(VectoCSVFile.ReadStream(stream)); + return Create(VectoCSVFile.ReadStream(stream), referenceRpm); } - public static TorqueConverterData Create(DataTable data) + public static TorqueConverterData Create(DataTable data, PerSecond referenceRpm) { if (data.Columns.Count != 3) { throw new VectoException("TorqueConverter Characteristics data must consist of 3 columns"); @@ -48,7 +48,7 @@ namespace TUGraz.VectoCore.InputData.Reader.ComponentData TorqueRatio = row.ParseDouble(1) }).ToList(); } - return new TorqueConverterData(characteristicTorque); + return new TorqueConverterData(characteristicTorque, referenceRpm); } private static bool HeaderIsValid(DataColumnCollection columns) diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index 592758e8df095caff2c199e4261277f5a0382581..0e71f25597cf0a28bb9b9969bd581b996f90d906 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -57,7 +57,6 @@ namespace TUGraz.VectoCore.Models.Declaration private SteeringPump _steeringPump; private WHTCCorrection _whtcCorrection; private AirDrag _airDrag; - private TorqueConverter _torqueConverter; private StandardBodies _standardBodies; private Payloads _payloads; @@ -164,11 +163,6 @@ namespace TUGraz.VectoCore.Models.Declaration get { return Instance()._airDrag ?? (Instance()._airDrag = new AirDrag()); } } - public static TorqueConverter TorqueConverter - { - get { return Instance()._torqueConverter ?? (Instance()._torqueConverter = new TorqueConverter()); } - } - public static int PoweredAxle() { return 1; diff --git a/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs b/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs deleted file mode 100644 index 9aa9837f63135794a7a34dcb24ed659679b1d40c..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/Models/Declaration/TorqueConverter.cs +++ /dev/null @@ -1,98 +0,0 @@ -/* -* 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; -using System.Data; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Utils; - -namespace TUGraz.VectoCore.Models.Declaration -{ - public sealed class TorqueConverter : LookupData<double, TorqueConverter.TorqueConverterEntry> - { - private const string ResourceId = "TUGraz.VectoCore.Resources.Declaration.DefaultTC.vtcc"; - - public TorqueConverter() - { - ParseData(ReadCsvResource(ResourceId)); - } - - - [Obsolete("Default Lookup not available. Use LookupMu or LookupTorque instead.", true)] - private 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.GetSection(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).Cast<Scalar>(), 2); - } - - public double LookupMu(double nu) - { - var sec = Data.GetSection(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; } - } - } -} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs index 1bbcf718f5c1a3fc4e074d644e2a138b61d4e80b..e7c44da3108f5eb6695160900dfd1e4e653bc7b2 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Gearbox/TorqueConverterData.cs @@ -31,30 +31,30 @@ using System; using System.Collections.Generic; -using System.Data; -using System.IO; using System.Linq; -using iTextSharp.text.pdf.codec; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { public class TorqueConverterData { - public List<TorqueConverterEntry> TorqueConverterEntries; + protected List<TorqueConverterEntry> TorqueConverterEntries; - protected internal TorqueConverterData(List<TorqueConverterEntry> torqueConverterEntries) + protected PerSecond ReferenceSpeed; + + protected internal TorqueConverterData(List<TorqueConverterEntry> torqueConverterEntries, PerSecond referenceSpeed) { TorqueConverterEntries = torqueConverterEntries; + ReferenceSpeed = referenceSpeed; } + public void GetInputTorqueAndAngularSpeed(NewtonMeter torqueOut, PerSecond angularSpeedOut, out NewtonMeter torqueIn, out PerSecond angularSpeedIn) { var solutions = new List<double>(); - var mpNorm = 1000.RPMtoRad().Value(); + var mpNorm = ReferenceSpeed.Value(); // Find analytic solution for torque converter operating point // mu = f(nu) = f(n_out / n_in) = T_out / T_in @@ -82,7 +82,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox solutions.AddRange(selected); } if (solutions.Count == 0) { - throw new VectoException("No solution for input torque/input speed found! n_out: {0}, tq_out: {1}", angularSpeedOut, torqueOut); + throw new VectoException("No solution for input torque/input speed found! n_out: {0}, tq_out: {1}", angularSpeedOut, + torqueOut); } angularSpeedIn = solutions.Min().SI<PerSecond>(); @@ -94,8 +95,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox { int index; TorqueConverterEntries.GetSection(x => x.SpeedRatio > nu, out index); - var muEdge = Edge.Create(new Point(TorqueConverterEntries[index].SpeedRatio, TorqueConverterEntries[index].TorqueRatio), - new Point(TorqueConverterEntries[index + 1].SpeedRatio, TorqueConverterEntries[index + 1].TorqueRatio)); + var muEdge = + Edge.Create(new Point(TorqueConverterEntries[index].SpeedRatio, TorqueConverterEntries[index].TorqueRatio), + new Point(TorqueConverterEntries[index + 1].SpeedRatio, TorqueConverterEntries[index + 1].TorqueRatio)); return muEdge.SlopeXY * nu + muEdge.OffsetXY; } } diff --git a/VectoCore/VectoCore/Resources/Declaration/DefaultTC.vtcc b/VectoCore/VectoCore/Resources/Declaration/DefaultTC.vtcc deleted file mode 100644 index 3676a37ec28628517e45e6567f4d9bc516766ca2..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/Resources/Declaration/DefaultTC.vtcc +++ /dev/null @@ -1,12 +0,0 @@ -nue,mue,MP1000 (1000/rpm)^2*Nm -1.000,1.000,0.00 -1.005,1.000,0.00 -1.100,1.000,-40.34 -1.222,1.000,-80.34 -1.375,1.000,-136.11 -1.571,1.000,-216.52 -1.833,1.000,-335.19 -2.200,1.000,-528.77 -2.750,1.000,-883.40 -4.400,1.000,-2462.17 -11.000,1.000,-16540.98 diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 6280561b3c874111f6d5ec89dd777b69c131f86b..d167e51be283c3fa55a77a0a71e158a28fd3f4e6 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -150,7 +150,6 @@ <Compile Include="Models\Declaration\Segments.cs" /> <Compile Include="Models\Declaration\StandardBodies.cs" /> <Compile Include="Models\Declaration\SteeringPump.cs" /> - <Compile Include="Models\Declaration\TorqueConverter.cs" /> <Compile Include="Models\Declaration\VehicleClass.cs" /> <Compile Include="Models\Declaration\Wheels.cs" /> <Compile Include="Models\Declaration\WHTCCorrection.cs" /> @@ -313,7 +312,6 @@ <EmbeddedResource Include="Resources\Declaration\VAUX\PS-Table.csv" /> <EmbeddedResource Include="Resources\Declaration\VAUX\SP-Table.csv" /> <EmbeddedResource Include="Resources\Declaration\VAUX\SP-Tech.csv" /> - <EmbeddedResource Include="Resources\Declaration\DefaultTC.vtcc" /> <EmbeddedResource Include="Resources\Declaration\VCDV\parameters.csv" /> <EmbeddedResource Include="Resources\Declaration\WHTC-Weighting-Factors.csv" /> <EmbeddedResource Include="Resources\Declaration\VAUX\ALT-Tech.csv" /> diff --git a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs index d8f0fbc69346dfa4825981874fb1f72b578cb9b0..ea8d0d0f9838ef1a698f1c95421a6f8125bc1166 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/DeclarationDataTest.cs @@ -238,48 +238,6 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration crossWindCorrectionCurve.EffectiveAirDragArea(kmph.KMPHtoMeterPerSecond())); } - [ - // fixed points - TestCase(150, 1.000, 1.000, 0.00), - TestCase(150, 1.100, 1.000, -40.34), - TestCase(150, 1.222, 1.000, -80.34), - TestCase(150, 1.375, 1.000, -136.11), - TestCase(150, 1.571, 1.000, -216.52), - TestCase(150, 1.833, 1.000, -335.19), - TestCase(150, 2.200, 1.000, -528.77), - TestCase(150, 2.750, 1.000, -883.40), - TestCase(150, 4.400, 1.000, -2462.17), - TestCase(150, 11.000, 1.000, -16540.98), - // interpolated - TestCase(150, 1.0025, 1.0, 0.0), - TestCase(150, 1.0525, 1.0, -20.17), - TestCase(150, 1.161, 1.0, -60.34), - TestCase(150, 1.2985, 1.0, -108.225), - TestCase(150, 1.473, 1.0, -176.315), - TestCase(150, 1.702, 1.0, -275.855), - TestCase(150, 2.0165, 1.0, -431.98), - TestCase(150, 2.475, 1.0, -706.085), - TestCase(150, 3.575, 1.0, -1672.785), - TestCase(150, 7.7, 1.0, -9501.575), - // extrapolated - TestCase(150, 0.5, 1.0, 0.0), - TestCase(150, 12.0, 1.0, -18674.133), // = (12-4.4)*(-16540.98- -2462.17)/(11-4.4)+ -2462.17 - ] - public void DefaultTcTest(double referenceRpm, double nu, double mu, double torque) - { - var referenceSpeed = referenceRpm.SI<PerSecond>(); - - var r = new Random(); - - var muLookup = DeclarationData.TorqueConverter.LookupMu(nu); - Assert.AreEqual(muLookup, mu); - - var angularSpeed = r.Next(1000).SI<PerSecond>(); - var torqueLookup = DeclarationData.TorqueConverter.LookupTorque(nu, angularSpeed, referenceSpeed); - AssertHelper.AreRelativeEqual( - torque.SI<NewtonMeter>() * Math.Pow((angularSpeed / referenceSpeed).Cast<Scalar>(), 2), torqueLookup); - } - [Test] public void AuxElectricSystemTest() { diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/TorqueConverterDataTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/TorqueConverterDataTest.cs index 25debf9c593b270c31b1d7f8d649b6fdc4c4b910..348076e7eb4450ded946bf44eeaed6d2e9096415 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/TorqueConverterDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/TorqueConverterDataTest.cs @@ -42,7 +42,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData var tqData = TorqueConverterDataReader.ReadFromStream(InputDataHelper.InputDataAsStream("Speed Ratio, Torque Ratio,MP1000", - tqInput)); + tqInput), 1000.RPMtoRad()); PerSecond inAngularSpeed; NewtonMeter inTorque; @@ -91,7 +91,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData var tqData = TorqueConverterDataReader.ReadFromStream(InputDataHelper.InputDataAsStream("Speed Ratio, Torque Ratio,MP1000", - tqInput)); + tqInput), 1000.RPMtoRad()); PerSecond inAngularSpeed; NewtonMeter inTorque;