I am trying to write a script to make a Lorenz attractor, using sverchok nodes, similar to this video: https://www.youtube.com/watch?v=V7xaPvaz0Ug
Using this script with the Scripted Node Lite does not work and running this script in Blender's text editor produces the following error from the console:
"Traceback (most recent call last): File "D:\0_RMaps\Projects\1700_Attractors\Blend Files\Attractors_v1.blend\Attractor_ChaoticAtmosphere_Lorenz.py", line 45, in NameError: name 'number' is not defined Error: Python script failed, check the message in the system console"
"""
in number s d=1000 n=2
in dt s d=0.01 n=2
in sigma s d=10.0 n=2
in phi s d=28.0 n=2
in beta s d=2.6667 n=2
out vertex v
out edges s
"""
import math
def Lorenz(n, t, sig, ph, bet):
x = 0.1
y = 0.1
z = 0.1
s = sig
p = ph
b = bet
for i in range(n):
dx = s*(y-x) * t
x = x + dx
dy = x*(p-z) * t
y = y + dy
dz = (x*y-b*z) * t
z = z + dz
p = [x,y,z]
vertex.append(p)
for i in range(n - 1):
v1 = i
v2 = i + 1
newEdge = (v1, v2)
edges.append(newEdge)
print(vertex)
Lorenz(number, dt, sigma, phi, beta)
I also made a script for the Three-Scroll Attractor here: https://chaoticatmospheres.com/mathrules-strange-attractors, which works. The script I used for the Three-Scroll is:
"""
in number s d=100 n=2
in dt s d=0.01 n=2
in a s d=40.0 n=2
in b s d=0.833 n=2
in c s d=0.5 n=2
in d s d=0.65 n=2
in e s d=20.0 n=2
out vertex v
out edges s
"""
import math
def Lorenz(n, t, p1, p2, p3, p4, p5):
x = 0.1
y = 0.1
z = 0.1
a = p1
b = p2
c = p3
d = p4
e = p5
for i in range(n):
dx = (a*(y-x)+c*x*z) * t
x = x + dx
dy = (e*y-x*z) * t
y = y + dy
dz = (b*z+x*y-d*x**2) * t
z = z + dz
p = [x,y,z]
vertex.append(p)
for i in range(n - 1):
v1 = i
v2 = i + 1
newEdge = (v1, v2)
edges.append(newEdge)
Lorenz(number, dt, a, b, c, d, e)
Not sure where to go from here. From the console error, it seems something is wrong with the 'number' input, but I'm having trouble seeing how this input works for the second script, but not the second.
Any help would be greatly appreciated. Thanks,