Solve 2 unknowns in 1 equation Saturation Pressure Curve

Just starting out? Need help? Post your questions and find answers here.
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by VB6_to_PBx »

Solve 2 unknowns in 1 equation Saturation Pressure Curve Formula

i want to calculate : "the DryR values" by reverse-engineering this equation "

Code: Select all

Global.d PSat, DegF, DryR

DegF = 59

DryR = DegF + 459.67
PSat = 29.9213 / (Exp((671.67 - DryR) * 35.913 * (Pow(DryR,-1.152437))))
Debug "PSat = " + StrD(PSat,4)
; Answer : PSat = 0.5033 for 59.0 DegF
; DryR = Degrees Rankine

If i already know the Saturation Pressure ,
how can i calculate the Dry Bulb's Rankine degree ( DryR ) ??

any help appreciated !
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by infratec »

Here you can find the solution in Quickbasic :mrgreen:

https://www.eng-tips.com/viewthread.cfm?qid=17569


Btw. WolframAlpha was not able to do it:

y = 29.9213 / e^((671.67 - x) * 35.913 * x^-1.152437)

https://www.wolframalpha.com/widgets/vi ... 98e97c00c5
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by VB6_to_PBx »

infratec wrote:Here you can find the solution in Quickbasic :mrgreen:

https://www.eng-tips.com/viewthread.cfm?qid=17569


Btw. WolframAlpha was not able to do it:

y = 29.9213 / e^((671.67 - x) * 35.913 * x^-1.152437)

https://www.wolframalpha.com/widgets/vi ... 98e97c00c5
infratec , yes i already did it with a Loop in year 1995 :lol:
.... just looking to do the same thing but "without" using a Loop 8)

Code: Select all

v4.50 QuickBasic Code :
dry1 = psat
FOR cnt = 1 TO 9
dry1 = ((x + (c * (dry1 ^ (-.152437)))) / (a * c)) ^ -.867726392#
NEXT
dryb = (dry1 - 460)
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by infratec »

converted:

Code: Select all

EnableExplicit

Define psat$
Define.i cnt
Define.f psat, x, b, a, c, d, dry1, dryb, t1

OpenConsole()
EnableGraphicalConsole(#True)

ConsoleLocate(5, 3)
PrintN("Input choices: dewpoint,vapor, or saturation pressure in inches Hg.")
ConsoleLocate(5, 5)
Print("Pressure inches Hg.= ")

psat$ = Input() : If Len(psat$) > 0 : psat = Val(psat$) : EndIf
If psat = 0 : psat = 0.5216 : EndIf ;'<--default value if no input, (60 deg.F)
 
x = Log(29.9213 / psat);   '<--29.9213 inches Hg. at sea-level at 59 F
b = psat
a = 671.67         ;<- 672 Rankine, (672 = 460 + 212) , 212 F = boiling pt. H2O
c = 35.913     ;<- Constant , 35.913 works With 671.67 And 459.67 (original)
d = -1.152437   ;<- Constant , best constant value For d,(-1.152437 orig.)
 

For cnt = 1 To 25   ;<---- 25 is best value For number of loops
  t1 = x - (a - b) * c * Pow(b, d)
  b = b + t1 / (a * c * d * Pow(b, (d - 1)) - c * (d + 1) * Pow(b, d))
Next cnt
 
dry1 = psat
For cnt = 1 To 9
  dry1 = Pow((x + (c * Pow(dry1, -0.152437))) / (a * c), -0.867726392)
Next
dryb = (dry1 - 459.67)
 
 
 
ConsoleLocate(5, 10)

PrintN("Temperature = " + StrF(dryb, 4))

Delay(10000)
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by VB6_to_PBx »

infratec wrote:
Btw. WolframAlpha was not able to do it:

y = 29.9213 / e^((671.67 - x) * 35.913 * x^-1.152437)

https://www.wolframalpha.com/widgets/vi ... 98e97c00c5
so if WolframAlpha site could not reverse it ( without using a Loop ) , then no one can ???

anyone else want to give it a try ??
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by VB6_to_PBx »

i used the English link , and no luck :(
they could not solve it .
the Loop works .. so it will have to do :D

thanks Olli for that Link ! :D
i can use it in future problems .

infratec wrote: Here you can find the solution in Quickbasic
converted to PB Console
thanks infratec , for Console conversion ! :)
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by Olli »

Code: Select all

y = 29.9213 / e^((671.67 - x) * 35.913 * x^-1.152437)
<=>

Code: Select all

y = 29.9213 / e^((671.67 - x) * 35.913 / x^1.152437)
<=>

Code: Select all

y = 29.9213 / e^((671.67 * 35.913 / x^1.152437) - (35.913 / x^0.152437) )
<=>

Code: Select all

y = 29.9213 / e^((24121.68471 / x^1.152437) - (35.913 / x^0.152437) )
f(x) = 0 is forbidden. <<<---- Edit : I was not awaken !!
f(x) = 0 is not forbidden, but
f(0) is forbidden really.


K, M, N, Alpha and Beta being constants, we have a template like this :

Code: Select all

y = K/e^g(x)
with

Code: Select all

g(x) = M/x^Alpha - N/x^Beta
Or

Code: Select all

g(x) = M/h(x) - N/i(x)
with

Code: Select all

h(x) = x ^ Alpha
i(x) = x ^ Beta
Even if solving is unable (Edit : solving is not unable), compute the two integrals stays possible, but it seems that the loops are far quicker.

Edit : f(x) is solvable too but x is distributed in 2 places in the equation through 2 different power levels. I have just read again this subject to see it. It is not in a small editing screen between a boar and a 50-satellites train I can take better advance.
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by Olli »

We can try a bad way... If we have above

Code: Select all

y = K/e^g(x)
This is equ to

Code: Select all

y = K/j(x)
with

Code: Select all

j(x) = e^g(x)
So

Code: Select all

j(x) = K / y
With y <> 0, it is now only I can say f(x) <> 0... I can say now it is not solvable...

Then

Code: Select all

e^g(x) = K / y
Also

Code: Select all

g(x) = ln(K / y)
Let's continue

Code: Select all

ln(K/y) = M/h(x) - N/i(x)
...We could say

Code: Select all

ln(K/y) = M*h2(x) - N*i2(x)
with

Code: Select all

h2(x) = x ^ (-alpha)
and

Code: Select all

i2(x) = x ^ (-beta)
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by Olli »

Now the "try" (real domain) is done, could you explain me what is the goal of this formula ?

Is not it the math expression in this article which seems to this :

Code: Select all

ln(K/y) = M/h(x) - N/i(x)
?
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by VB6_to_PBx »

Olli wrote:Now the "try" (real domain) is done, could you explain me what is the goal of this formula ?

Is not it the math expression in this article which seems to this :

Code: Select all

ln(K/y) = M/h(x) - N/i(x)
?
"could you explain me what is the goal of this formula ?"

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
infratec wrote:psat$ = Input() : If Len(psat$) > 0 : psat = Val(psat$) : EndIf
i changed your psat = Val(psat$)
to psat = ValD(psat$) .... because i tested some other input values and answers were not as accurate as i had remembered
now overall accuracy is much better thru out full temp Range

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


new Code Edit :
.... a 1 to 10 Loop ( instead of 9 Loops ) this should give you 6 decimal place accuracy of reversing Saturation Pressure back into temperature degrees
and using DryR = 459.67 as starting point before Loop

Code: Select all

  ;~~~~~~ Loop to reverse calulated Saturation Pressure in.Hg. back into Degrees Fahrenheit
  DryR = 459.67 ;<<--- starting value for Loop
 	For Cnt = 1 To 10
 	    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,6))

Last edited by VB6_to_PBx on Thu Aug 13, 2020 4:54 pm, edited 1 time in total.
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by Olli »

Here you can see a french car which was built in 1924.

150 HP
8500 Max RPM
1.5 Liter through 8 cylinders (why 3.0L in the 80's ?)
Entirely Aluminium
Hydraulic sequential gearbox : I recall, built in 1924 ! 4 speed levels.

Allowed 4 world races gains (one of 3 first places).
The first : 1927 (1st place)
The last : 1959 (2nd place)

Is ever perfect today, no accident !

My little and light question (no need to answer, but laugh together) :

Why use an accurate math op such accurate that you can analyse the whole atmospheric volum in the Earth, in a such small system that the one in a car engine ? !

Is this really useful ? :D
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 625
Joined: Mon May 09, 2011 9:36 am

Re: Solve 2 unknowns in 1 equation Saturation Pressure Curve

Post by VB6_to_PBx »

Olli wrote:Here you can see a french car which was built in 1924.

150 HP
8500 Max RPM
1.5 Liter through 8 cylinders (why 3.0L in the 80's ?)
Entirely Aluminium
Hydraulic sequential gearbox : I recall, built in 1924 ! 4 speed levels.

Allowed 4 world races gains (one of 3 first places).
The first : 1927 (1st place)
The last : 1959 (2nd place)

Is ever perfect today, no accident !

My little and light question (no need to answer, but laugh together) :

Why use an accurate math op such accurate that you can analyse the whole atmospheric volum in the Earth, in a such small system that the one in a car engine ? !

Is this really useful ? :D
new Code Edit :
.... a 1 to 10 Loop ( instead of 9 Loops ) this should give you 6 decimal place accuracy of reversing Saturation Pressure back into temperature degrees
and using DryR = 459.67 as starting point before Loop

Code: Select all

  ;~~~~~~ Loop to reverse calulated Saturation Pressure in.Hg. back into Degrees Fahrenheit
  DryR = 459.67 ;<<--- starting value for Loop
 	For Cnt = 1 To 10
 	    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,6))

Olli ,
i can view YouTube videos on my TV using
Roku ( https://www.roku.com/ )

while watching YouTube ,sometimes YouTube recommends
these old Car or Manufacturing Videos to watch .
The 2 most recommended i see popup are :

King Rose Archives on YouTube :
https://www.youtube.com/user/mrpitv/videos

US Auto Industry on YouTube :
https://www.youtube.com/c/USAutoIndustry/videos

you need to scroll pretty far down to find the really old
Car and Company videos

Last nite , i just viewed an old 1934 Chevrolet video
Louis_Chevrolet was also a Frenchman , co-founder of the Chevrolet Motor Car Company in 1911
https://en.wikipedia.org/wiki/Louis_Chevrolet

90+ percent of the Engines we build + Dyno test are Chevrolet engines :)
most of the Engines we build are 700+ HP to 2200+ HP
very seldom do anything under 600 HP

-------------------------------------------------
Why use an accurate math op such accurate that you can analyse
the whole atmospheric volume in the Earth, in a such small system that the one in a car engine ? !
knowing very accurate Weather conditions at time of Dyno testing or Racing events ,
especially help in Classes where there are ET Time Dial-ins , and many other Classes where as little as 0.001 seconds
can mean losing or winning , or qualifying position !
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
Post Reply