diff --git a/Documentation/Checklist_Release_VECTO_3.1.0.652.docx b/Documentation/Checklist_Release_VECTO_3.1.0.652.docx index 677faf395f672416b20b104bcae2108ce1334183..813617631e376cc34e86208a1948e143743af943 100644 Binary files a/Documentation/Checklist_Release_VECTO_3.1.0.652.docx and b/Documentation/Checklist_Release_VECTO_3.1.0.652.docx differ diff --git a/Documentation/checklist_VECTO_Release.dotx b/Documentation/checklist_VECTO_Release.dotx index 87c25bc1826a62c81e555690b13a75f8c6dbe817..656b63f4769f37bb8e5bad8e4b3aa3c05de0a168 100644 Binary files a/Documentation/checklist_VECTO_Release.dotx and b/Documentation/checklist_VECTO_Release.dotx differ diff --git a/VectoCore/VectoCore/InputData/Reader/FullLoadCurveReader.cs b/VectoCore/VectoCore/InputData/Reader/FullLoadCurveReader.cs index 7b0e695cf72c082817cf8fae662322985eafdfa2..8700c12428023abc9febbc1b06483c49a2fa6b97 100644 --- a/VectoCore/VectoCore/InputData/Reader/FullLoadCurveReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/FullLoadCurveReader.cs @@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.InputData.Reader tmp = new PT1(); } else { if (data.Columns.Count > 3) { - tmp = PT1Curve.Create(data); + tmp = new PT1(data); } else { tmp = new PT1(); } diff --git a/VectoCore/VectoCore/Models/Declaration/PT1.cs b/VectoCore/VectoCore/Models/Declaration/PT1.cs index e45f553866865c091d41cd5254bcf3f5d1d355be..387771d816bb17abf22ebb465e085fc876f46f89 100644 --- a/VectoCore/VectoCore/Models/Declaration/PT1.cs +++ b/VectoCore/VectoCore/Models/Declaration/PT1.cs @@ -34,7 +34,9 @@ using System.Collections.Generic; using System.Data; using System.Linq; using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.Declaration @@ -58,6 +60,11 @@ namespace TUGraz.VectoCore.Models.Declaration ParseData(ReadCsvResource(ResourceId)); } + public PT1(DataTable data) + { + ParseDataFromFld(data); + } + protected override void ParseData(DataTable table) { _entries = table.Rows.Cast<DataRow>() @@ -66,6 +73,30 @@ namespace TUGraz.VectoCore.Models.Declaration .ToList(); } + private void ParseDataFromFld(DataTable data) + { + if (data.Columns.Count < 3) { + throw new VectoException("FullLoadCurve/PT1 Data File must consist of at least 4 columns."); + } + + if (data.Rows.Count < 2) { + throw new VectoException( + "FullLoadCurve/PT1 must consist of at least two lines with numeric values (below file header)"); + } + + if (data.Columns.Contains(Fields.EngineSpeed) && data.Columns.Contains(Fields.PT1)) { + _entries = data.Rows.Cast<DataRow>() + .Select( + r => new KeyValuePair<PerSecond, Second>(DataTableExtensionMethods.ParseDouble(r, Fields.EngineSpeed).RPMtoRad(), + DataTableExtensionMethods.ParseDouble(r, Fields.PT1).SI<Second>())) + .OrderBy(x => x.Key).ToList(); + } else { + _entries = data.Rows.Cast<DataRow>() + .Select(r => new KeyValuePair<PerSecond, Second>(r.ParseDouble(0).RPMtoRad(), r.ParseDouble(3).SI<Second>())) + .OrderBy(x => x.Key).ToList(); + } + } + public override Second Lookup(PerSecond key) { var index = 1; @@ -86,5 +117,11 @@ namespace TUGraz.VectoCore.Models.Declaration } return pt1; } + + private static class Fields + { + public const string PT1 = "PT1"; + public const string EngineSpeed = "engine speed"; + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs deleted file mode 100644 index 72ef57f5c86a5a5407d14abd79f327cb955ad28c..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/PT1Curve.cs +++ /dev/null @@ -1,136 +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.Collections.Generic; -using System.Data; -using System.Linq; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Utils; - -namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine -{ - public sealed class PT1Curve : LookupData<PerSecond, Second> - { - private List<KeyValuePair<PerSecond, Second>> _entries; - - // just for Lookup-inheritance compatibility - protected override string ResourceId - { - get { return null; } - } - - // just for Lookup-inheritance compatibility - protected override string ErrorMessage - { - get { throw new InvalidOperationException(); } - } - - private PT1Curve(DataTable data) - { - ParseData(data); - } - - private PT1Curve(string file) - { - DataTable data; - try { - data = VectoCSVFile.Read(file); - } catch (Exception ex) { - throw new VectoException("ERROR while reading PT1 Curve File: " + ex.Message); - } - - ParseData(data); - } - - public static PT1Curve ReadFromFile(string fileName) - { - return new PT1Curve(fileName); - } - - public static PT1Curve Create(DataTable data) - { - return new PT1Curve(data); - } - - protected override void ParseData(DataTable data) - { - if (data.Columns.Count < 3) { - throw new VectoException("FullLoadCurve/PT1 Data File must consist of at least 4 columns."); - } - - if (data.Rows.Count < 2) { - throw new VectoException( - "FullLoadCurve/PT1 must consist of at least two lines with numeric values (below file header)"); - } - - if (data.Columns.Contains(Fields.EngineSpeed) && data.Columns.Contains(Fields.PT1)) { - _entries = data.Rows.Cast<DataRow>() - .Select(r => new KeyValuePair<PerSecond, Second>(r.ParseDouble(Fields.EngineSpeed).RPMtoRad(), - r.ParseDouble(Fields.PT1).SI<Second>())) - .OrderBy(x => x.Key).ToList(); - } else { - _entries = data.Rows.Cast<DataRow>() - .Select(r => new KeyValuePair<PerSecond, Second>(r.ParseDouble(0).RPMtoRad(), r.ParseDouble(3).SI<Second>())) - .OrderBy(x => x.Key).ToList(); - } - } - - public override Second Lookup(PerSecond key) - { - var index = 1; - if (key.IsSmaller(_entries[0].Key)) { - Log.Error("requested rpm below minimum rpm in pt1 - extrapolating. n_eng_avg: {0}, rpm_min: {1}", - key.ConvertTo().Rounds.Per.Minute, _entries[0].Key.ConvertTo().Rounds.Per.Minute); - } else { - index = _entries.FindIndex(x => x.Key.IsGreater(key)); - if (index <= 0) { - index = key.IsGreater(_entries[0].Key) ? _entries.Count - 1 : 1; - } - } - - var pt1 = VectoMath.Interpolate(_entries[index - 1].Key, _entries[index].Key, _entries[index - 1].Value, - _entries[index].Value, key); - if (pt1 < 0) { - throw new VectoException("The calculated pt1 value must not be smaller than 0. Value: " + pt1); - } - return pt1; - } - - private static class Fields - { - public const string PT1 = "PT1"; - public const string EngineSpeed = "engine speed"; - } - } -} \ No newline at end of file