NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
December 17, 2017, 08:58:13 pm

"Choose a job you love, and you will not have to work for a day in your life." ...Confucius (551-479 BC)

 Pages: [1]   Go Down
 Author Topic: Ejs Open Source Bar Magnet & Compass Model with Earth visualization java applet  (Read 17880 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Moderator
Hero Member

Offline

Posts: 1784

http://weelookang.blogspot.com

 « Embed this message on: September 24, 2009, 03:38:59 am » posted from:Fiesso D\'artico,Veneto,Italy

Name after 26 April 2010
Ejs Open Source Bar Magnet & Compass Model with Earth visualization java applet

Magnetic Bar Field Model to rename to Ejs Open Source Bar Magnet & Compass Model with Earth visualization java applet as request by one of the authors.
written by Wolfgang Christian, Francisco Esquembre, and Anne Cox remixed now by lookang
special thanks to Fu-Kwun Hwang for mentoring this learning community.

This now has great features, thanks to Wolfgang Christian, Francisco Esquembre, and Anne Cox for sharing their original applet, special thanks to Fu-Kwun Hwang for mentoring this learning community, support the development of this new and improved Ejs Open Source Bar Magnet & Compass Model with Earth visualization java applet.

This material is re-released under the GNU General Public License Version 3. http://www.gnu.org/licenses/gpl.html as legally required by the original authors.

Embed a running copy of this simulation

Embed a running copy link(show simulation in a popuped window)
Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
• Please feel free to post your ideas about how to use the simulation for better teaching and learning.
• Post questions to be asked to help students to think, to explore.
• Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!
 Ejs_Open_Source_Bar_Magnet_&_Compass_Model_with_Earth_visualization_java_applet.png (272.64 KB, 1024x738 - viewed 570 times.) « Last Edit: June 16, 2010, 04:47:25 pm by lookang » Logged
lookang
Moderator
Hero Member

Offline

Posts: 1784

http://weelookang.blogspot.com

 « Embed this message Reply #1 on: September 24, 2009, 03:45:27 am » posted from:Fiesso D\'artico,Veneto,Italy

O level Syllabus
draw the magnetic field pattern around a bar magnet and between the poles of two bar magnets
describe the plotting of magnetic field lines with a compass

Magnetic Bar Field Model
The EJS Magnetic Bar Field Model shows the field of a bar magnet and has a movable compass that reports the magnetic field values. The bar magnet model is built by placing a group of magnetic dipoles along the bar magnet. Users can examine and edit the model if Ejs is installed.
Exercises:

1. Run the simulation. Move the compass around in the magnetic field of the magnet. Move the magnet around. What is the relation between the compass and the field vector (small arrows)?
2. Test to see how well you can use the compass to determine the location of the magnet: Click on the Randomize position check box and then push the Hide Field button. Use the compass to show the direction of the magnetic field and then move the marker (same size as the magnet) to where you think the magnet is located. Click on Show Field to see if you were correct. If you were, describe your strategy. If you weren't, explain what went wrong and try again.
3. The model uses a group of magnetic dipoles to build a model of a bar magnet. If you have Ejs installed, examine the model and determine how many dipoles are stacked together (and in what configuration) to create a model of a bar magnet.

References:
* Giancoli, Physics for Scientists and Engineers, 4th edition, Chapter 27 (2008).

Credits:
The Magnetic Bar Field Model was created by Wolfgang Christian and Francisco Esquembre and modified by Anne J Cox using the Easy Java Simulations (EJS) authoring and modeling tool. Exercises written by Anne J Cox.

You can examine and modify a compiled EJS model if you run the program by double clicking on the model's jar file. Right-click within the running program and select "Open EJS Model" from the pop-up menu to copy the model's XML description into EJS. You must, of course, have EJS installed on your computer.

Information about EJS is available at: and in the OSP ComPADRE collection .

Learning Goals : Students will be able to http://phet.colorado.edu/en/contributions/view/2826
1.Predict the direction of the magnet field for different locations around a bar magnet and electromagnet.
2.Compare and contrast bar magnets and electromagnets
3.Identify the characteristics of electromagnets that are variable and what effects each variable has on the magnetic field’s strength and direction.
4.Relate magnetic field strength to distance quantitatively and qualitatively
5.Compare and contrast the fields of gravity and magnets qualitatively

Remix:
1 change the image to png in an attempt to fix the appear disappear when drag from http://phet.colorado.edu/simulations/sims.php?sim=Faradays_Electromagnetic_Lab#topics didnt work though
2 added a slider to simulate "magnetic field strength = 10 to 100 percent" or should it be "magnetic flux density"? hmmm
3 fixed the randomization checkbox to work now by adding to randomPositionCheck Action setLocation ()
4 fixed a bug on the markergroup and imagemagnet position not fixed to (xMagnet,yMagnet)
5 show magnetic field inside the magnet made
6 enable option to allow translation of languages
14April 2010
9 added codes to make the inside of the magnet Bx = 225 T, By = 0 T
10 modify the getBComputeField() to work for the Field only and the getB work for the compass
11 added MagneticFieldStrength B is affected by the slider by a factor of 0 to 1 by using vectorfieldmaxopposite can changing it the double solve the bug of displaying 0 or 225 cause by the integer type initially assigned by original authors
12 learn a new code from open source physics _view.format(getB(xCompass, yCompass)[1],"0.00")
Code:
fieldValueBx="B_{x}= "+_view.format(getB(xCompass, yCompass)[0],"0.00")+" T";
fieldValueBy="B_{y}= "+_view.format(getB(xCompass, yCompass)[1],"0.00")+" T";
fieldValueAngle="math_failure (math_unknown_error): \\theta = "+_view.format(getB(xCompass, yCompass)[3],"0.00") + "radian";
angledeg= getB(xCompass, yCompass)[3]*180/Math.PI;
fieldValueAngledeg = "math_failure (math_unknown_error): \\theta = "+ _view.format(angledeg,"0.0") + "math_failure (math_unknown_error): \\degree ";
16April 2010
13 rearrange the buttons at the bottom to be more grouped logically
14 added flip magnet from SN to NS orientation!!!! figure out how to change the B field as well as the Get B
15 added accompanying graphics to the new orientation by doing a rotation 180 deg
17 change the evolution equation to domega/dt = -k*getB(xCompass, yCompass)[2]*(Math.sin(deltaTheta))-damp*omega so that the motion of the compass depends on the B strength at the location of the xCompass, yCompass.
18 change damping factor of compass to damp instead of b which was confusing to the calculations of b[0]....b[3] in the custom function
19 varied the value of k from 1 to 0.2 to simulate real life behavior closer less spring force constant since B vary from 0 to 225 arbitrary set by lookang
20 varied damp from 0.2 to 1 to simulate real life behavior closer damping higher more critically damped
19April2010
22 better color for the rombus by making 2 triangles one red and one blue
23 change my mind the red n blue combo didnt look good, revert to red and teal
24 made the compass background semi transparent to allow students to place the compass and read off the reading of B
25 found this http://phet.colorado.edu/simulations/sims.php?sim=Magnet_and_Compass to be excellent, well done to University of Colorado Design Team of # Michael Dubson # Chris Malley (developer) # Kathy Perkins # Carl Wieman * Interviewer: Danielle Harlow * Interviewer: Archie Paulson
Kudo!
26 added rotation to the bar magnet thanks to Hwang http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1582.0 thansk to transformation:
$X=x \cos\theta+ y\sin\theta$
$Y=-x\sin\theta+ y\cos\theta$
for all the coordinates (magnet, compass, field)
27 added code +cta to barmagnet to make drawing follow the rotation correctly
28 fixed a bug is the calculation of B field
Code:
double dx=x-(dipoles[i][0]*cs+dipoles[i][1]*sc)-(xMagnet*cs+yMagnet*sc);//FKH
double dy=y-(-dipoles[i][0]*sc +dipoles[i][1]*cs)-(-xMagnet*sc+yMagnet*cs);//FKH
[/s]   by applying the transformation to the dipoles as well.
25April 2010
29 think double[] b = getB(xCompass*cs+yCompass*sc,-xCompass*sc+yCompass*cs); //FKH and fieldValue="B= "+_view.format(getB(xCompasstransform, yCompasstransform)[2],"0.00")+" T"; in fixed relationship fix the problem of 28
30 replaced x' y' of Bx By |B| theta' of the axes of magnet coordinate system with the new universal x y system
31 added codes to make the inside of magnet work again for any angle of rotation cta of the bar magnet
32 fixed the hide magnet to work with angle cta
33 setup the dipoles perfectly to achieve symmetry in reading of B.
Code:
// spacing done by lookang to achieve perfectly symmetry of B
// need nd =22 because from x =-0.5 to 0.5 put 11 each row
// 2 rows so nd = 11*2 =22

double dx=1.0/(nd-2); //set up dipoles under bar magnet
// dx = (0.5-(-0.5))/20 so that dx = 0.1
for(int i=0; i<=(nd-1); i+=2) {
dipoles[i][0]=-0.5+i*dx; // x position of first line of dipoles bottom
dipoles[i][1]=-.04; // y position move down by -0.04 of first line of dipoles bottom
dipoles[i+1][0]=-0.5+i*dx; // x position of 2nd line of dipoles top
dipoles[i+1][1]=0.04; // y position move up by +0.04 of top line of dipoles bottom
}
34 added earth http://www.squarecirclez.com/blog/intmath-newsletter-earth-geometry-board-math-and-obama-math/1415 by using Gimp to alter the transparency of the google earth picture with reduce icon for the checkbox image

21 appears to have a runtime bug http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1576.0 if you move the compass like mad very quickly sometimes it cause a ArrayIndexOutOfBoundsException: 20 error.

Things i noted when i was at Fiesso D\'artico,Veneto,Italy Sept 24 2009 during my stay at Italy MPTL 14
International Workshop on
Multimedia in Physics Teaching and Learning 14th edition
23-25 September 2009
Rizzi Scientific Campus
University of Udine, Italy!! http://www.fisica.uniud.it/URDF/mptl14/WEB_Booklet.pdf
things i want to do but can't figure out yet.
a flip magnet simulation possibility DONE!
better color for the rombus <> blue and red instead of the current teal and red.
[/s] DONE!
 800px-Kompas_Sofia.jpg (2.85 KB, 38x28 - viewed 640 times.) *** There are 2 more attached files. You need to login to acces it! « Last Edit: October 04, 2010, 09:34:15 am by lookang » Logged
lookang
Moderator
Hero Member

Offline

Posts: 1784

http://weelookang.blogspot.com

 « Embed this message Reply #2 on: December 09, 2009, 11:11:26 pm » posted from:Singapore,,Singapore

http://www.davidcolarusso.com/blog/

Enjoy!

YouTube. Was stuck at Portland airport from 11pm to 4am, decided to use the time to make some promotional video on the applets shared during 2010 AAPT Summer Meeting in Portland, Oregon
 « Last Edit: July 26, 2010, 09:24:10 pm by lookang » Logged
Coffee makers
watchlist

Offline

Posts: -5

Nice post thanks
 « Last Edit: December 17, 2009, 03:27:53 pm by lookang » Logged
lookang
Moderator
Hero Member

Offline

Posts: 1784

http://weelookang.blogspot.com

 « Embed this message Reply #4 on: April 14, 2010, 04:32:20 pm » posted from:Singapore,,Singapore

14April 2010
9 added codes to make the inside of the magnet Bx = 225 T, By = 0 T
10 modify the getBComputeField() to work for the Field only and the getB work for the compass
11 added MagneticFieldStrength B is affected by the slider by a factor of 0 to 1 by using vectorfieldmaxopposite can changing it the double solve the bug of displaying 0 or 225 cause by the integer type initially assigned by original authors
12 learn a new code from open source physics _view.format(getB(xCompass, yCompass)[1],"0.00")
Code:
fieldValueBx="B_{x}= "+_view.format(getB(xCompass, yCompass)[0],"0.00")+" T";
fieldValueBy="B_{y}= "+_view.format(getB(xCompass, yCompass)[1],"0.00")+" T";
fieldValueAngle="math_failure (math_unknown_error): \\theta = "+_view.format(getB(xCompass, yCompass)[3],"0.00") + "radian";
angledeg= getB(xCompass, yCompass)[3]*180/Math.PI;
fieldValueAngledeg = "math_failure (math_unknown_error): \\theta = "+ _view.format(angledeg,"0.0") + "math_failure (math_unknown_error): \\degree ";

 barmagnet01.PNG (41.76 KB, 724x495 - viewed 417 times.)  Ejs Open Source Bar Magnet Model java applet.png (96.52 KB, 847x669 - viewed 599 times.) « Last Edit: April 16, 2010, 11:37:40 pm by lookang » Logged
lookang
Moderator
Hero Member

Offline

Posts: 1784

http://weelookang.blogspot.com

 « Embed this message Reply #5 on: April 16, 2010, 11:37:20 pm » posted from:Singapore,,Singapore

16April 2010
13 rearrange the buttons at the bottom to be more grouped logically
14 added flip magnet from SN to NS orientation!!!! figure out how to change the B field as well as the Get B
15 added accompanying graphics to the new orientation by doing a rotation 180 deg
17 change the evolution equation to domega/dt = -k*getB(xCompass, yCompass)[2]*(Math.sin(deltaTheta))-damp*omega so that the motion of the compass depends on the B strength at the location of the xCompass, yCompass.
18 change damping factor of compass to damp instead of b which was confusing to the calculations of b[0]....b[3] in the custom function
19 varied the value of k from 1 to 0.2 to simulate real life behavior closer less spring force constant since B vary from 0 to 225 arbitrary set by lookang
20 varied damp from 0.2 to 1 to simulate real life behavior closer damping higher more critically damped

There appears to be a runtime bug, the applet hangs if there is on drag on the compass for a long time, it jams, strange. how to fix ? hmmmm
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.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)

but in
public void _method_for_hideField_actionoff () { // line 634
hideField=false; // line 635
computeField(); // line 636
}  // line 637 there is nothing strange
 « Last Edit: April 17, 2010, 12:50:14 am by lookang » Logged
ahmedelshfie
Ahmed
Hero Member

Offline

Posts: 954

 « Embed this message Reply #6 on: April 17, 2010, 02:08:26 am » posted from:,,Brazil

IS very interesting that you Edit src code Prof
 Logged
lookang
Moderator
Hero Member

Offline

Posts: 1784

http://weelookang.blogspot.com

 « Embed this message Reply #7 on: April 17, 2010, 07:19:12 am »

I have written down here what I learnt and made the original applet into a learning object that I would use.
That how I benefit the world
u can do it 2 , and it is really fun, but tough fun.
 *** There are 8 more attached files. You need to login to acces it! « Last Edit: April 24, 2010, 09:30:12 pm by lookang » Logged
lookang
Moderator
Hero Member

Offline

Posts: 1784

http://weelookang.blogspot.com

 « Embed this message Reply #8 on: April 25, 2010, 10:35:23 pm »

still working on it
 asiaglobegoogleearth.png (202.45 KB, 336x328 - viewed 449 times.)  googleearth.png (174.44 KB, 336x328 - viewed 466 times.) « Last Edit: April 26, 2010, 12:50:03 pm by lookang » Logged
lookang
Moderator
Hero Member

Offline

Posts: 1784

http://weelookang.blogspot.com

 « Embed this message Reply #9 on: April 26, 2010, 01:04:01 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

Ejs Open Source Bar Magnet & Compass Model with Earth visualization java applet.
This now has great features, thanks to Wolfgang Christian, Francisco Esquembre, and Anne Cox for sharing their original applet, special thanks to Fu-Kwun Hwang for mentoring this learning community, support the development of this new and improved Ejs Open Source Bar Magnet & Compass Model with Earth visualization java applet.
This has been a great learning journey for me
Enjoy!
Attached are the pictures of the last remix and the powerup rotation remix thanks to Prof Fu-Kwun Hwang.
 Ejs Open Source Bar Magnet Model java applet.png (96.52 KB, 847x669 - viewed 423 times.)  Ejs_Open_Source_Bar_Magnet_&_Compass_Model_with_Earth_visualization_java_applet.png (272.64 KB, 1024x738 - viewed 448 times.) Logged
 Pages: [1]   Go Up
"Choose a job you love, and you will not have to work for a day in your life." ...Confucius (551-479 BC)