homerseklet szenzorok

HWSW Famulus hwsw at famulus.hu
Mon Jan 12 17:51:59 CET 2004


> Arnold meg kiollozta egy adatlapból a C forrást. :)
>
> Arnold

No akkor Vb-ben a forras....form nelkul, de mankonak jo.

KJ

----------------------------------------
'wet a nedves homero mezo
'dry a szaraz homero mezo
'RH a relativ paratartalom mezo

'a dry mindig megadando,
'a wet ill. RH kozul az egyik adott akkor
'a masik erteke szamolodik
'a -50 (-50 C fok) a kozelti ciklus also vegerteke
'vagyis az also homerseklet hatar
'felso hatar a 100 C fok


Private Sub Command2_Click()
    Dim dummy As Double

    wet = computeTempByRH(RH, dry, -50)
    RH = computeByWB(dry, wet)

End Sub

Private Sub Command3_Click()
    RH = computeByWB(dry, wet)
End Sub

Function computeTempByRH(goalRH, startTemp, endTemp)

    Dim temp As Double
    Dim dt As Double
    Dim mrh As Double

    temp = startTemp
    Do
        temp = temp - 1
        mrh = computeRH(startTemp, temp)
        If (mrh <= goalRH) Then Exit Do
    Loop While temp >= endTemp

    dt = 0
    Do
        dt = dt + 0.01
        mrh = computeRH(startTemp, temp + dt)
        If (mrh >= goalRH) Then Exit Do
    Loop While dt < 1


   computeTempByRH = temp + dt


End Function

Function computeRH(db, wb)

    Dim vp As Double
    Dim xs As Double
    Dim hw As Double
    Dim ah As Double
    Dim vpd As Double
    Dim e As Double
    Dim myrh As Double

    vp = computeES(wb)
    xs = 0.622 * vp / (760 - vp)

    If (db <= 0) Then
         hw = -334 + 2.09 * wb
    Else
        hw = 4.19 * wb
    End If

    ah = (xs * (2500 + 1.85 * wb - hw) - 1.005 * (db - wb)) _
         / (2500 + 1.85 * db - hw)

    vpd = computeES(db)
    e = 760 * ah / (ah + 0.622)
    myrh = (e / vpd) * 100

    computeRH = myrh

End Function

Function computeES(temp)

    Dim a1 As Double
    Dim a2 As Double
    Dim a3 As Double
    Dim a4 As Double
    Dim a5 As Double
    Dim a6 As Double
    Dim b1 As Double
    Dim b2 As Double
    Dim b3 As Double
    Dim atc As Double
    Dim atemp As Double
    Dim base As Double
    Dim ps As Double

    a1 = 10.79574
    a2 = -5.028
    a3 = 0.000150475
    a4 = -8.2969
    a5 = 0.00042873
    a6 = 4.76955
    b1 = -9.09685
    b2 = -3.56654
    b3 = 0.87682
    atc = 273.15
    base = Log(10)
    Dim es As Double
    Dim p1 As Double
    Dim p2 As Double


    atemp = temp + atc
    p1 = 10 ^ a4 * (atemp / atc - 1)
    p2 = 10 ^ (a6 * (1 - atc / atemp))

    If (temp > 0) Then
     ps = a1 * (1 - atc / atemp) + a2 * Log(atemp / atc) _
         / base + a3 * (1 - p1) _
         + a5 * (p2 - 1) _
         + Log(4.581) / base
    Else
     ps = b1 * (atc / atemp - 1) + b2 * Log(atc / atemp) _
         / base + b3 * (1 - atc / atemp) + Log(4.581) / base
    End If

    es = (10 ^ ps)
    computeES = es

End Function



Function computeByWB(db, wb)

    Dim vp As Double
    Dim xs As Double
    Dim hw As Double
    Dim ah As Double
    Dim e As Double
    Dim h As Double
    Dim v As Double
    Dim ph As Double
    Dim c As Double
    Dim vpd As Double
    Dim ahd As Double
    Dim dp As Double
    Dim crh As Double


    vp = computeES(wb)
    xs = 0.622 * vp / (760 - vp)

    If (db <= 0) Then
        hw = -334 + 2.09 * wb
    Else
        hw = 4.19 * wb
    End If

    'absolute humidity
    ah = (xs * (2500 + 1.85 * wb - hw) - 1.005 * (db - wb)) _
      / (2500 + 1.85 * db - hw)

    'vapor pressure
    e = 760 * ah / (ah + 0.622)

    'enthalpy
    h = 1.005 * db + (2500 + 1.85 * db) * ah

    'specific volume
    v = 0.455 * (ah + 0.622) * (273.15 + db) / 100


    vpd = computeES(db)
    ahd = 0.622 * vpd / (760 - vpd)

    'percentage humidity
    ph = (ah / ahd) * 100

    '
    crh = (e / vpd) * 100

    If (db = wb) Then
         dp = db
    Else
          c = Log(101325 * ah / (ah + 0.622))
            If (db > 0) Then
                 dp = -42.92 - 0.0514 * c + 1.052 * c * c
            Else
                dp = -60.02 + 6.803 * c + 0.3966 * c * c
            End If
    End If

    'dp= dew-point temperature

    lah = Format(ah, "##0.0000") + " kg/kgD.A."
    lvp = Format(e, "##0.00") + " mmHg"
    lh = Format(h, "##0.0000") + " kJ/kgD.A."
    lv = Format(v, "##0.0000") + " m3/kgD.A."
    lph = Format(ph, "##0.00") + " %"
    ldp = Format(dp, "##0.00") + " C"
    computeByWB = Format(crh, "##0.00")

End Function

'http://www.fb.u-tokai.ac.jp/WWW/hoshi/env/humid.html#4
'a tobbi ertek is szamolva van a: ah,e,h,v,vpd,ahd,ph
' return ertekkent azok is visszaadhatok...
' computeByWB = Format(crh, "##0.00") mintara







More information about the Elektro mailing list