Station Pressure = 29.920 inches Hg.
.... because i tested some other input values and answers were not as accurate as i had remembered
Code: Select all
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Global W1
Global.i CT1, T1, T2, T3
Global.d G1, G2, G3
Enumeration FormFont
#Font_W1_0
#Font_W1_1
EndEnumeration
LoadFont(#Font_W1_0,"Verdana", 9)
LoadFont(#Font_W1_1,"Tahoma", 10)
Declare Clear()
Declare SatPressure()
Procedure OpenW1(x = 0, y = 0, width = 388, height = 109)
W1 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
SetWindowColor(W1, RGB(128,128,128))
CreateMenu(0, WindowID(W1))
CloseSubMenu()
MenuItem(0," Quit")
MenuItem(1,"Calculate")
MenuItem(2,"Clear")
MenuTitle("Saturation Data PDF")
MenuItem(3,"Download Smithsonian Meteorological .PDF")
CT1 = ContainerGadget(#PB_Any, 3, 4, 383, 82, #PB_Container_Raised)
SetGadgetColor(CT1, #PB_Gadget_BackColor,RGB(210,210,210))
G1 = 1 : StringGadget(G1, 174, 2, 100, 20, "",#PB_Text_Center)
SetGadgetColor(G1, #PB_Gadget_FrontColor,RGB(0,0,0))
SetGadgetColor(G1, #PB_Gadget_BackColor,RGB(255,255,255))
SetGadgetFont(G1, FontID(#Font_W1_0))
T1 = TextGadget(#PB_Any, 3, 3, 170, 18, " Dry Bulb degrees Fahrenheit")
SetGadgetColor(T1, #PB_Gadget_FrontColor,RGB(0,0,0))
SetGadgetColor(T1, #PB_Gadget_BackColor,RGB(255,255,255))
SetGadgetFont(T1, FontID(#Font_W1_1))
T2 = TextGadget(#PB_Any, 3, 23, 170, 18, " Saturation Pressure in.Hg.")
SetGadgetColor(T2, #PB_Gadget_FrontColor,RGB(0,0,0))
SetGadgetColor(T2, #PB_Gadget_BackColor,RGB(255,255,255))
SetGadgetFont(T2, FontID(#Font_W1_1))
G2 = 2 : StringGadget(G2, 174, 22, 100, 20, "",#PB_Text_Center)
SetGadgetColor(G2, #PB_Gadget_FrontColor,RGB(0,0,0))
SetGadgetColor(G2, #PB_Gadget_BackColor,RGB(255,255,255))
SetGadgetFont(G2, FontID(#Font_W1_0))
T3 = TextGadget(#PB_Any, 3, 50, 270, 18, " Reverse Saturation Pressure back to Deg F")
SetGadgetColor(T3, #PB_Gadget_FrontColor,RGB(0,0,0))
SetGadgetColor(T3, #PB_Gadget_BackColor,RGB(255,255,255))
SetGadgetFont(T3, FontID(#Font_W1_1))
G3 = 3 : StringGadget(G3, 274, 49, 100, 20, "",#PB_Text_Center)
SetGadgetColor(G3, #PB_Gadget_FrontColor,RGB(0,0,0))
SetGadgetColor(G3, #PB_Gadget_BackColor,RGB(255,255,255))
SetGadgetFont(G3, FontID(#Font_W1_0))
CloseGadgetList() ;<<--- close CT1
SetActiveGadget(G1)
EndProcedure
Procedure W1_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
Case 0 : End
Case 1 : SatPressure()
Case 2 : Clear()
Case 3 : RunProgram("http://www.mediafire.com/file/dfzqdi3jwmw/Smithsonian_Saturation_Pressure_Charts.pdf") ;<<-- minus -60.0 to 212.0 DegF .PDF Data
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case G1 To G3
Select EventType()
Case #PB_EventType_Focus : SendMessage_(GadgetID(EventGadget()),#EM_SETSEL,0,-1)
Case #PB_EventType_Change : SetGadgetText(G2,"") : SetGadgetText(G3,"")
EndSelect
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
OpenW1()
Repeat
event = WaitWindowEvent()
Until W1_Events(event) = #False
End
; Declare Clear()
Procedure Clear()
Protected.i Cnt
For Cnt = G1 To G3
SetGadgetText(Cnt,"")
SetActiveGadget(Cnt)
Next
SetActiveGadget(G1)
EndProcedure
; Declare SatPressure()
Procedure SatPressure()
Protected.i Cnt
Protected.d PSat , DegF , DryR
If Len(GetGadgetText(G1))<1 : SetGadgetText(G1,StrD(0,1)) : SetActiveGadget(G1) : EndIf
SendMessage_(GadgetID(EventGadget()),#EM_SETSEL,0,-1)
;~~~~~~ calculate Saturation Pressure in.Hg.
DryR = ValD(GetGadgetText(G1)) + 459.67
PSat = 29.9213 / (Exp((671.67 - DryR) * 35.913 * (Pow(DryR,-1.152437))))
SetGadgetText(G2,StrD(PSat,4));<<-- show 4 decimal places
If ValD(GetGadgetText(G1)) < 17 : SetGadgetText(G2,StrD(PSat,5)) : EndIf ;<<-- show 5 decimal places
;~~~~~~ Loop to reverse calulated Saturation Pressure in.Hg. back into Degrees Fahrenheit
For Cnt = 1 To 9
DryR = Pow((Log(29.9213 / PSat) + (35.913 * Pow(DryR, -0.152437))) / (24121.68471), -0.867726392)
Next
DegF = (DryR - 459.67)
SetGadgetText(G3,StrD(DegF,1))
EndProcedure
; the SatPressure() Procedure above , is the only Saturation Pressure formula or equations that uses
; multiple real Meteorlogical or Psychrometric Constants !
; example->
; 29.9213 = Sea Level Atmospheric Pressure Constant ( 29.92125558 or usually 29.92126 , 29.9213 , 29.921 , 29.92 in rounded-off forms )
; - 459.67 = which is Absolute Zero temperature ( the theoretical absence of all thermal energy )
; + 459.67 = 0.0 Degrees on the Fahrenheit Scale
; + 671.67 = 212.0 Degrees on the Fahrenheit Scale ( the Boiling Point of Water @ Sea Level MSL ) ( 671.67 = 212 + 459.67 )
;----------------------------------------------------------------------------------------------------------------------------------------------------------------
; ; the above SatPressure()'s equations are a slightly overall better "Fit" to Smithsonian Meteorological Saturation Pressure Charts from -60 degF -to- 212 degF
; ; than the following Equations ; ( these other Equations below , some use Polynomials or similar type routines to solve for Saturation Pressure )
; ;
; ; Magnus - Tetens
; ; Buck
; ; Buck 2
; ; GoffGratch
; ; Goff1957
; ; Hyland - Wexler
; ; WMO
; ; Wexler
; ; Vaisala
; ; Sonntag
; ; Bolton
; ; Marti Mauersberger
; ; Carrier ( Air Conditioner Manufacturer )
; ; ASHRAE ( Note: ASHRAE uses their own Saturation Pressure Chart data , that does not correlate to Smithsonian Meteorological Saturation Pressure Charts )
;
; after you calculate the Dry Bulb's temperature's Saturation pressure
; you multiply the Relative Humidity % percent times the Saturation pressure
; to solve for Dew Point Vapor Pressure
;
; then you subtract the Vapor Pressure from the location's Station Pressure
; in the Engine or Chassis Dyno Weather HP Correction Factor
;
; the HP Correction Factor is used to "standardize" Engine Torque and HP
; to a MotorSport's standard that is : ( example : SAE J607 June1974 )
; Station Pressure = 29.920 inches Hg.
; Dry Bulb DegF = 60.0
; Relative Humidity % = 0.0