4

As part of my electrical engineering unit, I would like to show various elements either producing or dissipating energy.

One of my lectures had this image, and I was wondering if using arrows from TikZ was the only way to achieve this image.

I'm happy to modify the output if CircuiTikZ has these shapes pre-defined.

Power dissipation (passive component)

My attempt using LaTeX:

\documentclass{standalone}
\usepackage{circuitikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{circuitikz}
    \draw (0, 0) -- (0.5, 0) to[generic] (0.5, 2) -- (0, 2);
    % Current direction arrows
    \draw[latex-] (-0.5, 2) node[anchor = east] {$i$} -- (-.1, 2);
    \draw[latex-] (-0.1, 0) -- (-.5, 0);
    % Charge signs
    \draw (0.5, 0) node[anchor = west] {$-$};
    \draw (0.5, 2) node[anchor = west] {$+$};
    % Power snake line
    \draw[<-, decorate, decoration = {snake, amplitude = .4mm, segment length = 2mm}]
    (0.71, 1) -- (1.21, 1.5) node[anchor = west] {$p=-vi$};
\end{circuitikz}
\end{document}

LaTeX attempt

0

2 Answers 2

4

You could just use the to[out=<angle>,in=<another angle>] syntax if you wanted you arrow to be like the one in your picture:

bent arrow

\documentclass{standalone}
\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}
    \draw (0, 0) -- (0.5, 0) to[generic] (0.5, 2) -- (0, 2);
    % Current direction arrows
    \draw[latex-] (-0.5, 2) node[anchor = east] {$i$} -- (-.1, 2);
    \draw[latex-] (-0.1, 0) -- (-.5, 0);
    % Charge signs
    \draw (0.5, 0) node[anchor = west] {$-$};
    \draw (0.5, 2) node[anchor = west] {$+$};
    % Power snake line
    \draw[<-] (0.72, 1) to[out=0,in=180] (1.21, 1.5) node[anchor = west] {$p=-vi$};
\end{circuitikz}
\end{document}
2
  • 1
    Thank you for the help! I think this line looks better than the snake variation I drew, so I might combine this with @Rmano's answer, as he creates a new style which I can reuse. Commented Jul 6, 2021 at 8:15
  • 2
    That's OK, you deserve to choose between all answers which one suits you the best. We're all happy to help.
    – SebGlav
    Commented Jul 6, 2021 at 8:26
6

circuitikz is basically an extension over TikZ, so I see no reason to re-do things that are already there. You can use advanced anchors to have kind-of power flows (see https://texdoc.org/serve/circuitikz/0#subsection.5.8), but in this case TikZ serves you quite well.

I would suggest to define a style and then use relative coordinates to position your power snake (so that you do not have to change anything if you move the component:)


\documentclass{standalone}
\usepackage{circuitikz}
\usetikzlibrary{decorations.pathmorphing}
\tikzset{power snake/.style=
    {Latex-, decorate, decoration={snake,
        amplitude=.4mm,segment length=2mm,post length=.2mm, pre length=2mm}
    }
}

\begin{document}
\begin{circuitikz}
    % name the component
    \draw (0, 0) -- (0.5, 0) to[generic, name=comp] (0.5, 2) -- (0, 2);
    % Current direction arrows
    \draw[latex-] (-0.5, 2) node[anchor = east] {$i$} -- (-.1, 2);
    \draw[latex-] (-0.1, 0) -- (-.5, 0);
    % Charge signs
    \draw (0.5, 0) node[anchor = west] {$-$};
    \draw (0.5, 2) node[anchor = west] {$+$};
    % Power snake line (use the component anchor, remember that anchors are
    % defined for the horizontal component going left to right!
    \draw[power snake] (comp.south) -- ++(.6,.5) node[anchor = west] {$p=-vi$};
\end{circuitikz}
\end{document}

enter image description here

You must log in to answer this question.

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