\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*thickape . nb*) 


    Needs["Graphics`ComplexMap`"]
\)Off[General::spell1]\(Clear[V, a, b, c, d, e, t, ksq, frc, frksq, sgn10a, 

      	\ \ \ \ \ \ \ \ \ \ \ sgn10b, mult, tex1, \ nec, nef, neq, tcf, tcb]

    
		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ Input\ data	*) 
\)\(V\  = \ 1\  (*\ Potential\ on\ lower\ plate\ in\ Volt, \ 

      		\ \ \ \ \ \ 
      potential\ on\ upper\ plate\ \(( = \ median\ plane)\)\  = \ 0\ *) ; \ 

    
a\  = \ 3\ \  (*\ 
      Shortest\ distance\ between\ the\ plates\ in\ 
        \(mm\  : 
\ \ \ \ \ \ \ \ \ 
          for\ 2\ 10^\(-5\)\  < \ a\  < \ 10^5\)	*) ; 


    b = a/2\ \  (*\ 
      Half\ the\ thickness\ of\ the\ lower\ plate\ in\ 
        \(mm\  : 
\ \ \ \ \ \ \ \ \ \ 
          for\  .0003  a\  < \ b\  < \ 4.71  a\)\ *) \ ; 
\ \ \ \ \ \ \ \ \ 
    
nec\  = \ 20\  (*\ 
      Number\ of\ lines\ used\ in\ 3  D - 
        image\ of\ 
\ \ \ \ \ \ \ \ \ \ \ \ el . \ field`s\ absolute\ 
          \(value : \ absef3D10\)\ *) ; 


    nef\  = \ 7\  (*\ Number\ of\ field\ lines\ between\ plates; 

      \ \ \ \ \ \ \ \ \ \ \ \ 
      variable\ needed\ in\ the\ 
        \(pictures : \ 
\ \ \ \ \ \ \ \ \ \ \ \ eflandeqpl10\), \ efl10, \ 
      absefateflu10, \ absefateflv10, \ 
\ \ \ \ \ \ \ \ \ \ \ \ efuatefl10, 
      \ efvatefl10\ *) ; 


    neq\  = \ 11\  (*\ Number\ of\ equipotential\ lines\ between\ plates; 

      \ \ \ \ \ \ \ \ \ \ \ \ 
      variable\ needed\ in\ the\ 
        \(pictures : \ 
\ \ \ \ \ \ \ \ \ \ \ \ eflandeqpl10\), \ eqpll10, \ 
      absefateqplu10, \ 
\ \ \ \ \ \ \ \ \ \ \ \ absefataqplv10, \ 
      efuateqpl10, \ efvateqpl10\ *) ; 


    tcf\  = \  .005	 (*\ 
      Relative\ thickness\ of\ field\ or\ equipotential\ 

        		\ \ \ \ \ \ \ \ \ \ \ \ lines\ in\ color\ diagrams	*) ; 


    tcb\  = \  .011	 (*\ 
      Relative\ thickness\ of\ lines\ representing\ 

        		\ \ \ 	\ \ \ \ \ \ \ 	boundaries, \ electrodes, \ pole\ shoes, 
      \ \(etc . \)		*) ; 


    \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ 
      Global\ variables\ *) 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 

    mult\  = \ V\ 1000/a; \ tex1\  = \ "E [V/m]"; \ \ \ \ \ \ \ \ \ \ \ 

    \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 

    \ \ \  (*\ 
      Calculation\ of\ the\ modulus\^2\  = \ 
        ksq\ for\ the\ elliptic\ integrals\ *) 


    af100 =  .5 
        \((2  EllipticE[1 - ksq] - \((1 + ksq)\) EllipticK[1 - ksq])\)/

          			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
          \((EllipticK[ksq] \((1 - ksq)\) - 2  EllipticE[ksq])\); 

    frksq = FindRoot[af100 - b/a, {ksq,  .01,  .05}]; \ ksq = ksq /. frksq; 

    t[z_, sgn10a_] = Sqrt[\((sgn10a\ Exp[z])\)/Sqrt[ksq]]; 
			

    \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ Functions\ *) 


    cm10[z_] = 
      \((a\ I\ \((
                \((1 - ksq)\)\ EllipticF[ArcSin[t[z, \(-1\)]], ksq] - 

                  				2\ EllipticE[ArcSin[t[z, \(-1\)]], ksq] - 
                  \((\((Sqrt[1\  - \ ksq*
			\ \ t[z, \ \(-1\)]^2]\ 
                          Sqrt[1\  - \ t[z, \ \(-1\)]^2])\)/t[z, \ \(-1\)])\))
                \))\)/
			\ \ 
          \((2\ EllipticE[ksq] - \((1 - ksq)\)\ EllipticK[ksq])\) - b; 

    			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ 
      Conformal\ map\ *) 


    ef10[z_, sgn10b_] = 
      \((2 \((2\ EllipticE[ksq]\  - \ \((1\  - \ ksq)\)\ EllipticK[ksq])\)*\ 
            
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 		t[z, \ 1])\)/
        \((a\ Sqrt[1\  + \ sgn10b\ t[z, \ 1]^2]*\ 

            			\ \ \ \ \ \ \ \ \ \ \ \ \ \ 
            Sqrt[1\  + \ sgn10b\ ksq\ t[z, \ 1]^2])\); \ 

    			\ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ 
      Function\ of\ the\ el . \ field\ *) 


    \ \ \ \ \ \ \ \ \ \ \ \  (*\ Variables\ needed\ in\ all\ pictures\ *) 

    \ \ \ \ \ \ \ \ \ 
d = 1.01\ cm10[c]; e = 1.01\ Im[cm10[c - I\ Pi]]; 

    frc = 
      FindRoot[cm10[c] - 2.5\ a - b, {c, 1, 10}, \ 

        			\ \ \ \ \ \ \ \ \ \ 
        AccuracyGoal -> 5 - Floor[N[Log[10, a]]]]; c = c /. frc; 


    Print[SequenceForm[

        "Distance between lower plate and median plane: a = ", \ a, \ 
        " mm."]]\)\(Print[
      SequenceForm[
"Thickness of lower plate: 2 b = ", \ 2\ b, \ 
        " mm."]]\)

(* Section with black & white graphics *)

Print["Electric field on upper plate "]
ppup10 = ParametricPlot[{cm10[-x], -(mult ef10[-x, 1])}, {x, -c, c}, 
    PlotRange -> {All, {0, (-3.2 mult)/a}}, 
    AxesLabel -> {"u[mm]", tex1}];
    
Print["Electric field lines & equipotentials "]
eflandeqpl10 = 
   CartesianMap[cm10, {-c, c,2c/(2nef-1)}, {-Pi + 1/10^10, -(1/10^10),Pi/(neq-1)}, 
    PlotRange -> All, AxesLabel -> {"u[mm]", "v[mm]"}, 
    Epilog -> {Thickness[tcb], 
      {Line[{{-d, 0}, {d, 0}}], 
       Line[{{-b, e}, {-b, -a}, {b, -a}, {b, e}}]}}];
       
Print["Electric field on left side of lower plate "]
ppdownleft10 = ParametricPlot[
            {Im[cm10[-(Pi I) + x]], mult Re[ef10[x, -1]]}, 
            {x, -c, Log[Sqrt[ksq]] - 0.001}, 
            PlotRange -> {{-a, e}, {0, (7 mult)/a}},  
            AxesOrigin -> {-a, 0}, 
            AxesLabel -> {"v[mm]", tex1}]; 
    
Print["Electric field on centre of lower plate "]
ppdowncentre10 = ParametricPlot[
           {Re[cm10[-(Pi I) + x]], mult Im[ef10[x, -1]]}, 
           {x, Log[Sqrt[ksq]] + 1/10^5, 
           Log[1/Sqrt[ksq]] - 1/10^5}, 
           PlotRange -> {All, {0, -((10 mult)/a)}}, 
           AxesLabel -> {"u[mm]", tex1}]; 
    
Print["Electric field on right side of lower plate "]
ppdownright10 = ParametricPlot[
            {Im[cm10[-(Pi I) + x]], mult Re[ef10[x, -1]]}, 
            {x, Log[1/Sqrt[ksq]] + 0.001, c}, 
            PlotRange -> {{-a, e}, {0, -((7 mult)/a)}}, 
            AxesOrigin -> {-a, 0}, 
            AxesLabel -> {"v[mm]", tex1}]; 
    
(* Calculations for a later picture *)    
ppdownright10inv = ParametricPlot[
     {-Im[cm10[-(Pi I) + x]], mult Re[ef10[x, -1]]}, 
     {x, Log[1/Sqrt[ksq]] + 0.001, c}, 
     PlotRange -> {{a, -e}, -((10 mult {-1, 1})/a)}, 
     DisplayFunction -> Identity];

Print["Electric field of median plate without units"]
Show[ppup10, 
     PlotRegion -> {{.01,.99},{.01,.99}},
     Ticks -> None, 
     AxesLabel -> {"u", "E"}];
 
  Print["Electric field lines & equipotentials without units"]
Show[eflandeqpl10, Axes -> None]; 

  Print["Electric field of lower plate without units"]
Show[GraphicsArray[{ppdownleft10, ppdowncentre10, ppdownright10inv}, 
         GraphicsSpacing -> 0] /. 
       (Ticks -> Automatic) -> Ticks -> None /. 
       (AxesLabel -> {"v[mm]", tex1}) -> 
        AxesLabel -> {None, None} /. 
       (AxesLabel -> {"u[mm]", tex1}) -> 
        AxesLabel -> {None, None} /. 
       (PlotRange -> {{-a, e}, {0, (7*mult)/a}}) -> 
        PlotRange -> {{-a, e}, -((10*mult*{1, -1})/a)} /. 
       (PlotRange -> {All, {0, -((10*mult)/a)}}) -> 
        PlotRange -> {All, -((10*mult*{1, -1})/a)}, 
      Epilog -> {Text["v ->              u ->                     <- v", 
      {1.5, 0.13}]}, 
        DisplayFunction -> $DisplayFunction];

(* Section with colour graphics *)

Print[ColumnForm[{"Absolute value of electric field in 3D", 
                  "seen from opposite of right lower plate"}]]
absef3D10 = ParametricPlot3D[Evaluate[
 		{Re[cm10[x + I y]],Im[cm10[x + I y]],
 		Abs[ef10[x + I y,1]]}],
  		{x,-c,c},{y,-Pi+10^-10,-10^-10},
  		PlotPoints -> nec,
  		AxesLabel -> {"u[mm]","v[mm]","|E| [V/m]"}, 
  		BoxRatios -> {1,1,1}];

hli =	Table[Hue[N[1 - (k-1)/(neq - 2)]],{k,neq-2}] ;
hlc =  	Join[{GrayLevel[0]}, Reverse[hli], {GrayLevel[0]}] ;
hlt = 	Table[Thickness[tcf],{k,neq}] ;
styleq = Transpose[{hlc,hlt}] ;

Print[neq, " Equipotential lines (including plates)"]
eqpl10 = ParametricPlot[ Evaluate[Table[      
		{Re[cm10[(1-k)/(neq-1) Pi I + x]], 
		 Im[cm10[(1-k)/(neq-1) Pi I + x]]},
		{k,neq}]],{x,-c,c}, 
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","v [mm]"},
		PlotStyle -> styleq,
      	Epilog -> { Thickness[tcb],
      	           {Line[{{-d,0},{d,0}}],
      	            Line[{{-b,e},{-b,-a},{b,-a},{b,e}}]}} ] ;

Print[ColumnForm[{"Absolute electric fields on equipotential lines as",
      "functions of u (colours match the colours above)"}]]
absefateqplu10 = ParametricPlot[ Evaluate[Table[
		{Re[cm10[(1-k)/(neq-1) Pi I + x]], 
		Abs[mult ef10[(1-k)/(neq-1) Pi I + x,1]]},
		{k,neq}]],{x,-c,c},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","|E(u)| [V/m]"},
		PlotStyle -> styleq] ;

Print[ColumnForm[{"Absolute electric fields on equipotential lines as",
      "functions of v (colours match the colours above)"}]]
absefateqplv10 = ParametricPlot[ Evaluate[Table[
		{Im[cm10[(1-k)/(neq-1) Pi I + x]], 
		Abs[mult ef10[(1-k)/(neq-1) Pi I + x,1]]},
		{k,neq}]],{x,-c,c},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"v [mm]","|E(v)| [V/m]"},
		PlotStyle -> styleq] ;

Print[ColumnForm[
	  {"Electric fields (v-component) on equipotential lines as", 
	  "functions of u (colours match the colours above)"}]]
efvateqpl10 = ParametricPlot[ Evaluate[Table[
		{Re[cm10[(1-k)/(neq-1) Pi I + x]], 
		-Re[mult ef10[(1-k)/(neq-1) Pi I + x,1]]},
		{k,neq}]],{x,-c,c},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","\!\(E\_v\) [V/m]"},
		PlotStyle -> styleq] ;

Print[ColumnForm[
	  {"Electric fields (u-component) on equipotential lines as",
	   "functions of v (colours match the colours above)"}]]
efuateqpl10 = ParametricPlot[ Evaluate[Table[
		{Im[cm10[(1-k)/(neq-1) Pi I + x]], 
		-Im[mult ef10[(1-k)/(neq-1) Pi I + x,1]]},
		{k,neq}]],{x,-c,c},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"v [mm]","\!\(E\_u\) [V/m]"},
		PlotStyle -> styleq] ;

hli =  	Table[Hue[N[1 - (k-1)/(nef - 2)]],{k,nef-2}] ;
hlc = 	Join[{GrayLevel[0]}, Reverse[hli],{GrayLevel[0]}, hli, {GrayLevel[0]}]; 
hlt = 	Table[Thickness[tcf],{k,2 nef-1}]; 
stylfe = Transpose[{hlc,hlt}];

Print[2 nef-1," Electric field lines"]
efl10 = ParametricPlot[ Evaluate[Table[
		{Re[cm10[-c+2(k-1)/(2 nef-2)c+I y]], 
		 Im[cm10[-c+2(k-1)/(2 nef-2)c+I y]]},
		{k,2 nef-1}]],{y,-Pi+10^-10,-10^-10}, 
		PlotRange->All,
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","v [mm]"},
		PlotStyle -> stylfe,
		Epilog->{ Thickness[.011],
		        {Line[{{-d,0},{d,0}}],
                 Line[{{-b,e},{-b,-a},{b,-a},{b,e}}]}}];

Print[ColumnForm[
	  {"Absolute electric fields on field lines as",
	  "functions of u (colours match the colours above)"}]]
absefateflu10 = ParametricPlot[ Evaluate[Table[
	   {Re[cm10[-c+2(k-1)/(2 nef-2)c+I y]], 
		 Abs[mult ef10[-c+2(k-1)/(2 nef-2)c+I y,1]]},
		{k,2 nef-1}]],{y,-Pi+10^-10,-10^-10},
		PlotRange -> All, 
		AxesOrigin -> {0,0},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","|E(u)| [V/m]"},
		PlotStyle -> stylfe];

Print[ColumnForm[
     {"Absolute electric fields on field lines as", 
	  "functions of v (colours match the colours above)"}]]
	  absefateflv10 = ParametricPlot[Evaluate[Table[
        {Im[cm10[-c+2(k-1)/(2 nef-2)c+I y]], 
		 Abs[mult ef10[-c+2(k-1)/(2 nef-2)c+I y,1]]},
		{k,nef}]],{y,-Pi+10^-10,-10^-10},
	    PlotRange -> All,
	    AxesOrigin -> {0,0}, 
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"v [mm]","|E(v)| V/m]"},
		PlotStyle -> stylfe];

Print[ColumnForm[
	  {"Electric fields (v-component) on field lines as", 
	  "functions of u (colours match the colours above)"}]]
efvatefl10 = ParametricPlot[ Evaluate[Table[
		{Re[cm10[-c+2(k-1)/(2 nef-2)c+I y]], 
		 -mult Re[ef10[-c+2(k-1)/(2 nef-2)c+I y,1]]},
		{k,2 nef-1}]],{y,-Pi(1-10^-10),-10^-10}, 
		PlotRange -> All,
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","\!\(E\_v\) [V/m]"},
		PlotStyle -> stylfe] ;

Print[ColumnForm[
	  {"Electric fields (u-component) on field lines as", 
	  "functions of v (colours match the colours above)"}]]
efuatefl10 = ParametricPlot[ Evaluate[Table[
		{Im[cm10[-c+2(k-1)/(2 nef-2)c+I y]],
		 -mult Im[ef10[-c+2(k-1)/(2 nef-2)c+I y,1]]},
		{k,2nef-1}]],{y,-Pi+10^-10,-10^-10}, 
		PlotRange -> All,
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"v [mm]","\!\(E\_u\) [V/m]"},
		PlotStyle -> stylfe] ;

Clear[up,vp,frefp,efp,error,imefp,s]

up = -5.5; vp = -4;
(* above you may insert values of the Cartesian coordinates 
u and v (in mm) of a point of your choice within the area 
shown in Fig. eflandeqpl10; but calculations below fail for points near corners. *) 

Which[vp > 0,     Print[vp " = vp > 0 is unphysical.",⚠],
      vp < -a && -b < up < b , 
     Print[vp " = vp < ",-a," and 
           ",up," = -b < up < b is unphysical.",⚠],
     True,

frefp = FindRoot[cm10[efp] - (-Sign[up]up + I vp), 
              {efp,4-.5I,-3-2 I}];
efp = -Sign[up] Re[efp]+I Im[efp] /. frefp; imefp = N[Im[efp]];
error = Abs[N[cm10[efp] - (up + I vp)]];

Which[0 < imefp, 	 Print["The calculated point doesn`t fulfill the requirements!",\[FreakedSmiley]], 
      imefp < -N[Pi], Print["The calculated point doesn`t fulfill the requirements!",\[FreakedSmiley]],
      error > 10^-6, Print["The error for the calculated point is too big !",☹], 
      True, Print["The calculated point fulfills the requirements.",☺];

valef = mult ef10[efp,1]//N ;
Print[
SequenceForm["At point (up,vp) = (",up ,", ",vp ,") mm : ",
"Potential = ",N[V(1+Im[efp]/Pi)], " V;"]];
Print[SequenceForm["Field (\!\(E\_u\),\!\(E\_v\)) = (", 
-Im[valef],", ",-Re[valef],") V/m;"]];
 
caleqpl10 = ParametricPlot[Evaluate[
	  {Re[cm10[I Im[efp] + s]], 
	   Im[cm10[I Im[efp] + s]]}], {s,-c,c}, 
	  PlotStyle -> Dashing[{.01}], 
	  DisplayFunction -> Identity];
calefl10 = ParametricPlot[Evaluate[
	  {Re[cm10[Re[efp] + I s]], 
	   Im[cm10[Re[efp] + I s]]}],
	  {s,-Pi+10^-10,-10^-10}, DisplayFunction -> Identity];
Show[caleqpl10,calefl10, DisplayFunction -> $DisplayFunction,
	  AspectRatio -> Automatic, AxesLabel -> {"u [mm]","v [mm]"},
		Epilog->{ Thickness[tcb],
		        {Line[{{-d,0},{d,0}}],
                 Line[{{-b,e},{-b,-a},{b,-a},{b,e}}]}}]; ]]

On[General::spell1]