From a80958b3935d5d3873a410a046a1952b522eea84 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Mon, 17 Oct 2022 12:42:10 +0200 Subject: [PATCH] adding different cases of heating for buses adding distribution of heating power depending on auxiliary configuration (heatpump, electric heater, fuel heater) for all environmental conditions adding testcase for heating cases and heating power distribution --- .../HeatingDistributionCasesMapReader.cs | 150 +++++++++++++++++ .../Impl/HVAC/HeatingDistributionCase.cs | 29 ++++ .../Impl/HVAC/HeatingDistributionCasesMap.cs | 43 +++++ .../Impl/HVAC/HeatingDistributionMap.cs | 61 +++++++ .../Models/Declaration/DeclarationData.cs | 9 + .../Declaration/Buses/HeatingDistribution.csv | 156 ++++++++++++++++++ .../Buses/HeatingDistributionCases.csv | 36 ++++ .../Declaration/BusDeclarationDataTest.cs | 96 ++++++++++- 8 files changed, 579 insertions(+), 1 deletion(-) create mode 100644 VectoCore/VectoCore/InputData/Reader/ComponentData/HeatingDistributionCasesMapReader.cs create mode 100644 VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionCase.cs create mode 100644 VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionCasesMap.cs create mode 100644 VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionMap.cs create mode 100644 VectoCore/VectoCore/Resources/Declaration/Buses/HeatingDistribution.csv create mode 100644 VectoCore/VectoCore/Resources/Declaration/Buses/HeatingDistributionCases.csv diff --git a/VectoCore/VectoCore/InputData/Reader/ComponentData/HeatingDistributionCasesMapReader.cs b/VectoCore/VectoCore/InputData/Reader/ComponentData/HeatingDistributionCasesMapReader.cs new file mode 100644 index 0000000000..5ad4d1f95e --- /dev/null +++ b/VectoCore/VectoCore/InputData/Reader/ComponentData/HeatingDistributionCasesMapReader.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.Reader.ComponentData +{ + public static class HeatingDistributionMapReader + { + public static HeatingDistributionMap ReadFile(string fileName) + { + if ((string.IsNullOrWhiteSpace(fileName))) { + return null; + } + + if (!File.Exists(fileName)) { + throw new FileNotFoundException(fileName); + } + + return Create(VectoCSVFile.Read(fileName)); + } + + public static HeatingDistributionMap ReadStream(Stream stream) + { + return Create(VectoCSVFile.ReadStream(stream)); + } + + public static HeatingDistributionMap Create(TableData data) + { + var requiredHeatPumps = EnumHelper.GetValues<HeatPumpType>() + .Where(x => !x.IsOneOf(HeatPumpType.none, HeatPumpType.not_applicable)).ToList(); + if (!HeaderIsValid(data.Columns, requiredHeatPumps)) { + throw new VectoException("Invalid Header vor heating distribution map"); + } + + var map = new Dictionary<Tuple<HeatingDistributionCase, int>, HeatingDistributionMap.Entry>(); + foreach (DataRow row in data.Rows) { + var heatPumpContr = new Dictionary<HeatPumpType, double>(); + foreach (var heatPumpType in requiredHeatPumps) { + var value = row.Field<string>(heatPumpType.GetLabel()).ToDouble(double.NaN) / 100.0; + if (!double.IsNaN(value)) { + heatPumpContr.Add(heatPumpType, value); + } + } + var hdCase = HeatingDistributionCaseHelper.Parse(row.Field<string>(Fields.HeatingDistributionCase)); + var envId = row.Field<string>(Fields.EnvironmentalId).ToInt(); + var elHeater = row.Field<string>(Fields.ElectricHeater).ToDouble(double.NaN) / 100.0; + var fuelHeater = row.Field<string>(Fields.FuelHeater).ToDouble(double.NaN) / 100.0; + map.Add(Tuple.Create(hdCase, envId), new HeatingDistributionMap.Entry(envId, heatPumpContr, elHeater, fuelHeater)); + } + + return new HeatingDistributionMap(map); + } + + public static bool HeaderIsValid(DataColumnCollection columns, List<HeatPumpType> requiredHeatPumps) + { + var header = requiredHeatPumps.Select(x => x.GetLabel()) + .ToList(); + header.AddRange(new[] { Fields.HeatingDistributionCase, Fields.ElectricHeater, Fields.FuelHeater }); + return header.All(h => columns.Contains(h)); + } + + public static class Fields + { + public const string HeatingDistributionCase = "HeatingDistributionCase"; + public const string EnvironmentalId = "Environmental ID"; + public const string ElectricHeater = "electric heater"; + public const string FuelHeater = "fuel heater"; + } + } + + public static class HeatingDistributionCasesMapReader + { + public static HeatingDistributionCasesMap ReadFile(string fileName) + { + if ((string.IsNullOrWhiteSpace(fileName))) { + return null; + } + + if (!File.Exists(fileName)) { + throw new FileNotFoundException(fileName); + } + + return Create(VectoCSVFile.Read(fileName)); + } + + public static HeatingDistributionCasesMap ReadStream(Stream stream) + { + return Create(VectoCSVFile.ReadStream(stream)); + } + + public static HeatingDistributionCasesMap Create(TableData data) + { + var requiredHeatPumps = EnumHelper.GetValues<HeatPumpType>() + .Where(x => !x.IsOneOf(HeatPumpType.none, HeatPumpType.not_applicable)).ToList(); + if (!HeaderIsValid(data.Columns, requiredHeatPumps)) { + throw new VectoException("Invalid Header vor heating distribution map"); + } + + var map = new List<HeatingDistributionCasesMap.Entry>(); + foreach (DataRow row in data.Rows) { + var allowedHeatPumps = new List<HeatPumpType>(); + foreach (var heatPumpType in requiredHeatPumps) { + var allowed = row.Field<string>(heatPumpType.GetLabel()).ToBoolean(); + if (allowed) { + allowedHeatPumps.Add(heatPumpType); + } + } + + if (allowedHeatPumps.Count > 1) { + throw new VectoException("One row shall not contain multiple heatpump technologies!"); + } + + if (allowedHeatPumps.Count == 0) { + allowedHeatPumps.Add(HeatPumpType.none); + } + map.Add(new HeatingDistributionCasesMap.Entry() { + HeatingDistributionCase = HeatingDistributionCaseHelper.Parse(row.Field<string>(Fields.HeatingDistributionCase)), + ElectricHeater = row.Field<string>(Fields.ElectricHeater).ToBoolean(), + FuelHeater = row.Field<string>(Fields.FuelHeater).ToBoolean(), + HeatPumpType = allowedHeatPumps.First() + }); + } + + return new HeatingDistributionCasesMap(map); + } + + public static bool HeaderIsValid(DataColumnCollection columns, List<HeatPumpType> requiredHeatPumps) + { + var header = requiredHeatPumps.Select(x => x.GetLabel()) + .ToList(); + header.AddRange(new[] {Fields.HeatingDistributionCase, Fields.ElectricHeater, Fields.FuelHeater}); + return header.All(h => columns.Contains(h)); + } + + public static class Fields + { + public const string HeatingDistributionCase = "HeatingDistributionCase"; + public const string ElectricHeater = "electric heater"; + public const string FuelHeater = "fuel heater"; + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionCase.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionCase.cs new file mode 100644 index 0000000000..cb59edffc0 --- /dev/null +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionCase.cs @@ -0,0 +1,29 @@ +using TUGraz.VectoCommon.Utils; + +namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public enum HeatingDistributionCase + { + HeatingDistribution1, + HeatingDistribution2, + HeatingDistribution3, + HeatingDistribution4, + HeatingDistribution5, + HeatingDistribution6, + HeatingDistribution7, + HeatingDistribution8, + HeatingDistribution9, + HeatingDistribution10, + HeatingDistribution11, + HeatingDistribution12, + } + + public static class HeatingDistributionCaseHelper + { + + public static HeatingDistributionCase Parse(string parse) + { + return parse.Replace("HD", "HeatingDistribution").ParseEnum<HeatingDistributionCase>(); + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionCasesMap.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionCasesMap.cs new file mode 100644 index 0000000000..40e0fbf3ef --- /dev/null +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionCasesMap.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Linq; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCommon.Exceptions; + +namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public class HeatingDistributionCasesMap + { + private List<Entry> Map; + + public HeatingDistributionCasesMap(List<Entry> map) + { + Map = map; + } + + public HeatingDistributionCase GetHeatingDistributionCase(HeatPumpType heatPump, HeaterType electricHeater, + bool fuelHeater) + { + var matching = Map.Where(x => x.IsEqual(heatPump, electricHeater, fuelHeater)).ToList(); + if (matching.Count != 1) { + throw new VectoException($"Zero or more than one matching entry! {matching.Count}"); + } + + return matching.First().HeatingDistributionCase; + } + + public class Entry + { + public HeatingDistributionCase HeatingDistributionCase; + public HeatPumpType HeatPumpType; + public bool ElectricHeater; + public bool FuelHeater; + + public bool IsEqual(HeatPumpType heatPump, HeaterType electricHeater, bool fuelHeater) + { + var hasElectricHeater = electricHeater != HeaterType.None; + var otherHeater = ElectricHeater == hasElectricHeater; + return HeatPumpType == heatPump && otherHeater && FuelHeater == fuelHeater; + } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionMap.cs b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionMap.cs new file mode 100644 index 0000000000..dcad607036 --- /dev/null +++ b/VectoCore/VectoCore/Models/BusAuxiliaries/DownstreamModules/Impl/HVAC/HeatingDistributionMap.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using TUGraz.VectoCommon.BusAuxiliaries; +using TUGraz.VectoCore.Models.Declaration; + +namespace TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC +{ + public class HeatingDistributionMap + { + protected Dictionary<Tuple<HeatingDistributionCase, int>, Entry> HeatingDistribution; + + public HeatingDistributionMap(Dictionary<Tuple<HeatingDistributionCase, int>, Entry> map) + { + HeatingDistribution = map; + } + + public Entry Lookup(HeatingDistributionCase hdCase, int environmentalId) + { + var key = Tuple.Create(hdCase, environmentalId); + if (HeatingDistribution.ContainsKey(key)) { + return HeatingDistribution[key]; + } + return null; + } + + public class Entry + { + protected int EnvironmentID; + protected Dictionary<HeatPumpType, double> HeatpumpContribution; + protected double ElectricHeaterContribution; + protected double FuelHeaterContribution; + + public Entry(int environmentID, Dictionary<HeatPumpType, double> heatpumpContribution, double electricHeaterContribution, double fuelHeaterContribution) + { + EnvironmentID = environmentID; + HeatpumpContribution = heatpumpContribution; + ElectricHeaterContribution = electricHeaterContribution; + FuelHeaterContribution = fuelHeaterContribution; + } + + public double GetHeatpumpContribution(HeatPumpType heatPump) + { + if (HeatpumpContribution.ContainsKey(heatPump)) { + return HeatpumpContribution[heatPump]; + } + + return 0; + } + + public double GetElectricHeaterContribution(HeaterType heater) + { + return double.IsNaN(ElectricHeaterContribution) ? 0 : ElectricHeaterContribution; + } + + public double GetFuelHeaterContribution() + { + return double.IsNaN(FuelHeaterContribution) ? 0 : FuelHeaterContribution; + } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs index b908450f98..f4a18a474d 100644 --- a/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs +++ b/VectoCore/VectoCore/Models/Declaration/DeclarationData.cs @@ -247,6 +247,8 @@ namespace TUGraz.VectoCore.Models.Declaration public static BusAlternatorTechnologies AlternatorTechnologies = new BusAlternatorTechnologies(); private static HVACCoolingPower hvacMaxCoolingPower; + private static HeatingDistributionCasesMap heatingDistributionCasesMap; + private static HeatingDistributionMap heatingDistributionMap; public static List<SSMTechnology> SSMTechnologyList => ssmTechnologies ?? (ssmTechnologies = SSMTechnologiesReader.ReadFromStream( @@ -256,6 +258,13 @@ namespace TUGraz.VectoCore.Models.Declaration envMap ?? (envMap = EnvironmentalContidionsMapReader.ReadStream( RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.DefaultClimatic.aenv"))); + public static HeatingDistributionCasesMap HeatingDistributionCases => + heatingDistributionCasesMap ?? (heatingDistributionCasesMap = HeatingDistributionCasesMapReader.ReadStream( + RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.HeatingDistributionCases.csv"))); + public static HeatingDistributionMap HeatingDistribution => + heatingDistributionMap ?? (heatingDistributionMap = HeatingDistributionMapReader.ReadStream( + RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.HeatingDistribution.csv"))); + public static ElectricalConsumerList DefaultElectricConsumerList => elUserConfig ?? (elUserConfig = ElectricConsumerReader.ReadStream( RessourceHelper.ReadStream(DeclarationDataResourcePrefix + ".Buses.ElectricConsumers.csv"))); diff --git a/VectoCore/VectoCore/Resources/Declaration/Buses/HeatingDistribution.csv b/VectoCore/VectoCore/Resources/Declaration/Buses/HeatingDistribution.csv new file mode 100644 index 0000000000..1159aa1a6d --- /dev/null +++ b/VectoCore/VectoCore/Resources/Declaration/Buses/HeatingDistribution.csv @@ -0,0 +1,156 @@ +HeatingDistributionCase , Environmental ID , R-744 , non R-744 2-stage , non R-744 3-stage , non R-744 4-stage , non R-744 continuous , electric heater , fuel heater +# only R-744 +HD1 , 1 , 100 , - , - , - , - , - , - +HD1 , 2 , 100 , - , - , - , - , - , - +HD1 , 3 , 100 , - , - , - , - , - , - +HD1 , 4 , 100 , - , - , - , - , - , - +HD1 , 5 , 100 , - , - , - , - , - , - +HD1 , 6 , 100 , - , - , - , - , - , - +HD1 , 7 , 100 , - , - , - , - , - , - +HD1 , 8 , 100 , - , - , - , - , - , - +HD1 , 9 , 100 , - , - , - , - , - , - +HD1 , 10 , 100 , - , - , - , - , - , - +HD1 , 11 , 100 , - , - , - , - , - , - + +# R-744 + other electric heater +HD2 , 1 , 50 , , , , , 50 , +HD2 , 2 , 100 , - , - , - , - , 0 , - +HD2 , 3 , 100 , - , - , - , - , 0 , - +HD2 , 4 , 100 , - , - , - , - , 0 , - +HD2 , 5 , 100 , - , - , - , - , 0 , - +HD2 , 6 , 100 , - , - , - , - , 0 , - +HD2 , 7 , 100 , - , - , - , - , 0 , - +HD2 , 8 , 100 , - , - , - , - , 0 , - +HD2 , 9 , 100 , - , - , - , - , 0 , - +HD2 , 10 , 100 , - , - , - , - , 0 , - +HD2 , 11 , 100 , - , - , - , - , 0 , - + +# R-744 + other electric heater + fuel heater +HD3 , 1 , 40 , - , - , - , - , 20 , 40 +HD3 , 2 , 70 , - , - , - , - , 0 , 30 +HD3 , 3 , 80 , - , - , - , - , 0 , 20 +HD3 , 4 , 100 , - , - , - , - , 0 , 0 +HD3 , 5 , 100 , - , - , - , - , 0 , 0 +HD3 , 6 , 100 , - , - , - , - , 0 , 0 +HD3 , 7 , 100 , - , - , - , - , 0 , 0 +HD3 , 8 , 100 , - , - , - , - , 0 , 0 +HD3 , 9 , 100 , - , - , - , - , 0 , 0 +HD3 , 10 , 100 , - , - , - , - , 0 , 0 +HD3 , 11 , 100 , - , - , - , - , 0 , 0 + +# R-744 + fuel heater +HD4 , 1 , 40 , - , - , - , - , - , 60 +HD4 , 2 , 70 , - , - , - , - , - , 30 +HD4 , 3 , 80 , - , - , - , - , - , 20 +HD4 , 4 , 100 , - , - , - , - , - , 0 +HD4 , 5 , 100 , - , - , - , - , - , 0 +HD4 , 6 , 100 , - , - , - , - , - , 0 +HD4 , 7 , 100 , - , - , - , - , - , 0 +HD4 , 8 , 100 , - , - , - , - , - , 0 +HD4 , 9 , 100 , - , - , - , - , - , 0 +HD4 , 10 , 100 , - , - , - , - , - , 0 +HD4 , 11 , 100 , - , - , - , - , - , 0 + +# Non R744 only +HD5 , 1 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 2 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 3 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 4 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 5 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 6 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 7 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 8 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 9 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 10 , - , 100 , 100 , 100 , 100 , - , - +HD5 , 11 , - , 100 , 100 , 100 , 100 , - , - + +# Non R-744 + other electric heater +HD6 , 1 , - , 0 , 0 , 0 , 0 , 100 , - +HD6 , 2 , - , 100 , 100 , 100 , 100 , 0 , - +HD6 , 3 , - , 100 , 100 , 100 , 100 , 0 , - +HD6 , 4 , - , 100 , 100 , 100 , 100 , 0 , - +HD6 , 5 , - , 100 , 100 , 100 , 100 , 0 , - +HD6 , 6 , - , 100 , 100 , 100 , 100 , 0 , - +HD6 , 7 , - , 100 , 100 , 100 , 100 , 0 , - +HD6 , 8 , - , 100 , 100 , 100 , 100 , 0 , - +HD6 , 9 , - , 100 , 100 , 100 , 100 , 0 , - +HD6 , 10 , - , 100 , 100 , 100 , 100 , 0 , - +HD6 , 11 , - , 100 , 100 , 100 , 100 , 0 , - + +# Non R-744 + other electric heater + fuel heater +HD7 , 1 , - , 0 , 0 , 0 , 0 , 20 , 80 +HD7 , 2 , - , 70 , 70 , 70 , 70 , 0 , 30 +HD7 , 3 , - , 80 , 80 , 80 , 80 , 0 , 20 +HD7 , 4 , - , 100 , 100 , 100 , 100 , 0 , 0 +HD7 , 5 , - , 100 , 100 , 100 , 100 , 0 , 0 +HD7 , 6 , - , 100 , 100 , 100 , 100 , 0 , 0 +HD7 , 7 , - , 100 , 100 , 100 , 100 , 0 , 0 +HD7 , 8 , - , 100 , 100 , 100 , 100 , 0 , 0 +HD7 , 9 , - , 100 , 100 , 100 , 100 , 0 , 0 +HD7 , 10 , - , 100 , 100 , 100 , 100 , 0 , 0 +HD7 , 11 , - , 100 , 100 , 100 , 100 , 0 , 0 + +# Non R-744 + fuel heater +HD8 , 1 , - , 0 , 0 , 0 , 0 , - , 100 +HD8 , 2 , - , 70 , 70 , 70 , 70 , - , 30 +HD8 , 3 , - , 80 , 80 , 80 , 80 , - , 20 +HD8 , 4 , - , 100 , 100 , 100 , 100 , - , 0 +HD8 , 5 , - , 100 , 100 , 100 , 100 , - , 0 +HD8 , 6 , - , 100 , 100 , 100 , 100 , - , 0 +HD8 , 7 , - , 100 , 100 , 100 , 100 , - , 0 +HD8 , 8 , - , 100 , 100 , 100 , 100 , - , 0 +HD8 , 9 , - , 100 , 100 , 100 , 100 , - , 0 +HD8 , 10 , - , 100 , 100 , 100 , 100 , - , 0 +HD8 , 11 , - , 100 , 100 , 100 , 100 , - , 0 + +# Other electric heater only +HD9 , 1 , - , - , - , - , - , 100 , +HD9 , 2 , - , - , - , - , - , 100 , +HD9 , 3 , - , - , - , - , - , 100 , +HD9 , 4 , - , - , - , - , - , 100 , +HD9 , 5 , - , - , - , - , - , 100 , +HD9 , 6 , - , - , - , - , - , 100 , +HD9 , 7 , - , - , - , - , - , 100 , +HD9 , 8 , - , - , - , - , - , 100 , +HD9 , 9 , - , - , - , - , - , 100 , +HD9 , 10 , - , - , - , - , - , 100 , +HD9 , 11 , - , - , - , - , - , 100 , + +# Ohter electric heater + fuel heater +HD10 , 1 , - , - , - , - , - , 20 , 80 +HD10 , 2 , - , - , - , - , - , 0 , 100 +HD10 , 3 , - , - , - , - , - , 0 , 100 +HD10 , 4 , - , - , - , - , - , 0 , 100 +HD10 , 5 , - , - , - , - , - , 0 , 100 +HD10 , 6 , - , - , - , - , - , 0 , 100 +HD10 , 7 , - , - , - , - , - , 0 , 100 +HD10 , 8 , - , - , - , - , - , 0 , 100 +HD10 , 9 , - , - , - , - , - , 0 , 100 +HD10 , 10 , - , - , - , - , - , 0 , 100 +HD10 , 11 , - , - , - , - , - , 0 , 100 + +# fuel heater only +HD11 , 1 , - , - , - , - , - , - , 100 +HD11 , 2 , - , - , - , - , - , - , 100 +HD11 , 3 , - , - , - , - , - , - , 100 +HD11 , 4 , - , - , - , - , - , - , 100 +HD11 , 5 , - , - , - , - , - , - , 100 +HD11 , 6 , - , - , - , - , - , - , 100 +HD11 , 7 , - , - , - , - , - , - , 100 +HD11 , 8 , - , - , - , - , - , - , 100 +HD11 , 9 , - , - , - , - , - , - , 100 +HD11 , 10 , - , - , - , - , - , - , 100 +HD11 , 11 , - , - , - , - , - , - , 100 + +# no heating +HD12 , 1 , - , - , - , - , - , - , - +HD12 , 2 , - , - , - , - , - , - , - +HD12 , 3 , - , - , - , - , - , - , - +HD12 , 4 , - , - , - , - , - , - , - +HD12 , 5 , - , - , - , - , - , - , - +HD12 , 6 , - , - , - , - , - , - , - +HD12 , 7 , - , - , - , - , - , - , - +HD12 , 8 , - , - , - , - , - , - , - +HD12 , 9 , - , - , - , - , - , - , - +HD12 , 10 , - , - , - , - , - , - , - +HD12 , 11 , - , - , - , - , - , - , - diff --git a/VectoCore/VectoCore/Resources/Declaration/Buses/HeatingDistributionCases.csv b/VectoCore/VectoCore/Resources/Declaration/Buses/HeatingDistributionCases.csv new file mode 100644 index 0000000000..09fcf3a726 --- /dev/null +++ b/VectoCore/VectoCore/Resources/Declaration/Buses/HeatingDistributionCases.csv @@ -0,0 +1,36 @@ +HeatingDistributionCase , R-744 , non R-744 2-stage , non R-744 3-stage , non R-744 4-stage , non R-744 continuous , electric heater , fuel heater +HD1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 + +HD2 , 1 , 0 , 0 , 0 , 0 , 1 , 0 + +HD3 , 1 , 0 , 0 , 0 , 0 , 1 , 1 + +HD4 , 1 , 0 , 0 , 0 , 0 , 0 , 1 + +HD5 , 0 , 1 , 0 , 0 , 0 , 0 , 0 +HD5 , 0 , 0 , 1 , 0 , 0 , 0 , 0 +HD5 , 0 , 0 , 0 , 1 , 0 , 0 , 0 +HD5 , 0 , 0 , 0 , 0 , 1 , 0 , 0 + +HD6 , 0 , 1 , 0 , 0 , 0 , 1 , 0 +HD6 , 0 , 0 , 1 , 0 , 0 , 1 , 0 +HD6 , 0 , 0 , 0 , 1 , 0 , 1 , 0 +HD6 , 0 , 0 , 0 , 0 , 1 , 1 , 0 + +HD7 , 0 , 1 , 0 , 0 , 0 , 1 , 1 +HD7 , 0 , 0 , 1 , 0 , 0 , 1 , 1 +HD7 , 0 , 0 , 0 , 1 , 0 , 1 , 1 +HD7 , 0 , 0 , 0 , 0 , 1 , 1 , 1 + +HD8 , 0 , 1 , 0 , 0 , 0 , 0 , 1 +HD8 , 0 , 0 , 1 , 0 , 0 , 0 , 1 +HD8 , 0 , 0 , 0 , 1 , 0 , 0 , 1 +HD8 , 0 , 0 , 0 , 0 , 1 , 0 , 1 + +HD9 , 0 , 0 , 0 , 0 , 0 , 1 , 0 + +HD10 , 0 , 0 , 0 , 0 , 0 , 1 , 1 + +HD11 , 0 , 0 , 0 , 0 , 0 , 0 , 1 + +HD12 , 0 , 0 , 0 , 0 , 0 , 0 , 0 diff --git a/VectoCore/VectoCoreTest/Models/Declaration/BusDeclarationDataTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/BusDeclarationDataTest.cs index efce6d6a22..b3ff35a759 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/BusDeclarationDataTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/BusDeclarationDataTest.cs @@ -1,6 +1,9 @@ -using NUnit.Framework; +using System.Linq; +using NUnit.Framework; +using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.BusAuxiliaries.DownstreamModules.Impl.HVAC; using TUGraz.VectoCore.Models.Declaration; namespace TUGraz.VectoCore.Tests.Models.Declaration; @@ -84,4 +87,95 @@ public class BusDeclarationDataTest var len = DeclarationData.BusAuxiliaries.CorrectionLengthDrivetrainVolume(vc, lowEntry, numAxles, articulated); Assert.AreEqual(expectedLength, len.Value()); } + + + [ + TestCase(HeatPumpType.R_744, HeaterType.None, false, HeatingDistributionCase.HeatingDistribution1), + TestCase(HeatPumpType.R_744, HeaterType.WaterElectricHeater, false, HeatingDistributionCase.HeatingDistribution2), + TestCase(HeatPumpType.R_744, HeaterType.AirElectricHeater, true, HeatingDistributionCase.HeatingDistribution3), + TestCase(HeatPumpType.R_744, HeaterType.None, true, HeatingDistributionCase.HeatingDistribution4), + TestCase(HeatPumpType.non_R_744_2_stage, HeaterType.None, false, HeatingDistributionCase.HeatingDistribution5), + TestCase(HeatPumpType.non_R_744_3_stage, HeaterType.WaterElectricHeater, false, HeatingDistributionCase.HeatingDistribution6), + TestCase(HeatPumpType.non_R_744_4_stage, HeaterType.AirElectricHeater, true, HeatingDistributionCase.HeatingDistribution7), + TestCase(HeatPumpType.non_R_744_2_stage, HeaterType.None, true, HeatingDistributionCase.HeatingDistribution8), + TestCase(HeatPumpType.none, HeaterType.OtherElectricHeating, false, HeatingDistributionCase.HeatingDistribution9), + TestCase(HeatPumpType.none, HeaterType.WaterElectricHeater, true, HeatingDistributionCase.HeatingDistribution10), + TestCase(HeatPumpType.none, HeaterType.None, true, HeatingDistributionCase.HeatingDistribution11), + TestCase(HeatPumpType.none, HeaterType.None, false, HeatingDistributionCase.HeatingDistribution12), + ] + public void TestBusAuxHeatingDistributionCase(HeatPumpType heatPump, HeaterType heater, bool fuelHeater, + HeatingDistributionCase expectedCase) + { + var heatingCase = + DeclarationData.BusAuxiliaries.HeatingDistributionCases.GetHeatingDistributionCase(heatPump, heater, + fuelHeater); + Assert.AreEqual(expectedCase, heatingCase); + } + + + [ + TestCase(HeatingDistributionCase.HeatingDistribution1, HeatPumpType.R_744, HeaterType.None, false), + TestCase(HeatingDistributionCase.HeatingDistribution2, HeatPumpType.R_744, HeaterType.WaterElectricHeater, false), + TestCase(HeatingDistributionCase.HeatingDistribution3, HeatPumpType.R_744, HeaterType.WaterElectricHeater, true), + TestCase(HeatingDistributionCase.HeatingDistribution4, HeatPumpType.R_744, HeaterType.None, true), + TestCase(HeatingDistributionCase.HeatingDistribution5, HeatPumpType.non_R_744_2_stage, HeaterType.None, false), + TestCase(HeatingDistributionCase.HeatingDistribution6, HeatPumpType.non_R_744_3_stage, HeaterType.WaterElectricHeater, false), + TestCase(HeatingDistributionCase.HeatingDistribution7, HeatPumpType.non_R_744_4_stage, HeaterType.WaterElectricHeater, true), + TestCase(HeatingDistributionCase.HeatingDistribution8, HeatPumpType.non_R_744_2_stage, HeaterType.None, true), + TestCase(HeatingDistributionCase.HeatingDistribution9, HeatPumpType.none, HeaterType.WaterElectricHeater, false), + TestCase(HeatingDistributionCase.HeatingDistribution10, HeatPumpType.none, HeaterType.WaterElectricHeater, true), + TestCase(HeatingDistributionCase.HeatingDistribution11, HeatPumpType.none, HeaterType.None, true), +// TestCase(HeatingDistributionCase.HeatingDistribution12, HeatPumpType.none, HeaterType.None, false), + ] + public void TestBusAuxHeatingDistribution(HeatingDistributionCase hdCase, HeatPumpType hpType, HeaterType heater, bool fuelHeater) + { + for (var environmentalId = 1; environmentalId <= 11; environmentalId++) { + var entry = DeclarationData.BusAuxiliaries.HeatingDistribution.Lookup(hdCase, environmentalId); + Assert.IsNotNull(entry); + var hp = entry.GetHeatpumpContribution(hpType); + var elHeater = entry.GetElectricHeaterContribution(heater); + var fuel = entry.GetFuelHeaterContribution(); + if (hdCase == HeatingDistributionCase.HeatingDistribution12) { + // in case 12 no heaters are present! + Assert.AreEqual(0, hp + elHeater + fuel); + } else { + Assert.AreEqual(1, hp + elHeater + fuel, + $"contributions do not sum up to 1 for configuration {hdCase}, {environmentalId}"); + } + } + } + + [Test] + public void TestBusAusHeatingDistribution_ALL() + { + var heatpumps = EnumHelper.GetValues<HeatPumpType>().Where(x => !x.IsOneOf(HeatPumpType.not_applicable)) + .ToList(); + var electricHeater = EnumHelper.GetValues<HeaterType>().Where(x => x != HeaterType.FuelHeater).ToList(); + var fuelHeater = new[] { true, false }; + + foreach (var heatpump in heatpumps) { + foreach (var heater in electricHeater) { + foreach (var auxHeater in fuelHeater) { + var heatingCase = + DeclarationData.BusAuxiliaries.HeatingDistributionCases.GetHeatingDistributionCase(heatpump, + heater, auxHeater); + + for (var envId = 1; envId <= 11; envId++) { + var entry = DeclarationData.BusAuxiliaries.HeatingDistribution.Lookup(heatingCase, envId); + var hp = entry.GetHeatpumpContribution(heatpump); + var elHeater = entry.GetElectricHeaterContribution(heater); + var fuel = entry.GetFuelHeaterContribution(); + if (heatingCase == HeatingDistributionCase.HeatingDistribution12) { + // in case 12 no heaters are present! + Assert.AreEqual(0, hp + elHeater + fuel); + } else { + Assert.AreEqual(1, hp + elHeater + fuel, + $"contributions do not sum up to 1 for configuration. {heatpump}, {heater}, {auxHeater} {heatingCase}, {envId}"); + } + } + } + } + } + + } } \ No newline at end of file -- GitLab