Created
March 11, 2012 05:24
-
-
Save gunungloli666/2015143 to your computer and use it in GitHub Desktop.
belajar_quiver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Mar 10 20:33:32 2012 | |
@author: fajar | |
""" | |
from numpy import linspace, meshgrid, array | |
import pylab as pl | |
from scipy.integrate import odeint | |
# membuat vektor | |
u = linspace(-5,5,21) | |
v = linspace(-5,5,21) | |
U,V = meshgrid(u,v) | |
def fu(u,v): | |
return u | |
def fv(u,v): | |
return -2*v | |
FU = fu(U,V) | |
FV = fv(U,V) | |
# sistem Persamaan: | |
def g(x,t): | |
y1 = x[0] | |
y2 = -2*x[1] | |
return [y1, y2] | |
time = linspace(0,1,100) | |
con = array([[1.5,3],[1.5,-3],[-1.5,3],[-1.5,-3]]) | |
pl.figure() | |
Q = pl.quiver(U,V,FU,FV, units='height', hold=True) | |
sol = odeint(g, con[0], time) | |
pl.plot(sol[:,0], sol[:,1], linewidth=2.1 , color='y') | |
sol = odeint(g, con[1], time) | |
pl.plot(sol[:,0], sol[:,1], linewidth=2.1,color='b') | |
sol = odeint(g, con[2], time) | |
pl.plot(sol[:,0], sol[:,1], linewidth=2.1 , color='m') | |
sol = odeint(g, con[3], time) | |
pl.plot(sol[:,0], sol[:,1], linewidth=2.1 , color='r') | |
pl.autoscale(enable=True,axis='Both', tight =True) | |
pl.xlabel('u', weight='bold') | |
pl.ylabel('v', weight='bold') | |
pl.title('u\'=u dan v\'=-2v',weight='bold') | |
pl.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment