Dipole distribution with poles at +1 and -1 on the x axis.
(double x, double y)
| 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. |