Created by: zeffii
cherrypicking from older commits.
- Functions that can be compiled using
numba
(usingnjit
), must be cached for snlite specific reasons. - The name of the
function
is thecache key
under the hood
sv_njit_clear(make_hadley3) # <-- if the cached function needs to be cleaned, comment this out when happy
# here pz are the results of the calculations.
pz = sv_njit(make_hadley3, parameters)
allowing this to be written
"""
in alpha s d=0.2 n=2
in beta s d=4.0 n=2
in delta s d=8.0 n=2
in gamma s d=1.0 n=2
in factor s d=7.0 n=2
in dif s d=0.005 n=2
in t s d=20000 n=2
in step s d=5 n=2
in mod s d=4 n=2
out verts v
"""
import sverchok
import numba
from numba import njit
@njit
def make_hadley3(alpha=0.2, beta=4.0, delta=8.0, gamma=1.0, factor=7.0, dif=0.005, t=20000, step=5, mod=4):
Points = []
p = Points.extend
x = 0.1
y = 0.0
z = 0.0
AxD = (alpha * delta)
for i in range(1, t):
for j in range(step):
x += dif * (-(y**2) - (z**2) - (alpha*x) + AxD)
y += dif * ((x*y) - (beta*x*z) - y + gamma)
z += dif * ((beta*x*y) + (x*z) - z)
if i % mod == 0:
p([x*factor, y*factor, z*factor])
return Points
# sv_njit_clear(make_hadley3)
parameters = (alpha, beta, delta, gamma, factor, dif, t, step, mod)
pz = sv_njit(make_hadley3, parameters)
verts.append(np.array(pz).reshape((-1, 3)).tolist())