Circuitikz:路径上的箭头以及使用可变电阻改变箭头的方向

Circuitikz:路径上的箭头以及使用可变电阻改变箭头的方向

对于我的R_2(t),我希望箭头从电阻器的左下角到右上角。有没有办法交换箭头方向?

另外,在非线性电阻上方,如何在路径上添加箭头?

以下是我要做的事情:

在此处输入图片描述

这是我的代码:

\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}

以下是我所拥有的:

在此处输入图片描述

答案1

\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}

在此处输入图片描述

  1. 我定义了一个variable american resistorm类似的新形状variable american resistor,但将箭头放置在所需的方向。

  2. 一个快速的解决方案是使用额外的路径;比如

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

答案2

这是一个可能的解决方案。对于箭头,此解决方案使用 R 然后绘制箭头。至于当前方向,使用i>^=$f(v_c)$,如下面的代码所示。

在此处输入图片描述

代码

\documentclass[convert = false,border=10pt]{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[R,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,i>^=$f(v_c)$]                          (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};
  \draw[thick,->,>=stealth] (1.2,2.1)--(1.7,2.35);
\end{circuitikz}
\end{document}

相关内容