Loading...
Searching...
No Matches
plotNonconservative.py
1#!/usr/bin/env python
2
3
36
37# Authors: Caleb Voss, Wilson Beebe
38
39import matplotlib.pyplot as plt
40from pylab import meshgrid, arange, quiver, quiverkey, sqrt
41import numpy as np
42
43def makeVectorField(f, xmin, xmax, ymin, ymax, step):
44 X, Y = meshgrid(arange(xmin, xmax, step), arange(ymin, ymax, step))
45 U, V = zip(*map(lambda xx: f(*xx), zip(X, Y)))
46 Q = quiver(X, Y, U, V, units='width')
47 quiverkey(Q, 0, 0, 4, '', coordinates='figure', labelpos='W')
48
49fig = plt.figure()
50ax = fig.gca(aspect='equal')
51x = np.loadtxt("vfrrt-nonconservative.path")
52makeVectorField(lambda x, y: (y / sqrt(x * x + y * y + 1e-6), -x / sqrt(x * x + y * y + 1e-6)),
53 -6, 6, -6, 6, 0.5)
54ax.plot(x[:, 0], x[:, 1])
55plt.show()