Magnetic field of a dipole magnet (pstricks)

For a simple method without pstricks, please see this page.

Sources: Inspiration, pstricks manual.

magnet_fieldlines_pstricks

Edit and compile if you like:

% Author: Izaak Neutelings (March 2020)
% PSTricks => compile with XeLaTeX
% http://mirror.easyname.at/ctan/graphics/pstricks/contrib/pst-magneticfield/doc/pst-magneticfield-doc.pdf
% N=6: number of turns
% R=2: radius
% L=4: length
% pointsB=500: maximum number of points on each line of the entire coil
% pointsS=1000: maximum number of points on lines around turns selected
% nL=8: number of lines of the entire coil
% PasB=0.02: differential steps for the lines of the entire coil
% PasS=0.00275: differential steps for the lines around turns selected
% numSpires={}: choice of individual coils to improve the rendering of its layout
% nS=1: number of field lines around the turns selected
% drawSelf=false: do not represent the solenoid with the option (useful for 3D)
% https://tex.stackexchange.com/questions/468225/pstricks-magnetic-field-lines-of-a-bar-magnet
%\documentclass{standalone}
\documentclass[border=3pt,tikz]{standalone}
\usepackage{tikz}
\usepackage{auto-pst-pdf}
\usepackage{pst-magneticfield}
\usepackage[outline]{contour} % glow around text
\usetikzlibrary{calc}
\tikzset{>=latex} % for LaTeX arrow head
\usetikzlibrary{decorations.pathreplacing}
%\usepackage{pgfplots}
%\newcommand{\fieldlinecurve}[2]{{(pow(#1,2)*(3*cos(#2)+cos(3*#2))}, {(pow(#1,2))*(sin(#2)+sin(3*#2))}}
\usepackage{xcolor}
\colorlet{Bcol}{violet!90}
\colorlet{Ncol}{red!60}
\colorlet{Scol}{blue!60}
\tikzstyle{north}=[thick,top color=red!60,bottom color=red!90,shading angle=20]
\tikzstyle{south}=[thick,top color=blue!60,bottom color=blue!90,shading angle=20]
\contourlength{1.5pt}
\begin{document}
%\psset{unit=0.5}
%\begin{pspicture*}(-20,-16)(20,16)
% \psframe[linecolor=black, fillstyle=solid,fillcolor=north](-2,0)(2,6)
% \psframe[linecolor=black, fillstyle=solid,fillcolor=south](-2,0)(2,-6)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Click to download: magnet_fieldlines_pstricks.texmagnet_fieldlines_pstricks.pdf
Open in Overleaf: magnet_fieldlines_pstricks.tex

Leave a Reply

Your email address will not be published.