Rossler Attractor Python Script in Grasshopper3d

Looking more into Python, the syntax and how you can use for loops, Rhinocommon and math within the GH Python Component, I decided to write and share this animated Python script of a Rossler attractor.  This particular attractor lies in the context of particle kinematics within chemical reactions. This system is defined by three non-linear ordinary differential equations originally studied by Otto Rössler. I find it to be, an extremely interesting and minimally beautiful system, mainly due to the particle’s easily observed movement in the Cartesian 3D space.



Thy python code looks something like this:

#”Rossler Attractor Grasshopper Python Component”
#Written by Marios Tsiliakos on 22/11/2012
#Based on the equations provided by Paul Bourke
#Rossler Attractor by Marios Tsiliakos is licensed under a
#Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
#Based on work at
from math import *
import _random as rnd
import Rhino
# Subfunction
def Rossler(it):
#random number
r0 = r.random()*0.1
# set the constants
a = 0.15 + r0
b = 0.2 – r0
c = 5.7 + r0
h = H
# provide the initial point
for i in range(it):
x0= x + h*(-y -z)
y0= y + h*(x + a*y)
z0= z + h*(b+z*(x-c))
#make the resulting coordinates the coordinates last point
x,y,z = x0, y0, z0
pts= Rhino.Geometry.Point3d(x,y,z)
#Main function
if Iterations == None:
Iterations = 1000
if H == None:
H = 0.05
if Seed == None:
Seed = 2
if Run== True:
#global lists
arrPts = []
var =[]
# always provide the creation of a curve by sufficient number of points
numpoints =counter+4
if numpoints < Iterations:
crv = Rhino.Geometry.Curve.CreateInterpolatedCurve(arrPts,3)
print counter
print “Rossler attractor with values: a =” , var[0][0],”b=” , var[0][1],”c=”, var[0][2],”h=” , H
if numpoints >= Iterations:
print “goal achieved”
# Comment out the next line to get the resulting points
#crv = Rhino.Geometry.Curve.CreateInterpolatedCurve(arrPts,3)
#counter = Iterations
Points = arrPts
else :
counter = 0

And here is a snapshot of the definition . You can download it at the usual place.



2-state Cellular Automaton in Python for Grasshopper


I just got my hands on Python for rhino last week (more specifically on a package called ironpython), because I wanted to try out the capabilities and the adaptive character of this powerful scripting/coding language. What is interesting in the case of ironpython is the import of both the rhinoscript syntax and the Rhinocommon elements within the Grasshopper3d environment. Having prior programming experience python is fairly easy to learn and quite user friendly. The  feature of debugging without compiling the code is also really useful.

To test the scripting possibilities of Python I wrote a 2-state cellular automaton based on this code from Processing on Worlfram 2d CA’s. I have implemented both Rhinocommon and rhinoscript syntax commands and members in the code, plus I have introduced some time based evolving  just to make the simulation dynamic.


The algorithm can create a variety of patterns, emerging from the initial rule defining the state relation between the automata (ie. the famous rule 110). The parameters of the python component are the number of the rule  used, the width of the drawing grid, the size of the cell and the time. The process becomes kind of slow after a few iterations because lots of geometry is being generated, thus if the boxes were to be replaced by simple points the algorithm would have a much better performance.



Here is a small video documenting the process.

This is a snapshot of the grasshopper definition. I plan to release the code after I clean it up a little bit, so stay tuned if you want to try it out.