I recently started using TikZ and want to replicate a simple 2-bus single line diagram as follows (with the transformer drawn on Paint... and highlighted in yellow, plus some changes in the annotation) using the CircuiTikZ package
\documentclass[border=1pt]{standalone}
\usepackage{circuitikz}
\usepackage{upgreek}
\usepackage{amsmath,amsfonts,amssymb}
\usetikzlibrary[shapes,arrows.meta]
\usetikzlibrary{positioning}
\usetikzlibrary{circuits.ee.IEC}
\renewcommand{\j}{\mathbf{j}}
\begin{document}
\tikzset{circuit declare symbol=source,
set source graphic={
draw,
circuit symbol lines,
circuit symbol size=width 2.5 height 2.5,
shape=generic circle IEC,
transform shape,
thick,
},
ac/.style={
/pgf/generic circle IEC/before background={
\pgftransformresetnontranslations
\pgfpathmoveto{\pgfpoint{-0.75\tikzcircuitssizeunit}{0pt}}
\pgfpathsine{
\pgfpoint{0.375\tikzcircuitssizeunit}{0.375\tikzcircuitssizeunit}
}
\pgfpathcosine{
\pgfpoint{0.375\tikzcircuitssizeunit}{-0.375\tikzcircuitssizeunit}
}
\pgfpathsine{
\pgfpoint{0.375\tikzcircuitssizeunit}{-0.375\tikzcircuitssizeunit}
}
\pgfpathcosine{
\pgfpoint{0.375\tikzcircuitssizeunit}{0.375\tikzcircuitssizeunit}
}
\pgfusepathqstroke
}
},
admittance/.style={
draw,
rectangle,
minimum width=10mm,
minimum height=3mm,
semithick
},
point/.style={
coordinate
},
arrow/.style={
->,shorten >=0pt,
>={Stealth[round]},
semithick
},
line/.style={
semithick
}
}
\begin{circuitikz}
% components
\node at (0,0) [source=ac] (v1) {};
\node at (2.5,0) [oosourcetransshape] (xformer1) {};
\node at (2.5,-0.5) {$\tau = t e^{\theta_{\text{s}}}$};
\node at (5,0) [admittance] (y1) {};
\node at (5,-0.5) {$y = g - \j b$};
\node at (7.75,0) [point] (load1) {};
% draw bus bars
\node at (1,0) [point] (bus1) {};
\node at (7,0) [point] (bus2) {};
\node at (1,0.75) {$\upsilon_1 = 1\angle0$};
\node at (7,0.75) {$\upsilon_2 = V_2 \angle \theta$};
\draw [ultra thick] (1,-0.5) node[below]{Bus 1} -- (1,0.5);
\draw [ultra thick] (7,-0.5) node[below]{Bus 2} -- (7,0.5);
% connect the lines
\draw [line] (v1) to (bus1);
\draw [line] (bus1) to (xformer1);
\draw [line] (xformer1) to (y1);
\draw [line] (y1) to (bus2);
\draw [arrow] (bus2) to (load1);
\end{circuitikz}
\end{document}[![enter image description here][2]][2]
I attempted to create a simple MWE pasted above,
However, there are things I don't fully understand how to create or do better/less hacky, listed as below:
- How to draw that particular transformer symbol, which I don't see on CircuiTikZ, and had to use
oosourcetransshape
instead. In addition, I usedoosourcetransshape
(which is a node object) rather thanoosourcetrans
(which is a path-style object) so that I can adjust its position and thesemithick
option without relying on the default line it creates. However, doing so results in the tiny whitespace at each end. - Is my way of adding the labels and annotations too wack? If so please teach me a better way to do the labelling.
- Is there a less hacky way of drawing the black bus bars? If possible as a node type object (not sure if this is the correct language) like the rest of the components.
The voltage source symbol defintion comes from this post "rotationally correct" AC source symbol in TikZ.
Thanks very much for any help in advance!!