As the title suggests, it takes a lot of time to find a combination of \vec{z}'=f
two-story differential equation (which is in the form of a differential equation of a first-order vector) that changes the initial value X0 and the parameter epsilon.Actually, I think it would be the fastest if I could do meshgrid, but it didn't work.
Please let me know if there is a way to avoid looping as much as possible and do the same as the code below.
def sol(q_x, kappa, h, x0, epsilon):
y = Symbol('y')
defsol(x,y,epsilon):
return f(x,y,q_x,kappa,h,epsilon)
y = np.linspace (0.0, 1000, 10001)
return order (fsol, x0, y, args=(epsilon,))
alpha=np.linspace(0,2*np.pi,101)
X = np.cos (alpha)
Y = np.sin(alpha)
ZEROS = [[0.0]*2 for i in range (len(alpha))]
X0 = np.c_ [X, Y, ZEROS ]
def disposition0(q_x, kappa, h, cutoff):
defz(x0, epsilon):
return sol(q_x, kappa, h, x0, epsilon)
epsilon=np.linspace(0,q_x**2+kappa+h,101)
Phi1 = np.empty ([alpha.shape[0], epsilon.shape[0]])
Phi2 = np.empty ([alpha.shape[0], epsilon.shape[0]])
for i in range(0,len(alpha)):
for jin range(0,len(epsilon)):
Phi1[i][j]=z(X0[i], epsilon[j])[1000][0]
Phi2[i][j]=z(X0[i], epsilon[j])[1000][1]
energy = 0
forkin range(0,len(epsilon)):
ifabs(Phi1[:,k])<cutoff&abs(Phi2[:,k])<cutoff:
energy=epsilon(k)
break
return energy
If you look at the code in the question, sol
is a routine that solves the normal differential equation, but we call that function 2 million times from dispersion0
. Even if it takes 1ms to calculate sol
, it takes 33 minutes.
The solution is calculated by dispersion0
, but the only way to do this is to reduce it.There is a way to use repeated numerical analysis solutions to remove the ones that are unlikely to be solved by cutting branches in search trees.
Also, fsol
is called so often that it should be accelerated using Cython
instead of using slow processing like SimPy
.
546 Understanding How to Configure Google API Key
549 PHP ssh2_scp_send fails to send files as intended
711 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
542 Unable to install versioned in Google Colab
537 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.