Oct-21-2019, 08:34 PM
Hello, this is my first post so sorry if I format something wrong, I am working on an assignment that goes as follows:
A long thin rod has escaped from a space station. The rod is 20 m long and 0.1 m in
diameter. The rod is made of steel.
a) Write a program that determines the
gravitational field produced by the rod.
The general approach is to partition the
rod into small pieces and sum up the field
contributions from each piece.
(Remember that these contributions are
vectors and hence must be summed up as
vectors.) Your program should be able to
find the gravitational field at any point
outside the rod. Create a simulation that
shows the rod and places an arrow
representing the field at the selected point.
b) Generate a picture that shows the field at points along a line parallel to the rod and separated by a
perpendicular distance d.
I must not have the force right or something because I cannot get the arrow to point in the proper direction. Any help would be much appriciated! This is the code I have so far:
A long thin rod has escaped from a space station. The rod is 20 m long and 0.1 m in
diameter. The rod is made of steel.
a) Write a program that determines the
gravitational field produced by the rod.
The general approach is to partition the
rod into small pieces and sum up the field
contributions from each piece.
(Remember that these contributions are
vectors and hence must be summed up as
vectors.) Your program should be able to
find the gravitational field at any point
outside the rod. Create a simulation that
shows the rod and places an arrow
representing the field at the selected point.
b) Generate a picture that shows the field at points along a line parallel to the rod and separated by a
perpendicular distance d.
I must not have the force right or something because I cannot get the arrow to point in the proper direction. Any help would be much appriciated! This is the code I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
GlowScript 2.9 VPython from visual import * from visual.graph import * #Space rod G = - 6.7e - 11 #gravitational constant point = sphere(pos = vector( 10 , 5 , 0 ), radius = . 05 , color = (color.white)) rod = cylinder(pos = vector( 0 , 0 , 0 ), axis = vector( 20 , 0 , 0 ), radius = 0.05 , color = color.cyan) rod.length = 20 #length of the rod rod.r = 0.05 #radius of the rod rod.v = rod.length * 3.14 * rod.r * * 2 #volume of rod rod.D = 8000 #density of steel rod.m = rod.D * rod.v #mass of rod dx = rod.pos.x dy = rod.pos.y dz = rod.pos.z dl = . 0001 #sections of the rod l = 0 #starting length dm = rod.m / dl fscale = 1 farr = arrow(pos = point.pos, color = color.cyan) while l< = rod.lenth: dx = dx + (rod.length / dl) r = ((point.pos.x - dx) * * 2 + (point.pos.y - dy) * * 2 + (point.pos.z - dz) * * 2 ) * * 0.5 Fg = G * r.hat * (dm) / mag2(r) l = l + dl netforce = Fg + netforce farr.axis = netforce * fscale |