[The dipole electrostatic potential.]

Week 9 Notes: Scalar and Vector Fields

We study scalar and vector fields in 2D and learn how to solve Laplace's equation using the relaxation method.

Dipole Field

A quantity, such as temperature, that has a numerical value at every point in space is a scalar field.  The Dipole Field Model displays the potential produced by an electrostatic dipole.  The potential field's values are computed on a grid defined as the potential[][] array in the Fixed Relation workpanel.

//scalar field is computed at each grid point
double d=separation/2;
for(int i=0; i<m; i++) {                         // loop over grid x
  double xi= _view.scalarField.indexToX(i);      // x-coordinate of grid point
  for(int j=0; j<m; j++) {                       // loop over grid y
    double yj= _view.scalarField.indexToY(j);    // y-coordinate of grid point
    double p1=-1.0/Math.sqrt((xi-d)*(xi-d)+yj*yj);
    double p2=1.0/Math.sqrt((xi+d)*(xi+d)+yj*yj);
    potential[i][j]=p1+p2;  // potential value
  } // end of y loop
} // end of x loop

The Fixed Relation code has two nested loops. The i-loop iterates through the grid's x-values and the j-loop iterates through the grid's y-values.  Note how we obtain the x-y vales at the grid points.

Related Models

The following EJS models demonstrate how to display two-dimensional scalar and vector fields using elements on the fields and plots tab on the EJS 2D Drawables palette.

Credits:

The Dipole Field Model was created by Wolfgang Christian using the Easy Java Simulations (EJS) version 4.1 authoring and modeling tool.  You can examine and modify a compiled EJS model if you run the model (double click on the model's jar file), right-click within a plot, and select "Open Ejs Model" from the pop-up menu.  You must, of course, have EJS installed on your computer.

 

Information about Ejs is available at: <http://www.um.es/fem/Ejs/> and in the OSP comPADRE collection <http://www.compadre.org/OSP/>.