Advertisement
Guest User

Lead Ball in Mariana Trench

a guest
May 11th, 2011
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.09 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. """
  4. lead_ball.py
  5.  
  6. Created by hariya on 2011-05-11.
  7. Copyright (c) 2011 hariya. All rights reserved.
  8. """
  9.  
  10. import numpy as np
  11. from scipy.special import cbrt
  12.  
  13. def temperature(s,t,p):
  14.   # Sea water potential temperature computation
  15.   # Ref: HL Bryden - Deep Sea Research and Oceanographic Abstracts, 1973
  16.  
  17.   p2 = p*p
  18.   p3 = p2*p
  19.  
  20.   t2 = t*t
  21.   t3 = t2*t
  22.  
  23.   ss = s - 35.0
  24.  
  25.   temp = t - p*(3.65e-4 + 8.32e-5*t - 5.41e-7*t2 + 4.03e-9*t3) \
  26.            - p*ss*(1.74e-5 - 2.98e-7*t) - p2*(8.93e-7 - 3.16e-8*t + 2.20e-10*t2) \
  27.            + 4.11e-9*p2*ss - p3*(-1.61e-10 + 5.05e-12*t)
  28.   return temp
  29.  
  30. def density(s,t,p):
  31.   # Sea water density computation
  32.   # Ref: GL Mellor - Journal of Atmospheric and Oceanic Technology, 1991
  33.   t2 = t*t
  34.   t3 = t*t2
  35.   t4 = t*t3
  36.   t5 = t*t4
  37.  
  38.   c = 1449.1 + 0.0821*p + 4.55*t -0.045*t2 + 1.34*(s - 35.0)
  39.   pcc = p/(c*c)
  40.  
  41.   rho = -0.157406 + 6.793952e-2*t - 9.095290e-3*t2 + 1.001685e-4*t3 - 1.120083e-6*t4 + 6.536332e-9*t5 \
  42.       + (0.824493 - 4.0899e-3*t + 7.6438e-5*t2 - 8.2467e-7*t3 + 5.3875e-9*t4)*s \
  43.       + (-5.72466e-3 + 1.0227e-4*t - 1.6546e-6*t2)*abs(s)**1.5 + 4.8314e-4*s*s
  44.      
  45.   rho = 1000.0 + rho + 1.0e5*pcc*(1.0 - 2.0*pcc)
  46.  
  47.   return rho
  48.  
  49. def main():
  50.   # Lead ball radius computation
  51.   pb_m = 1.0
  52.   pb_v = pb_m/11340.0
  53.   pb_r = cbrt(3*pb_v/(4*np.pi))
  54.  
  55.   print "Radius of lead ball is ",pb_r," m."
  56.  
  57.   # Guesses for salinity, and surface temperature
  58.   sal = 35.0 # Salinity in parts per thousand
  59.   sst = 25.0 # Sea surface temperature in C
  60.  
  61.   # Initialize some values
  62.   dt = 0.01
  63.   time = 0.0
  64.   depth = 0.0
  65.   vel = 0.0
  66.   rho = 1025.0
  67.  
  68.   # Loop till we hit the bottom
  69.   while depth > -10911.0:
  70.     p = -9.8*rho*depth*1.0e-5
  71.     tt = temperature(sal,sst,p)
  72.     rho = density(sal,tt,p)
  73.  
  74.     buoy = 9.8*(11340 - rho)*pb_v
  75.     drag = 6*np.pi*1.08e-3*vel*pb_r
  76.  
  77.     acc = (buoy - drag)
  78.  
  79.     time = time + dt
  80.     vel = vel + acc*dt
  81.     depth = depth - vel*dt
  82.    
  83.     print time,depth,vel,p,tt,rho,buoy,drag,acc
  84.  
  85.  
  86. if __name__ == '__main__':
  87.       main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement