\(\(\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \)\( (*\ 
      onecorne . \ 
        nb\ *) \)\(
\)\(
\)\(\(\(Needs["Graphics`ComplexMap`"]\)\(
\)
    \)

    Clear[V, a, b, c, d, e, f, g, nef, neq, 
      nec, 
	\ \ \ \ \ \ \ \ \ \ \ qq, tcf, tcb, mult, tex1]

    \(\(Off[
      General::spell1]\)\(
\)\(
\)\(		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 	\)\( (*\ Input\ data\ *) \)\(
\)
    \)			

    \(V\  = \ 1\  (*\ 
        Potential\ on\ upper\ plate\ in\ Volt, \ 
		\ \ \ \ \ \ potential\ on\ lower\ plate\ \((\(=\)\(\ \)\(median\ plane\))\)\  = \ 0\ *) ;\)


    \(a\  = \ 3\  (*\ 
        Distance\ between\ plates\ in\ \(mm\  : \ 
\ \ \ \ \ \ \ \ for\ 1.1\ 10^\(-5\)\  < \ a\  < \ 
              3\ 10^5\)\ *) ;\)\ 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 

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

    \(nef\  = \ 11\  (*\ 
        Number\ of\ field\ lines\ between\ plates; 
\ \ \ \ \ \ \ \ \ \ \ variable\ needed\ in\ the\ \(pictures : \ 
\ \ \ \ \ \ \ \ \ \ \ eflandeqpl5\), \ efl5, \ absefateflu5, \ 
        absefateflv5, \ 
	\ \ \ \ \ \ \ \ \ \ efuatefl5, \ 
        efvatefl5\ *) ;\)
\ \ \ \ \ \ \ \ \ \ \ \ 

    \(neq\  = \ 7\ \  (*\ 
        Number\ of\ equipotential\ lines\ between\ plates; 
\ \ \ \ \ \ \ \ \ \ \ variable\ needed\ in\ the\ \(pictures : \ 
\ \ \ \ \ \ \ \ \ \ \ eflandeqpl5\), \ eqpll5, \ absefateqplu5, \ 
        absefataqplv5, 
	\ \ \ \ \ \ \ \ \ \ efuateqpl5, \ 
        efvateqpl5\ *) ;\)


    \(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]"; \ 
    qq\  = \ Pi -  .001;\ \ \ \ \ \ \ \ \ \ \ \ 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ 
      Functions\ *) \ 


    \(cm5[z_] = 
        1/Pi\ a\ \ \((I\ \ \((2\ \ Sqrt[Exp[z]\  - \ 1]\  + \ 
                    Pi)\)\  - \ 
\ \ \ \ \ \ Log[\((I\ \ Sqrt[
                          Exp[z]\  - \ 1]\  + \ 1)\)/\((1\  - \ 
                      I\ \ Sqrt[
                          Exp[z]\  - \ 
                            1])\)])\);\)
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ 
      Conformal\ map\ *) \ \ \ \ \ \ \ \ 

    ef5[z_] = N[\(-mult\)/Sqrt[Exp[z]\  - \ 1]]; \  (*\ 
      Function\ of\ el . \ 
          field\ *) 

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

    b = 3.37465; c\  = \ Re[cm5[I\ \ Pi\  + \ b]]; \ 
    d\  = \ Re[cm5[I\ \ Pi\  + \ e]];

    e = \(-8.46758\); f = Re[cm5[e]]; g = Im[cm5[b]];


    Print[
      SequenceForm[
"Distance between horizontal upper plate and median plane: a = ", \ a, \ " mm."]]\)\)\)

(* Section with black & white graphics *)

Print["Electric field on vertical part of upper plate "]
ppupvert5 = ParametricPlot[{cm5[x]/I ,-mult/Sqrt[Exp[x]-1]},
      	{x,.1,b},
      	PlotRange -> All, 
      	AxesOrigin -> {a,0}, 
      	AxesLabel -> {"v[mm]",tex1}] ;
           
(* Calculations for a later picture *)     
ppupvert5inv = ParametricPlot[
           {-cm5[x]/I, -mult/Sqrt[Exp[x]-1]},{x,.1,b}, 
     	   PlotRange -> {{-a,-g},{0,-3 mult}}, 
           AxesOrigin -> {-a,0}, 
           DisplayFunction -> Identity] ;
      
Print["Electric field on horizontal part of upper plate "]
ppuphor5 = ParametricPlot[
           {cm5[x]-a I, -mult/Sqrt[1-Exp[x]]},
		   {x,e,-.001},
           PlotRange -> {{0,f},{0,-3 mult}}, 
      	   AxesLabel -> {"u[mm]",tex1}] ;
 
Print["Electric fieldlines & equipotentials "]
eflandeqpl5 = CartesianMap[cm5,
             {e,b,(b-e)/(nef-1)},{0,qq,qq/(neq-1)}, 
	    	 PlotRange -> All,
	    	 AxesLabel -> {"u[mm]","v[mm]"}, 
      	     Epilog -> { Thickness[tcb],
                        { Line[{{0,g},{0,a},{f,a}}],      
                          Line[{{c,0},{d,0}}]}}];

Print["Electric field on median plate "]
ppdown5 = ParametricPlot[
          {cm5[-x+I Pi], -mult/Sqrt[Exp[-x]+1]},{x,-b,-e}, 
      	  PlotRange -> {{c,d},{-V 10^-13,-mult}},
      	  AxesLabel -> {"u[mm]",tex1}] ;

Print["Electric field of upper plate without units"]
Show[GraphicsArray[{ppupvert5inv,ppuphor5}, 
GraphicsSpacing -> 0] /.
      (Ticks -> Automatic) -> (Ticks -> None) /.
      (AxesLabel -> {"u[mm]",tex1}) -> 
      (AxesLabel -> {None,None}),
      Epilog -> {Text[
         "<- v Vertical   Horizontal u ->",{1.05,0}]}] ;

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

Print["Electric field of median plate without units"] 
Show[ppdown5, 
     PlotRegion -> {{.01,.99},{.01,.99}},
     Ticks -> None, 
     AxesOrigin -> {0,0}, 
	 AxesLabel -> {"u","E"}] ;

(* Section with colour graphics *)

Print[ColumnForm[{"Absolute value of electric field in 3D seen",
                  "from opposite horizontal part of upper plate"}]]
absef3D5 = ParametricPlot3D[Evaluate[
 		{Re[cm5[x + I y]],Im[cm5[x + I y]],
 		Abs[ef5[x + I y]]}],
  		{x,e,b},{y,0,qq},
  		AxesLabel -> {"u[mm]","v[mm]","|E| [V/m]"}, 
  		BoxRatios -> {1,1,1}, 
  		PlotPoints -> nec,
  		ViewPoint -> {-1.07, 2.3, 1.5}];

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

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

Print[ColumnForm[
	  {"Absolute electric fields on equipotential lines as",
      "functions of u (colours match the colours above)"}]]
absefateqplu5 = ParametricPlot[ Evaluate[Table[
		{Re[cm5[(k-1)/(neq-1)Pi I + x]], 
		Abs[ef5[(k-1)/(neq-1)Pi I + x]]},
		{k,neq}]],{x,b,e}, 
		PlotRange -> {All,{0,2 Abs[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)"}]]
absefateqplv5 = ParametricPlot[Evaluate[Table[
        {Im[cm5[(k - 1)/(neq - 1)Pi I + x]], 
         Abs[ef5[(k - 1)/(neq - 1)Pi I + x]]}, {k, neq}]], 
         {x, b, e}, 
         PlotRange -> {All, {0, 2 Abs[mult]}}, 
         PlotRegion -> {{0.01, 0.99}, {0.01, 0.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)"}]]
efvateqpl5 = ParametricPlot[ Evaluate[Table[
		{Re[cm5[(k-1)/(neq-1)Pi I + x]], 
		-Im[ef5[(k-1)/(neq-1)Pi I + x]]},
		{k,neq}]],{x,b,e},  
		PlotRange -> {All,{0,-2 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)"}]]
efuateqpl5 = ParametricPlot[ Evaluate[Table[
		{Im[cm5[(k-1)/(neq-1)Pi I + x]], 
		Re[ef5[(k-1)/(neq-1)Pi I + x]]},
		{k,neq}]],{x,b,e},  PlotRange -> {All,{0,-2 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]}, hli, {GrayLevel[0]}] ;
hlt = 	Table[Thickness[tcf],{k,nef}] ;
stylfe = Transpose[{hlc,hlt}] ;
dx  = 	e - b;

Print[nef," Electric field lines"]
efl5 = ParametricPlot[ Evaluate[Table[
		{Re[cm5[b + (k-1)/(nef-1) dx  + I y]], 
		 Im[cm5[b + (k-1)/(nef-1) dx  + I y]]},
		{k,nef}]],{y,0,Pi}, 
		PlotRange -> All,
		PlotRegion -> {{.01,.99},{.01,.99}},
		AxesLabel -> {"u [mm]","v [mm]"},
		PlotStyle -> stylfe,
     	Epilog -> { Thickness[tcb],
                  { Line[{{0,g},{0,a},{f,a}}], 
                    Line[{{c,0},{d,0}}] }} ];

Print[ColumnForm[
	  {"Absolute electric fields on field lines as",
	  "functions of u (colours match the colours above)"}]]
absefateflu5 = ParametricPlot[ Evaluate[Table[
		{Re[cm5[b + (k-1)/(nef-1) dx  + I y]], 
		Abs[ef5[b + (k-1)/(nef-1) dx  + I y]]},
		{k,nef}]],{y,0,Pi}, 
		PlotRange -> {All,{0,2 Abs[mult]}},
		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)"}]]
absefateflv5 = ParametricPlot[ Evaluate[Table[
		{Im[cm5[b + (k-1)/(nef-1) dx  + I y]], 
		 Abs[ef5[b + (k-1)/(nef-1) dx  + I y]]},
		{k,nef}]],{y,0,Pi}, 
		PlotRange -> {All,{0,2 mult}},
		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)"}]]
efvatefl5 = ParametricPlot[ Evaluate[Table[
		{Re[cm5[b + (k-1)/(nef-1) dx  + I y]], 
		-Im[ef5[b + (k-1)/(nef-1) dx  + I y]]},
		{k,nef}]],{y,0,Pi}, 
		PlotRange -> {All,{0,-2 mult}},
		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)"}]]
efuatefl5 = ParametricPlot[ Evaluate[Table[
		{Im[cm5[b + (k-1)/(nef-1) dx  + I y]], 
		 Re[ef5[b + (k-1)/(nef-1) dx  + I y]]},
		{k,nef}]],{y,0,Pi}, 
		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 = -2; 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. eflandeqpl5 *)

Which[vp < 0,     Print[vp " = vp < 0 is unphysical.",⚠],
      vp > a && up > 0, 
     Print[vp " = vp > ",a," and 
           ",up," = up > 0 is unphysical.",⚠],
     True,
 
frefp = FindRoot[cm5[efp] - (up + I vp), 
			  {efp, -1 + I Min[.1,Abs[Pi - vp]]}];
efp = efp /. frefp; imefp = N[Im[efp]];
error = Abs[N[cm5[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 = ef5[efp]//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\)) = (", 
Re[valef],", ", -Im[valef],") V/m;"]]; 

caleqpl5 = ParametricPlot[Evaluate[
	  {Re[cm5[I Im[efp] + s]], Im[cm5[I Im[efp] + s]]}], {s,e,b}, 
	  PlotStyle -> Dashing[{.01}], DisplayFunction -> Identity];
	  
calefl5 = ParametricPlot[Evaluate[
	  {Re[cm5[Re[efp] + I s]], Im[cm5[Re[efp] + I s]]}], {s,0,Pi},
	  DisplayFunction -> Identity];
	  
Show[caleqpl5,calefl5, 
      DisplayFunction -> $DisplayFunction,
	  AxesLabel -> {"u [mm]","v [mm]"},
	  PlotRange -> All, 
	  Epilog -> { Thickness[tcb],
                { Line[{{0,g},{0,a},{f,a}}], 
                  Line[{{c,0},{d,0}}] }}]; ]]

On[General::spell1]