caramoan tour package

caramoan tour package

Author Topic: Lorenz Equations  (Read 1117 times)

Offline 'yus

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4251
  • Pogi/Ganda Points: 299
  • Gender: Male
  • hw -> fw -> sw
    • yus' projects
Lorenz Equations
« on: December 10, 2009, 02:26:52 PM »
nope, hindi po ito gawa ng isang impakta natin dito sa elab.. hehe

naghahanap kasi ako dati ng simple equation ng chua's circuit.
and every time na naggo-google ako, laging nababanggit ang Lorenz Equation / Lorenz System.

ito, may nakita rin akong simple python script for this Lorenz System:
Quote

Code: [Select]
from numpy import *
from scipy.integrate import odeint
import pylab as p
import mpl_toolkits.mplot3d as p3

def Lorenz(w, t, s, r, b):
    x, y, z = w
    return array([s*(y-x), r*x-y-x*z, x*y-b*z])

# Parameters
s = 8.0
r = 28.1
b = 8/3.0

w_0 = array([0., 0.8, 0.])         # Initial condition
time = arange(0., 100., 0.01) # time vector

trajectory = odeint(Lorenz, w_0, time, args=(s, r, b)) # 10^5 x 3 array

# There must be better ways to do this:
x = trajectory[:,0]
y = trajectory[:,1]
z = trajectory[:,2]

# 3D plotting
fig=p.figure()
ax = p3.Axes3D(fig)
ax.plot3D(x,y,z)   # I guess this is the method to use
p.show()


then run that script and here's the result: (compatible with Portable Eric 4 Python IDE )


references:
http://mathworld.wolfram.com/LorenzEquations.html
http://mathworld.wolfram.com/LorenzAttractor.html
http://www.ci.ee.uct.ac.za/postgrads/ryorke/gallery/lorenz.html
http://en.wikipedia.org/wiki/Lorenz_attractor
join  - Philippine Electronics and Robotics Enthusiasts Club - www.philrobotics.com

Philippine Electronics Forum

Lorenz Equations
« on: December 10, 2009, 02:26:52 PM »

Offline 'yus

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4251
  • Pogi/Ganda Points: 299
  • Gender: Male
  • hw -> fw -> sw
    • yus' projects
Re: Lorenz Equations
« Reply #1 on: December 10, 2009, 05:52:45 PM »
now integrated to a PyQt GUI: :)

*variable 'rho' value

Quote
Lorenz three differential equations:




Code: [Select]
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *

from numpy import *
from scipy.integrate import odeint
import mpl_toolkits.mplot3d as p3
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

class MyForm(QDialog):
    def __init__(self, parent = None):
        super(MyForm, self).__init__(parent)
        self.setWindowTitle('Lorenz System (matplotlib and PyQt) - yus')
        self.resize(420, 400)
        # widgets
        self.plot = LorenzPlot()
        self.r_label = QLabel(u"<font size=7 color=darkred> \u03C1 =</font>")   #rho symbol
        self.s_label = QLabel(u"<font size=7 color=darkred> \u03C3 = 8.0</font>")   #sigma symbol
        self.b_label = QLabel(u"<font size=7 color=darkred> \u03B2 = 8/3</font>")   #beta symbol
        self.r_intput = QDoubleSpinBox()
        self.r_intput.setDecimals(1)
        self.r_intput.setRange(0.0, 50)
        # layout
        layout = QGridLayout()
        layout.addWidget(self.plot, 0, 0, 10, 10)
        layout.addWidget(self.r_label, 10, 0)
        layout.addWidget(self.s_label, 10, 3)
        layout.addWidget(self.b_label, 10, 6)
        layout.addWidget(self.r_intput, 10, 1)       
        self.setLayout(layout)
        #signal
        self.connect(self.r_intput, SIGNAL("valueChanged(double)"), self.r_adjust)       
        self.r_intput.setValue(27)
       
    def r_adjust(self, r_new):
        self.plot.draw_plot(r = r_new)

class LorenzPlot(QWidget):
    def __init__(self, *args):
        QWidget.__init__(self, *args)
       
        self.fig = Figure((5.0, 4.0)) # 5" by 4"
        self.ax = p3.Axes3D(self.fig)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self)
       
    def Lorenz(self, w, t, s, r, b):
        x, y, z = w
        return array([s*(y-x), r*x-y-x*z, x*y-b*z])

    def draw_plot(self, s=8.0, r=28.1, b=8/3.0):
        # Parameters
        self.s, self.r, self.b = s, r, b
       
        self.w_0 = array([0., 0.8, 0.])         # initial condition
        self.time = arange(0., 100., 0.01)      # time vector
        #integrate a system of ordinary differential equations
        self.trajectory = odeint(self.Lorenz, self.w_0, self.time, args=(self.s, self.r, self.b))
       
        self.x = self.trajectory[:, 0]
        self.y = self.trajectory[:, 1]
        self.z = self.trajectory[:, 2]
       
        self.ax = p3.Axes3D(self.fig)
        self.ax.plot3D(self.x, self.y, self.z)
        self.canvas.draw()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    form = MyForm()
    form.show()
    sys.exit(app.exec_())
join  - Philippine Electronics and Robotics Enthusiasts Club - www.philrobotics.com

Philippine Electronics Forum

Re: Lorenz Equations
« Reply #1 on: December 10, 2009, 05:52:45 PM »

Offline z22

  • CR2032 Battery
  • **
  • Posts: 33
  • Pogi/Ganda Points: 3
  • Gender: Male
Re: Lorenz Equations
« Reply #2 on: December 10, 2009, 07:31:46 PM »

Philippine Electronics Forum

Re: Lorenz Equations
« Reply #2 on: December 10, 2009, 07:31:46 PM »

Offline I n s i d e r 2010

  • Diesel Generator
  • *
  • Posts: 1618
  • Pogi/Ganda Points: 100
  • Gender: Male
  • matalino ka man ngayon ay mapagiiwanan ka rin
Re: Lorenz Equations
« Reply #3 on: December 10, 2009, 07:38:04 PM »
naku po may multo sa loob ng kahon ;D ;D ;D ;D ;D
ang PIKON ay laging TALO,tandaan nyo po yan mga kapatid. IRESPETO ang bawat isa!
ang PANLALAIT sa kapwa ay isang kasalanan na
pagbabayaran mo rin balang araw!

Philippine Electronics Forum

Re: Lorenz Equations
« Reply #3 on: December 10, 2009, 07:38:04 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com