MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / dipole

Method dipole

src/org/opensourcephysics/display2d/TestData.java:21–28  ·  view source on GitHub ↗

Dipole distribution with poles at +1 and -1 on the x axis.

(double x, double y)

Source from the content-addressed store, hash-verified

19 * Dipole distribution with poles at +1 and -1 on the x axis.
20 */
21 public static double dipole(double x, double y) {
22 double r1 = Math.sqrt((x-1)*(x-1)+y*y);
23 double r2 = Math.sqrt((x+1)*(x+1)+y*y);
24 if((r1==0)||(r2==0)) {
25 return 0.0; // potential is undefined at r=0.
26 }
27 return 1/r1-1/r2;
28 }
29
30 /**
31 * A 2D Gaussian distribution function centered at x=0 and y=0 and standard deviation of 1.

Callers 1

dipoleScalarFieldMethod · 0.95

Calls 1

sqrtMethod · 0.80

Tested by

no test coverage detected