# [pstricks] Re : Re : Elektrostatic Field and equipotentiallines

mluque5130 at aol.com mluque5130 at aol.com
Fri Jan 22 15:51:38 CET 2010

 Dear all,

To try to limit the derive of the path, We can include a condition onthe potential value at the point which has been calculated. If V isthis value and V0 the initial value, We can, arbitrarily, decide that if the relative variation  |(V-V0)/V0|>1e-4  then the path will end.
I'm aware that all of this is tinkering, but i have good hope that afriend very good at Postscript will think about this question in orderto help us.

Example :

%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\usepackage{pstricks,pst-plot}
\SpecialCoor
\def\FieldLines{%
/r1 xP xA sub dup mul yP dup mul add sqrt def
/r2 xP xA add dup mul yP dup mul add sqrt def
/V q1 r1 div % potentiel
q2 r2 div
%        Ex=-dV/dx
/Ex q1 xP xA sub mul r1 3 exp div
q2 xP xA add mul r2 3 exp div
%        Ey=-dV/dy
/Ey yP
q1 r1 3 exp div
q2 r2 3 exp div
/NormeE Ex dup mul Ey dup mul add sqrt def
/dX Ex NormeE div pasX mul def
/dY Ey NormeE div pasX mul def
}
\begin{document}
\begin{center}
\begin{pspicture*}(-6,-8)(6,8)
% les limites INUTILES !!!
\pstVerb{/xmin -5 def /xmax 5 def /ymin -5 def /ymax 5 def}%
% le pas d'itération
\pstVerb{/pasX 0.020 def}%
\pstVerb{/q1 1 def           % les charges
/q2 -0.5 q1 mul def
/xA -2.5 def}%
% 15 degrés entre chaque ligne (24*15=360)
\multido{\iA=0+24}{15}{% 15 lignes de champ
\pstVerb{/xStart xA def
/pasX q1 q1 abs div 0.02 mul def
/xP xStart  pasX \iA\space cos mul add def
/yP 0 pasX \iA\space sin mul add def}%
\parametricplot[plotpoints=2000,linecolor=blue]{xmin}{xmax}{%
\FieldLines
xP yP
}
\pstVerb{/xStart xA neg def
/pasX q2 q2 abs div 0.02 mul def
\parametricplot[plotpoints=2000,linecolor=blue]{xmin}{xmax}{%
\FieldLines
xP yP
}}
\pstVerb{/pasX 0.01 def}%
\multido{\rX=-2+0.5}{9}{%
\pstVerb{/xP \rX\space def
\FieldLines
/V0 V def}%
\parametricplot[plotpoints=1000,linecolor=red]{0}{1}{%
\FieldLines
/dY Ex NormeE div pasX mul neg def
/dX Ey NormeE div pasX mul def
xP yP
V V0 sub abs V0 div 1e-1 ge {/pasX 0 def} if
}
\parametricplot[plotpoints=1000,linecolor=red]{0}{1}{%
\FieldLines
% on part perpendiculairement aux lignes de champ
/dY Ex NormeE div pasX mul neg def
/dX Ey NormeE div pasX mul def
xP yP neg
V V0 sub abs V0 div 1e-1 ge {/pasX 0 def} if
}}
\multido{\iA=0+24}{15}{% 15 lignes de champ
\pstVerb{/xStart xA def
/pasX q1 q1 abs div 0.02 mul def
/xP xStart pasX \iA\space cos mul add def
/yP 0 pasX \iA\space sin mul add def
0 1 100 {
\FieldLines
xP yP} for
/xP1 xP def
/yP1 yP def
100 1 105 {
\FieldLines
xP yP} for
/xP2 xP def
/yP2 yP def
}%
\psline[arrowsize=5pt,linecolor=blue]{<-}(!xP1 yP1)(!xP2 yP2)
\pstVerb{/xStart xA neg def
/pasX q2 q2 abs div 0.02 mul def
0 1 100 {
\FieldLines
xP yP} for
/xP1 xP def
/yP1 yP def
100 1 105 {
\FieldLines
xP yP} for
/xP2 xP def
/yP2 yP def
}%
\psline[arrowsize=5pt,linecolor=blue]{<-}(!xP2 yP2)(!xP1 yP1)}
\pscircle[fillstyle=solid](!xA 0){0.25}\pscircle[fillstyle=solid](!xA neg 0){0.25}
\rput(!xA 0){-}\rput(!xA neg 0){+}
\end{pspicture*}
\end{center}
\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Best Regards

Manuel

-----E-mail d'origine-----
De : Herbert Voss <Herbert.Voss at FU-Berlin.DE>
A : Graphics with PSTricks <pstricks at tug.org>
Envoyé le : Mardi, 19 Janvier 2010 20:06
Sujet : Re: [pstricks] Re :  Elektrostatic Field and equipotentiallines

Am 18.01.2010 21:32, schrieb Thomas Söll:

> ist possible to draw an equipotentialline in your solution of the
> fildlines through an given point?

also with Manuels solution. But I do not understand
why the V lines are far away from the charges?

Herbert

\documentclass{article}
\makeatletter
\let\ScreenCoor\tx at ScreenCoor
\makeatother
\def\FieldLines{
0 1 NoQ { /i ED xP i getX sub yP i getY sub Pyth } for
0 0
0 1 NoQ { /i ED
i getQ xP i getX sub mul i getR 3 exp Div add exch
i getQ yP i getY sub mul i getR 3 exp Div add exch
} for
/Ex ED  /Ey ED
/NormeE Ex Ey Pyth def
/dX Ex NormeE div pasX mul def
/dY Ey NormeE div pasX mul def
}

\begin{document}

\def\NoQ{4}
\def\dAngle{18}
\def\Qcharge{ 1 1 1 1}
\def\Xcoor{ -2.5  2.5 2.5 -2.5}
\def\Ycoor{ -2.5 -2.5 2.5  2.5}

\pstVerb{
/xmin -5 def /xmax 5 def /ymin -5 def /ymax 5 def
/pasX xmax xmin sub 200 div def % 0.05
/NoQ \NoQ\space 1 sub def
/Qcharge [\Qcharge] def
/Xcoor [\Xcoor] def
/Ycoor [\Ycoor] def
/getX { Xcoor exch get } def
/getY { Ycoor exch get } def
/getQ { Qcharge exch get } def
/getR { Radius exch get } def
}
\begin{center}
\begin{pspicture*}(-5,-5)(5,5)
\multido{\iB=0+1}{\NoQ}{%
\psforeach{\iA}{0,10,..,360}{%
\psparametricplot[plotpoints=2000]{xmin}{xmax}[{
/xStart \iB\space getX  def
/yStart \iB\space getY def
/pasX  \iB\space getQ dup abs Div 0.05 mul def
/xP xStart pasX \iA\space cos mul add def
/yP yStart pasX \iA\space sin mul add def
}]{\FieldLines
/xP xP dX add def /yP yP dY add def xP yP }%
}
\pscustom{
\code{
0 1 NoQ { /i exch def
i getX i getY \ScreenCoor\space 10 i getQ abs mul 0 360 arc
gsave i getQ 0 gt {1 0 0}{0 0 1}ifelse setrgbcolor fill grestore
stroke
} for
}}
}
%
\multido{\rX=-8.1+0.5}{32}{%
\psparametricplot[plotpoints=1000,linecolor=blue]{0}{1}[{
/xStart 0 getX  def
/yStart 0 getY def
/pasX 0.017 def
/xP \rX\space def
/yP 0 def
}]{\FieldLines
/dY Ex NormeE div pasX mul neg def
/dX Ey NormeE div pasX mul def
xP yP }
}
\end{pspicture*}
\end{center}
\end{document}
_______________________________________________
PSTricks mailing list
PSTricks at tug.org
http://tug.org/mailman/listinfo/pstricks
archive: http://www.tug.org/pipermail/pstricks/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/pstricks/attachments/20100122/e3893db8/attachment.html>