Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

On this blog I found a 3D drawing of a transformer by Thomas Söll.

After a few changes, I have the following code:

\documentclass{article}

\usepackage{pst-solides3d}
\usepackage{expl3}

% Parameters.
\def\radius{1.11}
\def\windingsOne{32}
\def\windingsTwo{64}

% Activating floating point calculation.
\ExplSyntaxOn
  \cs_new_eq:NN
    \calc
  \fp_eval:n
\ExplSyntaxOff

% Constants.
\def\factor{\calc{5*\windingsTwo}}
\def\lengthA{\calc{2*pi*\windingsOne/\factor}}
\def\lengthB{\calc{2/5*pi}}
\def\vertDist{\calc{3/4*pi}}
\def\thickness{\calc{16/(25*\windingsTwo)}}
% Global setup.
\psset{%
  viewpoint=20 5 15 rtp2xyz,
  lightsrc=20 60 60 rtp2xyz,
  Decran=30
}
\psset{%
  solidmemory,
  algebraic
}
% Objects with predefined options.
\newpsobject{core}{psSolid}{%
  object=parallelepiped,
  incolor=red,
  fillcolor=cyan!50,
  grid=false
}
\newpsobject{wire}{psSolid}{
  object=courbe,
  r=\thickness,
  linewidth=0.5pt,
  linecolor=red!60,
  incolor=red!60,
  fillcolor=red!60,
  resolution=727,
  ngrid=727 30,
  action=none
}
\newpsobject{connect}{psSolid}{
  object=fusion,
  linecolor=gray,
  grid=false,
  action=draw**
}

\pagestyle{empty}

\begin{document}

\begin{figure}[htbp]
\centering
\begin{pspicture}(-3,-3)(8,8)
% --------------- Core ---------------
\core[a=1,b=5,c=1,action=draw**,name=H1](0,1.5,-0.5)
\core[a=1,b=1,c=3,action=none,name=H2](0,-0.5,1.5)
\core[a=1,b=1,c=3,action=none,name=H3](0,3.5,1.5)
% --------------- Wire ---------------
{\defFunction{helixA}(t){\radius*cos(\factor*t)}{\radius*sin(\factor*t)}{\vertDist*t}
\wire[function=helixA,range=0 \lengthA,name=wire1](0,-0.5,0)}%
{\defFunction{helixB}(t){\radius*cos(\factor*t)}{-\radius*sin(\factor*t)}{\vertDist*t}
\wire[function=helixB,range=0 \lengthB,name=wire2](0,3.5,0)}%
% ------------- Assembly -------------
\connect[base=H2 wire1]
\connect[base=H3 wire2]
\composeSolid
\core[a=1,b=5,c=1,action=draw**,name=H4](0,1.5,3.5)
\end{pspicture}
\end{figure}

\end{document}

My problem is that the values of the constants \factor, \lengthA, \lengthB, \vertDist, and \thickness are found by hand. Can someone tell me what should be precisely if they should be dependant on the number of windings around the transformer core?

P.S. The code takes a long time (circa 1 minute on my computer) to compile, so if someone can teel me how to recure the compile time, please let me know!

Final Version

\documentclass{article}

\usepackage{pst-solides3d}

%% Parameters
% Windings
\def\lWind{60}
\def\rWind{30}
% Radii
\def\rHelix{1.13}
\def\rWire{0.006}

% Constants
\def\factor{160} % \factor > \lWind,\rWind
\pstVerb{%
  /left 2 \lWind\space mul \factor\space div def
  /right 2 \rWind\space mul \factor\space div def
}

%% Colours
\colorlet{wireColor}{red!60}
\colorlet{coreColor}{cyan!50}
%% Wire
\newpsobject{wire}{psSolid}{%
  object=courbe,
   % Choose max(left,right)
   % The smaller max(left,right), the larger the constant multiplied with it
  ngrid=970 left mul cvi 15,
  r=\rWire,
  fillcolor=wireColor,
  incolor=wireColor
}

\pagestyle{empty}

\begin{document}

\begin{figure}[htbp]
\centering
 \begin{pspicture}(-5,-5)(5,5)
  \psset{%
    algebraic,
    viewpoint=20 5 10 rtp2xyz,
    lightsrc=20 60 60 rtp2xyz,
    Decran=30,
    solidmemory,
    action=none,
    grid=false
  }
  %%--------- Core ----------
  \psSolid[object=anneau,h=1.0,R=4,r=2.5,ngrid=4,RotZ=90,RotY=45,RotX=90,
    fillcolor=coreColor,name=core]
  %%--------- Wire ----------
  % Left
  \defFunction{heliceA}(t){\rHelix*cos(\factor*t)}{\rHelix*sin(\factor*t)}{t/left}
  \wire[function=heliceA,range=0 Pi left mul,name=wireA](0,-2.25,-1.5)
  % Right
  \defFunction{heliceB}(t){\rHelix*cos(\factor*t)}{-\rHelix*sin(\factor*t)}{t/right}
  \wire[function=heliceB,range=0 Pi right mul,name=wireB](0,2.25,-1.5)
  %%------- Assembly --------
  \psSolid[object=fusion,base=core wireA wireB,action=draw**]
 \end{pspicture}
\end{figure}

\end{document}
share|improve this question
    
Related but no duplicate is this question about how to draw a coil in TikZ around a bar. –  Tobi Jan 3 '13 at 12:06
add comment

1 Answer 1

up vote 13 down vote accepted

at first: create minimal examples! It is not important that you have a language danish here!

\documentclass{minimal}
\pagestyle{empty}
\usepackage{pst-solides3d}
\begin{document}

\def\Ra{1} \def\Rb{0.025}
\def\F{80}
\def\Nleft{0.75 } \def\Nright{0.25 }% Max wire is 1

\begin{pspicture}(-5,-5)(5,5)
\psset{viewpoint=20 5 10 rtp2xyz,lightsrc=20 60 60 rtp2xyz,Decran=30,solidmemory,
  action=none,grid=false,fillcolor=cyan!50}
%--------- iron ---------------------------------------
\psSolid[object=anneau,h=1.,R=4,r=2.5,ngrid=4,RotZ=90,RotY=45,RotX=90,name=iron]
%--------- wire -------------------------------------
\defFunction[algebraic]{heliceA}(t){\Ra*cos(\F*t)}{\Ra*sin(\F*t)}{t/\Nleft}% left  
\psSolid[object=courbe,range=0 3 \Nleft mul,function=heliceA,r=\Rb,
  fillcolor=red!60,incolor=red!60,ngrid=720 \Nleft mul cvi 15,name=wire1](0,-2.25,-1.5)
%  
\defFunction[algebraic]{heliceB}(t){\Ra*cos(\F*t)}{-\Ra*sin(\F*t)}{t/\Nright}% right
\psSolid[object=courbe,range=0 3 \Nright mul,function=heliceB,r=\Rb,
  fillcolor=red!60,incolor=red!60,ngrid=720 \Nleft mul cvi 15,name=wire2](0,2.25,-1.5)
%-------- Compose -------------------------------------
\psSolid[object=fusion,base=iron wire1 wire2,action=draw**]
\end{pspicture}

\end{document}

enter image description here

and with

\def\Nleft{0.2 } \def\Nright{0.1 }% Max wire is 1


enter image description here

share|improve this answer
    
What I would like is to only enten the values for the number of windings on the primary and the secondary side and then have PSTricks calculate the other variables relative to these two values. Doesn't \Ra, \Rb, and \F depend on \Nleft and \Nright in some way? –  Svend Tveskæg Jan 3 '13 at 10:15
    
Is my request in the previous comment possible? (Sorry if bumping the post like this is against the rules -- please tell me if it is.) –  Svend Tveskæg Jan 4 '13 at 12:40
    
the number of wires depends to the height of the hole in the iron and the width (radius) of the wire. MaxW=height/Rb –  Herbert Jan 4 '13 at 12:57
    
Arrrh, that simple! I will accept your answer right away. –  Svend Tveskæg Jan 4 '13 at 13:12
1  
should be MaxW=height/(2*Rb) –  Herbert Jan 4 '13 at 13:17
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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