diff --git a/src/VCRC/Abstract/ITwoStageVCRC.cs b/src/VCRC/Abstract/ITwoStageVCRC.cs index 1f3ef2f..8377a4c 100644 --- a/src/VCRC/Abstract/ITwoStageVCRC.cs +++ b/src/VCRC/Abstract/ITwoStageVCRC.cs @@ -8,10 +8,10 @@ public interface ITwoStageVCRC : IVCRC /// /// Absolute intermediate pressure. /// - public Pressure IntermediatePressure { get; } + Pressure IntermediatePressure { get; } /// /// Specific mass flow rate of the intermediate circuit. /// - public Ratio IntermediateSpecificMassFlow { get; } + Ratio IntermediateSpecificMassFlow { get; } } diff --git a/src/VCRC/Abstract/IVCRC.cs b/src/VCRC/Abstract/IVCRC.cs index 3678022..93bc929 100644 --- a/src/VCRC/Abstract/IVCRC.cs +++ b/src/VCRC/Abstract/IVCRC.cs @@ -8,70 +8,70 @@ public interface IVCRC : IEntropyAnalysable /// /// Evaporator. /// - public IEvaporator Evaporator { get; } + IEvaporator Evaporator { get; } /// /// Compressor. /// - public ICompressor Compressor { get; } + ICompressor Compressor { get; } /// /// Heat releaser (condenser for subcritical VCRC or gas cooler for transcritical VCRC). /// - public IHeatReleaser HeatReleaser { get; } + IHeatReleaser HeatReleaser { get; } /// /// Condenser (not null for subcritical VCRC). /// - public ICondenser? Condenser { get; } + ICondenser? Condenser { get; } /// /// Gas cooler (not null for transcritical VCRC). /// - public IHeatReleaser? GasCooler { get; } + IHeatReleaser? GasCooler { get; } /// /// true if VCRC is transcritical, false if VCRC is subcritical. /// - public bool IsTranscritical { get; } + bool IsTranscritical { get; } /// /// Specific mass flow rate of the evaporator. /// - public Ratio EvaporatorSpecificMassFlow { get; } + Ratio EvaporatorSpecificMassFlow { get; } /// /// Specific mass flow rate of the condenser or gas cooler. /// - public Ratio HeatReleaserSpecificMassFlow { get; } + Ratio HeatReleaserSpecificMassFlow { get; } /// /// Specific work of isentropic compression. /// - public SpecificEnergy IsentropicSpecificWork { get; } + SpecificEnergy IsentropicSpecificWork { get; } /// /// Specific work of real compression. /// - public SpecificEnergy SpecificWork { get; } + SpecificEnergy SpecificWork { get; } /// /// Specific cooling capacity of the cycle. /// - public SpecificEnergy SpecificCoolingCapacity { get; } + SpecificEnergy SpecificCoolingCapacity { get; } /// /// Specific heating capacity of the cycle. /// - public SpecificEnergy SpecificHeatingCapacity { get; } + SpecificEnergy SpecificHeatingCapacity { get; } /// /// Energy efficiency ratio, aka cooling coefficient. /// - public double EER { get; } + double EER { get; } /// /// Coefficient of performance, aka heating coefficient. /// - public double COP { get; } + double COP { get; } } diff --git a/src/VCRC/EntropyAnalysis/EntropyAnalysisExtensions.cs b/src/VCRC/EntropyAnalysis/EntropyAnalysisExtensions.cs index 7cb3cc9..708a535 100644 --- a/src/VCRC/EntropyAnalysis/EntropyAnalysisExtensions.cs +++ b/src/VCRC/EntropyAnalysis/EntropyAnalysisExtensions.cs @@ -8,41 +8,48 @@ public static class EntropyAnalysisExtensions /// /// Performs VCRC entropy analysis over a range of indoor and outdoor temperatures. /// - /// List of VCRCs. - /// List of indoor temperatures. - /// List of outdoor temperatures. + /// Enumerable of VCRCs. + /// Enumerable of indoor temperatures. + /// Enumerable of outdoor temperatures. /// Result of the VCRC entropy analysis in range of temperatures. - /// The lists should have the same length! + /// Inputs should have the same length! public static IEntropyAnalysisResult EntropyAnalysis( - this IList cycles, - IList indoor, - IList outdoor - ) => - cycles.Count == indoor.Count && indoor.Count == outdoor.Count - ? cycles - .Select((cycle, i) => cycle.EntropyAnalysis(indoor[i], outdoor[i])) - .ToList() + this IEnumerable cycles, + IEnumerable indoor, + IEnumerable outdoor + ) + { + var cyclesList = cycles.ToList(); + var indoorList = indoor.ToList(); + var outdoorList = outdoor.ToList(); + return cyclesList.Count == indoorList.Count && indoorList.Count == outdoorList.Count + ? cyclesList + .Select((cycle, i) => cycle.EntropyAnalysis(indoorList[i], outdoorList[i])) .Average() - : throw new ArgumentException("The lists should have the same length!"); + : throw new ArgumentException("Inputs should have the same length!"); + } /// - /// Computes the average of a list of the entropy analysis results. + /// Computes the average of the entropy analysis results. /// - /// List of the entropy analysis results. + /// Enumerable of the entropy analysis results. /// The average. - public static IEntropyAnalysisResult Average(this IList results) => - new EntropyAnalysisResult( - results.Select(i => i.ThermodynamicPerfection.Percent).Average().Percent(), - results.Select(i => i.MinSpecificWorkRatio.Percent).Average().Percent(), - results.Select(i => i.CompressorEnergyLossRatio.Percent).Average().Percent(), - results.Select(i => i.CondenserEnergyLossRatio.Percent).Average().Percent(), - results.Select(i => i.GasCoolerEnergyLossRatio.Percent).Average().Percent(), - results.Select(i => i.ExpansionValvesEnergyLossRatio.Percent).Average().Percent(), - results.Select(i => i.EjectorEnergyLossRatio.Percent).Average().Percent(), - results.Select(i => i.EvaporatorEnergyLossRatio.Percent).Average().Percent(), - results.Select(i => i.RecuperatorEnergyLossRatio.Percent).Average().Percent(), - results.Select(i => i.EconomizerEnergyLossRatio.Percent).Average().Percent(), - results.Select(i => i.MixingEnergyLossRatio.Percent).Average().Percent(), - results.Select(i => i.AnalysisRelativeError.Percent).Average().Percent() + public static IEntropyAnalysisResult Average(this IEnumerable results) + { + var resultsList = results.ToList(); + return new EntropyAnalysisResult( + resultsList.Select(i => i.ThermodynamicPerfection.Percent).Average().Percent(), + resultsList.Select(i => i.MinSpecificWorkRatio.Percent).Average().Percent(), + resultsList.Select(i => i.CompressorEnergyLossRatio.Percent).Average().Percent(), + resultsList.Select(i => i.CondenserEnergyLossRatio.Percent).Average().Percent(), + resultsList.Select(i => i.GasCoolerEnergyLossRatio.Percent).Average().Percent(), + resultsList.Select(i => i.ExpansionValvesEnergyLossRatio.Percent).Average().Percent(), + resultsList.Select(i => i.EjectorEnergyLossRatio.Percent).Average().Percent(), + resultsList.Select(i => i.EvaporatorEnergyLossRatio.Percent).Average().Percent(), + resultsList.Select(i => i.RecuperatorEnergyLossRatio.Percent).Average().Percent(), + resultsList.Select(i => i.EconomizerEnergyLossRatio.Percent).Average().Percent(), + resultsList.Select(i => i.MixingEnergyLossRatio.Percent).Average().Percent(), + resultsList.Select(i => i.AnalysisRelativeError.Percent).Average().Percent() ); + } } diff --git a/tests/VCRC.Tests/EntropyAnalysis/EntropyAnalysisExtensionsTests.cs b/tests/VCRC.Tests/EntropyAnalysis/EntropyAnalysisExtensionsTests.cs index d49f551..76a585a 100644 --- a/tests/VCRC.Tests/EntropyAnalysis/EntropyAnalysisExtensionsTests.cs +++ b/tests/VCRC.Tests/EntropyAnalysis/EntropyAnalysisExtensionsTests.cs @@ -27,7 +27,7 @@ public void EntropyAnalysisInRange_ListsOfTemperaturesWithDifferentCount_ThrowsA action .Should() .Throw() - .WithMessage("The lists should have the same length!"); + .WithMessage("Inputs should have the same length!"); } [Fact]