5

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 enter image description here

\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, enter image description here

However, there are things I don't fully understand how to create or do better/less hacky, listed as below:

  1. How to draw that particular transformer symbol, which I don't see on CircuiTikZ, and had to use oosourcetransshape instead. In addition, I used oosourcetransshape (which is a node object) rather than oosourcetrans (which is a path-style object) so that I can adjust its position and the semithick option without relying on the default line it creates. However, doing so results in the tiny whitespace at each end.
  2. Is my way of adding the labels and annotations too wack? If so please teach me a better way to do the labelling.
  3. 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!!

1
  • 3
    Hi! I have no time now, but judging from your preamble you are mixing circuitikz with the internal circuits library, which is not recommended.
    – Rmano
    May 2, 2021 at 7:56

1 Answer 1

4

Let's see how I would do it in circuitikz (see footnote):

  1. the bus thing is used a couple of times, so I would define an on-line macro to position one. I have heavily commented it in the code.

  2. The sinusoidal source is vsourcesinshape, you can find it there. We rotate it (beware that the anchors will rotate too, so .s is at the right now) enter image description here

  3. The same can be done for the double-inductance simbol; use the node shape and the corresponding anchors: enter image description here

So basically it becomes quite simple:

\documentclass[border=10pt]{standalone}
\usepackage[RPvoltages]{circuitikz}

\newcommand{\bushere}[2]{%
    % starting point; draw an edge and then two nodes
    % save the position
    coordinate(tmp)
    % go up and do an edge down
    ++(0,1) node[above]{#1} edge[ultra thick] ++(0,-2)
    % edges do not move the current point, go down to position the node
    ++(0,-2) node[below]{#2}
    % go back to where we started
    (tmp)
}
\begin{document}
\begin{tikzpicture}[thick]% default line thickness
    \draw (0,0) node[vsourcesinshape, rotate=90](S){} (S.south) -- ++(1,0)
        \bushere{$\upsilon_1 = 1\angle0$}{Bus 1} -- ++(1,0)
        node[americaninductorshape, anchor=midtap, rotate=-90](L1){}
        ++(0.5,0)
        node[americaninductorshape, rotate=90](L2){} (L2.midtap)
        to[generic, l_={$y=g-\mathbf{j}b$}] ++(3,0)
        \bushere{$\upsilon_2 = V_{2}\angle\theta$}{Bus 2} -- ++(1,0)
        edge[-Stealth] ++(0.5,0)
        ;
\end{tikzpicture}
\end{document}

enter image description here


footnote:

I think that the oosourcetrans is the correct symbol for this kind of schematics; the other one is really a symbol used in more detailed schematics with all the connections. That makes the code more straightforward:

\begin{tikzpicture}[semithick]% default line width
    \draw (0,0) node[vsourcesinshape, rotate=90](S){} (S.south) -- ++(1,0)
        \bushere{$\upsilon_1 = 1\angle0$}{Bus 1} -- ++(1,0)
        to[oosourcetrans] ++(1,0)
        to[generic, l_={$y=g-\mathbf{j}b$}] ++(3,0)
        \bushere{$\upsilon_2 = V_{2}\angle\theta$}{Bus 2} -- ++(1,0)
        edge[-Stealth] ++(0.5,0)
        ;
\end{tikzpicture}

enter image description here

1
  • Thanks so much for your detailed answer!!
    – gouhaha
    May 2, 2021 at 19:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .