The Philippine Electronics and Technology Forum
February 10, 2012, 02:52:06 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  

Pages: [1]   Go Down
  Print  
Author Topic: Lorenz Equations  (Read 839 times)
'yus
Technical People
Nuclear Reactor
*****

Pogi/Ganda Points: 274
Offline Offline

Gender: Male
Posts: 4170


oops, kernel panic!


WWW
« 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:
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
Logged

join PhilRobotics - Amateur Robotics Club of the Philippines
The Philippine Electronics and Technology Forum
« on: December 10, 2009, 02:26:52 PM »

 Logged
'yus
Technical People
Nuclear Reactor
*****

Pogi/Ganda Points: 274
Offline Offline

Gender: Male
Posts: 4170


oops, kernel panic!


WWW
« Reply #1 on: December 10, 2009, 05:52:45 PM »

now integrated to a PyQt GUI: Smiley

*variable 'rho' value

Quote
Lorenz three differential equations:





Code:
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_())
Logged

join PhilRobotics - Amateur Robotics Club of the Philippines
z22
CR2032 Battery
**

Pogi/Ganda Points: 3
Offline Offline

Gender: Male
Posts: 33


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

browser based:
http://rapidshare.com/files/318883486/lorenz.html
Logged
I n s i d e r 2010
Diesel Generator
*

Pogi/Ganda Points: 99
Offline Offline

Gender: Male
Posts: 1618

matalino ka man ngayon ay mapagiiwanan ka rin


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

naku po may multo sa loob ng kahon Grin Grin Grin Grin Grin
Logged

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!
The Philippine Electronics and Technology Forum
   

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Good textbook on differential equations? « 1 2 »
Mathematics
HK-47 32 4467 Last post October 07, 2008, 11:28:42 PM
by ronchiedean
Part 1: Elementary Differential Equations by Earl Raiville & Phillip Bedient
Mathematics
Kiks 10 1875 Last post July 31, 2011, 10:28:32 PM
by reenlee
help..! solution manual for elementary differential equations??
General Electronics and Technology Discussion
kreesh 9 943 Last post July 31, 2011, 09:56:07 PM
by reenlee
equations for rms & avg of smps waveforms
Industrial Engineering
Pro-Engineer 0 160 Last post October 22, 2010, 11:30:39 AM
by Pro-Engineer
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!