Python Forum
Need to fix SyntaxError in cycle try
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need to fix SyntaxError in cycle try
#6
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)
Reply


Messages In This Thread
RE: Need to fix SyntaxError in cycle try - by alexfrol86 - Mar-24-2022, 05:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing a cycle to find the nearest point from the array Tysrusko 0 267 May-10-2024, 11:49 AM
Last Post: Tysrusko
  Trying to cycle through a list of charcters pooky2483 12 4,807 Sep-28-2020, 06:55 AM
Last Post: pooky2483
  <while> cycle is not interrupted when using the <random>module ShityCoder 3 2,328 Sep-04-2020, 04:05 PM
Last Post: ShityCoder
  Cycle of numpy variables Zero01 0 1,628 Jul-31-2020, 11:58 AM
Last Post: Zero01
  stop cycle while windows11 1 2,126 May-16-2020, 03:17 PM
Last Post: deanhystad
  Occurrences using FOR and IF cycle P86 2 2,643 Jul-29-2019, 04:37 PM
Last Post: ThomasL
  pool map cycle skorost5 5 4,015 Apr-07-2019, 09:21 AM
Last Post: skorost5
  lifetime cycle counter Ixxxxxx 0 2,574 Mar-07-2018, 07:26 PM
Last Post: Ixxxxxx

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020