Skip to content

Commit

Permalink
Merge pull request #229 from portyanikhin/update-target-frameworks
Browse files Browse the repository at this point in the history
Updated target frameworks
  • Loading branch information
portyanikhin committed Nov 15, 2023
2 parents ee9a9f7 + 86305c2 commit af33772
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 573 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-tests.yml
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-binaries.yml
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Restore Python dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Restore tools
run: dotnet tool restore
- name: Check code style
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -24,11 +24,19 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/publish-nuget.yml
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Expand Up @@ -4,7 +4,7 @@
<Authors>Vladimir Portyanikhin</Authors>
<Copyright>Copyright (c) Vladimir Portyanikhin 2021</Copyright>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/portyanikhin/SharpProp</PackageProjectUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Expand Up @@ -8,7 +8,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>NuGet.md</PackageReadmeFile>
<TargetFrameworks>netstandard2.0;netstandard2.1;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
53 changes: 20 additions & 33 deletions src/SharpProp/Enums/FluidInfoAttribute.cs
Expand Up @@ -3,62 +3,49 @@
/// <summary>
/// Fluid predefined info.
/// </summary>
/// <param name="name">CoolProp internal name.</param>
/// <param name="backend">Type of CoolProp backend.</param>
/// <param name="pure">True if pure or pseudo-pure fluid.</param>
/// <param name="mixType">Mass-based or volume-based mixture.</param>
/// <param name="fractionMin">Minimum possible fraction.</param>
/// <param name="fractionMax">Maximum possible fraction.</param>
[AttributeUsage(AttributeTargets.Field)]
public sealed class FluidInfoAttribute : Attribute
public sealed class FluidInfoAttribute(
string name,
string backend = "HEOS",
bool pure = true,
Mix mixType = Mix.Mass,
double fractionMin = 0,
double fractionMax = 1
) : Attribute
{
/// <summary>
/// Fluid predefined info.
/// </summary>
/// <param name="name">CoolProp internal name.</param>
/// <param name="backend">Type of CoolProp backend.</param>
/// <param name="pure">True if pure or pseudo-pure fluid.</param>
/// <param name="mixType">Mass-based or volume-based mixture.</param>
/// <param name="fractionMin">Minimum possible fraction.</param>
/// <param name="fractionMax">Maximum possible fraction.</param>
public FluidInfoAttribute(
string name,
string backend = "HEOS",
bool pure = true,
Mix mixType = Mix.Mass,
double fractionMin = 0,
double fractionMax = 1
)
{
Name = name;
Backend = backend;
Pure = pure;
MixType = mixType;
FractionMin = fractionMin;
FractionMax = fractionMax;
}

/// <summary>
/// CoolProp internal name.
/// </summary>
public string Name { get; }
public string Name { get; } = name;

/// <summary>
/// Type of CoolProp backend.
/// </summary>
public string Backend { get; }
public string Backend { get; } = backend;

/// <summary>
/// True if pure or pseudo-pure fluid.
/// </summary>
public bool Pure { get; }
public bool Pure { get; } = pure;

/// <summary>
/// Mass-based or volume-based mixture.
/// </summary>
public Mix MixType { get; }
public Mix MixType { get; } = mixType;

/// <summary>
/// Minimum possible fraction.
/// </summary>
public double FractionMin { get; }
public double FractionMin { get; } = fractionMin;

/// <summary>
/// Maximum possible fraction.
/// </summary>
public double FractionMax { get; }
public double FractionMax { get; } = fractionMax;
}
6 changes: 2 additions & 4 deletions src/SharpProp/Fluids/AbstractFluid.cs
@@ -1,8 +1,6 @@
namespace SharpProp;

/// <summary>
/// Abstract fluid.
/// </summary>
/// <inheritdoc cref="IAbstractFluid"/>
public abstract partial class AbstractFluid : IAbstractFluid
{
protected AbstractState Backend = default!;
Expand Down Expand Up @@ -100,7 +98,7 @@ protected double KeyedOutput(Parameters key)
.FirstOrDefault(input => input.CoolPropKey == key)
?.Value;
var result = input ?? Backend.KeyedOutput(key);
new OutputsValidator(result).Validate();
OutputsValidator.Validate(result);
return result;
}

Expand Down
6 changes: 2 additions & 4 deletions src/SharpProp/Fluids/Fluid.cs
Expand Up @@ -2,13 +2,11 @@

namespace SharpProp;

/// <summary>
/// Pure/pseudo-pure fluid or binary mixture.
/// </summary>
/// <inheritdoc cref="IFluid"/>
public class Fluid : AbstractFluid, IFluid
{
/// <summary>
/// Pure/pseudo-pure fluid or binary mixture.
/// <inheritdoc cref="IFluid"/>
/// </summary>
/// <param name="name">Selected fluid name.</param>
/// <param name="fraction">
Expand Down
6 changes: 2 additions & 4 deletions src/SharpProp/Fluids/Mixture.cs
@@ -1,14 +1,12 @@
namespace SharpProp;

/// <summary>
/// Mass-based mixture of pure fluids.
/// </summary>
/// <inheritdoc cref="IMixture"/>
public class Mixture : AbstractFluid, IMixture
{
private const string AvailableBackend = "HEOS";

/// <summary>
/// Mass-based mixture of pure fluids.
/// <inheritdoc cref="IMixture"/>
/// </summary>
/// <param name="fluids">List of selected names of pure fluids.</param>
/// <param name="fractions">List of mass-based fractions.</param>
Expand Down
6 changes: 2 additions & 4 deletions src/SharpProp/HumidAir/HumidAir.cs
@@ -1,8 +1,6 @@
namespace SharpProp;

/// <summary>
/// Real humid air (see ASHRAE RP-1485).
/// </summary>
/// <inheritdoc cref="IHumidAir"/>
public partial class HumidAir : IHumidAir
{
private IList<IKeyedInput<string>> _inputs = new List<IKeyedInput<string>>(
Expand Down Expand Up @@ -104,7 +102,7 @@ protected double KeyedOutput(string key)
_inputs[2].CoolPropKey,
_inputs[2].Value
);
new OutputsValidator(result).Validate();
OutputsValidator.Validate(result);
return result;
}

Expand Down
23 changes: 6 additions & 17 deletions src/SharpProp/IO/Input.cs
Expand Up @@ -3,24 +3,13 @@
/// <summary>
/// CoolProp keyed input for fluids and mixtures.
/// </summary>
public record Input : IKeyedInput<Parameters>
/// <param name="CoolPropKey">CoolProp internal key.</param>
/// <param name="Value">Input value in SI units.</param>
public record Input(Parameters CoolPropKey, double Value)
: KeyedInput<Parameters>(CoolPropKey, Value)
{
/// <summary>
/// CoolProp keyed input for fluids and mixtures.
/// </summary>
/// <param name="coolPropKey">CoolProp internal key.</param>
/// <param name="value">Input value.</param>
protected Input(Parameters coolPropKey, double value)
{
CoolPropKey = coolPropKey;
Value = value;
}

public Parameters CoolPropKey { get; }

public string CoolPropHighLevelKey => CoolPropKey.ToString().TrimStart('i');

public double Value { get; }
public override string CoolPropHighLevelKey =>
CoolPropKey.ToString().TrimStart('i');

/// <summary>
/// Mass density.
Expand Down
22 changes: 5 additions & 17 deletions src/SharpProp/IO/InputHumidAir.cs
Expand Up @@ -3,24 +3,12 @@
/// <summary>
/// CoolProp keyed input for humid air.
/// </summary>
public record InputHumidAir : IKeyedInput<string>
/// <param name="CoolPropKey">CoolProp internal key.</param>
/// <param name="Value">Input value in SI units.</param>
public record InputHumidAir(string CoolPropKey, double Value)
: KeyedInput<string>(CoolPropKey, Value)
{
/// <summary>
/// CoolProp keyed input for humid air.
/// </summary>
/// <param name="coolPropKey">CoolProp internal key.</param>
/// <param name="value">Input value.</param>
protected InputHumidAir(string coolPropKey, double value)
{
CoolPropKey = coolPropKey;
Value = value;
}

public string CoolPropKey { get; }

public string CoolPropHighLevelKey => CoolPropKey;

public double Value { get; }
public override string CoolPropHighLevelKey => CoolPropKey;

/// <summary>
/// Altitude above sea level.
Expand Down
12 changes: 12 additions & 0 deletions src/SharpProp/IO/KeyedInput.cs
@@ -0,0 +1,12 @@
namespace SharpProp;

/// <inheritdoc cref="IKeyedInput{T}"/>
/// <param name="CoolPropKey">CoolProp internal key.</param>
/// <param name="Value">Input value in SI units.</param>
public abstract record KeyedInput<T>(T CoolPropKey, double Value)
: IKeyedInput<T>
{
public T CoolPropKey { get; } = CoolPropKey;
public abstract string CoolPropHighLevelKey { get; }
public double Value { get; } = Value;
}
25 changes: 3 additions & 22 deletions src/SharpProp/IO/OutputsValidator.cs
@@ -1,29 +1,10 @@
namespace SharpProp;

/// <summary>
/// CoolProp outputs validator.
/// </summary>
internal class OutputsValidator
internal static class OutputsValidator
{
private readonly double _output;

/// <summary>
/// CoolProp outputs validator.
/// </summary>
/// <param name="output">
/// CoolProp output.
/// </param>
public OutputsValidator(double output) => _output = output;

/// <summary>
/// Validates the CoolProp output.
/// </summary>
/// <exception cref="ArgumentException">
/// Invalid or not defined state!
/// </exception>
public void Validate()
public static void Validate(double output)
{
if (double.IsInfinity(_output) || double.IsNaN(_output))
if (double.IsInfinity(output) || double.IsNaN(output))
{
throw new ArgumentException("Invalid or not defined state!");
}
Expand Down
4 changes: 2 additions & 2 deletions src/SharpProp/SharpProp.csproj
Expand Up @@ -45,10 +45,10 @@
<DependentUpon>$([System.String]::Copy(I%(Filename).cs))</DependentUpon>
</Compile>
<Compile Update="IO\Input.cs">
<DependentUpon>IKeyedInput.cs</DependentUpon>
<DependentUpon>KeyedInput.cs</DependentUpon>
</Compile>
<Compile Update="IO\InputHumidAir.cs">
<DependentUpon>IKeyedInput.cs</DependentUpon>
<DependentUpon>KeyedInput.cs</DependentUpon>
</Compile>
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions tests/Directory.Build.props
Expand Up @@ -9,11 +9,11 @@
</PropertyGroup>

<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
<TargetFrameworks>net48;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net48;net6.0;net8.0</TargetFrameworks>
</PropertyGroup>

</Project>
7 changes: 3 additions & 4 deletions tests/SharpProp.Tests/Fluids/FluidExtended.cs
Expand Up @@ -5,15 +5,14 @@
/// the <see cref="Fluid"/> class.
/// </summary>
/// <seealso cref="IFluidExtended"/>
public class FluidExtended : Fluid, IFluidExtended
public class FluidExtended(FluidsList name, Ratio? fraction = null)
: Fluid(name, fraction),
IFluidExtended
{
private MolarMass? _molarDensity;
private double? _ozoneDepletionPotential;
private SpecificEntropy? _specificHeatConstVolume;

public FluidExtended(FluidsList name, Ratio? fraction = null)
: base(name, fraction) { }

public SpecificEntropy SpecificHeatConstVolume =>
_specificHeatConstVolume ??= SpecificEntropy
.FromJoulesPerKilogramKelvin(KeyedOutput(Parameters.iCvmass))
Expand Down

0 comments on commit af33772

Please sign in to comment.