Código de visual Basic
Enviado por nestor.fcq • 20 de Octubre de 2017 • Práctica o problema • 5.893 Palabras (24 Páginas) • 435 Visitas
Option Explicit
Option Base 1
Public Const B2kP As Double = 100
Function tvsat(P) As Double
Dim A0 As Double, A1 As Double, a2 As Double, a3 As Double, a4 As Double, a5 As Double, a6 As Double, a7 As Double, lnp As Double
A0 = -20.69171
A1 = 13.610819
a2 = 7.50043
a3 = -0.37146631
a4 = 0.26070017
a5 = -0.0240092
a6 = 0.0013378831
a7 = -8.9845187E-33
lnp = Log(P * B2kP * a2)
tvsat = A0 + A1 * lnp + a3 * lnp ^ 2 + a4 * lnp ^ 3 + a5 * lnp ^ 4 + a6 * lnp ^ 5 + a7 * lnp ^ 30
tvsat = tvsat + 273.15
End Function
Function Psat(tvsat) As Double
Dim B0 As Double, B1 As Double, b2 As Double, b3 As Double, b4 As Double
B0 = 98.0904
B1 = 21.675595
b2 = -0.017091984
b3 = -6249.2
b4 = 0.000010643944
Psat = B0 * Exp(B1 + b2 * (tvsat) + b3 / (tvsat) + b4 * (tvsat) ^ 2)
Psat = Psat / B2kP
End Function
Function hliq(P) As Double
Dim C0 As Double, C1 As Double, c2 As Double, c3 As Double, c4 As Double, c5 As Double, c6 As Double, c7 As Double, c8 As Double, c9 As Double
C0 = -38196.597
C1 = 8156.7769
c2 = 0.062913098
c3 = 5.9407557E-13
c4 = 1.1973266E-59
c5 = 135722.09
c6 = -170161.83
c7 = 66738.664
c8 = -2246.77
c9 = 402.37285
P = P * B2kP / 98.0904
hliq = C0 + C1 * (P) ^ 0.1 + c2 * (P) ^ 1.5 + c3 * (P) ^ 6 + c4 * (P) ^ 26 + c5 / (P) ^ 0.1 + c6 / (P) ^ 0.15 + c7 / (P) ^ 0.2 + c8 / (P) ^ 0.4 + c9 / (P) ^ 0.5
End Function
Function hvsat(P) As Double
Dim D0 As Double, D1 As Double, d2 As Double, d3 As Double, d4 As Double, d5 As Double, d6 As Double, d7 As Double, d8 As Double, d9 As Double
D0 = 16394.097
D1 = -2326.9083
d2 = -0.12038685
d3 = -1.11011E-13
d4 = -1.2893239E-59
d5 = -46574.48
d6 = 54360.668
d7 = -19508.785
d8 = 368.64023
d9 = -38.23317
P = P * B2kP / 98.0904
hvsat = D0 + D1 * (P) ^ 0.1 + d2 * (P) ^ 1.5 + d3 * (P) ^ 6 + d4 * (P) ^ 26 + d5 / (P) ^ 0.1 + d6 / (P) ^ 0.15 + d7 / (P) ^ 0.2 + d8 / (P) ^ 0.4 + d9 / (P) ^ 0.5
End Function
Public Function DT(Tent) As Double
Dim ValorCelda1 As Double, ValorCelda2 As Double
ValorCelda1 = Worksheets("propiedades").Range("B2").Value 'Temperatura inicial
ValorCelda2 = Worksheets("propiedades").Range("B4").Value 'Tv sat
DT = ValorCelda1 - ValorCelda2 'DEFINIR CELDAS
If DT >= 0 Then
DT = DT
ElseIf DT < 0 Then
DT = 0
End If
End Function
Public Function Fact(P) As Double
Dim e() As Variant
Dim f() As Variant
Dim g() As Variant
Dim h() As Variant
Dim Z() As Variant
Dim j() As Variant
Dim K() As Variant
Dim l() As Variant
Dim m() As Variant
Dim n() As Variant
Dim o() As Variant
Dim y As Double
f(1) = 1.3051623: f(2) = -0.0042356094: f(3) = 4.755113: f(4) = 0.0000033460062: f(5) = -0.0047564201: f(6) = 0.090788927
g(1) = -0.17902741: g(2) = -0.0017548594: g(3) = 1.9129151: g(4) = 0.0000013486553: g(5) = -0.0019127371: g(6) = 0.033372795
h(1) = 0.0070375183: h(2) = 0.000063713237: h(3) = -0.067828775: h(4) = -0.000000048269714: h(5) = 0.000067821775: h(6) = -0.0012414538
Z(1) = -0.00016133576: Z(2) = -0.0000014687338: Z(3) = 0.0015400988: Z(4) = 1.1192714E-09: Z(5) = -0.0000015399384: Z(6) = 0.00002855647
j(1) = 0.000001828274: j(2) = 0.000000016671918: j(3) = -0.000016788785: j(4) = -1.2747094E-11: j(5) = 0.000000016786967: j(6) = -0.00000032387253
K(1) = -9.2397816E-09: K(2) = -8.4526863E-11: K(3) = 0.000000081538461: K(4) = 6.4869756E-14: K(5) = -8.1529273E-11: K(6) = 1.6395529E-09
l(1) = 1.6794938E-11: l(2) = 1.5433165E-13: l(3) = -1.4013435E-10: l(4) = -1.1907966E-16: l(5) = 1.4011765E-13: l(6) = -2.9868728E-12
m(1) = 0.060726062: m(2) = 0.00051064489: m(3) = -0.5476973: m(4) = -0.00000036934366: m(5) = 0.0005476369: m(6) = -0.01035083
n(1) = -0.00056957354: n(2) = -0.0000047956662: n(3) = 0.0051488159: n(4) = 3.4673021E-09: n(5) = -0.0000051482494: n(6) = 0.000097125868
o(1) = 0.88778641: o(2) = 0.0060101547: o(3) = -6.2985134: o(4) = -0.0000042275055: o(5) = 0.0062976297: o(6) = -0.12744559
P = P / 1.01972
For y = 1 To 6
e(y) = f(y) + g(y) * P + h(y) * (P) ^ 2 + Z(y) * (P) ^ 3 + j(y) * (P) ^ 4 + K(y) * (P) ^ 5 + l(y) * (P) ^ 6 + (m(y) / P) + (n(y) / (P) ^ 2) + o(y) * (P) ^ 0.5
Next y
Fact = e(1) + e(2) * DT + e(3) / DT + e(4) * (DT) ^ 2 + e(5) / (DT) ^ 2 + e(6) * (DT) ^ 0.5
End Function
Function HVapSCAgua(HVapSatAgua) As Double
HVapSCAgua = HvsatAgua + Fact * (DT) 'Introducir HvsatAgua
...