Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

plot_vector_field3d in spherical coordinates

Hello,

How can I draw a vector field in spherical coordinates?

For example

E=EuclideanSpace(3)
c_cart.<x,y,z>=E.cartesian_coordinates()
c_spher.<r,ph,th>=E.spherical_coordinates()

f_spher=E.frames()[2] # frame in spherical coordinates
E.set_default_chart(c_spher)
E.set_default_frame(f_spher) 

vf=E.vectorfield((r,0,0), frame=f_spher,cart=c_spher,name="vf");show(vf.display())

This beutifully gives me a vector field as r e_r

Now, I would like to plot this field in spherical coordinates

plot_vector_field3d([c.expr() for c in vf[:]], (r,2,10),(th,0,pi),(ph,0,2*pi))

I also tried out the transformation keyword as it is in plot3d function, but it still plots r as x. How can I plot the vector field in spherical coordinates? I was expecting to see outgoing arrows in all directions from r=2 to 10?

click to hide/show revision 2
retagged

plot_vector_field3d in spherical coordinates

Hello,

How can I draw a vector field in spherical coordinates?

For example

E=EuclideanSpace(3)
c_cart.<x,y,z>=E.cartesian_coordinates()
c_spher.<r,ph,th>=E.spherical_coordinates()

f_spher=E.frames()[2] # frame in spherical coordinates
E.set_default_chart(c_spher)
E.set_default_frame(f_spher) 

vf=E.vectorfield((r,0,0), frame=f_spher,cart=c_spher,name="vf");show(vf.display())

This beutifully gives me a vector field as r e_r

Now, I would like to plot this field in spherical coordinates

plot_vector_field3d([c.expr() for c in vf[:]], (r,2,10),(th,0,pi),(ph,0,2*pi))

I also tried out the transformation keyword as it is in plot3d function, but it still plots r as x. How can I plot the vector field in spherical coordinates? I was expecting to see outgoing arrows in all directions from r=2 to 10?