From e0adada4692b6d1883d72e7b97b695d3b15878b5 Mon Sep 17 00:00:00 2001 From: Elias Ruemmler Date: Thu, 7 Mar 2019 17:21:11 +0100 Subject: [PATCH] Erweiterung Systemberechnung --- FlowCalc.sln | 6 + FlowCalc/FlowCalc.csproj | 6 +- FlowCalc/PoolSystem/BaseFitting.cs | 36 ++++ FlowCalc/PoolSystem/Elbow.cs | 71 +++++++ FlowCalc/PoolSystem/Fitting.cs | 47 ----- FlowCalc/PoolSystem/FittingDetailAttribute.cs | 28 +++ FlowCalc/PoolSystem/Fittings.cs | 21 +++ FlowCalc/PoolSystem/Medium.cs | 175 ++++++++++++++++++ FlowCalc/PoolSystem/Pipe.cs | 77 +++++++- FlowCalc_Test/FlowCalc_Test.csproj | 74 ++++++++ FlowCalc_Test/Pipe_Tests.cs | 28 +++ FlowCalc_Test/Properties/AssemblyInfo.cs | 20 ++ FlowCalc_Test/packages.config | 5 + 13 files changed, 543 insertions(+), 51 deletions(-) create mode 100644 FlowCalc/PoolSystem/BaseFitting.cs create mode 100644 FlowCalc/PoolSystem/Elbow.cs delete mode 100644 FlowCalc/PoolSystem/Fitting.cs create mode 100644 FlowCalc/PoolSystem/FittingDetailAttribute.cs create mode 100644 FlowCalc/PoolSystem/Fittings.cs create mode 100644 FlowCalc/PoolSystem/Medium.cs create mode 100644 FlowCalc_Test/FlowCalc_Test.csproj create mode 100644 FlowCalc_Test/Pipe_Tests.cs create mode 100644 FlowCalc_Test/Properties/AssemblyInfo.cs create mode 100644 FlowCalc_Test/packages.config diff --git a/FlowCalc.sln b/FlowCalc.sln index ad8c08f..0d1dc61 100644 --- a/FlowCalc.sln +++ b/FlowCalc.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28307.168 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowCalc", "FlowCalc\FlowCalc.csproj", "{43E44C73-0DB7-478D-8766-BD1D884D3090}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowCalc_Test", "FlowCalc_Test\FlowCalc_Test.csproj", "{81F19295-D779-4FF4-AC3E-90360E7360B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {43E44C73-0DB7-478D-8766-BD1D884D3090}.Debug|Any CPU.Build.0 = Debug|Any CPU {43E44C73-0DB7-478D-8766-BD1D884D3090}.Release|Any CPU.ActiveCfg = Release|Any CPU {43E44C73-0DB7-478D-8766-BD1D884D3090}.Release|Any CPU.Build.0 = Release|Any CPU + {81F19295-D779-4FF4-AC3E-90360E7360B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81F19295-D779-4FF4-AC3E-90360E7360B2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81F19295-D779-4FF4-AC3E-90360E7360B2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81F19295-D779-4FF4-AC3E-90360E7360B2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FlowCalc/FlowCalc.csproj b/FlowCalc/FlowCalc.csproj index a00e80a..7f8ab74 100644 --- a/FlowCalc/FlowCalc.csproj +++ b/FlowCalc/FlowCalc.csproj @@ -64,12 +64,16 @@ + + + + - + Form1.cs diff --git a/FlowCalc/PoolSystem/BaseFitting.cs b/FlowCalc/PoolSystem/BaseFitting.cs new file mode 100644 index 0000000..1aa9f1d --- /dev/null +++ b/FlowCalc/PoolSystem/BaseFitting.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowCalc.PoolSystem +{ + /// + /// Rohrbogen + /// + public abstract class BaseFitting + { + /// + /// Name der Armatur bzw. des Formstückes + /// + public string Name { get; set; } + + /// + /// Innendurchmesser + /// in [mm] + /// + public double Diameter { get; set; } + + /// + /// Rohrrauheit + /// in [mm] + /// + public double Roughness { get; set; } + + /// + /// Druckverlustbeiwert + /// + public abstract double Zeta { get; } + } +} diff --git a/FlowCalc/PoolSystem/Elbow.cs b/FlowCalc/PoolSystem/Elbow.cs new file mode 100644 index 0000000..4e9cc0b --- /dev/null +++ b/FlowCalc/PoolSystem/Elbow.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowCalc.PoolSystem +{ + public class Elbow : BaseFitting + { + #region Member + + + #endregion Member + + #region Properties + /// + /// Mittlerer Krümmungsradius des Rohrbogens + /// in [mm] + /// + public double Radius { get; set; } + + /// + /// Krümmungswinkel des Rohrbogens + /// in [Grad] + /// + public double Angle { get; set; } + + /// + /// Druckverlustbeiwert + /// + public override double Zeta + { + get + { + var x = Radius / Diameter; + if (x < 1 || x > 10) + throw new IndexOutOfRangeException("Gültigkeitsbereich für Zeta-Berechnung verletzt!"); + + return 0; + } + } + #endregion Properties + + #region Constructor + /// + /// Empty constructor for Elbow + /// + public Elbow() + { + + } + + #endregion Constructor + + #region Services + + + #endregion Services + + #region Internal services + + + #endregion Internal services + + #region Events + + + #endregion Events + } +} diff --git a/FlowCalc/PoolSystem/Fitting.cs b/FlowCalc/PoolSystem/Fitting.cs deleted file mode 100644 index 7188c49..0000000 --- a/FlowCalc/PoolSystem/Fitting.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FlowCalc.PoolSystem -{ - public class Fitting - { - #region Member - - - #endregion Member - - #region Properties - - - #endregion Properties - - #region Constructor - /// - /// Empty constructor for Fitting - /// - public Fitting() - { - - } - - #endregion Constructor - - #region Services - - - #endregion Services - - #region Internal services - - - #endregion Internal services - - #region Events - - - #endregion Events - } -} diff --git a/FlowCalc/PoolSystem/FittingDetailAttribute.cs b/FlowCalc/PoolSystem/FittingDetailAttribute.cs new file mode 100644 index 0000000..d56e6b9 --- /dev/null +++ b/FlowCalc/PoolSystem/FittingDetailAttribute.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowCalc.PoolSystem +{ + [AttributeUsage(AttributeTargets.Field)] + public class FittingDetailAttribute : Attribute + { + public string DisplayName { get; set; } + + public int NominalDiameter { get; set; } + + public double InnerDiameter { get; set; } + + public double Zeta { get; set; } + + public FittingDetailAttribute(string name, int dn, double zeta, double diameter) + { + DisplayName = name; + NominalDiameter = dn; + Zeta = zeta; + InnerDiameter = diameter; + } + } +} diff --git a/FlowCalc/PoolSystem/Fittings.cs b/FlowCalc/PoolSystem/Fittings.cs new file mode 100644 index 0000000..9f9346b --- /dev/null +++ b/FlowCalc/PoolSystem/Fittings.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowCalc.PoolSystem +{ + public enum Fittings + { + [FittingDetail("Bogen 90°", 40, 0.191, 42.6)] + Dn40Elbow90, + [FittingDetail("Winkel 90°", 40, 0.565, 50)] + Dn40Angle90, + [FittingDetail("Winkel 45°", 40, 0.565, 50)] + Dn40Angle45, + Dn40TPipe90, + Dn40TPipe45, + Dn40YPipe + } +} diff --git a/FlowCalc/PoolSystem/Medium.cs b/FlowCalc/PoolSystem/Medium.cs new file mode 100644 index 0000000..0adac3a --- /dev/null +++ b/FlowCalc/PoolSystem/Medium.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlowCalc.PoolSystem +{ + /// + /// Medienparameter + /// + [Serializable] + public class Medium + { + #region Member + + + #endregion Member + + #region Properties + /// + /// Name des Mediums + /// + public string Name { get; set; } + + /// + /// Temperatur + /// in [°C] + /// + public double Temperature { get; set; } + + /// + /// Dichte + /// in [kg/m^3] + /// + public double Density { get; set; } + + /// + /// Dynamische Viskosität + /// in [10E-6 kg/ms] + /// + public double DynamicViscosity { get; set; } + + /// + /// Kinetische Viskosität + /// in [10E-6 m^2/s] + /// + public double KineticViscosity { get; set; } + + #endregion Properties + + #region Static services + /// + /// Wasser bei 10 °C + /// Stoffwerte übernommen von: http://www.uni-magdeburg.de/isut/LSS/Lehre/Arbeitsheft/IV.pdf + /// + public static Medium Water10 + { + get + { + return new Medium() + { + Name = "Wasser", + Temperature = 10, + Density = 999.7, + DynamicViscosity = 1306.4, + KineticViscosity = 1.307 + }; + } + } + + /// + /// Wasser bei 15 °C + /// Stoffwerte übernommen von: http://www.uni-magdeburg.de/isut/LSS/Lehre/Arbeitsheft/IV.pdf + /// + public static Medium Water15 + { + get + { + return new Medium() + { + Name = "Wasser", + Temperature = 15, + Density = 999.1, + DynamicViscosity = 1138, + KineticViscosity = 1.139 + }; + } + } + + /// + /// Wasser bei 20 °C + /// Stoffwerte übernommen von: http://www.uni-magdeburg.de/isut/LSS/Lehre/Arbeitsheft/IV.pdf + /// + public static Medium Water20 + { + get + { + return new Medium() + { + Name = "Wasser", + Temperature = 20, + Density = 998.21, + DynamicViscosity = 1002, + KineticViscosity = 1.004 + }; + } + } + + /// + /// Wasser bei 25 °C + /// Stoffwerte übernommen von: http://www.uni-magdeburg.de/isut/LSS/Lehre/Arbeitsheft/IV.pdf + /// + public static Medium Water25 + { + get + { + return new Medium() + { + Name = "Wasser", + Temperature = 25, + Density = 997.05, + DynamicViscosity = 890.45, + KineticViscosity = 0.893 + }; + } + } + + /// + /// Wasser bei 30 °C + /// Stoffwerte übernommen von: http://www.uni-magdeburg.de/isut/LSS/Lehre/Arbeitsheft/IV.pdf + /// + public static Medium Water30 + { + get + { + return new Medium() + { + Name = "Wasser", + Temperature = 30, + Density = 995.65, + DynamicViscosity = 797.68, + KineticViscosity = 0.801 + }; + } + } + #endregion Static services + + #region Constructor + /// + /// Empty constructor for Medium + /// + public Medium() + { + + } + + #endregion Constructor + + #region Services + + + #endregion Services + + #region Internal services + + + #endregion Internal services + + #region Events + + + #endregion Events + } +} diff --git a/FlowCalc/PoolSystem/Pipe.cs b/FlowCalc/PoolSystem/Pipe.cs index 87ad59a..495bc8c 100644 --- a/FlowCalc/PoolSystem/Pipe.cs +++ b/FlowCalc/PoolSystem/Pipe.cs @@ -20,6 +20,18 @@ public class Pipe /// public double Diameter { get; set; } + /// + /// Rohrlänge + /// in [m] + /// + public double Length { get; set; } + + /// + /// Rohrrauheit + /// in [mm] + /// + public double Roughness { get; set; } + /// /// Rohrquerschnitt /// in mm^2 @@ -28,7 +40,7 @@ public double CrossArea { get { - return Math.Pow(Diameter, 2) * (4 / Math.PI); + return Math.PI * Math.Pow(Diameter, 2) / 4; } } @@ -36,18 +48,31 @@ public double CrossArea #region Constructor /// - /// Empty constructor for Pipe + /// Konstruktor /// public Pipe() { } + /// + /// Konstruktor + /// + /// Rohrlängein [m] + /// Innerer Rohrdurchmesser in [mm] + /// Rohrrauheit in [mm] + public Pipe(double l, double di, double k) + { + Length = l; + Diameter = di; + Roughness = k; + } + #endregion Constructor #region Services /// - /// Berechnet die Strömungsgeschwindigkeit + /// Strömungsgeschwindigkeit berechnen /// /// Volumenstrom in [m^3/h] /// Strömungsgeschwindigkeit in [m/s] @@ -59,6 +84,52 @@ public double CalcFlowVelocity(double flowRate) return q / a; } + /// + /// Druckverlust berechnen + /// (es wird von einer turbulenten Strömung ausgegangen) + /// + /// Stoffdaten + /// Volumenstrom in [m^3/h] + /// Druckverlust in [bar] + public double CalcPressureDrop(Medium medium, double flowRate) + { + double di = Diameter / 1000; // [m] + double k = Roughness / 1000; // [m] + double v = CalcFlowVelocity(flowRate); // [m/s] + double kv = medium.KineticViscosity / 1E6; // [m^2/s] + double re = v * di / kv; + + // Rohrreibungszahl (Lambda) nach Colebrook und White siehe: https://de.wikipedia.org/wiki/Rohrreibungszahl + // Iterative Berechnung + double lambda = 0.005; // Startwert für Lambda + double s = 0.001; // Schrittweite für Antastung + int i = 7; // Anzahl der Richtungswechsel + + double error = double.MaxValue - 1; + double lastError = double.MaxValue; + while (i > 0) + { + lastError = error; + error = 1 / Math.Sqrt(lambda) - (-2 * Math.Log10((2.51 / (re * Math.Sqrt(lambda))) + (k / (3.71 * di)))); + + if (Math.Abs(error) >= Math.Abs(lastError)) + { + s /= -10; + i--; + } + lambda += s; + } + + + // Druckverlust durch Rohrreibung + // https://www.schweizer-fn.de/stroemung/druckverlust/druckverlust.php#druckverlustrohr + double deltaP = (lambda * Length * medium.Density * Math.Pow(v, 2)) / (di * 2); // [Pa] + + double deltaP_Bar = deltaP / 1E5; + + return deltaP_Bar; + } + #endregion Services #region Internal services diff --git a/FlowCalc_Test/FlowCalc_Test.csproj b/FlowCalc_Test/FlowCalc_Test.csproj new file mode 100644 index 0000000..011d55e --- /dev/null +++ b/FlowCalc_Test/FlowCalc_Test.csproj @@ -0,0 +1,74 @@ + + + + + + Debug + AnyCPU + {81F19295-D779-4FF4-AC3E-90360E7360B2} + Library + Properties + FlowCalc_Test + FlowCalc_Test + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + + + + + + + + {43e44c73-0db7-478d-8766-bd1d884d3090} + FlowCalc + + + + + + + Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + + + + + + \ No newline at end of file diff --git a/FlowCalc_Test/Pipe_Tests.cs b/FlowCalc_Test/Pipe_Tests.cs new file mode 100644 index 0000000..aeb7fcc --- /dev/null +++ b/FlowCalc_Test/Pipe_Tests.cs @@ -0,0 +1,28 @@ +using System; +using FlowCalc.PoolSystem; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace FlowCalc_Test +{ + [TestClass] + public class Pipe_Tests + { + [TestMethod] + public void CalcFlowVelocity_Test() + { + var testPipe = new Pipe(1, 45.2, 0.1); + + // Vergleichsergebnis aus Druckverlust 7.0 (http://druckverlust.de) + Assert.AreEqual(1.731, testPipe.CalcFlowVelocity(10),1E-3); + } + + [TestMethod] + public void CalcPressureDrop_Test() + { + var testPipe = new Pipe(1, 45.2, 0.1); + + // Vergleichsergebnis aus Druckverlust 7.0 (http://druckverlust.de) + Assert.AreEqual(0.002, testPipe.CalcPressureDrop(Medium.Water20, 5), 1E-3); + } + } +} diff --git a/FlowCalc_Test/Properties/AssemblyInfo.cs b/FlowCalc_Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..840a1bf --- /dev/null +++ b/FlowCalc_Test/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("FlowCalc_Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("RC-Art Solutions")] +[assembly: AssemblyProduct("FlowCalc_Test")] +[assembly: AssemblyCopyright("Copyright © RC-Art Solutions 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("81f19295-d779-4ff4-ac3e-90360e7360b2")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/FlowCalc_Test/packages.config b/FlowCalc_Test/packages.config new file mode 100644 index 0000000..102a45c --- /dev/null +++ b/FlowCalc_Test/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file