NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: lookang on April 18, 2010, 05:30:12 pm



Title: Runtime error in Magnetic Bar Field Model
Post by: lookang on April 18, 2010, 05:30:12 pm
http://www.compadre.org/OSP/items/detail.cfm?ID=9414
when i move the compass very quickly, sometimes it is possible to get a runtime error.
any idea how the error can be solved?
I tried to fix it but can't figure out the cause, i increase the array to nx and ny to [21] but that didn't solve the runtime error.
i have been puzzled by this runtime error. i can't understand what is causing it. chance to look at it ? thanks!

"Where is "Thread-3"? this error position happen at this point, i did a screen capture(http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=1576.0;attach=2137;image)(http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=1576.0;attach=2139;image)

Error is:
Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBoundsException: 20
   at org.opensourcephysics.drawing2d.VectorField.prepareField(Unknown Source)
   at org.opensourcephysics.drawing2d.VectorField.draw(Unknown Source)
   at org.opensourcephysics.display.DrawingPanel.paintDrawableList(Unknown Source)
   at org.opensourcephysics.display.DrawingPanel.paintEverything(Unknown Source)
   at org.opensourcephysics.display.DrawingPanel.render(Unknown Source)
   at org.opensourcephysics.display.DrawingPanel.render(Unknown Source)
   at org.colos.ejs.library.control.swing.ControlDrawablesParent.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.updateWhenIdle(Unknown Source)
   at org.colos.ejs.library.control.EjsControl.updateSimulationWhenIdle(Unknown Source)
   at org.colos.ejs.library.control.ControlElement.variablesChanged(Unknown Source)
   at org.colos.ejs.library.control.drawing2d.ControlElement2D.propagatePosition(Unknown Source)
   at org.colos.ejs.library.control.drawing2d.ControlElement2D.reportMouseMotion(Unknown Source)
   at org.colos.ejs.library.control.drawing2d.ControlElement2D.interactionPerformed(Unknown Source)
   at org.opensourcephysics.drawing2d.Element.invokeActions(Unknown Source)
   at org.colos.ejs.library.control.swing.UpdateHotSpot2DDelayedAction.performAction(Unknown Source)
   at org.colos.ejs.library.Animation.checkMethodsInvokedByView(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)


Title: Re: Runtime error in Magnetic Bar Field Model
Post by: Fu-Kwun Hwang on April 18, 2010, 09:54:34 pm
I did not find any error when I run it.
Is it possible it is your modified version(not the original verison) which intriduce error?


Title: Re: Runtime error in Magnetic Bar Field Model
Post by: lookang on April 18, 2010, 11:03:21 pm
i move the compass non-stop up and down across the picture of the magnet.

it is not exactly a reproducible error and i can't pin point where it happens, but it has happened to me on different machines Mac and PC.

and yes you are right, the error is also found in my modified version, that is why i went back to the http://www.compadre.org/OSP/items/detail.cfm?ID=9414 version and drag the compass like mad, and true enough, it happens too.

i also checked with wolfgang he  said "The model does not change the array size and appears to be an EJS drawing problem."
i also checking with paco :)

i just tried again on a Mac
the error is:
Exception in thread "Thread-2" java.lang.ArrayIndexOutOfBoundsException: 20
   at org.opensourcephysics.drawing2d.VectorField.processMagnitude(Unknown Source)
   at org.opensourcephysics.drawing2d.VectorField.prepareField(Unknown Source)
   at org.opensourcephysics.drawing2d.VectorField.draw(Unknown Source)
   at org.opensourcephysics.display.DrawingPanel.paintDrawableList(Unknown Source)
   at org.opensourcephysics.display.DrawingPanel.paintEverything(Unknown Source)
   at org.opensourcephysics.display.DrawingPanel.render(Unknown Source)
   at org.opensourcephysics.display.DrawingPanel.render(Unknown Source)
   at org.colos.ejs.library.control.swing.ControlDrawablesParent.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.updateWhenIdle(Unknown Source)
   at org.colos.ejs.library.control.EjsControl.updateSimulationWhenIdle(Unknown Source)
   at org.colos.ejs.library.control.ControlElement.variablesChanged(Unknown Source)
   at org.colos.ejs.library.control.drawing2d.ControlElement2D.propagatePosition(Unknown Source)
   at org.colos.ejs.library.control.drawing2d.ControlElement2D.reportMouseMotion(Unknown Source)
   at org.colos.ejs.library.control.drawing2d.ControlElement2D.interactionPerformed(Unknown Source)
   at org.opensourcephysics.drawing2d.Element.invokeActions(Unknown Source)
   at org.colos.ejs.library.control.swing.UpdateHotSpot2DDelayedAction.performAction(Unknown Source)
   at org.colos.ejs.library.Animation.checkMethodsInvokedByView(Unknown Source)
   at org.colos.ejs.library.Animation.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:637)

seems slightly different error message from the windows 7

i attached the picture of the line 637 (http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=1576.0;attach=2142;image) of the file MagneticBarFieldView.java  and the file itself.

never mind if it cannot be solved, i think the applet is more stable after the reset button is clicked once, i try to add the reset code to it and see how.


Title: Re: Runtime error in Magnetic Bar Field Model
Post by: lookang on April 18, 2010, 11:34:56 pm
i think i have solved it!

i added
_reset(); to the beginning of the initialization page and i drag the compass like mad like 30 seconds! and nothing!! no bug!!! LOL

maybe i did it!


will test again  ;D