[Tex/LaTex] Circuitikz: arrows on the path and changing directions of arrow with variable resistor

arrowscircuitikznodes

For my R_2(t), I would like the arrow bottom left to top right of the resistor. Is there a way to swap the arrow direction?

Also, above the non-linear resistor, how can I add an arrow on the path?

Here is what I am going for:

enter image description here

Here is my code:

\documentclass[convert = false]{standalone}
\usepackage[american, cuteinductors]{circuitikz}
\usepackage{siunitx}

\begin{document}
\begin{circuitikz}[scale = 2]
  \draw                                             (0, 0)
        to[american voltage source, v^ = $e(t)$]    (0, 3)
        to[R, l^ = $R_1$, -*]                       (1.5, 3)
        to[vR, l_ = $R_2(t)$]                       (1.5, 1.5)
        to[L, l^ = $i_L(t)$, i = $ \ $, -*]         (1.5, 0)
        to[short]                                   (0, 0);
  \draw                                             (1.5, 0)
        to[short, -*]                               (3, 0)
        to[C, l^ = $v_c(t)$, -*]                    (3, 3)
        to[short]                                   (1.5, 3);
  \draw                                             (3, 3)
        to[short]                                   (4.5, 3)
        to[R]                                       (4.5, 0)
        to[short]                                   (3, 0);

  \node at (1.25, .75) {$L$};
  \node at (3.35, 1.5) {$C$};
  \node at (3.1, 1.65) {$+$};
  \node[align = left] at (5.1, 1.5) {Nonlinear \\ resistor};
\end{circuitikz}
\end{document}

Here is what I have:

enter image description here

Best Answer

\documentclass[convert = false,border=3pt]{standalone}
\usepackage[american, cuteinductors]{circuitikz}
\usepackage{siunitx}

\makeatletter
\ctikzset{bipoles/vresistorm/height/.initial=.6}
\ctikzset{bipoles/vresistorm/width/.initial=.8}
\def\pgf@circ@vresistorm@path#1{\ifpgf@circuit@europeanresistor\pgf@circ@bipole@path{tgeneric}{#1}\else\pgf@circ@bipole@path{vresistorm}{#1}\fi}

\tikzset{variable resistorm/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@vresistorm@path, l=#1}}
\tikzset{variable american resistorm/.style= {\circuitikzbasekey, /tikz/to path=\pgf@circ@bipole@path{vresistorm}{#1}, l=#1}}


\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vresistorm/height}}{vresistorm}{\ctikzvalof{bipoles/vresistorm/height}}{\ctikzvalof{bipoles/vresistorm/width}}{
        \pgf@circ@res@step = \ctikzvalof{bipoles/vresistorm/width}\pgf@circ@Rlen
        \divide \pgf@circ@res@step by 12
        \def\myfrac{.5}

        \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}
        \pgf@circ@res@other = \pgf@circ@res@left
        \advance\pgf@circ@res@other by \pgf@circ@res@step 
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@up}}
        \advance\pgf@circ@res@other by 2\pgf@circ@res@step 
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@down}}
        \advance\pgf@circ@res@other by 2\pgf@circ@res@step
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@up}}
        \advance\pgf@circ@res@other by 2\pgf@circ@res@step
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@down}}
        \advance\pgf@circ@res@other by 2\pgf@circ@res@step
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@up}}
        \advance\pgf@circ@res@other by 2\pgf@circ@res@step
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\myfrac\pgf@circ@res@down}}
        \advance\pgf@circ@res@other by \pgf@circ@res@step
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
        \pgfusepath{draw}

        \pgfscope
        \pgfsetarrowsend{latex'}
        \pgfpathmoveto{\pgfpoint{.7\pgf@circ@res@other}{-\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@other}{-\pgf@circ@res@down}}
        \pgfusepath{draw}
        \endpgfscope
}
\makeatother

\begin{document}
\begin{circuitikz}[scale = 2]
  \draw                                             (0, 0)
        to[american voltage source, v^ = $e(t)$]    (0, 3)
        to[R, l^ = $R_1$, -*]                       (1.5, 3)
        to[variable american resistorm, l_ = $R_2(t)$]                       (1.5, 1.5)
        to[L, l^ = $i_L(t)$, i = $ \ $, -*]         (1.5, 0)
        to[short]                                   (0, 0);
  \draw                                             (1.5, 0)
        to[short, -*]                               (3, 0)
        to[C, l^ = $v_c(t)$, -*]                    (3, 3)
        to[short]                                   (1.5, 3);
  \draw                                             (3, 3)
        to[short]                                   (4.5, 3)
        to[R]                                       (4.5, 0)
        to[short]                                   (3, 0);
  \draw                 (4.5,2.75)
        to[short,i=$f_{v}(c)$]          (4.5,2);      
  \node at (1.25, .75) {$L$};
  \node at (3.35, 1.5) {$C$};
  \node at (3.1, 1.65) {$+$};
  \node[align = left] at (5.1, 1.5) {Nonlinear \\ resistor};
\end{circuitikz}
\end{document}

enter image description here

  1. I defined a new shape variable american resistorm similar to variable american resistor but placing the arrow in the required direction.

  2. A quick solution is to use an additional path; something like

    \draw                   (4.5,2.75)
        to[short,i=$f_{v}(c)$]          (4.5,2);