1

I have to create a charge distribution of circular shape. I already created a square charge distribution and it look like this. How can I change this square distribution to circular?

My code for the square distribution:

Nmax = 120; Niter = 10
V = zeros((Nmax, Nmax+100)  , float)
for k in range(0, 40): V[40+k,40] = 2400.0
for k in range(0, 40): V[40,k+40] = 2400.0
for k in range(0, 40): V[80,k+40] = 2400.0
for k in range(0, 40): V[40+k,80] = 2400.0
Mel
  • 5,837
  • 10
  • 37
  • 42
michal9229
  • 13
  • 2

1 Answers1

0

You can do this:

from math import sin, cos, pi
import matplotlib.pyplot as plt

x,y = [cos((i*pi)/500) for i in range(1000)], [sin((i*pi)/500) for i in range(1000)]
plt.plot(x,y)
plt.show()

Or use the circle function from matplotlib, as demonstrated in this answer.

Community
  • 1
  • 1
rofls
  • 4,993
  • 3
  • 27
  • 37
  • use `[r*cos((i*pi)/500) for i in range(1000)], [r*sin((i*pi)/500) for i in range(1000)]` where `r` is the radius you want :) – rofls Dec 15 '15 at 19:42