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

Easy Java Simulations (2001- ) => Collaborative Community of EJS => Topic started by: lookang on September 30, 2010, 10:22:58 pm



Title: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on September 30, 2010, 10:22:58 pm
Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visualization Representation Java Applet by Hwang Fu-Kwun. I did not make this, i only slightly edited it.


reference:
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=539.new#new

You can drag either charge and find out the new electric Field Vector, Field Lines, Potential distribution, need to release the charge for simulation to recalculate.


The field line are calculated in real time. However, please remember field line is not the same as trajectory for a test charge move in the same field.  
You can add test charge if the check box were checked and watch the trajectory of test charge.

It is easy to draw those vectors which represent electric field at different positions.
Because we can calculate the electric field with $\vec{E}=\frac{kq_1}{r_1^2}\hat{r_1}+ \frac{kq_2}{r_2^2}\hat{r_2}$.
However, do you know how those field lines were calculated?

Hint: The tangential components of electric field line is the same as the direction of electric field at the same point.
Answer is
Biot–Savart law ! http://en.wikipedia.org/wiki/Biot%E2%80%93Savart_law
[ejsapplet]


Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on September 30, 2010, 10:27:08 pm
changes

1 color scheme
2 reposition Q1 and Q2 to correspond to the same side of the slider with color scheme, follow the physlet color scheme
3 Potential = Contour, rename
4 text Q1 and Q2
05 august
added the field lines arrow heads from http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=539.new#new
add more functions in terms of the slider options



Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on August 05, 2011, 03:49:42 pm
05 august
added the field lines arrow heads from http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=539.new#new
add more functions in terms of the slider options

finished remixing!
enjoy


reference:
Dhasthagheer Akbhar
I need example EJS simulation which used "Model methods to control EJS applets using Java Script" . If I look the code, it will help me lot. I am developing physics simulation for 6 th std students to learn physics interactively. Thanks in advance......

please download the attachment called ejs_group.zip
which has a html file on the simulation inside the folder
it has the java script generated from Ejs that controls the simulation


Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on September 07, 2011, 03:16:31 am
additional changes, added on 07 September 2011

added value of potential to be shown adapted codes from http://www.compadre.org/OSP/items/detail.cfm?ID=11443 Point Charge Electric Potential Model written by Wolfgang Christian
// adapted from http://www.compadre.org/OSP/items/detail.cfm?ID=11443
// adapted from http://www.compadre.org/OSP/items/detail.cfm?ID=11443
public void potentialMessage () {
  double xm=_view.DrawingPanel.getMouseX();   // mouse x-location
  double ym=_view.DrawingPanel.getMouseY();   // mouse y-location
  double v=0;
//  for(int p=0; p    double dx=xm-x1; // for first charge                        // x-separation from grid point
    double dy=ym-y1;                         // y-separation from grid point
    double r2=dx*dx+dy*dy;             // charge to grid point distance squared
    double dx2=xm-x2; // for second charge                        // x-separation from grid point
    double dy2=ym-y2;                         // y-separation from grid point
    double r22=dx2*dx2+dy2*dy2;             // charge to grid point distance squared
    
    if(r2==0||r22==0){                                 // check for singularity
      v=Double.NaN;                            // field is not defined at singularity
//      break;                                   // break from loop  
    }else{                                
      v = k*q1/Math.sqrt(r2)+k*q2/Math.sqrt(r22);      // add scalar potential
//      Evalue = G*q1/r2+G*q2/r2;
    } // end of if statement
//  } // end of charge loop
  dragMsg="V = "+_view.format(v,"0.0E0")+ " J/C";
//  dragMsgE="g = "+_view.format(Evalue,"0.0E0")+ " N/kg";
  
}


added value of field strength to be shown redesigned by myself with reference and using http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=539.0
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1968.0 by Fu-Kwun Hwang.

// adapted from http://www.compadre.org/OSP/items/detail.cfm?ID=11443
// adapted from http://www.compadre.org/OSP/items/detail.cfm?ID=11443
public void fieldMessage () {
  double xm=_view.DrawingPanel.getMouseX();   // mouse x-location
  double ym=_view.DrawingPanel.getMouseY();   // mouse y-location
  double Evalue=0;
//  for(int p=0; p    double dx1=xm-x1;   //first charge                      // x-separation from grid point
    double dy1=ym-y1;                         // y-separation from grid point
    double r12=dx1*dx1+dy1*dy1;                     // charge to grid point distance squared
     double dx2=xm-x2;    //second charge                     // x-separation from grid point
    double dy2=ym-y2;                         // y-separation from grid point
    double r22=dx2*dx2+dy2*dy2;             // charge to grid point distance squared
double dx=q1*dx1/(r12*Math.sqrt(r12))+q2*dx2/(r22*Math.sqrt(r22));
double  dy=q1*dy1/(r12*Math.sqrt(r12))+q2*dy2/(r22*Math.sqrt(r22));  
double d=Math.sqrt(dx*dx+dy*dy);
double   Evaluex=dx;
double   Evaluey=dy;
//double Evalue = Math.sqrt(Evaluex*Evaluex+Evaluex*Evaluex);
 if(r12==0||r22==0){                                 // check for singularity
      Evaluex=Double.NaN;                            // field is not defined at singularity
     Evaluey=Double.NaN;
//      break;                                   // break from loop
    }else{                                
   Evaluex=k*dx;
   Evaluey=k*dy;
Eangle = Math.atan2(Evaluey,Evaluex)*180/pi;  
//      v = G*q1/Math.sqrt(r2)+G*q2/Math.sqrt(r2);      // add scalar potential
    Evalue = Math.sqrt(Evaluex*Evaluex+Evaluey*Evaluey);
    } // end of if statement
 // } // end of charge loop
//  dragMsg="V = "+_view.format(v,"0.0E0")+ " V";
  dragMsgEx="Ex = "+_view.format(Evaluex,"0.0E0")+ " N/C";
    dragMsgEy="Ey = "+_view.format(Evaluey,"0.0E0")+ " N/C";
    dragMsgE="|E| = "+_view.format(Evalue,"0.0E0")+ " N/C at angle =" +_view.format(Eangle,"000") +" degree to +x-axis counterclockwise";
    }



Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on January 09, 2013, 10:58:06 am
got a request from teacher

We are doing a PLC project cum lesson study on E-field using Java simulation as one of the ICT tool, in 3-4 weeks time.

We would like to request for your help to make the following modifications to the EJS:

1. ability to enter values instead of sliding bars.
done

2. What is the purpose of value of m=2.0?
to experience inertia, F = m*a, so F constant, m double, a halved  

3. ability to show at a point X, the E-field due to charge A, E-field due to charge B and thus the resultant field.
added E1 and E2 and E with selectable check-box to show, only when m is selected


4. if possible (will be most ideal), can show E-field lines due to 3 charges. It appears in 2008 specimen paper.
i cannot do this, maybe you can show another applet
http://www.compadre.org/osp/items/detail.cfm?ID=9412





I have attached the .jar file for your reference.

Thank you.


Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on January 28, 2013, 02:48:22 pm
more discussion with teacher


My team have tested the EJS when designing our worksheet.
 
We find the following issues with the EJS.......
Error in field lines (refer to attached image):
1. The field lines are not drawn correctly. Everytime I vary the number of field lines, a different error in the field lines will appear.
Also, chances of error is particularly high if i use the slider bar to change the number of field lines. Error will likely occur when the EJS recalculate the field lines.
we solved the issue by allowing the Q2 to draw the field lines at different starting positions


 
Aesthetic:
1. colour scheme: can we request for light background contrasted with dark arrows and field lines.

background is actual an equal potential scalar plot, the sim now remembers what the student select, u can also disable it for a white background.
field lines are now black and thick.


 

2. Hide options to change colour of arrows, field lines and background. We felt it is not necessary for students to be able to change colour of arrows, field lines and background.


 
Thank you.


Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on January 30, 2013, 10:17:09 am
more discussion with teacher.

teacher disagree with the simulation as it shows field lines intersecting the null point in the center.
an example is this java applet from a website instead.
http://surendranath.tripod.com/Applets/Electricity/FieldLines/EFL.html

The imperfection is resolved. Enjoy
http://surendranath.tripod.com/Applets/Electricity/FieldLines/EFL.html is actually 2 fixed points with fixed lines, may not be so ‘inquiry enabled’.


i am not sure if this is correctly represented in http://surendranath.tripod.com/Applets/Electricity/FieldLines/EFL.html when
Q1 =1, Q2 = 5*Q1 for example.


Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on January 30, 2013, 10:23:24 am
more discussion with teacher


Can we have a centre line joining the +ve and -ve charges?

done.
Centre field line is drawn for +- case but missing in ++ or – cases.
I don’t understand why 3 more lines (first picture), I only understand the centre line (2nd picture).
The current field lines are drawn starting at equal distance around the circumference of the charge (scientifically accurate), so to get more lines, select a higher number of lines to draw.



Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on January 30, 2013, 11:05:24 am
tried to update the top post but cannot take the 12 version.

testing here Upload new EJS jar file.

ok it does not work now.
Hi prof Hwang, can check ?

i attached as attachment for your testing


Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on February 01, 2013, 12:58:19 pm
trying to add field lines as function of Q



Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: Fu-Kwun Hwang on February 07, 2013, 12:24:13 pm
Try to help you upload modified jar file.


Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on February 20, 2013, 01:02:59 pm
made the enhancement here
http://weelookang.blogspot.sg/2013/01/ajc-lesson-with-2-charges-simulation.html
made the enhancement to the electric field lines as proportional to strength of Q2.
thanks to goh khoon song for the feedback and use in his lessons.
Q1 is limited to -1 or 1, hence-fore.

download: https://dl.dropbox.com/u/44365627/lookangEJSworkspace/export/ejs_twopointcharges18q2work.jar
original authors: Fu-Kwun Hwang and lookang and szeyee
enjoy!



Title: Re: Ejs Open Source 2 Charge Model with Field Vector, Field Lines, Potential Visual
Post by: lookang on August 15, 2013, 07:41:28 am
he simulation has added a new feature, test charge polarity to simulate -e

enjoy!

(http://2.bp.blogspot.com/-xrSAvoJhsp8/UgwhpzU1ZpI/AAAAAAAAZvY/aKOkJKd5V6M/s640/charges_2013-08-14_1706up.PNG)
an electron test mass moving through the point of minimum potential between Q2 = +3C and Q1= +1C. the theoretical path is one that the test charge electron moves and oscillates in the curved path as shown. The slight loop shape in due to the unbalanced forces at a far distance that deviates the direction of the electron to go slightly towards to the Q1 in this case. 

(http://3.bp.blogspot.com/-95nMHHkH8qQ/Ugwjoac1HTI/AAAAAAAAZv8/xp3GTiuzjW0/s640/soilution_ajc_2013-08-15_0840.png)
solution to  2012 A level H2 P2 Q7d(ii) by jeffrey toh. and his team. thanks for sharing!