\documentclass{article} \usepackage[a4paper]{geometry} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage[frenchb]{babel} \usepackage{pst-plot,pst-3d} \makeatletter % magnetic field of two parallel arranged wires \pst@addfams{pst-twowires} \define@key[psset]{pst-twowires}{a}[2]{\def\psk@twowiresa{#1 }}% abscisse position fil \define@key[psset]{pst-twowires}{I1}[1]{\def\psk@twowiresIA{#1 }}%intensité du courant 1 \define@key[psset]{pst-twowires}{I2}[1]{\def\psk@twowiresIB{#1 }}%intensité du courant 2 \define@key[psset]{pst-twowires}{points}[2000]{\def\psk@twowiresPoints{#1 }}%nombre maximum de pts \define@key[psset]{pst-twowires}{H}[0.025]{\def\psk@twowiresH{#1 }}%pas pour RK4 %\define@key[psset]{pst-twowires}{posArrow}[20]{\def\psk@twowiresPosArrow{#1 }}%position de la flèche \define@key[psset]{pst-twowires}{x0}[-6]{\def\psk@twowiresX{#1 }}%abscisse départ ligne de champ \define@key[psset]{pst-twowires}{y0}[0]{\def\psk@twowiresY{#1 }}%ordonnée départ ligne de champ \psset[pst-twowires]{a=2,I1=1,I2=1,points=2500,H=0.05,x0=-6,y0=0} \newpsstyle{Arrows}{arrows=>->,arrowsize=0.175,arrowinset=0.075} \newpsstyle{ArrowsInverse}{arrows=<-<,arrowsize=0.175,arrowinset=0.075} % style arrows \define@key[psset]{pst-twowires}{stylearrows}{% \@namedef{psk@twowiresstylearrows}{#1}} \psset[pst-twowires]{stylearrows=Arrows} \newif\ifPst@twowires@arrow \define@key[psset]{pst-twowires}{drawarrows}[false]{\@nameuse{Pst@twowires@arrow#1}} \psset[pst-twowires]{drawarrows=false} \def\psfieldlinestwowires{\pst@object{psfieldlinestwowires}} \def\psfieldlinestwowires@i{% \pst@killglue% \begingroup% \use@par% \begin@SpecialObj% \pst@Verb{% /x01 \psk@twowiresa neg def /x02 \psk@twowiresa def /I1 \psk@twowiresIA def /I2 \psk@twowiresIB def /H \psk@twowiresH def /ValeurMax \psk@twowiresPoints def /x0 \psk@twowiresX def /y0 \psk@twowiresY def /r12 {Xi x01 sub dup mul Yi dup mul add } def /r22 {Xi x02 sub dup mul Yi dup mul add } def /r1 {r12 sqrt} def /r2 {r22 sqrt} def %Bx=-y*(1/((x-1)^2+y^2)+1/((x+1)^2+y^2)) %By=(x-1)/((x-1)^2+y^2)+(x+1)/((x+1)^2+y^2) /B1x {Yi neg r12 div I1 mul} def /B2x {Yi neg r22 div I2 mul} def /Bx {B1x B2x add} def /B1y {Xi x01 sub r12 div I1 mul} def /B2y {Xi x02 sub r22 div I2 mul} def /By {B1y B2y add} def /BM {Bx dup mul By dup mul add sqrt} def %% Runge-Kutta 4 /kx1 {/Xi x0 def /Yi y0 def Bx} def /kx2 {/Xi x0 0.5 H mul add def /Yi y0 0.5 kx1 mul H mul add def Bx} def /kx3 {/Xi x0 0.5 H mul add def /Yi y0 0.5 kx2 mul H mul add def Bx} def /kx4 {/Xi x0 H add def /Yi y0 kx3 H mul add def Bx} def /x1 {x0 kx1 2 kx2 mul add 2 kx3 mul add kx4 add 6 div H mul add } def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /ky1 {/Xi x0 def /Yi y0 def By} def /ky2 {/Xi x0 0.5 H mul add def /Yi y0 0.5 ky1 mul H mul add def By} def /ky3 {/Xi x0 0.5 H mul add def /Yi y0 0.5 ky2 mul H mul add def By} def /ky4 {/Xi x0 H add def /Yi y0 ky3 H mul add def By} def /y1 {y0 ky1 2 ky2 mul add 2 ky3 mul add ky4 add 6 div H mul add } def %%%%%%%%%%%%%%%% end RK4 %%%%%%%%%%%%%%%% /TraceLigne{ /Xi x0 def /Yi y0 def /nbreElements 0 def /Ligne [ x0 y0 { x1 y1 /x0 x1 def /y0 y1 def /nbreElements nbreElements 2 add def nbreElements ValeurMax ge {exit} if % x1 xMax ge {exit} if y1 0.1 sub 0 gt {exit} if % y1 0 ge x1 0 ge or {exit} if } loop ] def /LigneYP [ 0 2 Ligne length 2 sub {/i exch def Ligne i get Ligne i 1 add get neg } for ] def% } def }% \pst@Verb{TraceLigne}% \ifPst@twowires@arrow \listplot[style=\@nameuse{psk@twowiresstylearrows}]{Ligne aload pop} \else \listplot{Ligne aload pop} \fi \listplot{LigneYP aload pop} \end@SpecialObj% \endgroup% \ignorespaces} \makeatother \parindent=0pt \pagestyle{empty} \begin{document} \begin{center} \begin{pspicture}(-8,-7)(8,7) \psgrid[subgriddiv=0,griddots=10,gridlabels=0pt,gridwidth=0.75\pslinewidth] \psset{a=1} \multido{\rX=-6+0.5}{10}{% \psset{drawarrows=true,linecolor=blue} \psfieldlinestwowires[x0=\rX]} \psfieldlinestwowires[x0=2.5,H=-0.02,linecolor=blue] \psfieldlinestwowires[x0=-0.01,H=-0.01,linecolor=blue,points=3000] \psfieldlinestwowires[x0=0.01,H=0.01,linecolor=blue,points=3000] \pscircle(-1,0){0.15}\pscircle(1,0){0.15} \psdots(-1,0)(1,0) \psaxes[linecolor=black,linewidth=0.75\pslinewidth](0,0)(-8,-7)(8,7) \end{pspicture} \end{center} \end{document}