Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Fri Feb 12 14:59:36 2016
  4.  
  5. @author: Complex_Batac
  6. """
  7.  
  8. import matplotlib.pyplot as plt
  9.  
  10. def ex2_5(Z):
  11. # Definition of variables
  12. a_1 = 15.67
  13. a_2 = 17.23
  14. a_3 = 0.75
  15. a_4 = 93.2
  16.  
  17. # Creates empty containers for all of the binding energies per
  18. # nucleon (B divided by A) and all of the corresponding mass numbers
  19. bepn = []
  20. mass_num = []
  21. # Solves for binding energy per nucleon for each A from A = Z to A = 3Z
  22. for i in xrange(Z, 3 * Z + 1):
  23. A_i = i
  24. if A_i % 2 != 0:
  25. a_5 = 0.0
  26. elif A_i % 2 == 0 and Z % 2 == 0:
  27. a_5 = 12.0
  28. elif A_i % 2 == 0 and Z % 2 != 0:
  29. a_5 = -12.0
  30. B_i = (a_1 * A_i) - (a_2 * A_i**(2.0/3.0)) - \
  31. (a_3 * Z**2.0 / A_i**(1.0/3.0)) - \
  32. (a_4 * (A_i - 2.0 * Z)**2.0 / A_i) + \
  33. (a_5 / (A_i**(1.0/2.0)))
  34. bepn.append(B_i/A_i)
  35. mass_num.append(A_i)
  36. # Prints out the A and B of the most stable nucleus
  37. print "MOST STABLE NUCLEUS OF ELEMENT WITH Z = " + str(Z)
  38. print "Mass number: " + str(mass_num[bepn.index(max(bepn))])
  39. print "Binding energy per nucleon: " + str(max(bepn))
  40.  
  41. # Creates empty containers for all atomic numbers, all
  42. # of the corresponding maximum binding energies per nucleon
  43. # and all of the corresponding mass numbers
  44. atomic_num = []
  45. max_bepn = []
  46. mass_num_ = []
  47. # Iterates from Z = 1 to Z = 100
  48. for m in xrange(1, 101):
  49. atomic_num.append(m)
  50. bepn_m = []
  51. mass_num_m = []
  52. # Iterates from A = Z to A = 3Z
  53. for n in xrange(m, 3 * m + 1):
  54. A_m_n = n
  55. if A_m_n % 2 != 0:
  56. a_5 = 0.0
  57. elif A_m_n % 2 == 0 and m % 2 == 0:
  58. a_5= 12.0
  59. elif A_m_n % 2 == 0 and m % 2 != 0:
  60. a_5 = -12.0
  61. B_m_n = (a_1 * A_m_n) - (a_2 * A_m_n**(2.0/3.0)) - \
  62. (a_3 * m**2.0 / A_m_n**(1.0/3.0)) - \
  63. (a_4 * (A_m_n - 2.0 * m)**2.0 / A_m_n) + \
  64. (a_5 / (A_m_n**(1.0/2.0)))
  65. bepn_m.append(B_m_n/A_m_n)
  66. mass_num_m.append(A_m_n)
  67. # Exception handling for when bepn_m is an empty sequence
  68. try:
  69. max_bepn.append(max(bepn_m))
  70. except:
  71. max_bepn.append(0)
  72. mass_num_.append(mass_num_m[bepn_m.index(max(bepn_m))])
  73. # Prints the most stable value of A for each Z
  74. for o in xrange(100):
  75. print (max_bepn[o], mass_num_[o])
  76. # Prints the value of Z at which the highest
  77. # binding energy per nucleon occurs
  78. print "\n HIGHEST BINDING ENERGY PER NUCLEON AT Z = " + \
  79. str(atomic_num[max_bepn.index(max(max_bepn))])
  80.  
  81. # Graph the binding energy per nucleon for the most stable
  82. # nucleus of each element as a function of atomic number
  83. plt.plot(atomic_num, max_bepn)
  84. plt.xlabel("Atomic number (Z)")
  85. plt.ylabel("Maximum binding energy per nucleon")
  86. plt.show()
  87. plt.close()
  88.  
  89. ex2_5(40)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement