7

I have this circuit below and want to draw voltage loops within the circuit so it is simiarly to the picture at the bottom. I have however seen someone use the arc, but it was not what i hoped for. Hope anyone can help me.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{circuitikz}
\usepackage{float}
\usepackage{calc}

\begin{document}

\begin{circuitikz}[american, straight voltages] \draw (-1,0) to [american voltage source, v=$V_P$, invert, voltage shift=1] (-1,4) %Input voltage Vp to [R, R=$R_p$, i^>=$i_p$] (2,4) to [R=$R_L$] (4,4) to [L, l_=$L$, v^<=$v_L$, i=$i_L$, voltage shift=1.5] (7,4)

to [Tnigbt,bodydiode] (10,4)
to [short] (12,4)
to [american voltage source, v^&lt;=$V_{out}$, voltage shift=1] (12,0)
to [short] (-1,0)

(2.0,4) to [R=$R_Ci$, i=$i_{Ci}$] (2.0,1.5)
to [C, l_=$C_i$, v^&lt;=$v_{Ci}$] (2.0,0)

(7.2,4) to [Tnigbt,bodydiode, invert] (7.2,0)

(10.0,4) to [R=$R_Co$, i=$i_{Co}$] (10.0,1.5)
to [C, l_=$C_o$, v^&lt;=$v_{Co}$] (10.0,0)

(8.5,5) node[align=center]{$G_2$}
(6.1,2) node[align=center]{$G_1$}
(7.2,0) node[circ, scale=1.5]{$1$}
(7.2,4) node[circ, scale=1.5]
(2,0) node[circ, scale=1.5]
(2,4) node[circ, color=red, scale=1.5]
(10,4) node[circ, color=red, scale=1.5]
(10,0) node[circ, color=red, scale=1.5]

;

\end{circuitikz}

\end{document}

This are the circuit i am trying to recreate

enter image description here

  • 2
    Is this what you want? https://tex.stackexchange.com/a/548319/274769 – internet Dec 14 '22 at 08:28
  • Somewhat related: https://tex.stackexchange.com/questions/304283/physical-model-of-transformer-using-circuitikz/304305?r=SearchResults&s=5%7C11.1501#304305 – John Kormylo Dec 14 '22 at 18:25

1 Answers1

9

I propose to define a macro that can put an "elliptical" arrow in the center of a mesh, feeding it three corners and the label. It can be tweaked a lot, but more or less, the idea could be the following one:

\documentclass[margin=3mm]{standalone}
\usepackage[siunitx,RPvoltages]{circuitikz}

\newcommand{\mesharrow}[5][red]{% optional: color, default red % mandatory: corner 1, corner 2, corner 3, label \coordinate (tmp-c) at ($(#2)!0.5!(#4)$); \node[#1] at (tmp-c) {#5}; \draw[thick, -Stealth, #1] let \p1 = ($(#3)-(#2)$), \p2=($(#4)-(#3)$), \n1={0.3veclen(\x1,\y1)}, \n2={0.3veclen(\x2,\y2} in ($(tmp-c)+(0.3*\x1,0)$) arc(0:270:\n1 and \n2); } \begin{document}

\tikzset{% this definition is at tikz level, because % it will be used with a node[... ] element bigO/.style={circle, draw, fill=red, inner sep=2pt}, } \begin{circuitikz} \draw (0,0) coordinate(start) % this number here (5)--v is the one referenced below in text to [battery=$V_p$] ++(0,5) coordinate(corner1) to[R=$R_p$, f=$i_p$] ++(4,0) coordinate(corner2) to[R=$R_{ci}$, f=$i_{ci}$] ++(0,-2) coordinate(rci) to[C=$C_i$, v=$v_{ci}$, -*] (corner2|-start) coordinate(corner3) -- (start); %% rest of the circuit... \draw[dashed] (corner2) -- ++(1,0) (corner3) -- ++(1,0); %% red blobs \node [bigO] at (corner2) {}; \node [bigO] at (rci) {}; %% \mesharrow{corner1}{corner2}{corner3}{$i_1$} \end{circuitikz} \end{document}

mesh current

Notice that the ellipse adjusts automatically to the mesh; if I change the number 5 marked above to 4 or 3 I have:

mesh current with different shape

Notice:

Rmano
  • 40,848
  • 3
  • 64
  • 125
  • Thanks, that is really helpful. Can you explain to me what (corner2|-start) does, becuase I dont think i quite understand the command. – Mads P Olesen Dec 17 '22 at 15:45
  • It's one of the most useful TikZ coordinate tricks for circuits; it means the point vertically from corner2 and horizontally from start; see https://tikz.dev/tikz-coordinates#pgf.perpendicular – Rmano Dec 17 '22 at 16:19
  • Ah okay, it is a little confusing but think I get it. Can i reverse the direction of the arrow? – Mads P Olesen Dec 17 '22 at 20:50
  • You mean, using Stealth- instead of -Stealth? Of course, look at arrows in the TikZ manual. I suggest going through the first TikZ tutorial, it'll save you a lot of time in the end! – Rmano Dec 17 '22 at 22:05
  • Ah okay thanks! – Mads P Olesen Dec 17 '22 at 22:47