Also bezüglich Code habe ich jetzt folgendes recherchiert:
"Python"
[code=php]
#!/usr/bin/python
# coding=utf-8
import math
def dewpoint(t, h):
a1 = 7.45
b1 = 235
dp = float(t)
fw = float(h)
x1 = (a1*dp)/(b1+dp)
e1 = 6.1*math.exp(x1*2.3025851)
e2 = e1*fw/100
x2 = e2/6.1
x3 = 0.434292289*math.log(x2)
dew = (235*x3)/(7.45-x3)*100
dew = math.floor(dew)/100
hum = (216.7*e2)/(273.15+dp)*100
hum = round(hum)/100
dew = "%02.2f" % (dew)
hum = "%02.2f" % (hum)
dew = '{: >5}'.format(dew)
hum = '{: >5}'.format(hum)
return dew,hum
temp = '22'
hum = '50'
print "Luft temp: {}°C ... hum: {}%" . format(temp, hum)
dewp, awat = dewpoint(temp, hum)
print("dewpoint: "+dewp+" °C (condensing)")
print("feu: "+awat+" (g water per 1m³ air)")
[/php]
"Arduino / AVR #1"
[code=php]
float calculateDewpoint(float h, float t) {
h *= 0.1;
t *= 0.1;
float k = (log10(h)-2)/0.4343 + (17.62*t)/(243.12+t);
return 243.12*k/(17.62-k);
}
[/php]
"Arduino / AVR #2"
[code=php]
// dewPoint function NOAA
// reference (1) : http://wahiduddin.net/calc/density_algorithms.htm
// reference (2) : http://www.colorado.edu/geography/weat…_site/about.htm
//
double dewPoint(double celsius, double humidity) {
// (1) Saturation Vapor Pressure = ESGG(T)
double RATIO = 373.15 / (273.15 + celsius);
double RHS = -7.90298 * (RATIO - 1);
RHS += 5.02808 * log10(RATIO);
RHS += -1.3816e-7 * (pow(10, (11.344 * (1 - 1/RATIO ))) - 1) ;
RHS += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;
RHS += log10(1013.246);
// factor -3 is to adjust units - Vapor Pressure SVP * humidity
double VP = pow(10, RHS - 3) * humidity;
// (2) DEWPOINT = F(Vapor Pressure)
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558 - T);
}
// delta max = 0.6544 wrt dewPoint()
// 6.9 x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity) {
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
double Td = (b * temp) / (a - temp);
return Td;
}
[/php]
"PHP"
[code=php]
<?php
error_reporting(E_ALL);
/********************************************************************
* Ported from:
* File dew.js
* Copyright 2003 Wolfgang Kuehn
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
********************************************************************/
define( 'NaN', NULL );
define( 'C_OFFSET', 273.15 );
define( 'minT', 173 ); // -100 Deg. C.
define( 'maxT', 678 );
/*
* Saturation Vapor Pressure formula for range -100..0 Deg. C.
* This is taken from
* ITS-90 Formulations for Vapor Pressure, Frostpoint Temperature,
* Dewpoint Temperature, and Enhancement Factors in the Range 100 to +100 C
* by Bob Hardy
* as published in "The Proceedings of the Third International Symposium on Humidity & Moisture",
* Teddington, London, England, April 1998
*/
define( 'k0', -5.8666426e3 );
define( 'k1', 2.232870244e1 );
define( 'k2', 1.39387003e-2 );
define( 'k3', -3.4262402e-5 );
define( 'k4', 2.7040955e-8 );
define( 'k5', 6.7063522e-1 );
function pvsIce($T) {
$lnP = k0/$T + k1 + (k2 + (k3 + (k4*$T))*$T)*$T + k5*log($T);
return exp($lnP);
}
/**
* Saturation Vapor Pressure formula for range 273..678 Deg. K.
* This is taken from the
* Release on the IAPWS Industrial Formulation 1997
* for the Thermodynamic Properties of Water and Steam
* by IAPWS (International Association for the Properties of Water and Steam),
* Erlangen, Germany, September 1997.
*
* This is Equation (30) in Section 8.1 "The Saturation-Pressure Equation (Basic Equation)"
*/
define( 'n1', 0.11670521452767e4 );
define( 'n6', 0.14915108613530e2 );
define( 'n2', -0.72421316703206e6 );
define( 'n7', -0.48232657361591e4 );
define( 'n3', -0.17073846940092e2 );
define( 'n8', 0.40511340542057e6 );
define( 'n4', 0.12020824702470e5 );
define( 'n9', -0.23855557567849 );
define( 'n5', -0.32325550322333e7 );
define( 'n10', 0.65017534844798e3 );
function pvsWater($T) {
$th = $T+n9/($T-n10);
$A = ($th+n1)*$th+n2;
$B = (n3*$th+n4)*$th+n5;
$C = (n6*$th+n7)*$th+n8;
$p = 2*$C/(-$B+sqrt($B*$B-4*$A*$C));
$p *= $p;
$p *= $p;
return $p*1e6;
}
/**
* Compute Saturation Vapor Pressure for minT<T[Deg.K]<maxT.
*/
function PVS($T) {
if ($T<minT $T>maxT) return NaN;
else if ($T<C_OFFSET)
return pvsIce($T);
else
return pvsWater($T);
}
/**
* Compute dewPoint for given relative humidity RH[%] and temperature T[Deg.C].
*/
function dewPoint($RH,$T) {
if ( ! is_numeric( $T ) )
return $T;
$T = $T + C_OFFSET; // C to K
return solve($RH/100*PVS($T), $T) - C_OFFSET;
}
/**
* Newton's Method to solve f(x)=y for x with an initial guess of x0.
*/
function solve($y,$x0) {
$x = $x0;
$maxCount = 10;
$count = 0;
do
{
$xNew;
$dx = $x/1000;
$z=PVS($x);
$xNew = $x + $dx*($y-$z)/(PVS($x+$dx)-$z);
if (abs(($xNew-$x)/$xNew)<0.0001)
return $xNew;
else if ($count>$maxCount) {
$xnew=NaN;
return C_OFFSET;
}
$x = $xNew;
$count ++;
} while ( TRUE );
}
//print dewPoint( $argv[1], $argv[2] )."\n";
?>
[/php]
Allerdings bin ich aktuell etwas verwirrt weil jeweils unterschiedliche Einheiten zur Berechnung verwendet werden, zum Beispiel 273.15 ; 243.12 ; 241.88 ; 237.7 ... Wobei ich nicht weiß ob es für das selbe steht, ist nur geraten da relativ ähnlich (2xx)