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

## Easy Java Simulations (2001- ) => Electromagnetism => Topic started by: Fu-Kwun Hwang on August 13, 2008, 08:43:04 am

 Title: Magnetic field generated bar magnet Post by: Fu-Kwun Hwang on August 13, 2008, 08:43:04 am You can drag the magnetic neddle to generate another sets of magnetic field line when the simulation is in pause state (when it finish generate the field line or click pause button). Title: Re: Magnetic field generated bar magnet Post by: lookang on August 13, 2008, 06:07:21 pm my journey:1. added mbar.gif graphics into folder _data/mbar.gifso now i can compile it n it works nicely.question:reference:http://upload.wikimedia.org/math/5/f/f/5ff6494ee391f0ac7cfd0da8851422f3.pngcan explain is this the Biot–Savart law you used to model the magnetic feild lines?  (http://upload.wikimedia.org/math/5/f/f/5ff6494ee391f0ac7cfd0da8851422f3.png)compare it with the codeCode:double r2,r3,f;// caluclate magnetic field at point xp,yp use Biot-Savart Law Fproportional to dlXr/r^3public double calFx (double xp,double yp) { f=0; for(int i=0;i  for(int j=0;j   r2=(xp-xc[j])*(xp-xc[j])+(yp-yc[i])*(yp-yc[i])+zc[i]*zc[i];   r3=r2*Math.sqrt(r2);   f-=(yc[i]*(yp-yc[i])-zc[i]*zc[i])/r3;  } } return f;}public double calFy (double xp,double yp) { f=0; for(int i=0;i  for(int j=0;j   r2=(xp-xc[j])*(xp-xc[j])+(yp-yc[i])*(yp-yc[i])+zc[i]*zc[i];   r3=r2*Math.sqrt(r2);   f+=yc[i]*(xp-xc[j])/r3;  } } return f;}it looks different, sorry it is difficult to follow, as Biot-Savart Law i don't have a deep understandingi am usuallly on MSN microsoft messager : lookang , can add me as frd then maybe we can arrange to discuss the applet? Title: Re: Magnetic field generated bar magnet Post by: Fu-Kwun Hwang on August 14, 2008, 11:53:27 pm Original form for Biot-Savart Law is$d\vec{B}=\frac{\mu_0}{4\pi} \frac{I\,d\vec{l}\times\hat{r}} {r^2}$For the calculation in the code. I use another variable(cst) to represent $\frac{\mu_o\, I}{4\pi}$And transform $\frac{I\,d\vec{l}\times\hat{r}}{r^2}$ into $\frac{I\,d\vec{l}\times\vec{r}}{r^3}$Where $\hat{r}= \frac{\vec{r}}{r}$.$\vec{l}$ is in y-z plane. corresponds to (yc,zc) in the code.and $\vec{r}$ corresponds to (xp-xc,yp-yc,zc)Then calculate the cross product for the above two vector.The integration is done by sum of components from all the coil segments. Title: Re: Magnetic field generated bar magnet Post by: lookang on September 24, 2009, 02:23:56 am good sharing by W. K. Adams, Co-Director PhET Interactive Simulations University of Colorado, Boulder, USAhttp://www.fisica.uniud.it/URDF/mptl14/dtlprogramme.htmhttp://phet.colorado.edu/simulations/sims.php?sim=Faradays_Electromagnetic_Lab#topicsmost popular hit http://www.walter-fendt.de/ph14e/mfbar.htmGold mine find written by Wolfgang Christian, Francisco Esquembre, and Anne Cox http://www.compadre.org/osp/document/ServeFile.cfm?ID=9414&DocID=1310#Doc1310 Title: Re: Magnetic field generated bar magnet Post by: lookang on September 28, 2009, 09:00:19 am there is a remix version herehttp://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1210msg4759;topicseen#msg4759(http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=1210.0;attach=1367;image)enjoy