The Wimol-Banlue attractor via the Taylor Series Method

Click For Summary

Discussion Overview

The discussion centers around the Wimol-Banlue attractor and its implementation using the Taylor Series Method in Python. Participants explore the code provided, its functionality, and the potential for visualizing the attractor through plotting.

Discussion Character

  • Technical explanation
  • Exploratory
  • Homework-related

Main Points Raised

  • One participant describes the attractor as unusual due to its use of both the tanh() and abs() functions, providing a code snippet for generating data.
  • Several participants express interest in obtaining a sample argument list to run the provided Python code.
  • There is a suggestion that the code does not include plotting functionality, implying that users will need to handle visualization separately.
  • Another participant mentions having plotting programs available on GitHub and discusses the need for libraries like matplotlib and Pi3d for visualization.
  • One participant notes their experience with Python and expresses confidence in generating plots using available libraries.
  • Another participant reiterates the potential for creating animated plots using a specific script provided in the README.

Areas of Agreement / Disagreement

Participants generally agree on the need for visualization of the attractor data and the potential use of external libraries, but there is no consensus on the best approach or specific tools to use for plotting.

Contextual Notes

Some participants mention limitations in the provided code, such as the absence of plotting capabilities and the need for additional libraries for visualization. There is also a reference to the complexity of the code, which may affect its usability for those unfamiliar with Python.

Who May Find This Useful

This discussion may be useful for individuals interested in dynamical systems, attractors, and those looking to implement and visualize mathematical models using Python.

m4r35n357
Messages
657
Reaction score
148
This attractor is unusual because it uses both the tanh() and abs() functions. A picture can be found here (penultimate image). Here is some dependency-free Python (abridged from the GitHub code, but not flattened!) to generate the data to arbitrary order:
Python:
#!/usr/bin/env python3
from sys import argv
from math import tanh

def t_jet(n, value=0.0):
    jet = [0.0] * n
    jet[0] = value
    return jet

def t_abs(u, k):
    if k == 0:
        return abs(u[0])
    elif k == 1:
        return u[1] if u[0] > 0.0 else (-u[1] if u[0] < 0.0 else 0.0)
    return 0.0

def t_prod(u, v, k):
    return sum(u[j] * v[k - j] for j in range(k + 1))

def t_tanh_sech2(t, s2, u, k):
    if k == 0:
        return tanh(u[0]), 1.0 - tanh(u[0])**2
    tk = s2[0] * u[k] + sum(j * u[j] * s2[k - j] for j in range(1, k)) / k
    return tk, - (2.0 * (t[0] * tk + sum(j * t[j] * t[k - j] for j in range(1, k)) / k))

def main():
    model, order, δt, n_steps = argv[1], int(argv[3]), float(argv[4]), int(argv[5])  # integrator controls
    x0, y0, z0 = float(argv[6]), float(argv[7]), float(argv[8])  # initial values
    x, y, z = t_jet(order + 1), t_jet(order + 1), t_jet(order + 1)  # coordinate jets

    if model == "wimol-banlue":
            a_ = t_jet(order, float(argv[9]))  # constant jet
            tx, sx = t_jet(order), t_jet(order)  # temporary jets
            print(f'{x0:.9e} {y0:.9e} {z0:.9e} {0.0:.5e}')
            for step in range(1, n_steps + 1):
                x[0], y[0], z[0] = x0, y0, z0  # Taylor Series Method
                for k in range(order):
                    tx[k], sx[k] = t_tanh_sech2(tx, sx, x, k)  # sech^2 stored but not used in ODE equations
                    x[k + 1] = (y[k] - x[k]) / (k + 1)
                    y[k + 1] = - t_prod(z, tx, k) / (k + 1)
                    z[k + 1] = (- a_[k] + t_prod(x, y, k) + t_abs(y, k)) / (k + 1)
                x0, y0, z0 = x[order], y[order], z[order]  # Horner's method
                for i in range(order - 1, -1, -1):
                    x0 = x0 * δt + x[i]
                    y0 = y0 * δt + y[i]
                    z0 = z0 * δt + z[i]
                print(f'{x0:.9e} {y0:.9e} {z0:.9e} {step * δt:.5e}')

main()
To run it
Code:
./wb.py wimol-banlue 16 10 0.1 10001 1 0 0 2.0
Enjoy!
[EDIT] fixed bug in t_abs() !
 
Last edited:
Technology news on Phys.org
Very interesting attractors.

Can you provide a sample arg list to try?

I tried it on my iPad using Pythonista hoping it might run but the args stopped me.
 
Also it doesn’t plot anything I guess that part. is left to the student.
 
jedishrfu said:
Can you provide a sample arg list to try?
See OP ;)
Also, the posters on the website in the OP have parameters on them.
 
jedishrfu said:
Also it doesn’t plot anything I guess that part. is left to the student.
You expect much from 45 lines of Python ;)
I have plotting programs on GitHub (there is a branch called float if you don't want arbitrary precision), but will you need matplotlib for graphs and Pi3d for real time 3d trajectories (tentative virtual env instructions in the README).
Otherwise, the data should be easy enough to parse into something else for display (SciLab?).
 
Last edited:
Okay thanks. I use python for work. Mostly the Anaconda distro although I also have Pythonista on the iPad. Both have numpy and matplotlib modules so it should be possible to generate a plot which would make the code even more interesting visually.
 
jedishrfu said:
Okay thanks. I use python for work. Mostly the Anaconda distro although I also have Pythonista on the iPad. Both have numpy and matplotlib modules so it should be possible to generate a plot which would make the code even more interesting visually.
OK, so if you have matplotlib you should at least be able to plot the graphs in progressive animated fashion using the plotAnimated.py script. See the README for an example invocation.
pi3d is much more impressive visually though.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 16 ·
Replies
16
Views
3K
Replies
3
Views
4K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 10 ·
Replies
10
Views
11K