ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/multipole/Quadrupole.py
Revision: 4411
Committed: Tue Apr 5 21:44:16 2016 UTC (9 years ago) by gezelter
Content type: text/x-python
File size: 1605 byte(s)
Log Message:
new figures and tables

File Contents

# Content
1 #!/opt/local/bin/python2.7
2
3 '''An example script that generates a picture of the field lines for an electric quadrupole.'''
4
5 import math
6 import VectorFieldPlot as vfp
7
8 # create a document. we specify the file name and image size here
9 doc = vfp.FieldplotDocument( 'Quadrupole', width=800,height=600,unit=100)
10
11 # create a field opbject
12 field = vfp.Field()
13 # add the qpole
14 # note, parameters are should be [ r_x, r_y, phi, q], where r is the position vector, phi is the angle of the quadrupole in radians, and q is the charge magnitude
15 field.add_element('quadrupoles' , [ [ 0, 0, 0.0, 100] ] )
16
17 # draw the charges for the field on the document
18 doc.draw_charges(field)
19
20 # start drawing the field lines
21 # we are going to draw 20 field lines comming off of the quadrupole at uniformly spaced angles.
22 N = 37
23 for i in range(N):
24 # compute the angle that the line will start off at
25 angle = float(i) * 2.0* math.pi / float(N-1)
26 direction = 'forward'
27
28 if (math.fabs(angle - 0.0) < 1.0e-3):
29 direction = 'backwards'
30 if (math.fabs(angle - math.pi) < 1.0e-3):
31 direction = 'backwards'
32
33 print angle, direction
34 # generate the line this takes the initial position, the x and y
35 # components of the initial direction, and whether or not should
36 # go forward or backward.
37 line = vfp.FieldLine( field, [0.15*math.cos(angle),0.15*math.sin(angle)], start_v=[math.cos( angle ) , math.sin( angle )],directions=direction )
38 # draw the lin on the document
39 doc.draw_line(line,arrows_style={'min_arrows':1,'scale':0.5,'max_arrows':2})
40
41 # write the document
42 doc.write()
43

Properties

Name Value
svn:executable *