Fixed python calculations, added gitignore

This commit is contained in:
2023-03-22 15:07:19 +04:00
parent bd8cd9e635
commit 95fa3c4f3f
11 changed files with 77 additions and 46 deletions

View File

@@ -24,36 +24,33 @@ plt.ylabel('I(r)', fontsize=18)
# Integration
def q_res_g(z, func):
ans = integrate.quad(lambda x: x * func(x) * q_g_z(x, z) * (~np.iscomplex(q_g_z(x, z))).astype(float),
ans = integrate.quad(lambda dr: dr * func(dr) * q_g_z(dr, z) * (~np.iscomplex(q_g_z(dr, z))).astype(float),
0, r_max, epsabs=1e-12, epsrel=1e-6)
return ans[0]
return 2 * np.pi * ans[0] / (np.pi * w0 ** 2)
def q_res_s(z, func):
ans = integrate.quad(lambda x: x * func(x) * q_s_z(x, z) * (~np.iscomplex(q_s_z(x, z))).astype(float),
ans = integrate.quad(lambda dr: dr * func(dr) * q_s_z(dr, z) * (~np.iscomplex(q_s_z(dr, z))).astype(float),
0, r_max, epsabs=1e-12, epsrel=1e-6)
return ans[0]
return 2 * np.pi * ans[0] / (np.pi * w0 ** 2)
# Calculation
n = 200
z = np.linspace(-2 * Rsp, 2 * Rsp, n)
axial_g = gauss_peak() * [q_res_g(x, gauss) for x in z]
axial_s = gauss_peak() * [q_res_s(x, gauss) for x in z]
axial_g = [q_res_g(dz, gauss) for dz in z]
axial_s = [q_res_s(dz, gauss) for dz in z]
f_0 = n1 * P / constants.c # net force
axial_g = np.array(axial_g[::-1])
axial_s = np.array(axial_s[::-1])
axial_g = F0 * np.array(axial_g[::-1])
axial_s = F0 * np.array(axial_s[::-1])
axial = axial_g + axial_s
z = -z[::-1]
# Graphics
fig2 = plt.figure(2, figsize=(10, 6))
plt.plot(z, f_0*axial_g, '-.', lw=1, label='$F_{g}$')
plt.plot(z, f_0*axial_s, '--', lw=1, label='$F_{s}$')
plt.plot(z, f_0*axial, lw=1, label='$F_{t}$')
plt.plot(z, axial_g, '-.', lw=1, label='$F_{g}$')
plt.plot(z, axial_s, '--', lw=1, label='$F_{s}$')
plt.plot(z, axial, lw=1, label='$F_{t}$')
plt.xlabel('r, m', fontsize=18)
plt.ylabel('F, N', fontsize=18)
plt.legend(fontsize=18)