有没有一种“简单”的方法可以在 TikZ 中绘制类似以下的东西?我只有框架,但那些漩涡状的东西很难画:
\centering
\begin{tikzpicture}
\draw (0,0) --(0,5) -- (7,5) -- (7,0) -- (0,0) ;
\draw (1,1) -- (1,4) -- (3,4) -- (3,1) -- (1,1) ;
\draw (4,1) -- (4,4) -- (6,4) -- (6,1) -- (4,1) ;
\draw[very thick] (8,4.8) -- (8,2.8);
\draw[very thick] (8,2.2) -- (8,.2);
\draw[very thick] (9,4.8) -- (9,2.8);
\draw[very thick] (9,2.2) -- (9,.2);
\draw[very thick] (10,4.8) -- (10,2.8);
\draw[very thick] (10,2.2) -- (10,.2);
\draw[thick] (-0.3,3.5) -- (1,3.5);
\draw[thick] (1,3.5) to [out=180,in=45] (1.2,3.3);
\end{tikzpicture}
答案1
如果可以选择 PSTricks 解决方案,则可以使用以下内容:
\documentclass{article}
\usepackage[margin = 3cm]{geometry}
\usepackage{pstricks-add}
\let\Name\MakeUppercase
%%% values needed (automatically calculated)
\usepackage{xfp}
% picture frame
\newcommand*\DiagramHorizontalStart{
\fpeval{-\WindingRadius-5080/7227}% (5080/7227)mm = 2pt = \psdot diameter (if I am not mistaken)
}
\newcommand*\DiagramHorizontalEnd{
\fpeval{3*\CoreThickness+2*\CoreholeHorizontal+\WindingRadius
+\ElectroamgnetComponentDistance+3*\ComponentThickness
+2*\ComponentsHorizontalDistance+0.1}
}
\newcommand*\DiagramVerticalEnd{
\fpeval{2*\CoreThickness+\CoreholeVertical}
}
% intermediate functions
\newcommand*\WirePosition[1]{%
\fpeval{(#1)*\WindingRadius}
}
\newcommand*\WindingsPositionX[1]{%
\fpeval{(#1-1)*(\CoreThickness+\CoreholeHorizontal)}
}
\newcommand*\LabelPositionX[1]{%
\fpeval{\CoreThickness/2+\WindingsPositionX{#1}}
}
\newcommand*\LabelPositionY{%
\fpeval{(\CoreholeVertical+\WirePosition{4*\NumberOfWindingsBottom+2}
-\WirePosition{4*\NumberOfWindingsTop+2})/2+\CoreThickness}
}
\newcommand*\ComponentStart{%
\fpeval{3*\CoreThickness+2*\CoreholeHorizontal+\WindingRadius
+\ElectroamgnetComponentDistance}
}
\newcommand*\ComponentHeight{%
\fpeval{\CoreThickness+\CoreholeVertical/2-2*\ComponentEndHeight
-\ComponentsVerticalDistance/2}
}
\newcommand*\ComponentNumber[1]{%
\fpeval{(#1-1)*(\ComponentsHorizontalDistance+\ComponentThickness)}
}
\newcommand*\ComponentNoteX[1]{%
\fpeval{\ComponentStart+\ComponentNumber{#1}}
}
% core
\newcommand*\Core{
% `outer frame'
\psframe(0,0)%
(\fpeval{3*\CoreThickness+2*\CoreholeHorizontal},
\fpeval{2*\CoreThickness+\CoreholeVertical})
% first hole
\psframe(\CoreThickness,\CoreThickness)%
(\fpeval{\CoreThickness+\CoreholeHorizontal},
\fpeval{\CoreThickness+\CoreholeVertical})
% second hole
\psframe(\fpeval{2*\CoreThickness+\CoreholeHorizontal},\CoreThickness)%
(\fpeval{2*(\CoreThickness+\CoreholeHorizontal)},
\fpeval{\CoreThickness+\CoreholeVertical})%
}
% single winding
\newcommand*\Loop[1]{%
\psarc(0,\WirePosition{4*#1-1}){\WindingRadius}{90}{270}
\psline(0,\WirePosition{4*#1-2})(\CoreThickness,\WirePosition{4*#1-2})
\psarc(\CoreThickness,\WirePosition{4*#1-3}){\WindingRadius}{270}{90}%
}
% collection of windings
\newcommand*\WireFull[1]{%
\psline{*-}(-\WireEndLength,\WirePosition{4*#1+2})%
(\CoreThickness,\WirePosition{4*#1+2})
\psarc(\CoreThickness,\WirePosition{4*#1+1}){\WindingRadius}{270}{90}
\multido{\iA = 1+1}{#1}{\Loop{\iA}}
\psline{-*}(0,0)(-\WireEndLength,0)%
}
% label
\newcommand*\Label[2]{%
\def\displacement{0.2}
\def\LabelSeparation{1pt}
\uput{\LabelSeparation}[90]%
(\LabelPositionX{#1},\fpeval{\LabelPositionY+\displacement})%
{$\Psi_{\scriptscriptstyle \Name{#2}}$}
\uput{\LabelSeparation}[270]%
(\LabelPositionX{#1},\LabelPositionY)%
{\psline{->}(0,\fpeval{-1+\displacement})(0,\displacement)}%
}
% windings and label combined
\newcommand*\Column[2]{%
% top windings
\rput(\WindingsPositionX{#1},
\fpeval{(\CoreThickness+\CoreholeVertical)
-(\WirePosition{4*\NumberOfWindingsTop+2}
+\WindingsCoreCornerDistance)})%
{\WireFull{\NumberOfWindingsTop}}
% label
\Label{#1}{#2}
% bottom windings
\rput(\WindingsPositionX{#1},
\fpeval{\CoreThickness+\WindingsCoreCornerDistance})%
{\WireFull{\NumberOfWindingsBottom}}%
}
% black component
\newcommand*\BlackComponent[3]{%
% nodes
\pnodes%
(\ComponentNoteX{#1},
0){P1}%
(\ComponentNoteX{#1},
\ComponentEndHeight){P2}%
(\fpeval{\ComponentStart-\ComponentThickness/2+\ComponentNumber{#1}},
\ComponentEndHeight){P3}%
(\fpeval{\ComponentStart+\ComponentThickness/2+\ComponentNumber{#1}},
\fpeval{\ComponentEndHeight+\ComponentHeight}){P4}%
(\ComponentNoteX{#1},
\fpeval{\ComponentEndHeight+\ComponentHeight}){P5}%
(\ComponentNoteX{#1},
\fpeval{2*\ComponentEndHeight+\ComponentHeight}){P6}
% bottom wire
\psline{*-}(P1)(P2)
% component
\psframe[
fillstyle = solid,
fillcolor = black
](P3)(P4)
% top wire
\psline{-*}(P5)(P6)
% labels
\uput[20](P1){$#2$}
\uput[340](P6){$#3$}%
}
% black component, gathered
\newcommand*\Component[3]{%
\rput(0,\fpeval{1016/7227}){\BlackComponent{#1}{#2}{#3}}
\rput(0,\fpeval{\CoreThickness+\CoreholeVertical/2
+\ComponentsVerticalDistance/2-1016/7227})%
{\BlackComponent{#1}{\Name{#2}}{\Name{#3}}}%
}
%%% parameters %%%
% core placement
\newcommand*\CoreThickness{2}
\newcommand*\CoreholeHorizontal{5}
\newcommand*\CoreholeVertical{8}
% wire placement
\newcommand*\WindingsCoreCornerDistance{0.5}
\newcommand*\WireEndLength{0.7}
\newcommand*\WindingRadius{0.15}
% number of windings
\newcommand*\NumberOfWindingsTop{2}
\newcommand*\NumberOfWindingsBottom{3}
% electromagnet--components distance
\newcommand*\ElectroamgnetComponentDistance{4}
% black components
\newcommand*\ComponentEndHeight{0.8}
\newcommand*\ComponentThickness{1}
\newcommand*\ComponentsHorizontalDistance{3}
\newcommand*\ComponentsVerticalDistance{2}
\pagestyle{empty}
\begin{document}
\begin{center}
\psset{unit = 0.5}
\begin{pspicture}%
(\DiagramHorizontalStart,0)%
(\DiagramHorizontalEnd,\DiagramVerticalEnd)
%%% electromagnet
% core
\Core
% wires and labels
\Column{1}{a}
\Column{2}{b}
\Column{3}{c}
%%% components
\Component{1}{a}{x}
\Component{2}{b}{y}
\Component{3}{c}{z}
\end{pspicture}
\end{center}
\end{document}
请注意,绘图是“自动化的”;您可以自己选择所有参数的值,然后绘图将进行相应的调整。
答案2
这里有一个起点。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (7,5);
\draw (1,1) rectangle (3,4);
\draw (4,1) rectangle (6,4);
\foreach \i in {0,3,6}{
\begin{scope}[xshift=\i{}cm]
\path[fill] (-0.3,3.5) circle (2pt);
\draw[thick] (-0.3,3.5) -- (1,3.5) arc [start angle=0, delta angle =-180, radius=.5mm, rotate=90];
\draw[thick] (0,3.4) arc [start angle=0, delta angle =180, radius=.5mm, rotate=90] -- (1,3.3) arc [start angle=0, delta angle =-180, radius=.5mm, rotate=90];
\draw[thick] (0,3.2) arc [start angle=0, delta angle =180, radius=.5mm, rotate=90] -- (1.3,3.1);
\path[fill] (1.3,3.1) circle (2pt);
\end{scope}}
\end{tikzpicture}
\end{document}
更新
只是为了好玩,我认为这是一个很好的例子,可以用pics
和来练习quotes
。你需要TiKZ 3.0.0哪个将前往 CTAN
新代码为:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{quotes,arrows.meta}
\begin{document}
\tikzset{
terminal_a/.pic = {%
\coordinate (-in) at (-3mm,0);
\coordinate (-out) at (-3mm,-4.5mm);
\path[fill] (-in) circle (2pt);
\draw[thick] (-in)--(0,0)--++(0:1cm) arc[start angle=90, delta angle=-180, radius=.75mm];
\draw[thick] (0,-1.5mm) arc[start angle=90, delta angle=180, radius=.75mm]--++(0:1cm) arc[start angle=90, delta angle=-180, radius=.75mm];
\fill (-out) circle (2pt);
\draw[thick] (-out) -- ++(0:3mm);
},
terminal_b/.pic = {%
\coordinate (-in) at (-3mm,0);
\coordinate (-out) at (-3mm,-7.5mm);
\path[fill] (-in) circle (2pt);
\draw[thick] (-in)--(0,0)--++(0:1cm) arc[start angle=90, delta angle=-180, radius=.75mm];
\draw[thick] (0,-1.5mm) arc[start angle=90, delta angle=180, radius=.75mm]--++(0:1cm) arc[start angle=90, delta angle=-180, radius=.75mm];
\draw[thick] (0,-4.5mm) arc[start angle=90, delta angle=180, radius=.75mm]--++(0:1cm) arc[start angle=90, delta angle=-180, radius=.75mm];
\fill (-out) circle (2pt);
\draw[thick] (-out) -- ++(0:3mm);
},
field/.pic = {
\draw[thick,-Stealth] (0,0) -- (90:7mm) node[above] {\tikzpictext};
}
}
\begin{tikzpicture}
\draw (0,0) rectangle (7,5);
\draw (1,1) rectangle (3,4);
\draw (4,1) rectangle (6,4);
\foreach \i/\j in {0/A,3/B,6/C}{
\pic (upper-\j) at (\i,3.8) {terminal_a};
\pic (lower-\j) at (\i,2) {terminal_b};
\pic["$\Psi_\j$"] at ([xshift=5mm]\i,2.2) {field};
}
\node[left] at (upper-A-in) {A};
\draw[red] (upper-A-out) to [bend right] (lower-A-in);
\end{tikzpicture}
\end{document}
结果是
答案3
我对三相变压器使用了以下库。(可以实现更多自动化。)
它使用被注释部分中的部分。
\documentclass[border=3mm]{standalone}
\usepackage[siunitx,european]{circuitikz}
\usepackage{comment}
\begin{document}
\begin{circuitikz}
{ % core HV - LV
\coordinate (a) at (-4,-5);
\draw (a)
%node {X} %debug
[thick](a) ++(0.95,3.3) -- +(6.1,0);
\draw [thick](a) ++(0.95,2.3) -- +(6.1,0);
\draw [thick](a) ++(0.95,1.3) -- +(6.1,0);
}
{ % LV star
\coordinate (a) at (4,-5);
\draw (a)
%node {x} %debug
++(0,0) node [anchor=north] {$n_2$}
to [short, *-]
++(-3.5,0) to [short,-]
++(0,3) to [short,-]
++(+0.5,0)
++(-0.5,-1) to [short,*-]
++(+0.5,0)
++(-0.5,-1) to [short,*-]
++(+0.5,0);
}
{ % HV delta1
\coordinate (a) at (-4,-5);
\draw (a)
%node {X} %debug
++(0,3)
to [short,-]
++(3,-1)
(a)++(0,2)
to [short,-]
++(3,-1)
(a)++(3,3)
to [short,-]
++(0.5,0)
to [short,-]
++(0,-2.5)
to [short,-]
++(-3.25,0)
to [short,-*]
++(0,0.5);
}
{ % HV conection
\coordinate (a) at (-4,-5);
\draw (a)
%node {X}%debug
++(-1,0) node [anchor=east] {$N$}
to[short, o-]
++(1,0)
++(-1,1) node [anchor=east] {$C$}
to[short, o-]
++(1,0)
++(-1,1) node [anchor=east] {$B$}
to[short, o-]
++(1,0)
++(-1,1) node [anchor=east] {$A$}
to[short, o-]
++(1,0);
}
{ % LV conection
\coordinate (a) at (4,-5);
\draw (a)
%node {x}%debug
++(0,0)
to[short, -o]
++(1,0) node [anchor=west] {$n$}
++(-1,1)
to[short, -o]
++(1,0)node [anchor=west] {$c$}
++(-1,1)
to[short, -o]
++(1,0) node [anchor=west] {$b$}
++(-1,1)
to[short, -o]
++(1,0)node [anchor=west] {$a$};
}
{ % HV Winding
\coordinate (a) at (-4,-5);
\draw (a)
%node {X}%debug
++(0,1) node [anchor=north] {$C_2$}
to [L,*-*, i>^=$i_{CB}$]
+(3,0) node [anchor=north] {$C_1$};
\draw
(a)++(0,2) node [anchor=north] {$B_2$}
to [L,*-*]
+(3,0) node [anchor=north] {$B_1$};
\draw
(a)++(0,3) node [anchor=north] {$A_2$}
to [L,*-*]
+(3,0) node [anchor=north] {$A_1$};
}
{ % LV Winding
\coordinate (a) at (4,-5);
\draw (a)
%node {x} %debug
++(-3,1) node [anchor=north] {$c_1$}
to [L,*-*, i=$i_{c_{12}}$, v_=$u_{c_{12}}$]
+(3,0) node [anchor=north] {$c_2$};
\draw
(a)++(-3,2) node [anchor=north] {$b_1$}
to [L,*-*]
+(3,0) node [anchor=north] {$b_2$};
\draw
(a)++(-3,3) node [anchor=north] {$a_1$}
to [L,*-*]
+(3,0) node [anchor=north] {$a_2$};
}
\end{circuitikz}
\begin{comment}
Transformer parts.
\begin{circuitikz}
\draw (0,0) node {(0,0)};
{ % HV conection
\coordinate (a) at (-5,5);
\draw (a)
node {X}%debug
++(-1,0) node [anchor=east] {$N$}
to[short, o-]
++(1,0)
++(-1,1) node [anchor=east] {$C$}
to[short, o-]
++(1,0)
++(-1,1) node [anchor=east] {$B$}
to[short, o-]
++(1,0)
++(-1,1) node [anchor=east] {$A$}
to[short, o-]
++(1,0);
}
{ % LV conection
\coordinate (a) at (5,5);
\draw (a)
node {x}%debug
++(0,0)
to[short, -o]
++(1,0) node [anchor=west] {$n$}
++(-1,1)
to[short, -o]
++(1,0)node [anchor=west] {$c$}
++(-1,1)
to[short, -o]
++(1,0) node [anchor=west] {$b$}
++(-1,1)
to[short, -o]
++(1,0)node [anchor=west] {$a$};
}
{ % HV Winding
\coordinate (a) at (-4,1);
\draw (a)
node {X}%debug
% ++(0,1) node [anchor=north] {$C_2$} % option 1
++(0,1) node [anchor=south] {$C_2$} % option 2
to [L,*-*]
+(3,0) node [anchor=north] {$C_1$};
\draw
(a)++(0,2) node [anchor=north] {$B_2$}
to [L,*-*]
+(3,0) node [anchor=north] {$B_1$};
\draw
(a)++(0,3) node [anchor=north] {$A_2$}
to [L,*-*]
+(3,0) node [anchor=north] {$A_1$};
}
{ % LV Winding
\coordinate (a) at (4,1);
\draw (a)
node {x} %debug
++(-3,1) node [anchor=north] {$c_1$}
to [L,*-*]
% +(3,0) node [anchor=north] {$c_2$}; % option 1
+(3,0) node [anchor=south] {$c_2$}; % option 2
\draw
(a)++(-3,2) node [anchor=north] {$b_1$}
to [L,*-*]
+(3,0) node [anchor=north] {$b_2$};
\draw
(a)++(-3,3) node [anchor=north] {$a_1$}
to [L,*-*]
+(3,0) node [anchor=north] {$a_2$};
}
{ % HV star
\coordinate (a) at (-4,5);
\draw (a)
node {X} %debug
++(0,0) node [anchor=north] {$N_2$}
to [short, *-]
++(3.5,0) to [short,-]
++(0,3) to [short,-]
++(-0.5,0)
++(+0.5,-1) to [short,*-]
++(-0.5,0)
++(+0.5,-1) to [short,*-]
++(-0.5,0);
}
{ % LV star
\coordinate (a) at (4,5);
\draw (a)
node {x} %debug
++(0,0) node [anchor=north] {$n_2$}
to [short, *-]
++(-3.5,0) to [short,-]
++(0,3) to [short,-]
++(+0.5,0)
++(-0.5,-1) to [short,*-]
++(+0.5,0)
++(-0.5,-1) to [short,*-]
++(+0.5,0);
}
{ % HV delta1
\coordinate (a) at (-4,13);
\draw (a)
node {X} %debug
++(0,3)
to [short,-]
++(3,-1)
(a)++(0,2)
to [short,-]
++(3,-1)
(a)++(3,3)
to [short,-]
++(0.5,0)
to [short,-]
++(0,-2.5)
to [short,-]
% ++(-3.25,0) % option 1
++(-3.5,0) % option 2
to [short,-*]
++(0,0.5);
++(0,0.5)node;
}
{ % HV delta11
\coordinate (a) at (-4,9);
\draw (a)
node {X} %debug
++(0,1)
to [short,-]
++(3,1)
(a)++(0,2)
to [short,-]
++(3,1)
(a)++(3,1)
to [short,-]
++(0.5,0)
to [short,-]
++(0,2.5)
to [short,-]
% ++(-3.25,0) % option 1
++(-3.5,0) % option 2
to [short,-*]
++(0,-0.5);
}
{ % LV delta11
\coordinate (a) at (4,9);
\draw (a)
node {x} %debug
++(-3,1)
to [short,-]
++(3,1)
(a)++(-3,2)
to [short,-]
++(3,1)
% link
(a)++(-3,3)
to [short,-]
++(-0.5,0)
to [short,-]
++(0,-2.5)
to [short,-]
% ++(3.25,0) % option 1
++(3.5,0) % option 2
to [short,-*]
++(0,0.5);
}
{ % LV delta1
\coordinate (a) at (4,13);
\draw (a)
node {x} %debug
++(-3,3)
to [short,-]
++(3,-1)
(a)++(-3,2)
to [short,-]
++(3,-1)
%link
(a)++(-3,1)
to [short,-]
++(-0.5,0)
to [short,-]
++(0,2.5)
to [short,-]
% ++(3.25,0) % option 1
++(3.5,0) % option 2
to [short,-*]
++(0,-0.5);
}
{ % core HV - LV
\coordinate (a) at (-4,17);
\draw (a)
node {X} %debug
[thick](a) ++(0.95,3.3) -- +(6.1,0);
\draw [thick](a) ++(0.95,2.3) -- +(6.1,0);
\draw [thick](a) ++(0.95,1.3) -- +(6.1,0);
}
\end{circuitikz}
\end{comment}
\end{document}