daily pastebin goal
39%
SHARE
TWEET

Gravity Balloon pressure, radius, and mass relations

AlanSE Nov 3rd, 2013 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Gval()
  2.   Gval = 6.67384E-11
  3. End Function
  4. Function Pi()
  5.   Pi = 3.14159265358979
  6. End Function
  7. ' Functions based on (M,R,t) triple
  8. Function M_Rt(R As Double, t As Double, rho As Double) As Double
  9.   M_Rt = (4# / 3#) * Pi() * rho * ((R + t) ^ 3 - R ^ 3)
  10. End Function
  11. Function R_Mt(M As Double, t As Double, rho As Double) As Double
  12.   R_Mt = (-t + (t ^ 2 - 4 * ((t ^ 2) / 3 - M / (4 * Pi() * rho * t))) ^ (1 / 2)) / (2)
  13. End Function
  14. Function t_RM(R As Double, M As Double, rho As Double) As Double
  15.   t_RM = (M / ((4 / 3) * Pi() * rho) + R ^ 3) ^ (1 / 3) - R
  16. End Function
  17. Function dtdR_RM(R As Double, M As Double, rho As Double) As Double
  18.   dtdR_RM = R ^ 2 / (3 * M / (4 * Pi() * rho) + R ^ 3) ^ (2 / 3) - 1
  19. End Function
  20. ' Composite function
  21. Function dPdR_RM(R As Double, M As Double, rho As Double) As Double
  22.   dPdR_RM = dPdR_Rt(R, t_RM(R, M, rho), rho) + dPdt_Rt(R, t_RM(R, M, rho), rho) * dtdR_RM(R, M, rho)
  23. End Function
  24. ' Functions based on (P,R,t) triple
  25. Function P_Rt(R As Double, t As Double, rho As Double) As Double
  26.   P_Rt = (2# / 3) * Pi() * Gval() * (t * rho) ^ 2 * (3 * R + t) / (R + t)
  27. End Function
  28. Function dPdt_Rt(R As Double, t As Double, rho As Double) As Double
  29.   dPdt_Rt = (4# / 3) * rho ^ 2 * Pi() * Gval() * t * (3 * R ^ 2 + 3 * R * t + t ^ 2) / (R + t) ^ 2
  30. End Function
  31. Function dPdR_Rt(R As Double, t As Double, rho As Double) As Double
  32.   dPdR_Rt = 4 * t ^ 3 * Gval() * Pi() * rho ^ 2 / (3 * (R + t) ^ 2)
  33. End Function
  34. Function R_Pt(P As Double, t As Double, rho As Double) As Double
  35.   R_Pt = (1# / 3) * t * (3 * P - 2 * rho ^ 2 * Pi() * Gval() * t ^ 2) / (-P + 2 * rho ^ 2 * Pi() * Gval() * t ^ 2)
  36. End Function
  37. Function t_RP(R As Double, P As Double, rho As Double) As Double
  38.   Dim n As Integer, delta As Double
  39.   t_RP = 1.366 * (P / (2 * Gval() * Pi())) ^ (1# / 2) / rho
  40.   n = 1
  41.   Do
  42.     delta = -(P_Rt(R, t_RP, rho) - P) / dPdt_Rt(R, t_RP, rho)
  43.     t_RP = t_RP + delta
  44.     n = n + 1
  45.     If (Math.Abs(delta / t_RP) < 0.000001) Then
  46.       Exit Do
  47.     ElseIf (n > 20) Then
  48.       t_RP = -2
  49.       Exit Do
  50.     End If
  51.   Loop
  52. End Function
  53. ' Functions based on the (P,R,M) triple
  54. Function M_RP(R As Double, P As Double, rho As Double) As Double
  55.   M_RP = M_Rt(R, t_RP(R, P, rho), rho)
  56. End Function
  57. Function P_RM(R As Double, M As Double, rho As Double) As Double
  58.   P_RM = P_Rt(R, t_RM(R, M, rho), rho)
  59. End Function
  60. Function R_MP(M As Double, P As Double, rho As Double) As Double
  61.   Dim n As Integer, delta As Double
  62.   R_MP = R_Mt(M, (P / (2 * Pi() * Gval())) ^ (1 / 2) / rho, rho) - 0.5 * (P / (2 * Pi() * Gval())) ^ (1 / 2) / rho
  63.   n = 1
  64.   Do
  65.     delta = -(P_RM(R_MP, M, rho) - P) / dPdR_RM(R_MP, M, rho)
  66.     R_MP = R_MP + delta
  67.     n = n + 1
  68.     If (Math.Abs(delta * rho / (P / (2 * Gval() * Pi()))) ^ (1 / 2) < 0.000001) Then ' divide by est. value of t
  69.      Exit Do
  70.     ElseIf (n > 20) Then
  71.       R_MP = -2
  72.       Exit Do
  73.     End If
  74.   Loop
  75. End Function
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top