From d007ee78c2c016c105994354c585b7d9a85e4a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ben=C3=AD=C4=8Dek?= Date: Thu, 16 Nov 2023 16:45:50 +0100 Subject: [PATCH] Added calculation for PT100 and PT1000 --- Electric/RTD/PT100.cs | 70 ++++++++++++++++++++++++++++++++++++++++++ Electric/RTD/PT1000.cs | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 Electric/RTD/PT100.cs create mode 100644 Electric/RTD/PT1000.cs diff --git a/Electric/RTD/PT100.cs b/Electric/RTD/PT100.cs new file mode 100644 index 0000000..109c8c7 --- /dev/null +++ b/Electric/RTD/PT100.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Calculations.Electric.TemperatureSensorsRecalculation +{ + public static class PT100 + { + private static readonly decimal KoeficientA = 0.0039083M; + private static readonly decimal KoeficientB = -0.0000005775M; + private static readonly decimal KoeficientC = -0.000000000004183M; + + + /// + /// Recalculate temperature to PT100 Resistance + /// + /// Temperature in °C + /// Resistance + public static decimal TemperatureToResistance(decimal temperature) + { + if (temperature < 0) + { + return 100 * (1 + KoeficientA * temperature + KoeficientB * (decimal)Math.Pow((double)temperature, 2) + KoeficientC * (decimal)Math.Pow((double)temperature, 3) * (temperature - 100)); + } + else + { + return 100 * (1 + KoeficientA * temperature + KoeficientB * (decimal)Math.Pow((double)temperature, 2)); + } + } + + /// + /// Recalculate PT100 resistance to Temperature + /// + /// Resistance PT100 + /// Temperature in °C + public static double ResistanceToTemperature(double resistance) + { + return (Math.Sqrt((double)KoeficientB * resistance - 100 * (double)KoeficientB + 25 * Math.Pow((double)KoeficientA, 2)) - 5 * (double)KoeficientA) / (double)(10 * KoeficientB); + } + + /// + /// Recalculate PT100 resistance to Temperature + /// + /// Resistance PT100 + /// Temperature in °C + public static double ResistanceToTemperature(decimal resistance) + { + return ResistanceToTemperature((double)resistance); + } + + + + + + + + + + + + + + + + + + } +} diff --git a/Electric/RTD/PT1000.cs b/Electric/RTD/PT1000.cs new file mode 100644 index 0000000..332680e --- /dev/null +++ b/Electric/RTD/PT1000.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Calculations.Electric.RTD +{ + public static class PT1000 + { + private static readonly decimal KoeficientA = 0.0039083M; + private static readonly decimal KoeficientB = -0.0000005775M; + private static readonly decimal KoeficientC = -0.000000000004183M; + + + /// + /// Recalculate temperature to PT1000 Resistance + /// + /// Temperature in °C + /// Resistance PT1000 + public static decimal TemperatureToResistance(decimal temperature) + { + if (temperature < 0) + { + return 1000 * (1 + KoeficientA * temperature + KoeficientB * (decimal)Math.Pow((double)temperature, 2) + KoeficientC * (decimal)Math.Pow((double)temperature, 3) * (temperature - 100)); + } + else + { + return 1000 * (1 + KoeficientA * temperature + KoeficientB * (decimal)Math.Pow((double)temperature, 2)); + } + } + + /// + /// Recalculate PT1000 resistance to Temperature + /// + /// Resistance PT1000 + /// Temperature in °C + public static double ResistanceToTemperature(double resistance) + { + return (Math.Sqrt((double)KoeficientB * (resistance / 10) - 100 * (double)KoeficientB + 25 * Math.Pow((double)KoeficientA, 2)) - 5 * (double)KoeficientA) / (double)(10 * KoeficientB); + } + + /// + /// Recalculate PT1000 resistance to Temperature + /// + /// Resistance PT1000 + /// Temperature in °C + public static double ResistanceToTemperature(decimal resistance) + { + return ResistanceToTemperature((double)resistance); + } + + } +}