\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ threepla . nb\ *) 

Needs["Graphics`ComplexMap`"]

    \)\(Clear[V, a, b, c, d, e, f, g, h, ksq, mult, tex1, 

      	\ \ \ \ \ \ \ \ \ \ \ frc, frd, nec, nef, neq, tcb, tcf]\)\(Off[General::spell1]


    \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ Input\ data\ *) 
\)\(V = 1\  (*\ Potential\ on\ central\ plate\ in\ Volt, \ 
		\ \ \ \ \ 
      potential\ on\ outer\ plates\  = \ 0\ *) ; 

    a = 1\  (*\ 
      Half\ the\ length\ of\ central\ plate\ in\ 
        \(mm : 
\ \ \ \ \ \ \ \ for\ 10^\(-5\)\  < \ a\  < \ 25\)\ *) ; 

    b = 3\  (*\ 
      Distance\ between\ central\ and\ outer\ plates\ in\ 
        \(mm\  : \ 
\ \ \ \ \ \ \ for\ a/200\  < \ b\  < \ 2.5\ a\)\ *) \ ; 
    

nec\  = \ 30\  (*\ 
      Number\ of\ lines\ used\ in\ 3  D - 
        image\ of\ 
\ \ \ \ \ \ \ \ \ \ \ \ el . \ field`s\ absolute\ 
          \(value : \ absef3D12\)\ *) ; 


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

      \ \ \ \ \ \ \ \ \ \ \ \ 
      variable\ needed\ in\ the\ 
        \(pictures : \ 
\ \ \ \ \ \ \ \ \ \ \ \ eflandeqpl12\), \ efl12, \ 
      absefateflu12, \ 
	\ \ \ \ \ \ \ \ \ \ \ absefateflv12, \ efuatefl12, 
      \ efvatefl12\ *) ; 


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

      \ \ \ \ \ \ \ \ \ \ \ \ 
      variable\ needed\ in\ the\ 
        \(pictures : \ 
\ \ \ \ \ \ \ \ \ \ \ \ eflandeqpl12\), \ eqpll12, \ 
      absefateqplu12, \ 
\ \ \ \ \ \ \ \ \ \ \ \ absefataqplv12, \ 
      efuateqpl12, \ efvateqpl12\ *) ; 


    tcb\  = \  .011	 (*\ 
      Relative\ thickness\ of\ lines\ representing\ 
		\ \ \ 	\ \ \ 
        boundaries, \ electrodes, \ pole\ shoes, \ \(etc . \)\ *) ; 
	

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

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


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


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


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


    ksq\  = \ \((a/\((a\  + \ b)\))\)^2; \ 
    h\  = \ \((2*EllipticK[ksq])\)/EllipticK[1\  - \ ksq]; 


    cm12[z_] = \((a + b)\)\ JacobiDC[I\ z\ EllipticK[1 - ksq], ksq]; 

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


    ef12[z_] = 
      \((Sqrt[ksq] JacobiCN[I\ z\ EllipticK[1\  - \ ksq], \ ksq]^2)\)/

        \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        \((\((1\  - \ ksq)\) Pi\ EllipticK[1\  - \ ksq]*

            \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
            JacobiSN[I\ z\ EllipticK[1\  - \ ksq], \ ksq])\); 

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


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

e = \(-cm12[\(-I\)\ c]\); 
    f = \(-cm12[\(-I\)\ d]\); 

    frc = FindRoot[
        e + 1.75\ \((a + b)\), {
          c,  .5 \((\(-0.5\)\ h)\),  .5 \((\(-0.7\)\ \ h)\)}, 
        AccuracyGoal\  -> \ 4 - Floor[N[Log[10, a + b]]]]; c = c /. frc; 

    frd = FindRoot[
        f - 1.75\ \((a + b)\), {
          d,  .5 \((\(-1.3\))\)\ h,  .5 \((\(-1.5\))\)\ h}]; 

    \(d = d /. frd; 


    Print[SequenceForm[
"Length of central plate: 2a = ", \ 2  a, \ 
        " mm."]]\)\)\(Print[
      SequenceForm[
"Distance between central and outer plates: b = ", \ 
        b, \ " mm."]]\)

\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ 
      \(Section\ with\ black\ &\)\ white\ graphics\ *) 


    Print["Electric field on top side of left outer plate "]\)\(pptopleft12 = 
      ParametricPlot[{\(-cm12[\(-I\)\ y]\), mult\ ef12[\(-I\)\ y]}, {y, 
          \(- .001\), c}, 
	\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 	
        AxesOrigin -> {\(-a\) - b, 0}, \ \ \ \ \ \ \ \ \ \ \ 

        	\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 	
        PlotRange -> {All, {10^\(-15\), \(- .35\)\ mult}}, 

        \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 		
        AxesLabel -> {"u[mm]", tex1}]; 


    Print["Electric field on top side of central plate "]\)\(pptopcent12 = 
      ParametricPlot[{\(-cm12[1 + I\ y]\), mult\ ef12[1 + I\ y]}, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {y,  .0001, h -  .001}, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 	
        PlotRegion\  -> \ {{ .01,  .99}, { .01,  .99}}, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        PlotRange -> {All, {0, mult}}, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        AxesLabel -> {"u[mm]", tex1}]; 


    Print["Electric field on top side of right outer plate "]\)\(pptopright12 = 
      ParametricPlot[{\(-cm12[\(-I\)\ y]\), mult\ ef12[\(-I\)\ y]}, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {y, d, 
          \(-h\) +  .001}, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        PlotRange -> {All, {10^\(-15\), \(- .35\)\ mult}}, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        AxesOrigin -> {a + b, 0}, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        AxesLabel -> {"u[mm]", tex1}]; 


    Print["Electric field lines & equipotentials "]\)\(\(eflandeqpl12 = 
      CartesianMap[cm12, 

        		{\(- .9999\), 1, 1.9999/\((2  neq - 1)\)}, {0, 
          h,  .9999  h/\((2  nef - 1)\)}, 
		PlotPoints -> neq, 
		
        AxesLabel -> {"u[mm]", "v[mm]"}, 
        PlotRange 
          -> {{\(-1.75\)\ \((a + b)\), 1.75\ \((a + b)\)}, {\(-a\) - b, 
              a + b}}, 
        Epilog -> {Thickness[tcb], 

            				\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {
              Line[{{\(-1.8\)\ \((a + b)\), 0}, {\(-a\) - b, 0}}], 

              					\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
              Line[{{\(-a\), 0}, {a, 0}}], 

              				\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 	
              Line[{{a + b, 0}, {1.8\ \((a + b)\), 0}}]}}]; \)\)

Print["Electric field on top of all plates without units"]\(Show[pptopleft12, pptopcent12, pptopright12, 
	
      PlotRange 
        -> {{\(-1.8\)\ \((a + b)\), 1.8\ \((a + b)\)}, {
            \(- .35\)\ mult,  .6\ mult}}, 
	
      PlotRegion\  -> \ {{ .01,  .99}, { .01,  .99}}, 
	Ticks -> None, 
      
	AxesOrigin -> {0, 0}, 
	
      AxesLabel -> {"u", "E"}]; 


    Print["Electric fieldlines & equipotentials without units"]\)Show[eflandeqpl12, Axes -> None];

\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ 
      Section\ with\ colour\ graphics\ *) 


    Print[ColumnForm[{"Absolute value of electric field", 

          \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
          "in 3D seen from above upper plate"}]]\)\(\(absef3D12 = 
      ParametricPlot3D[
        Evaluate[

          			{Re[cm12[x + I\ y]], Im[cm12[x + I\ y]], 
            Abs[mult\ ef12[x + I\ y]]}], \ \ \ \ \ \ \ \ \ 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {x, \(- .9999\), 1}, {
          y, 0, h}, 
	\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 	
        PlotRange -> {0,  .15\ mult}, 

        	\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 	
        AxesLabel -> {"u[mm]", "v[mm]", "|E| [V/m]"}, 

        	\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 	
        BoxRatios -> {3, 1, 1}]; \)\)

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

Print[2neq-1," Equipotential lines (including plates)"]
eqpl12 = ParametricPlot[ Evaluate[Table[
     {Re[cm12[(k-1)/(neq-1) + I y]],
      Im[cm12[(k-1)/(neq-1) + I y]]},
		{k,-neq+2,neq}]],{y,0,h}, 
		PlotRange -> {{-1.8(a+b),1.8(a+b)},All},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","v [mm]"},
		PlotStyle -> styleq,
     	Epilog -> {Thickness[tcb],
                  {Line[{{-1.8 (a+b),0},{-a-b,0}}],
				   Line[{{-a,0},{a,0}}],
				   Line[{{a+b,0},{1.8 (a+b),0}}]}}];

Print[ColumnForm[
	  {"Absolute electric fields on equipotential lines as",
      "functions of u (colours match the colours above)"}]]
absefateqplu12 = ParametricPlot[ Evaluate[Table[
	{Re[cm12[(1.001 k-1)/(neq-1) + I y]],
     Abs[mult ef12[(1.001 k-1)/(neq-1) + I y]]},
		{k,-neq+2,neq}]],{y,0,h},
		PlotRange->{{-1.8(a+b),1.8(a+b)},{0,.17 mult}},
		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)"}]]
absefateqplv12 = ParametricPlot[ Evaluate[Table[
	{Im[cm12[(k-1)/(neq-1) + I y]],
    Abs[mult ef12[(k-1)/(neq-1) + I y]]},
		{k,-neq+2,neq}]],{y,0,h}, 
		PlotRange->{All,{0,.17 mult}},
		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)"}]]
efvateqpl12 = ParametricPlot[ Evaluate[Table[
	{Re[cm12[(k-1)/(neq-1) + I y]],
     Im[mult ef12[(k-1)/(neq-1) + I y]]},
		{k,-neq+2,neq}]],{y,0,h}, 
		PlotRange -> {{-1.8(a+b),1.8(a+b)},{-.3 mult,.3 mult}},
		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)"}]]
efuateqpl12 = ParametricPlot[ Evaluate[Table[
	{Im[cm12[(k-1)/(neq-1) + I y]],
     Re[mult ef12[(k-1)/(neq-1) + I y]]},
		{k,-neq+2,neq}]],{y,0,h}, 
		PlotRange -> {{-1.8(a+b),1.8(a+b)},{-.05 mult,.17 mult}},
		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,2nef-1}] ;
stylef = Transpose[{hlc,hlt}] ;

Print[2 nef-1," Electric field lines"]
efl12 = ParametricPlot[ Evaluate[Table[
     {Re[cm12[(1.001 k-1)/(2nef-2)I h + x]],
      Im[cm12[(1.001 k-1)/(2nef-2)I h + x]]},
		{k,2nef-1}]],{x,-.9999,1}, 
		PlotRange->{{-1.8(a+b),1.8(a+b)},{-15,15}},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","v [mm]"},
		PlotStyle -> stylef,
     	Epilog -> {Thickness[tcb],
                  {Line[{{-1.8 (a+b),0},{-a-b,0}}],
				   Line[{{-a,0},{a,0}}],
				   Line[{{a+b,0},{1.8 (a+b),0}}]}}];

Print[ColumnForm[
	  {"Absolute electric fields on field lines as",
	  "functions of u (colours match the colours above)"}]]
absefateflu12 = ParametricPlot[ Evaluate[Table[
	{Re[cm12[(1.001 k-1)/(2nef-2)I h + x]],
     Abs[mult ef12[(1.001 k-1)/(2nef-2)I h + x]]},
		{k,2nef-1}]],{x,-.9999,1},
		PlotRange->{{-1.8(a+b),1.8(a+b)},{0,.3 mult}},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","|E(u)| [V/m]"},
		PlotStyle -> stylef] ;

Print[ColumnForm[
	  {"Absolute electric fields on field lines as", 
	  "functions of v (colours match the colours above)"}]]
absefateflv12 = ParametricPlot[ Evaluate[Table[
	{Im[cm12[(1.001 k-1)/(2nef-2)I h + x]],
     Abs[mult ef12[(1.001 k-1)/(2nef-2)I h + x]]},
		{k,2nef-1}]],{x,-.9999,1},
		PlotRange -> {{-1.8(a+b),1.8(a+b)},{0,.2mult}},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"v [mm]","|E(v)| [V/m]"},
		PlotStyle -> stylef] ;

Print[ColumnForm[
	  {"Electric fields (v-component) on field lines as", 
	  "functions of u (colours match the colours above)"}]]
efvatefl12 = ParametricPlot[ Evaluate[Table[
	{Re[cm12[(1.001 k-1)/(2nef-2)I h + x]],
     Im[mult ef12[(1.001 k-1)/(2nef-2)I h + x]]},
		{k,2nef-1}]],{x,-.9999,1},
		PlotRange->{{-1.8(a+b),1.8(a+b)},{-.3 mult,.3 mult}},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","\!\(E\_v\) [V/m]"},
		PlotStyle -> stylef] ;

Print[ColumnForm[
	  {"Electric fields (u-component) on field lines as", 
	  "functions of v (colours match the colours above)"}]]
efuatefl12 = ParametricPlot[ Evaluate[Table[
	{Im[cm12[(1.001 k-1)/(2nef-2)I h + x]],
     Re[mult ef12[(1.001 k-1)/(2nef-2)I h + x]]},
		{k,2nef-1}]],{x,-.9999,1},
		PlotRange->{{-a-b,a+b},{-.17 mult,.3 mult}},
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"v [mm]","\!\(E\_u\) [V/m]"},
		PlotStyle -> stylef] ;

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

up = 4.; vp = 3.;
(* 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. eflandeqpl12 *) 
				
frefp = FindRoot[cm12[efp] - (up + I vp), 
           {efp,-.3 + Sign[up] .3 I h,.7 + Sign[up] .7 I h}];
efp = efp /. frefp; imefp = N[Im[efp]]; reefp = N[Re[efp]];
error = Abs[N[cm12[efp] - (up + I vp)]];

(*Which[!(0 < imefp < h), 	 Print["The calculated point doesn`t fulfill the requirements!",\[FreakedSmiley]], 
      !(-1 < reefp < 1), 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 ef12[efp]//N;
Print[
SequenceForm["At point (up,vp) = (",up ,", ",vp ,") mm : ",
"Potential = ",N[V Im[efp]/Pi], " V;"]];
Print[SequenceForm["Field (\!\(E\_u\),\!\(E\_v\)) = (", 
Re[valef],", ", Im[valef],") V/m "]]; 

caleqpl12 = ParametricPlot[Evaluate[
	  {Re[cm12[Re[efp] + I s]], Im[cm12[Re[efp] + I s]]}], {s,0,h}, 
	  PlotStyle -> Dashing[{.01}], 
	  DisplayFunction -> Identity];
	  
calefl12 = ParametricPlot[Evaluate[
	  {Re[cm12[I Im[efp] + s]], Im[cm12[I Im[efp] + s]]}],
	  {s,0,Pi}, DisplayFunction -> Identity];
	  
Show[caleqpl12,calefl12, 
      DisplayFunction -> $DisplayFunction,
      PlotRange -> All,
	  AxesLabel -> {"u","v"},
 	  Epilog -> { Thickness[tcb],
                 {Line[{{-1.8 (a+b),0},{-a-b,0}}],
				  Line[{{-a,0},{a,0}}],
				  Line[{{a+b,0},{1.8 (a+b),0}}]}}];  
				  
On[General::spell1]