The Open Source Physics website will be unavailable Friday evening through Saturday afternoon as electrical work occurs in the American Center of Physics server room. Down time will begin at 6PM Eastern Time on Friday. Service is expected to resume by 6PM on Saturday, July 30.

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

possible to draw static magnetic field lines on a bar magnet in 3D post and replies

Return to the possible to draw static magnetic field lines on a bar magnet in 3D thread
Login to post to this thread

possible to draw static magnetic field lines on a bar magnet in 3D - Aug 3, 2012 at 12:46PM
lookang Avatar
lookang
175 Posts

is it possible to draw static magnetic field lines on a bar magnet in 3D? i looked at examples in EJS, E:\workspace\source\ModelingScience\Ch03_Basics\DipolePotential.xml it resembled the magnetic field lines of a magnet bar. is it possible to create a 3D version of this? it would be useful to many physics EJS users trying to draw "unchanging" field lines without the need to ODE. for your consideration :)

 or maybe my question should be can share a EJS example of an 3D magnetic lines of a bar magnet?

 

thanks!

 

Post edited August 3, 2012 at 12:39 PM EST.

Post edited August 3, 2012 at 12:41 PM EST.

Post edited August 3, 2012 at 12:41 PM EST.

Post edited August 3, 2012 at 12:42 PM EST.


OSP@SG blog
OSP@SG Digital Library

Replies to possible to draw static magnetic field lines on a bar magnet in 3D

Re: possible to draw static magnetic field lines on a bar magnet in 3D - Aug 03 2012 4:17PM
Wolfgang
103 Posts

EJS 3D objects can indeed be used to plot field lines.  There are two ways to do this:

1) Use the analytic formula for a dipole to generate a sequence of (x,y,z) points for a Trail3D Element.
2) Solve the ODE for the field line starting at some initial point (x0,y0,z0) and store the solution in a Trail3D.

In general, I think field vectors provide a better representation than field lines. See the following E&M programs for this representation:

http://www.compadre.org/osp/items/detail.cfm?ID=8311
http://www.compadre.org/osp/items/detail.cfm?ID=8983



Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D - Aug 04 2012 9:47AM
lookang Avatar
lookang
175 Posts

quote:
1) Use the analytic formula for a dipole to generate a sequence of (x,y,z) points for a Trail3D Element.
unquote:



may i humbly request for an example for me to work on?
it will greatly enhance my understanding and if i am correct, you will add an new example that does not exist yet on OSP digital library!

thanks Prof Wolfgang.
:)


OSP@SG blog
OSP@SG Digital Library


Re: Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D - Aug 06 2012 10:21AM
mrg_psu
5 Posts

I've done some field line tracing in animations, so I've played with this sort of thing before. The impression I get is that tracing field lines is computationally expensive. I threw together a quick and dirty model for a dipole with some commentary (no warranties). Rename the file from .zip to .jar if you want to just run it. I also put it here: http://phys23p.sl.psu.edu/~mrg3/EJS_betas/ejs_fieldlines_3D.jar

 

I'm not sure if this is exactly what Wolfgang meant.

 

Let me know if this helps. -Mike Gallis

Attached File: ejs_fieldlines_3D.zip



Re: Re: Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D - Aug 07 2012 4:12AM
lookang Avatar
lookang
175 Posts

Thanks mike
it helps!

i also made my own simple model using eclipse equations inspired by General parametric form

http://en.wikipedia.org/wiki/Ellipse
An ellipse in general position can be expressed parametrically as the path of a point (X(t),Y(t)), where

    X(t)=X_c + a\,\cos t\,\cos \varphi - b\,\sin t\,\sin\varphi
    Y(t)=Y_c + a\,\cos t\,\sin \varphi + b\,\sin t\,\cos\varphi

remove the zip to run as a jar.
:)

Post edited August 7, 2012 at 4:07 AM EST.

Post edited August 7, 2012 at 4:08 AM EST.


OSP@SG blog
OSP@SG Digital Library


Re: Re: Re: Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D - Aug 07 2012 4:15AM
lookang Avatar
lookang
175 Posts

correct file now

Attached File: ejs_fieldlines3D.jar.zip


OSP@SG blog
OSP@SG Digital Library


Re: Re: Re: Re: Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D - Aug 07 2012 4:18AM
lookang Avatar
lookang
175 Posts

added a slider to control the B field strength

Attached File: ejs_fieldlines3D.jar1.zip


OSP@SG blog
OSP@SG Digital Library


Re: Re: Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D - Aug 08 2012 2:30PM
lookang Avatar
lookang
175 Posts

hi prof mike,

i did some editing on your source code and i encountered this runtime error when i try to move the display around.

any idea how to overcome this?

i wonder if this is an error with EJS that requires Paco and Wolfgang's inputs.
thanks!



Exception in thread "Thread-3" java.lang.NullPointerException
at org.opensourcephysics.drawing3d.simple3d.SimpleElementTrail.computePositions(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleElementTrail.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.Element.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.ElementTrail.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.Group.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.Group.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleDrawingPanel3D.paintDrawableList(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleDrawingPanel3D.paintEverything(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleDrawingPanel3D.render(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleDrawingPanel3D.render(Unknown Source)
at org.opensourcephysics.drawing3d.DrawingPanel3D.render(Unknown Source)
at org.colos.ejs.library.control.drawing3d.ControlDrawingPanel3D.finalUpdate(Unknown Source)
at org.colos.ejs.library.control.EjsControl.finalUpdate(Unknown Source)
at org.colos.ejs.library.Animation.update(Unknown Source)
at org.colos.ejs.library.Animation.step(Unknown Source)
at org.colos.ejs.library.Animation.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-3" java.lang.NullPointerException
at org.opensourcephysics.drawing3d.simple3d.SimpleElementTrail.computePositions(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleElementTrail.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.Element.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.ElementTrail.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.Group.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.Group.processChanges(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleDrawingPanel3D.paintDrawableList(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleDrawingPanel3D.paintEverything(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleDrawingPanel3D.render(Unknown Source)
at org.opensourcephysics.drawing3d.simple3d.SimpleDrawingPanel3D.render(Unknown Source)
at org.opensourcephysics.drawing3d.DrawingPanel3D.render(Unknown Source)
at org.colos.ejs.library.control.drawing3d.ControlDrawingPanel3D.finalUpdate(Unknown Source)
at org.colos.ejs.library.control.EjsControl.finalUpdate(Unknown Source)
at org.colos.ejs.library.Animation.update(Unknown Source)
at org.colos.ejs.library.Animation.step(Unknown Source)
at org.colos.ejs.library.Animation.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Attached File: ejs_fieldlines_3Dmike.zip


OSP@SG blog
OSP@SG Digital Library


Re: possible to draw static magnetic field lines on a bar magnet in 3D - Aug 11 2012 3:39PM
Wolfgang
103 Posts

I have posted a 3D model showing both field lines and field vectors from a magnetic dipole.

http://www.compadre.org/osp/items/detail.cfm?ID=12361

Attached File: DipoleField3D.jpg



Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D - Aug 14 2012 11:31AM
lookang Avatar
lookang
175 Posts

thanks!
will try to implement them on my remixed models


OSP@SG blog
OSP@SG Digital Library


The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics