Mar-24-2022, 05:08 PM
(This post was last modified: Mar-24-2022, 05:23 PM by alexfrol86.)
The code was running over 2 hours, and during that time, I haven't received any results. But once I tried to accelerate the code by using @njit, already few minutes later the first result occurred. However, now it works over 2 hours in the way presented below, and I received only 10 vectors. How can I accelerate loops by using F2PY?
@njit def function_gam(et0, y30, ph0b, ot, y70): ht = ot[0] * et0 * np.cos(y30) / np.sqrt(ph0b) + ot[1] * -et0 * np.sin(y30) / np.sqrt(ph0b) + y70 * np.sqrt(1 / ph0b) * et0 * np.sin(y30) + funct_labt(y30, ot, y70) * (np.sqrt(1 / ph0b) * (1 + et0 * np.cos(y30) * (1 + et0 * np.cos(y30)**2) / ph0b**2)) return ht @njit def funct_labt(y30, ot, y70): y80 = ot[1] * et0 *(np.sin(y30)) / np.sqrt(ph0b) - y70 * (ph0b * et0 * (np.sin(y30)) / (1 + et0 * np.cos(y30)))**2 + (-ot[0] * et0 *(np.cos(y30)) / np.sqrt(ph0b)) return y80 tol = E-5 for i in z30: # iteratation through values for variable z30 for o in zres: # iteratation through values for array zres which includes 2 interconnected variales. The values of the first are in zres[0], for the other - in zres[1] for l in z70: # iteratation through values for variable z70 ht0 = function_gam(et0, i, ph0b, o, l) if np.isclose(ht0, 0): # only these combinations of variables values are collected that satisfy the condition ht == 0 lh0 = i, o[0], o[1], l print(lh0)