4
$\begingroup$

I have to plot the Electrical Field of half infinity charged plates.

The mathematical Function to this is:

Efeld[x_, 
  z_] := {\[Sigma] (Log[x^2 + (z - d)^2] - 
     Log[x^2 + (z + d)^2]), \[Sigma] (\[Pi] Sign[z - d] + 
     2 ArcTan[x/(z - d) ] - \[Pi] Sign[z + d] - 2 ArcTan[x/(z + d) ])}

This are my StreamPlots:

strp = Table[{y, 0}, {y, -5, 7, .5}];

additionalstrp = Join[strp,
   {{6.`, 4.8}, {6.`, 5.6},
    {6.`, 6.4}, {6.`, 7.15},
    {6.`, 7.9}, {6.8`, 8},
    {6.`, -4.8}, {6.`, -5.6},
    {6.`, -6.4}, {6.`, -7.15},
    {6.`, -7.9}, {6.8`, -8},
    {-4.5`, 7.6}, {-4.9`, 8.},
    {-4.5`, -7.6}, {-4.9`, -8.},
    {0.125, \[Pi]}}];

This are some Parameters:

plotsizeminx := 5
plotsizemaxx := 7
plotsizeminy := 8.5
plotsizemaxy := 8.5

This is the Plot:

 strplot =StreamPlot[
  Efeld[-x, -y] /. {\[Sigma] -> 1, 
    d -> \[Pi]}, {x, -plotsizeminx, +plotsizemaxx}, {y, -plotsizeminy,
    plotsizemaxy}, 
  Epilog -> {Black, Thickness[0.01], 
    Line[{{-plotsizeminx, Pi}, {0, Pi}}], 
    Line[{{-plotsizeminx, -Pi}, {0, -Pi}}]}, StreamScale -> None, 
  StreamStyle -> {Thickness[0.002], Black}, 
  StreamPoints -> additionalstrp, PlotRangePadding -> -0.3, 
  AspectRatio -> 1/1.5]

This is picture of the plot:

enter image description here

As you can see i have highligted some areas where the streaming arrows stop "too early".

Mainly i defined the Streampoints depending on the horizontal symmetry axis, so that it looks simular to another picture.

Even tho i have definde the StreamPoints by myself i do not have enough control to get rid of this "gaps" at the and of a "StreamLine".

Do you have any Idea how to get rid of this gaps.

Thank you.

$\endgroup$
  • $\begingroup$ have already found a solution $\endgroup$ – Mike Apr 10 '17 at 15:49
  • $\begingroup$ Please write up your solution? $\endgroup$ – chris Apr 11 '17 at 19:37
2
$\begingroup$

Ok, so some time ago a other user helped me with a similar problem. at least i took this solution and manipulated it to fit to the acutal problem.

strp2 = Table[{y, 0}, {y, -4.5, 15, .5}]

params = {\[Sigma] -> 1, d -> \[Pi]};

ode = {x'[t], y'[t]} == (Efeld[x, y] /. {v : y | x :> v[t]} /. params)

{Derivative[1][x][t], 
  Derivative[1][y][t]} == {Log[x[t]^2 + (-\[Pi] - y[t])^2] - 
   Log[x[t]^2 + (\[Pi] - y[t])^2], -2 ArcTan[x[t]/(-\[Pi] - y[t])] + 
   2 ArcTan[
     x[t]/(\[Pi] - y[t])] + \[Pi] Sign[-\[Pi] - 
      y[t]] - \[Pi] Sign[\[Pi] - y[t]]}

psol = ParametricNDSolveValue[
   {
    ode,
    {x[0], y[0]} == {a, b},
    WhenEvent[
     Abs[x[t]] < plotsizemaxx || Abs[x[t]] > plotsizeminx || 
      Abs[y[t]] < plotsizemaxy || Abs[y[t]] > plotsizeminy, 
     "StopIntegration"], 
    WhenEvent[Abs[y[t] - \[Pi]] < 0.01 && x[t] < 0, "StopIntegration"]
    },
   {x, y},
   {t, -100, 100},
   {a, b},
   Method -> {"ExplicitRungeKutta", "StiffnessTest" -> True},
   MaxSteps -> 10000,
   MaxStepSize -> 0.01];

sols = psol @@@ strp2; // AbsoluteTiming
(*{25.573434066961003`,Null}*)

its a numerical solution. so i totally bypass the function StreamPlot. i apply this method to every streampoint so i get every line upto the detail needed. with Graphics[] you can plot them alltogether.

Graphics[
 {Black, Thickness[0.002], 
  Line[Transpose@Through[#["ValuesOnGrid"]] & /@ sols], {Black, 
   Thickness[0.01], Line[{{-plotsizeminx, \[Pi]}, {0, \[Pi]}}], Black,
    Thickness[0.01], Line[{{-plotsizeminx, -\[Pi]}, {0, -\[Pi]}}]}}
 , PlotRange -> {{-plotsizeminx, +plotsizemaxx}, {-plotsizeminy, 
    plotsizemaxy}}]

at this point i´m no expert to this (acutually im having a mathematica lecture right now, until now i had to learn this by myself), so i hope this is helpful.

$\endgroup$
  • 1
    $\begingroup$ I suppose you mean this answer? (When the help came from Q&A on this site, the common practice is to include a link. And often people link to references off-site, too.) $\endgroup$ – Michael E2 Apr 12 '17 at 22:44
  • $\begingroup$ yes, i meant this one ^^ thx again :) $\endgroup$ – Mike Apr 15 '17 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.