ai = 1.0
# potentiall edit the 0.7 as I believe this is speciic to the De Sitter Universe
phi0 = (mp * (1/(H_0_true**(2) * 0.7))**(1/alpha))
for i in del_t_range:
#friedmann equation which is updated every iteration with new values of scale factor
H = (H_0_true * m.sqrt(((w_m/(ai**3)) + (w_r/(ai**4)) + (w_v) + (w_c/(ai**2)))))
#H values needed for analysis purposes
H_vals.append(H)
time.append(i)
#finite difference differentiation method for universe expansion
del_a = ai * H * del_t
a_val = ai + del_a
a.append(a_val)
ai = a_val
############################# ISSUE ###########################
#field potential calculation
V = (phi0 / mp)**(-alpha)
#appended to use for graphing
V_vals.append(V)
#print(V)
#differentiation of the potential wrt the field
V_dash = alpha * (phi0 / mp)**(-alpha - 1.0)
#print(V_dash)
#finite differnce of time derivative of phi
y_val = yi - (3 * H * yi - V_dash) * del_t
#print(y_val)
# needed for graphing
y_list.append(y_val)
# used for updating values of phi
phi_val = phi0 + (yi * del_t)
phi_list.append(phi_val)
# Energy Density calculations
rho_phi = 0.5 * (y_val / mp)**(2) + (V / mp**(4)) * (1 / tp)**(2)
#calculation required to sort out units
rho_phi_true = rho_phi / mp**(2)
#Used for graphing
rho_phi_vals.append(rho_phi_true)
# updates values for next iteration of loop
phi0 = phi_val
yi = y_val
下面的代码循环了,所以我可以获得变量phi0,rho_phi,yi,V和V_dash的更新值。然后将每个更新的值附加到python列表中并进行绘制。但是,即使我在循环末尾写了phi0的新值等于phi_val,我似乎仍然无法更新phi0的值。每次迭代中phi0的值保持不变。例如,
[1.0011701031373587e+30, 1.0011701031373587e+30, 1.0011701031373587e+30, 1.0011701031373587e+30, ...]
如果我一直含糊不清或感到困惑,我深表歉意,请谅解是否有任何问题。非常感谢你! :-)