半经验质量公式

The semi-empirical mass formula

我的作业如下:

直到 c) 我的代码工作,我尝试了不同的 Z 值。这是我的代码:

# This program calculates the mass number for which the binding energy per nucleon is max for a given atomic number. 
import math
from math import *
import numpy as np
from numpy import *
# First we define some variables
a_1 = 15.67
a_2 = 17.23
a_3 = 0.75
a_4 = 93.2
# We ask for input Z
Z = float(input("Enter the atomic number: "))
list_B = []
list_A = []
list_B_A = []
# We set up the loop
for A in arange(Z,3*Z+1): #we make A run from Z to 3Z
    list_A.append(A)
        if (A%2)==0:
            if ((A+Z)%2)==0:
                a_5 = 12.0
            else:
                a_5 = -12.0
        else:
            a_5 = 0
        B = a_1*A - a_2*(A**(2/3)) - a_3*(Z**2)/(A**(1/3)) - a_4*((A-2*Z)**2)/A + a_5/(A**(1/2))
        B_A = B/A #We print the resulting value of B
        list_B.append(B)
        list_B_A.append(B/A) #We make a list with this values


print("The Mass number for the maximum binding energy is: ",list_A[list_B_A.index(max(list_B_A))])

现在,当我尝试执行 d) 它不起作用,并且对于大于 z= 24 的值,它总是给出 A max = 50,这不是第一个代码给我的。 例如,当我 运行 c) Z=28 的代码给我 A max =58。但是当我 运行 d) 的代码时,一旦 Z 达到 24,它总是 returns 50.

import math
from math import *
import numpy as np
from numpy import *
# First we define some variables
a_1 = 15.67
a_2 = 17.23
a_3 = 0.75
a_4 = 93.2
# We ask for input Z
list_B = []
list_A = []
list_B_A = []

for Z in arange(1,101,1):
    for A in arange(Z,3*Z+1): #we make A run from Z to 3Z
        list_A.append(A)
        if (A%2)==0:
            if ((A+Z)%2)==0:
                a_5 = 12.0
            else:
                a_5 = -12.0
        else:
            a_5 = 0
        B = a_1*A - a_2*(A**(2/3)) - a_3*(Z**2)/(A**(1/3)) - a_4*((A-2*Z)**2)/A + a_5/(A**(1/2))
        B_A = B/A #We print the resulting value of B
        list_B.append(B)
        list_B_A.append(B/A) #We make a list with this values
    print("The Mass number for the maximum binding energy is: ",list_A[list_B_A.index(max(list_B_A))], "given the atomic number :", Z)

您需要重新初始化所有列表,然后才能使用新的 Z 值重新计算。否则,您会将此 Z 的数据与之前的所有数据合并。

for Z in arange(1,101,1):
    list_B = []
    list_A = []
    list_B_A = []
    # rest of your code here