PKÈL,G¡+ 5‹ ‹ plotdf/__init__.py# (c) Jyotirmoy Bhattacharya [jyotirmoy@jyotirmoy.net # Licensed under GPLv3 #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER #IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN #CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ Plot phase portraits of 2D differential equations. Example: from math import sin from plotdf import plotdf def f(x,g=1,l=1,m=1,b=1): return np.array([x[1],-g*sin(x[0])/l-b*x[1]/m/l]) plotdf(f, # Function giving the rhs of the diff. eq. system np.array([-10,2]), # [xmin,xmax] np.array([-14,14]),# [ymin,ymax] [(1.05,-9),(0,5)], # list of initial values for trajectories (optional) # Additional parameters for `f` (optional) parameters={"g":9.8,"l":0.5,"m":0.3,"b":0.05}) """ import numpy as np import scipy.integrate as scint import matplotlib.pyplot as plt def plotdf(f, xbound,ybound, inits=None,tbounds=[0,10],tsteps=100, gridsteps=10, parameters = dict(), axes = None): """ Plot a direction field and optional trajectories of a planar differential equation system. Arguments ----- f: A function of of the form f(x) where 'x' is a 2-element numpy array denoting the current state, 't' is the current time and we expect 'f' to return the rhs of the differential equation system. xbound: a two-element sequence giving the minimum and maximum values of 'x' to plot. ybound: a two-element sequence giving the minimum and maximum values of 'y' to plots. inits: if not None, gives the set of initial values to plot trajectories from. tbounds: the starting and ending time for trajectories nsteps: number of steps in trajectories gridsteps: number of steps in the x-y grid parameters: additional keyword arguments for 'f' axes: the matplot axes in which to draw the plot. If not provided use the current axes. Return Value ------ A list the first element of which is the matplotlib Quiver object representing the arrows of the direction field and the rest are the Lines2D objects representing the trajectories. """ if axes is None: axes = plt.gca() x = np.linspace(xbound[0],xbound[1],gridsteps) y = np.linspace(ybound[0],ybound[1],gridsteps) xx,yy = np.meshgrid(x,y) uu = np.empty_like(xx) vv = np.empty_like(yy) for i in range(gridsteps): for j in range(gridsteps): res = f(np.array([xx[i,j],yy[i,j]]),**parameters) uu[i,j] = res[0] vv[i,j] = res[1] artists = [] artists.append(axes.quiver(xx,yy,uu,vv,color="darkred",width=0.002)) if inits is not None: def g(x,t): return f(x,**parameters) t = np.linspace(tbounds[0],tbounds[1],tsteps) for y0 in inits: traj = scint.odeint(g,y0,t) artists.extend(axes.plot(traj[:,0],traj[:,1],linewidth=1.2)) plt.xlim(xbound) plt.ylim(ybound) return artists PK„Q,G^-Ò $plotdf-0.1.dist-info/DESCRIPTION.rstUNKNOWN PK„Q,G¡ìÅ+"plotdf-0.1.dist-info/metadata.json{"classifiers": ["Development Status :: 3 - Alpha", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3"], "extensions": {"python.details": {"contacts": [{"email": "jyotirmoy@jyotirmoy.net", "name": "Jyotirmoy Bhattacharya", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/jmoy/plotdf"}}}, "extras": [], "generator": "bdist_wheel (0.24.0)", "keywords": ["matplotlib", "differential-equations", "numerics", "plot"], "license": "GPLv3", "metadata_version": "2.0", "name": "plotdf", "run_requires": [{"requires": ["numpy", "matplotlib", "scipy"]}], "summary": "Plot phase portraits of 2D differential equations", "version": "0.1"}PK„Q,GåÈY//plotdf-0.1.dist-info/pbr.json{"git_version": "c61a499", "is_release": false}PK„Q,GàQ¡m"plotdf-0.1.dist-info/top_level.txtplotdf PK„Q,G‡3onnplotdf-0.1.dist-info/WHEELWheel-Version: 1.0 Generator: bdist_wheel (0.24.0) Root-Is-Purelib: true Tag: py2-none-any Tag: py3-none-any PK„Q,G4©i]]plotdf-0.1.dist-info/METADATAMetadata-Version: 2.0 Name: plotdf Version: 0.1 Summary: Plot phase portraits of 2D differential equations Home-page: https://github.com/jmoy/plotdf Author: Jyotirmoy Bhattacharya Author-email: jyotirmoy@jyotirmoy.net License: GPLv3 Keywords: matplotlib differential-equations numerics plot Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3) Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Requires-Dist: numpy Requires-Dist: matplotlib Requires-Dist: scipy UNKNOWN PK„Q,G¶yDryyplotdf-0.1.dist-info/RECORDplotdf/__init__.py,sha256=3xNgcd-YVqLfFcFnIo7GsCzsBvIRlQbJJeHA9gUwCuQ,3211 plotdf-0.1.dist-info/pbr.json,sha256=uwbpteK-CM2jfrq-ORHOFWZ2D5A1lwfHmxcZCv9Jtgs,47 plotdf-0.1.dist-info/metadata.json,sha256=mBWfW32moHDJzNTOJwQGUkPuGzEky1OBXF7qQJDBiwA,790 plotdf-0.1.dist-info/RECORD,, plotdf-0.1.dist-info/DESCRIPTION.rst,sha256=OCTuuN6LcWulhHS3d5rfjdsQtW22n7HENFRh6jC6ego,10 plotdf-0.1.dist-info/METADATA,sha256=YK9nz5qsjYVWfMywAqFoksfhbmHB0ErKJVNBz9NvSfc,605 plotdf-0.1.dist-info/WHEEL,sha256=AvR0WeTpDaxT645bl5FQxUK6NPsTls2ttpcGJg3j1Xg,110 plotdf-0.1.dist-info/top_level.txt,sha256=dZ5jryOzI-w_h10t6-fUHxhOa4-2sFRRbErvbeoJD-o,7 PKÈL,G¡+ 5‹ ‹ plotdf/__init__.pyPK„Q,G^-Ò $» plotdf-0.1.dist-info/DESCRIPTION.rstPK„Q,G¡ìÅ+" plotdf-0.1.dist-info/metadata.jsonPK„Q,GåÈY//]plotdf-0.1.dist-info/pbr.jsonPK„Q,GàQ¡m"Çplotdf-0.1.dist-info/top_level.txtPK„Q,G‡3onnplotdf-0.1.dist-info/WHEELPK„Q,G4©i]]´plotdf-0.1.dist-info/METADATAPK„Q,G¶yDryyLplotdf-0.1.dist-info/RECORDPKYþ