ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/multipole/PointCharges.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: 1301 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 dipole.'''
4    
5     import math
6     import VectorFieldPlot as vfp
7    
8    
9     # create a document. we specify the file name and image size here
10     doc = vfp.FieldplotDocument( 'PointCharges', width=800,height=600,unit=100)
11    
12     # create a field opbject
13     field = vfp.Field()
14     # add the point charges
15     field.add_element('monopoles' , [ [ 1,0, 1] # the positive charge
16     , [-1,0,-1] # the negative charge
17     ] )
18    
19     # draw the charges for the field on the document
20     doc.draw_charges(field)
21    
22     # start drawing the field lines
23     # we are going to draw 20 field lines comming off of the positive charge at uniformly spaced angles.
24     N = 20
25     for i in range(N):
26     # compute the angle that the line will start off at
27     angle = i * 2.*math.pi / (N-1)
28     # generate the line
29     # this takes the initial position, the x and y components of the initial direction, and whether or not should go forward
30     # or backward.
31     line = vfp.FieldLine( field, [1,0], start_v=[math.cos( angle ) , math.sin( angle )],directions='forward' )
32     # draw the lin on the document
33     doc.draw_line(line,arrows_style={'min_arrows':1,'scale':0.4,'max_arrows':3})
34    
35     # write the document
36     doc.write()

Properties

Name Value
svn:executable *