possible to draw static magnetic field lines on a bar magnet in 3D
lookang
245 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?
Re: possible to draw static magnetic field lines on a bar magnet in 3D -
Wolfgang
192 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:
Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D -
lookang
245 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!
Re: Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D -
mrg_psu
9 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.
Re: Re: Re: Re: possible to draw static magnetic field lines on a bar magnet in 3D -
lookang
245 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)