\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  (*\ round1co . \ nb\ *) 


    Needs["Graphics`ComplexMap`"]
\)\(Clear[V, a, b, c, d, e, f, g, p, A, eps, frc, frd, frp, 

      	\ \ \ \ \ \ \ \ \ \ \ lambda, nef, neq, nec, 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.5\ 10^\(-5\)\  < \ a\  < \ 2\ 10^5\)\ *) ; \ 

\ 
    b\  = \ a/3\ \  (*\ 
      Radius\ of\ circular\ arc\ in\ 
        \(mm : 
\ \ \ \ \ \ \ \ \ \ \ \ for\ a/5000\  < \ b\  < \ a/2\)\ *) 
      \ ; 
\ \ \ \ \ \ \ 

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

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

      \ \ \ \ \ \ \ \ \ \ \ 
      variable\ needed\ in\ the\ 
        \(pictures : \ 
\ \ \ \ \ \ \ \ \ \ \ eflandeqpl6\), \ efl6, \ 
      absefateflu6, \ absefateflv6, \ 
	\ \ \ \ \ \ \ \ \ \ efuatefl6, \ 
      efvatefl6\ *) ; 
\ \ \ \ \ \ \ \ \ \ \ \ 

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

      \ \ \ \ \ \ \ \ \ \ \ 
      variable\ needed\ in\ the\ 
        \(pictures : \ 
\ \ \ \ \ \ \ \ \ \ \ eflandeqpl6\), \ eqpll6, \ 
      absefateqplu6, \ absefataqplv6, 
	\ \ \ \ \ \ \ \ \ \ efuateqpl6, \ 
      efvateqpl6\ *) ; 


    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]"; 

    A\  = \ a/Pi\ 1/\((Sqrt[p]\  + \ lambda\ Sqrt[q])\)\ \ ; 

    lambda\  = \ 
      \((\((2\ a/\((Pi\ b)\) \((1 - Sqrt[p]\ ArcTan[Sqrt[1/p]])\) - Sqrt[p])
            \))\)/Sqrt[q]; 
q\  = \ p + eps; 
eps\  = \  .96\ ; 
    \  (*\ Variable\ to\ fit\ the\ arc\ of\ the\ 

        		\ \ \ \ \ \ \ \ \ \ \ \ rounded\ corner\ to\ a\ quarter\ circle
        \ *) \ \ \ 


    \ \ \ \ \ \ \ \ \  (*\ 
      Calculation\ of\ parameter\ depending\ on\ ratio\ a/b\ *) 


    af60\  = \ 2\ lambda\ A \((1 - Sqrt[q]\ ArcTanh[Sqrt[1/q]])\)\ \ ; 

    frp\  = \ FindRoot[af60\  == \ \(-b\), {p,  .1,  .5}, 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        AccuracyGoal\  -> \ \((6 - Floor[N[Log[10, b]]])\), 

        		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
        WorkingPrecision\  -> \ \ \ \ \ \ \ \ \ \ \ 

          			\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ $MachinePrecision - If[b < 1, Floor[N[Log[10, b]]], 0]]\ ; 

    p\  = \ p /. frp\ ; \ \ 
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 

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


    cm6[t_] = \ 
      2\ I\ A \((
            Sqrt[t - p] - Sqrt[p] ArcTan[Sqrt[\((t - p)\)/p]] + 

              		\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ lambda \((Sqrt[t - q] - 
                    Sqrt[q]*

                      \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
                      ArcTan[Sqrt[\((t - q)\)/q]])\))\) + I\ a\ ; \ 

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


    ef6[t_] = \ 1/A\ 1/\((Sqrt[t - p] + lambda\ Sqrt[t - q])\)\ ; 
    \ \ \ \ \ \ \ \ \ \ \ 

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


    t[z_]\  = \ Exp[z]\ ; 


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

    e\  = \ Re[cm6[t[c]]]; \ f\  = \ Im[cm6[t[d]]]; \ 
    g\  = \ Re[cm6[\(-t[d]\)]]\ ; 

    frc\  = \ FindRoot[e - 2.5\ a, {c, \(-5\), \(-10\)}]; \ c = c /. frc\ ; 

    frd\  = \ FindRoot[f - 3.5\ a, {d, 6, 10}]; \ d = d /. frd\ ; 


    Print[SequenceForm[

        "Distance between horizontal upper plate and median plane: a = ", 
        \ a, \ " mm."]]\)\(Print[
      SequenceForm[
"Radius of circular arc at the upper plate: b = ", \ 
        b, \ " mm."]]\)

(* Section with black & white graphics *)

Print[ColumnForm[{"Electric field on vertical part of upper plate",
                 "and vertical component of circular arc "}]]
ppupvert6 = ParametricPlot[{ Im[cm6[t[x]]],-mult Re[ef6[t[x]]] },
       {x,Log[p],d}, 
       PlotRange -> {All,{0,-1.3 mult Pi/a}}, 
       AxesLabel -> {"v[mm]",tex1}] ;
   
Print[ColumnForm[{"Electric field on horizontal part of upper plate",
                  "and horizontal component of circular arc "}]]
ppuphor6 = ParametricPlot[{Re[cm6[t[x]]],mult Im[ef6[t[x]]] },
       {x,c,Log[eps + p]}, 
       PlotRange -> {All,{0,-2 mult Pi/a}}, 
       AxesLabel -> {"u[mm]",tex1}] ;
     
Print["Electric fieldlines & equipotentials "]
eflandeqpl6 = CartesianMap[cm6[t[#]] &, {c,d,(d-c)/(nef-1)},{0,Pi,Pi/(neq-1)}, 
              PlotRange -> All,
              AxesLabel -> {"u[mm]","v[mm]"}, 
              Epilog -> { Thickness[tcb], 
                        { Line[{{g,0},{e,0}}], Line[{{e,a},{b,a}}], 
                          Line[{{0,a + b},{0,f}}], 
                          Circle[{b,a + b},b,{-Pi,-Pi/2}] }} ];
 
Print["Electric field on median plate "]
ppdown6 = ParametricPlot[{cm6[-t[-x]],mult Im[ef6[-t[-x]]] },
       {x,-c,-d}, 
       PlotRange -> {0,-1.1 mult Pi/a},
       AxesLabel -> {"u[mm]",tex1}] ;

Print["Electric field on vertical part of upper plate without units"]
Show[ppupvert6, 
     PlotRegion -> {{.01,.99},{.01,.99}}, 
     Ticks -> None, 
     AxesLabel -> {"v","E"}] ; 

Print["Electric field on horizontal part of upper plate without units"]
Show[ppuphor6, 
     PlotRegion -> {{.01,.99},{.01,.99}}, 
     Ticks -> None, 
     AxesLabel -> {"u","E"}] ;

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

Print[ColumnForm[{"Absolute value of electric field in 3D seen",
                  "from opposite horizontal part of upper plate"}]]
absef3D6 = ParametricPlot3D[Evaluate[
 		{Re[cm6[t[x + I y]]],Im[cm6[t[x + I y]]],
 		Abs[mult ef6[t[x + I y]]]}],
  		{x,c,d},{y,0,Pi}, 
  		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)"]
eqpl6 = ParametricPlot[Evaluate[Table[ 
	 {Re[cm6[t[(k-1)/(neq-1)Pi I + x]]],
	  Im[cm6[t[(k-1)/(neq-1)Pi I + x]]]}, {k,neq}]],{x,c,d}, 
	  PlotRegion -> {{.01,.99},{.01,.99}},
	  AxesLabel -> {"u [mm]","v [mm]"},
	  PlotStyle -> styleq,       
      Epilog -> { Thickness[tcb], 
              	{ Line[{{g,0},{e,0}}], Line[{{e,a},{b,a}}], 
                Line[{{0,a + b},{0,f}}], 
                Circle[{b,a + b},b,{-Pi,-Pi/2}] }}] ;

Print[ColumnForm[
	  {"Absolute electric fields on equipotential lines as",
      "functions of u (colours match the colours above)"}]]
absefateqplu6 = ParametricPlot[Evaluate[Table[
     {Re[cm6[t[(k-1)/(neq-1)Pi I + x]]], 
     Abs[mult ef6[t[(k-1)/(neq-1)Pi I + x]]]},
     {k,neq}]], {x,c,d}, 
     PlotRange -> {All,{0, Automatic}},
     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 u (colours match the colours above)"}]]
absefateqplv6 = ParametricPlot[Evaluate[Table[
     {Im[cm6[t[(k-1)/(neq-1)Pi I + x]]],
      Abs[mult ef6[t[(k-1)/(neq-1)Pi I + x]]]},
      {k,neq}]],{x,c,d},
      PlotRange -> {All,{0, Automatic}},
      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)"}]]
efvateqpl6 = ParametricPlot[Evaluate[Table[
     {Re[cm6[t[(k-1)/(neq-1)Pi I + x]]], 
      mult Im[ef6[t[(k-1)/(neq-1)Pi I + x]]]},
     {k,neq}]], {x,c,d}, 
     PlotRange -> All, 
     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)"}]]
efuateqpl6 = ParametricPlot[Evaluate[Table[
     {Im[cm6[t[(k-1)/(neq-1)Pi I + x]]], 
      -mult Re[ef6[t[(k-1)/(neq-1)Pi I + x]]]},
     {k,neq}]], {x,c,d}, 
     PlotRange -> All,
     PlotRegion -> {{.01,.99},{.01,.99}},	
	 AxesLabel -> {"v [mm]", "\!\(E\_u\) [V/m]"},
	 PlotStyle -> styleq] ;

hli =  	Reverse[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  = 	d - c;

Print[nef," Electric field lines"]
efl6 = ParametricPlot[Evaluate[Table[ 
	 {Re[cm6[t[c + (k-1)/(nef-1) dx  + I y]]],
	  Im[cm6[t[c + (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[{{g,0},{e,0}}], Line[{{e,a},{b,a}}], 
                Line[{{0,a + b},{0,f}}], 
                Circle[{b,a + b},b,{-Pi,-Pi/2}] }}] ;

Print[ColumnForm[
	  {"Absolute electric fields on field lines as",
	  "functions of u (colours match the colours above)"}]]
absefateflu6 = ParametricPlot[Evaluate[Table[
     {Re[cm6[t[c + (k-1)/(nef-1) dx + I y]]], 
      Abs[mult ef6[t[c + (k-1)/(nef-1) dx + I y]]]},
      {k,nef}]], {y,0,Pi}, 
      PlotRange -> {All,{0,Automatic}},
      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)"}]]
absefateflv6 = ParametricPlot[Evaluate[Table[
     {Im[cm6[t[c + (k-1)/(nef-1) dx + I y]]], 
      Abs[mult ef6[t[c + (k-1)/(nef-1) dx + I y]]]},
      {k,nef}]], {y,0,Pi}, 
      PlotRange -> {All,{0,Automatic}},
      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)"}]]
efvatefl6 = ParametricPlot[Evaluate[Table[
     {Re[cm6[t[c + (k-1)/(nef-1) dx + I y]]], 
      mult Im[ef6[t[c + (k-1)/(nef-1) dx + I y]]]},
     {k,nef}]], {y,0,Pi}, 
     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)"}]]
efvatefl6 = ParametricPlot[Evaluate[Table[
     {Im[cm6[t[c + (k-1)/(nef-1) dx + I y]]], 
      -mult Re[ef6[t[c + (k-1)/(nef-1) dx + I y]]]},
     {k,nef,1,-1}]], {y,0,Pi}, 
     PlotRange -> {All,{0,-.5 mult}}, 
     PlotRegion -> {{.01,.99},{.01,.99}},	
	 AxesLabel -> {"v [mm]", "\!\(E\_u\) [V/m]"},
	 PlotStyle -> stylfe] ;

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

up = -8; vp = 5;
(* 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. eflandeqpl6 *)

Which[vp < 0, Print[vp " = vp < 0 is unphysical.",⚠],
      vp > a && up > b || vp > (a+b) && up > 0 || 
      Abs[(up-b)^2+(vp-a-b)^2] < b^2,
      Print["("up ,", ",vp ,") is inside the condenser and therefore unphysical.",⚠],
      True,
      
frefp = FindRoot[cm6[t[efp]] - (up + I vp), 
			  {efp, -1 + I Min[.1,Abs[Pi - vp]]}];
			  
efp = efp /. frefp; imefp = N[Im[efp]];
error = Abs[N[cm6[t[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 ef6[t[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;"]];

caleqpl6 = ParametricPlot[Evaluate[
	  {Re[cm6[t[I Im[efp] + s]]], Im[cm6[t[I Im[efp] + s]]]}], {s,c,d}, 
	  PlotStyle -> Dashing[{.01}], DisplayFunction -> Identity ];
calefl6 = ParametricPlot[Evaluate[
	  {Re[cm6[t[Re[efp] + I s]]], Im[cm6[t[Re[efp] + I s]]]}],
	  {s,0,Pi},  DisplayFunction -> Identity];
Show[caleqpl6,calefl6, 
      DisplayFunction -> $DisplayFunction,
	  AspectRatio -> Automatic, 
	  AxesLabel -> {"u [mm]","v [mm]"},
	  Epilog -> { Thickness[tcb], 
              	{ Line[{{g,0},{e,0}}], Line[{{e,a},{b,a}}], 
                  Line[{{0,a + b},{0,f}}], 
                  Circle[{b,a + b},b,{-Pi,-Pi/2}] }}] ;]] 
                  
On[General::spell1]