(* Near field ⟹ d/100 ≤ y ≤ d/10 or π/200 ≤ \(y\&^\) ≤ π/10 planar electrode array surface *)

d =. ; Vo =. ; d2 = 2*d; 
      xh =. ; yh =. ;

Ex = ((2*Vo)/(Pi*d))*(ArcTan[Sin[xh]/Sinh[yh]] - 
            ArcTan[Cos[xh]/Sinh[yh]])

Ey = 
      (Vo/(Pi*d))*
        Log[((Cosh[yh] + Cos[xh])/(Cosh[yh] - Cos[xh]))*((Cosh[yh] + Sin[xh])/(Cosh[yh] - Sin[xh]))]

Exx = ((2*Vo*
              Sinh[yh])/(d^2)) (Cos[xh]/(Cosh[2*yh] - Cos[2*xh]) + 
            Sin[xh]/(Cosh[2*yh] + Cos[2*xh]))

Exy = ((2*Vo*
              Cosh[yh])/(d^2)) (Cos[xh]/(Cosh[2*yh] + Cos[2*xh]) - 
            Sin[xh]/(Cosh[2*yh] - Cos[2*xh]))

Eyx = Exy; Eyy = -Exx;

grdE2x = 2*(Ex*Exx + Ey*Eyx);grdE2y = 2*(Ex*Exy + Ey*Eyy);

d = 1; Vo = 1; d2 = 2*d; y = 0.1*d ; xhmn = 0; xhmx = 2*Pi;

yh = Pi*y/(2*d)

yh = π/20;  
    Plot[Ex, {xh, xhmn, xhmx}, PlotRange -> {-2, 2}]

yh = π/20; 
    Plot[Ey, {xh, xhmn, xhmx}, PlotRange -> {-2, 2}]

yh = π/20;Plot[Exx, {xh, xhmn, xhmx}, 
      PlotRange -> {-7, 7}]

yh = π/20; 
    Plot[Exy, {xh, xhmn, xhmx}, PlotRange -> {-5, 5}]

yh = π/20; 
    Plot[grdE2x, {xh, xhmn, xhmx}, 
      PlotRange -> {-15, 15}]

yh = π/20; 
    Plot[grdE2y, {xh, xhmn, xhmx}, PlotRange -> {-30, 1}]

yh = π/20; 
    Plot[Exx*Ey, {xh, xhmn, xhmx}, PlotRange -> {-1, 11}]

yh = π/20; 
    Plot[Eyx*Ex, {xh, xhmn, xhmx}, PlotRange -> {-7, 2}]

(* Plots and results for thesis ch 6.3  & Appendix 6  C  .2  *)

yh =. ;EyATh2=(Vo/(Pi*d))*(Log[4] - 
              2 Log[yh] - ((2*(xh^2))/((xh^2) + 2 (yh^2))) + 2*xh)

yh = 0.1570796;Plot[{Ey,EyATh2},{xh, -Pi/4, Pi/4},PlotRange -> {0, 2},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]}}]

yh = 0.01570796;Plot[{Ey,EyATh2},{xh, -Pi/4, Pi/4},PlotRange -> {0, 3.5},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]}}]

yh =. ; 
    ExxATh1 = ((Vo*yh)/(d^2))*((1/((yh^2)  + (xh^2))) + 
            (xh/(1 - (xh^2))))

yh = 0.157079632;Plot[{Exx,ExxATh1},{xh, -Pi/4, Pi/4},PlotRange -> {0, 7},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]}}]

yh = 0.0157079632;Plot[{Exx,ExxATh1},{xh, -Pi/4, Pi/4},PlotRange -> {0, 70},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]}}]

yh = π/20;Plot[{Ey*Exx,EyATh2*ExxATh1},{xh, -Pi/4, Pi/4},PlotRange -> {0, 10.5},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]} }]

yh = 0.0157079632;Plot[{Ey*Exx,EyATh2*ExxATh1},{xh, -Pi/4, Pi/4},PlotRange -> {-1, 200},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]} }]

yh =. ; b = Pi/4;

I1Th = 
      2*(Log[4] - 2*Log[yh] + 2)*ArcTan[(b/yh)] - 
        4*(Sqrt[2])*ArcTan[(b/(yh*(Sqrt[2])))]

yh =. ; 
    I2Th = N[2*Log[((4 + π)/(4 - π))] - π]*yh

IEyExxATh1 =  ((-8*(Vo^2))/((π^2)*(d^3))) (I1Th)

IEyExxATh12 =  ((-8*(Vo^2))/((π^2)*(d^3))) (I1Th + 
            I2Th)

Plot[{-(16/(2*π))*NIntegrate[Ey*Exx,{xh, ((-Pi)/4), (Pi/4)}],(4/(2*π))*(NIntegrate[grdE2y, {xh, (Pi/4), (Pi/2) - (Pi/10)}]+NIntegrate[
                      grdE2y, {xh, (Pi/2) - (Pi/10), (Pi/2) + (Pi/10)}]+NIntegrate[
                      grdE2y, {xh, (Pi/2) + (Pi/10), (Pi/2) + (Pi/4)}]),((-16)/(2*π))*NIntegrate[EyATh2*ExxATh1,{xh, ((-Pi)/4), (Pi/4)}],IEyExxATh1,IEyExxATh12},{yh, Pi/200, Pi/5},PlotRange -> {-25, 0},PlotStyle->{{RGBColor[1, 0, 0]},{RGBColor[0,1,1],Dashing[{0.01, 0.01}]},{RGBColor[0, 0, 1]},{RGBColor[0,1,0],Dashing[{0.05, 0.05}]},{RGBColor[1, 0, 1],Dashing[{0.03, 0.03}]}}]

yh = Pi/200;a = 0;Int1=NIntegrate[grdE2y, {xh, a + (Pi/4), a + (Pi/2) - (Pi/10)}]+NIntegrate[
              grdE2y, {xh, a + (Pi/2) - (Pi/10), a + (Pi/2) + (Pi/10)}]+NIntegrate[
              grdE2y, {xh, a + (Pi/2) + (Pi/10), a + (Pi/2) + (Pi/4)}]

yh = Pi/200;a = Pi/2;Int2=NIntegrate[grdE2y, {xh, a + (Pi/4), a + (Pi/2) - (Pi/10)}]+NIntegrate[
              grdE2y, {xh, a + (Pi/2) - (Pi/10), a + (Pi/2) + (Pi/10)}]+NIntegrate[
              grdE2y, {xh, a + (Pi/2) + (Pi/10), a + (Pi/2) + (Pi/4)}]

yh = Pi/200;a = Pi;Int3=NIntegrate[grdE2y, {xh, a + (Pi/4), a + (Pi/2) - (Pi/10)}]+NIntegrate[
              grdE2y, {xh, a + (Pi/2) - (Pi/10), a + (Pi/2) + (Pi/10)}]+NIntegrate[
              grdE2y, {xh, a + (Pi/2) + (Pi/10), a + (Pi/2) + (Pi/4)}]

yh = Pi/200;a = 3*Pi/2;Int4=NIntegrate[grdE2y, {xh, a + (Pi/4), a + (Pi/2) - (Pi/10)}]+NIntegrate[
              grdE2y, {xh, a + (Pi/2) - (Pi/10), a + (Pi/2) + (Pi/10)}]+NIntegrate[
              grdE2y, {xh, a + (Pi/2) + (Pi/10), a + (Pi/2) + (Pi/4)}]

checkpoint = (1/(2*Pi)) (Int1 + Int2 + Int3 + Int4)

yh = Pi/200;a = 0;Inx1=NIntegrate[grdE2x, {xh, a + (Pi/4), a + (Pi/2) - (Pi/10)}]+NIntegrate[
              grdE2x, {xh, a + (Pi/2) - (Pi/10), a + (Pi/2) + (Pi/10)}]+NIntegrate[
              grdE2x, {xh, a + (Pi/2) + (Pi/10), a + (Pi/2) + (Pi/4)}]

yh = Pi/200;a = Pi/2;Inx2=NIntegrate[grdE2x, {xh, a + (Pi/4), a + (Pi/2) - (Pi/10)}]+NIntegrate[
              grdE2x, {xh, a + (Pi/2) - (Pi/10), a + (Pi/2) + (Pi/10)}]+NIntegrate[
              grdE2x, {xh, a + (Pi/2) + (Pi/10), a + (Pi/2) + (Pi/4)}]

(* output plot for thesis ch 6.3 - full non-dashed lines have handles useful for re-dashing by Word 2000 editor The plots show the green approximation is good & justisfies its subsequent application *)
Plot[{-(16/(2*π))*NIntegrate[Ey*Exx,{xh, ((-Pi)/4), (Pi/4)}],(4/(2*π))*(NIntegrate[
                        grdE2y, {xh, (Pi/4), (Pi/2) - (Pi/10)}] + 
                      NIntegrate[
                        grdE2y, {xh, (Pi/2) - (Pi/10), (Pi/2) + (Pi/10)}] + 
                      NIntegrate[
                        grdE2y, {xh, (Pi/2) + (Pi/10), (Pi/2) + (Pi/4)}]),((-16)/(2*π))*NIntegrate[EyATh2*ExxATh1,{xh, ((-Pi)/4), (Pi/4)}],IEyExxATh1,IEyExxATh12},{yh, Pi/200, Pi/5},PlotRange -> {-25, 0},PlotStyle->{{RGBColor[1, 0, 0]},{RGBColor[0,1,1]},{RGBColor[0, 0, 1]},{RGBColor[0,1,0]},{RGBColor[1, 0, 1]}}]

Plot[{-(16/(2*π))*NIntegrate[Ey*Exx,{xh, ((-Pi)/4), (Pi/4)}],(4/(2*π))*(NIntegrate[grdE2y, {xh, (Pi/4), (Pi/2) - (Pi/10)}]+NIntegrate[
                      grdE2y, {xh, (Pi/2) - (Pi/10), (Pi/2) + (Pi/10)}]+NIntegrate[
                      grdE2y, {xh, (Pi/2) + (Pi/10), (Pi/2) + (Pi/4)}]),((-16)/(2*π))*NIntegrate[EyATh2*ExxATh1,{xh, ((-Pi)/4), (Pi/4)}],IEyExxATh1,IEyExxATh12},{yh, Pi/200, Pi/20},PlotRange -> {-25, -9},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 1, 1], 
              Dashing[{0.01, 0.01}]}, {RGBColor[0, 0, 1]}, {RGBColor[0, 1, 
                0], Dashing[{0.05, 0.05}]}, {RGBColor[1, 0, 1], 
              Dashing[{0.03, 0.03}]}}]

yh = Pi/20;-(16/(2*π))*NIntegrate[Ey*Exx,{xh, ((-Pi)/4), (Pi/4)}]

yh = Pi/20;-(16/(2*π))*NIntegrate[EyATh2*ExxATh1,{xh, ((-Pi)/4), (Pi/4)}]

yh =. ; a = 1/10; 
    AvGrdE2Near1 = ((-16*(Vo^2))/(π*(d^3))) (N[Log[2/a] + 3 - (Sqrt[2])]/(1 + yh/a))

yh =. ; a = π/25; 
    AvGrdE2Near2 = ((-16*(Vo^2))/(π*(d^3))) (N[Log[2/a] + 3 - (Sqrt[2])]/(1 + yh/a))

yh =. ; a = π/35; 
    AvGrdE2Near3 = ((-16*(Vo^2))/(π*(d^3))) (N[Log[2/a] + 3 - (Sqrt[2])]/(1 + yh/a))

(* output plot for thesis ch 6.3The plots show either blue a = 1/10 or green a  =  
            Pi/25 gives a satisfactory approximation to the red *)

yh =. ;Plot[{-(16/(2*π))*NIntegrate[Ey*Exx,{xh, ((-Pi)/4), (Pi/4)}],AvGrdE2Near1,AvGrdE2Near2},{yh, Pi/200, Pi/5},PlotRange -> {-23, 0},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]}, {RGBColor[0, 1, 0]}, {RGBColor[1, 0, 1]}}]

yh =. ;Plot[{-(16/(2*π))*NIntegrate[Ey*Exx,{xh, ((-Pi)/4), (Pi/4)}],AvGrdE2Near1,AvGrdE2Near2,AvGrdE2Near3},{yh, Pi/200, Pi/20},PlotRange -> {-23, -10},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]}, {RGBColor[0, 1, 0]}, {RGBColor[1, 0, 1]}}]

(* Another ' point' yh = 
          Pi/200 check that numerical integration is correct *)

yh = Pi/200;-(16/(2*π))*NIntegrate[Ey*Exx,{xh, ((-Pi)/4), (Pi/4)}]

(* \(computation\ of\ constant, \ \(y\&^\), \ \(\(y\&^\)\^2\ terms\ for\ thesis\ ch\ 6.3\ appendix\ 6  
              C  .2\ eqns\ \((6  C  .2  .25)\)\  &\)\ \((6  C  .2  .31)\)\)  *)

yh =. ; a = 1/10; yh0term = N[Log[2/a] + 3 - (Sqrt[2])]

yh =. ; a = 1/10;  
    yh1term = 
      N[((Log[2/a] - 1 - (Sqrt[2]))/a) - 
          (8/(π^2))*(Log[(2/a)] + 1)]

yh1term*π/20

yh =. ; a = 1/10; 
    yh2term = N[(8/(a*(π^2)))*(3 - Log[(2/a)])]

yh2term*(π^2)/(20^2)

yh =. ; a = π/20; yh0term = N[Log[2/a] + 3 - (Sqrt[2])]

yh =. ; a = π/20;  
    yh1term = 
      N[((Log[2/a] - 1 - (Sqrt[2]))/a) - 
          (8/(π^2))*(Log[(2/a)] + 1)]

yh1term*π/20

yh =. ; a = π/20; 
    yh2term = N[(8/(a*(π^2)))*(3 - Log[(2/a)])]

yh2term*(π^2)/(20^2)

yh =. ; a = π/25; yh0term = N[Log[2/a] + 3 - (Sqrt[2])]

yh =. ; a = π/25;  
    yh1term = 
      N[((Log[2/a] - 1 - (Sqrt[2]))/a) - 
          (8/(π^2))*(Log[(2/a)] + 1)]

yh1term*π/20

yh =. ; a = π/25; 
    yh2term = N[(8/(a*(π^2)))*(3 - Log[(2/a)])]

yh2term*(π^2)/(20^2)

yh =. ; a = 1/10; 
    AvGrdE2Near1 = ((-16*(Vo^2))/(π*(d^3))) (N[Log[2/a] + 3 - (Sqrt[2])]/(1 + yh/a))

yh =. ; 
    grdE2yFar = -((32*(Vo^2))/(π*(d^3)))*
        Exp[-2*yh]

yh =. ;Plot[{-(8/π)*NIntegrate[Ey*Exx,{xh, ((-Pi)/4), (Pi/4)}],AvGrdE2Near1,grdE2yFar},{yh, Pi/200, Pi/2},PlotRange -> {-23, 0},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]}, {RGBColor[0, 1, 0]}, {RGBColor[0, 1, 1]}}]

yh =. ; 
    grdE2ymodel = ((-16)/(2*π))*IEyExxA6*
          Exp[-(20/π)*(yh - (π/200))] + ((-32)/π)*(1 - Exp[-(20/π)*(yh - (π/200))])*Exp[-2*yh]

yh =. ;a = Pi/25;Plot[{-(16/(2*π))*NIntegrate[Ey*Exx,{xh, ((-Pi)/4), (Pi/4)}],AvEyExxA,grdE2yFar,grdE2ymodel},{yh, Pi/200, Pi/2},PlotRange -> {-30, 0},PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 
                  1]}, {RGBColor[0, 1, 0]}, {RGBColor[0, 1, 1]}}]