def fluxpoints(self, field, n, uniform=False):
"""Returns points where field lines should enter/exit the surface.
The flux points are usually chosen so that they are equally separated
in electric field flux. However, if 'uniform' is True then the points
are equispaced.
This method requires that the flux be in xor out everywhere on the
circle (unless 'uniform' is True)."""
# Create a dense array of points around the circle
a = radians(linspace(0, 360, 1001)) + self.a0
assert len(a)%4 == 1
x = self.r*array([cos(a), sin(a)]).T + self.x
if uniform:
flux = ones_like(a)
else:
# Get the flux through each point. Ensure the fluxes are either
# all in or all out.
flux = field.projection(x, a)
if numpy.sum(flux) < 0:
flux *= -1
assert alltrue(flux > 0)
# Create an integrated flux curve
intflux = insert(cumsum((flux[:-1]+flux[1:])/2), 0, 0)
assert isclose(intflux[-1], numpy.sum(flux[:-1]))
# Divide the integrated flux curve into n+1 portions, and calculate
# the corresponding angles.
v = linspace(0, intflux[-1], n+1)
a = lininterp2(intflux, a, v)[:-1]
return self.r*array([cos(a), sin(a)]).T + self.x
评论列表
文章目录