From 8fcdc0e8d0fec4d9bb9d906ac4696544ccc03354 Mon Sep 17 00:00:00 2001
From: Vladimir Portyanikhin <86243191+portyanikhin@users.noreply.github.com>
Date: Thu, 3 Oct 2024 14:45:52 +0300
Subject: [PATCH] Refactoring
---
src/VCRC/Fluids/IRefrigerant.cs | 6 ++++++
src/VCRC/Fluids/Refrigerant.cs | 7 ++++---
tests/VCRC.Tests/Fluids/RefrigerantTests.cs | 1 +
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/VCRC/Fluids/IRefrigerant.cs b/src/VCRC/Fluids/IRefrigerant.cs
index e96f6c1..845b63d 100644
--- a/src/VCRC/Fluids/IRefrigerant.cs
+++ b/src/VCRC/Fluids/IRefrigerant.cs
@@ -90,6 +90,12 @@ public interface IRefrigerant : IFluid
/// Invalid superheat!
IRefrigerant Superheated(Pressure pressure, TemperatureDelta superheat);
+ ///
+ new IRefrigerant SpecifyPhase(Phases phase);
+
+ ///
+ new IRefrigerant UnspecifyPhase();
+
///
new IRefrigerant WithState(
IKeyedInput firstInput,
diff --git a/src/VCRC/Fluids/Refrigerant.cs b/src/VCRC/Fluids/Refrigerant.cs
index 615df9a..b552100 100644
--- a/src/VCRC/Fluids/Refrigerant.cs
+++ b/src/VCRC/Fluids/Refrigerant.cs
@@ -32,11 +32,8 @@ public Refrigerant(FluidsList name)
.ToUnit(TemperatureDeltaUnit.Kelvin);
public bool HasGlide => Glide > 0.01.Kelvins();
-
public bool IsSingleComponent => !IsAzeotropicBlend && !IsZeotropicBlend;
-
public bool IsAzeotropicBlend => BlendRegex(false).IsMatch(Name.ToString());
-
public bool IsZeotropicBlend => BlendRegex(true).IsMatch(Name.ToString());
public IRefrigerant Subcooled(
@@ -64,6 +61,10 @@ public IRefrigerant Superheated(Pressure pressure, TemperatureDelta superheat) =
: superheat.Equals(TemperatureDelta.Zero, Tolerance.Kelvins()) ? DewPointAt(pressure)
: DewPointAt(pressure).HeatingTo(DewPointAt(pressure).Temperature + superheat);
+ public new IRefrigerant SpecifyPhase(Phases phase) => (Refrigerant)base.SpecifyPhase(phase);
+
+ public new IRefrigerant UnspecifyPhase() => (Refrigerant)base.UnspecifyPhase();
+
public new IRefrigerant WithState(
IKeyedInput firstInput,
IKeyedInput secondInput
diff --git a/tests/VCRC.Tests/Fluids/RefrigerantTests.cs b/tests/VCRC.Tests/Fluids/RefrigerantTests.cs
index 672ee0a..dd39b7f 100644
--- a/tests/VCRC.Tests/Fluids/RefrigerantTests.cs
+++ b/tests/VCRC.Tests/Fluids/RefrigerantTests.cs
@@ -256,6 +256,7 @@ public void Methods_New_ReturnsInstancesOfTheRefrigerantType()
{
_sut.Clone().Should().BeOfType();
_sut.Factory().Should().BeOfType();
+ _sut.SpecifyPhase(Phases.Gas).UnspecifyPhase().Should().BeOfType();
_sut.IsentropicCompressionTo(HighPressure).Should().BeOfType();
_sut.CompressionTo(HighPressure, _isentropicEfficiency).Should().BeOfType();
_sut.IsenthalpicExpansionTo(LowPressure).Should().BeOfType();