fork download
  1. # A Python script:
  2. G= 6.673*10**-11
  3. M=10**27
  4. m=1.0
  5. c=299792458.0
  6.  
  7. def swartrad(m):
  8. return (2*G*m) / (c**2)
  9.  
  10. print "Schwarzschild Radius: ", swartrad(M)
  11.  
  12. def force(m,M,d):
  13. return (G*m*M) /(d**2)
  14.  
  15. pos=200*swartrad(M)
  16. endpos= swartrad(M)
  17.  
  18. step=0.001
  19. energy=0
  20. while pos>endpos:
  21. energy += force(m,M, pos)*step
  22. pos -= step
  23.  
  24.  
  25. print "potential energy of one kilo" , energy
  26. print "total energy of one kilo " , c**2
  27. print "ratio" , energy / c**2
Success #stdin #stdout 0.37s 7692KB
stdin
Standard input is empty
stdout
Schwarzschild Radius:  1.48494276481
potential energy of one kilo 4.47097342531e+16
total energy of one kilo     8.98755178737e+16
ratio 0.497462883228