ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/multipole/Quadrupole.py
Revision: 4407
Committed: Wed Mar 30 17:58:47 2016 UTC (9 years, 1 month ago) by gezelter
Content type: text/x-python
File size: 1378 byte(s)
Log Message:
Added some scripts to produce field line figures for the schematic

File Contents

# User Rev Content
1 gezelter 4407 #!/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, 1.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 = 49
23     for i in range(N):
24     # compute the angle that the line will start off at
25     angle = i * 2.*math.pi / (N-1)
26     # generate the line
27     # this takes the initial position, the x and y components of the initial direction, and whether or not should go forward
28     # or backward.
29     line = vfp.FieldLine( field, [0.1*math.cos(angle),0.1*math.sin(angle)], start_v=[math.cos( angle ) , math.sin( angle )],directions='forward' )
30     # draw the lin on the document
31     doc.draw_line(line,arrows_style={'min_arrows':1,'scale':0.4,'max_arrows':3})
32    
33     # write the document
34     doc.write()
35    

Properties

Name Value
svn:executable *