# How can I draw variable springs and dampers using Circuitikz?

I would like to be able to a draw mechanical circuit that includes variable springs and dampers using the circuitikz package. Circuitikz already includes commands for constant springs and dampers, but not for variable ones. Until variable springs and dampers are added to the package, how can I draw them in a manner that fits neatly with the circuitikz package? Ideally, the variable spring and damper symbols would use the same arrows that the variable resistors and capacitors already have.

## Minimal working example

Here is a minimal working example that generates a mechanical circuit with a constant spring and damper:

\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\pgfmathsetmacro\BY{-2} % bottom y-values
\coordinate (T1) at (0,0); % T for top'' row
\coordinate (T2) at (1,0);
\coordinate (T3) at (2,0);
\coordinate (B1) at (0,\BY); % B for bottom'' row
\coordinate (B2) at (1,\BY);
\coordinate (B3) at (2,\BY);
\coordinate (E1) at (1, 0.5); % E for extra''
\coordinate (E2) at (1, \BY-0.5);
\draw
(B1) to [spring, .-.] (T1)
(B3) to [damper, .-.] (T3)
(T1) -- (T3)
(B1) -- (B3)
(T2) to [short, -*] (E1)
(B2) to [short, -*] (E2)
;
\end{circuitikz}
\end{document}

If your question is only how to add these arrows, you could do

\documentclass{standalone}
\usepackage{circuitikz}
\usetikzlibrary{calc}
\begin{document}
\begin{circuitikz}
\pgfmathsetmacro\BY{-2} % bottom y-values
\coordinate (T1) at (0,0); % T for top'' row
\coordinate (T2) at (1,0);
\coordinate (T3) at (2,0);
\coordinate (B1) at (0,\BY); % B for bottom'' row
\coordinate (B2) at (1,\BY);
\coordinate (B3) at (2,\BY);
\coordinate (E1) at (1, 0.5); % E for extra''
\coordinate (E2) at (1, \BY-0.5);
\draw
(B1) to [spring,.-.] (T1)
(B3) to [damper,.-.] (T3)
(T1) -- (T3)
(B1) -- (B3)
(T2) to [short,-*] (E1)
(B2) to [short,-*] (E2)
;
\foreach \X in {1,3}
{\path (B\X) -- (T\X) coordinate[midway] (aux\X);
\draw[thick,-stealth] ([xshift=-5mm,yshift=-4mm]aux\X) --
([xshift=5mm,yshift=4mm]aux\X);}
\end{circuitikz}
\end{document}

If you want a more automatized version, this may require considerably more effort.

• I would prefer a more automated version, so that I could write "(B3) to [variable spring] (T3)", but that will probably necessitate updating the circuitikz package. Your answer is a good stop-gap approach in the mean-time. Jan 29 '19 at 19:13
• @RobotRaven On this site you can find several examples in which a new shape for circuitikz is declared. The reason why I would hesitate to do that is that this will introduce a lot of new parameters and so on. And also because circuitikz does some drastic redefinitions of TikZ syntax, so I am very likely to fall in some pit.
– user121799
Jan 29 '19 at 19:18