5

For the following schematic of an electromechanical system, I would like to:

1- reduce and optimize the code as much as possible for the following:

  • drawing a line from its center by specifying its length and rotation (e.g. the line below N_1 and above N_2)

  • find a more compact way to position and draw the pattern-filled rectangle instead of defining coordinates

  • find a more optimized way to place the twisted arrows halfway between the vertical lines and the motor and cylinder

2- center the current arrow i_a between the resistance and the inductance,

3- understand the reason behind the existence of the gap between (M1.east) and the horizontal line next to it.

4- know why do I need to write down the unit mm for xshift and yshift to make it work as expected.

5- move E_a with its positive and negative signs to the right to be horizontally aligned with the circuit terminals. i.e. both signs and terminals and E_a should be horizontally aligned.

Further recommendations and code reductions are highly appreciated.

enter image description here

\documentclass[border=5mm]{standalone}

\usepackage{tikz}
\usepackage[american,siunitx]{circuitikz}
\usetikzlibrary{arrows,shapes,calc, positioning, patterns, decorations, decorations.markings}

\newcommand{\mymotor}[2] % #1 = name , #2 = rotation angle
{\draw[thick,rotate=#2] (#1) circle (10pt)
    node[]{$\mathsf M$} 
    ++(-12pt,3pt)--++(0,-6pt) --++(2.5pt,0) ++(-2.8pt,6pt)-- ++(2.5pt,0pt);
    \draw[thick,rotate=#2] (#1) ++(12pt,3pt)--++(0,-6pt) --++(-2.5pt,0) ++(2.8pt,6pt)-- ++(-2.5pt,0pt);
}

\begin{document}

    \begin{tikzpicture}[damper/.style={thick,
            decorate,
            decoration={markings,  
                mark connection node=dmp,
                mark=at position 0.5 with 
                {
                    \node (dmp) [thick, inner sep=0pt, 
                    transform shape, 
                    rotate=-90, 
                    minimum width=15pt, 
                    minimum height=10pt, draw=none] {};
                    \draw [thick] ($(dmp.north east)+(4pt,0)$) -- 
                    (dmp.south east) -- (dmp.south west) -- 
                    ($(dmp.north west)+(4pt,0)$);
                    \draw [thick] ($(dmp.north)+(0,-8pt)$) -- 
                    ($(dmp.north)+(0,8pt)$);
        }}},]

        \draw (0,2) to[R=$R_a$,o-,  f=$i_a$] ++(2,0)  to[L,cute inductor, l=$L_a$,]  ++(2,0)  to[sV, color=white, name=M1] ++(0,-2) to[short,-o] ++(-4,0);
        \mymotor{M1}{90}

        \draw (0,2) to [open, v=$E_a$] (0,0);

        \draw[thick] (M1.north) -- ++(1.5,0) -- +(0,0.5) node [anchor=south] {$N_1$} -- +(0,-0.5) coordinate (N1);

        \draw[->] ([xshift=7.5mm,yshift=-2mm]M1.north)  to [out=-60,in=60, looseness=4] ++(0,0.4) node [above=1mm] {$T_m, \theta_m$};

        \draw[thick] ([yshift=-2]N1) -- ++(0,-1.5) node [below] {$N_2$} ++(0,0.75) -- ++(1,0) node [cylinder, black, shape border rotate=180, draw,
        minimum height=2, minimum width=1, aspect=0.5,cylinder uses custom fill, cylinder end fill = gray!20,anchor=west] (c) {Load Inertia};

        \draw[->] ([xshift=-5mm,yshift=-2mm]c.west)  to [out=-120,in=120, looseness=4] ++(0,0.4) node [above=1mm] {$\theta_L$};

        \draw [damper] (c.east) -- node[above=3mm] {$d_1$} ++(0:2) ++(0,-1) coordinate (pttrn);


        \draw[preaction={fill=gray!10},pattern=north east lines,pattern=bricks] (pttrn) rectangle ++(0.5,2);
    \end{tikzpicture}

\end{document}
Diaa
  • 9,599
  • 1
    Assuming you really need to do the cylinder in one stretch, you could do \draw[thick] ([yshift=-2]N1) -- ++(0,-1.5) node [below] {$N_2$} coordinate[midway] (aux) (aux) -- ++ (1,0) node [anchor=top,right,cylinder, black, shape border rotate=180, draw, minimum height=2, minimum width=1, aspect=0.5,cylinder uses custom fill, cylinder end fill = gray!20, path picture={\draw($(c.before top)!0.5!(c.after top)$) -- (c.top);}] (c) {Load Inertia};. –  Nov 01 '19 at 18:09
  • @Schrödinger'scat Thanks for your consideration :) – Diaa Nov 01 '19 at 18:11
  • 1
    The problem is that the cylinder end fill is rather "violent", so it always goes in front, which prevents simpler solutions. If you want simpler solutions, you may need something like this definition of a filled cylinder, which also allows more fancy shadings. Similar ordering problems appear here. –  Nov 01 '19 at 18:12
  • @Schrödinger'scat Thanks for referring me to these questions. May I know what coordinate[midway] (aux) (aux) means to be used instead of ++(0,0.75)? – Diaa Nov 01 '19 at 18:16
  • 1
    Well, it will always be in the middle, also if you change the dimensions. It is a matter of taste which option one considers "better". –  Nov 01 '19 at 18:19

1 Answers1

4

1

find a more optimized way to place the twisted arrows halfway between the vertical lines and the motor and cylinder

Define a pic and use.

\tikzset{rotarrow/.pic={
\draw[thin,->] (-0.2,-0.2)  to [out=-60,in=60, looseness=4] ++(0,0.4) node [above=1mm] {\tikzpictext};
},
}

% \draw (0,0) -- pic[pic text={$\theta$}]{rotarrow} ++(1.5,0); %<-use pic

2

Use a short in between resistor and inductor and use flow arrow there.

\draw (0,2) to[R=$R_a$,o-] ++(2,0) to[short,f=$i_a$] ++(0.1,0) to[L,cute inductor, l=$L_a$,]  ++(2,0)  to[sV, color=white, name=M1] ++(0,-2) to[short,-o] (0,0);

3

M1 is a sinusoidal voltage source (sV). So its trying to access the east node of sV not mymotor. You can fix it by increasing the radius of circle in \mymotor. Or you can just use the elmech element.

\draw (M1) node[elmech,scale=0.7]{M};

4

Default unit is pt. See this questions: Different dimensions with shift and xshift and Setting “cm” as default unit of measures in tikzpicture

5

Use tikz path

\path (0,2)node[below]{+} -- node[midway]{$E_a$} (0,0)node[above]{-};

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usepackage[american,siunitx]{circuitikz}
\usetikzlibrary{arrows,shapes,calc, positioning, patterns, decorations, decorations.markings,quotes}
\tikzset{rotarrow/.pic={
\draw[thin,->] (-0.2,-0.2)  to [out=-60,in=60, looseness=4] ++(0,0.4) node [above=1mm] {\tikzpictext};
},
}

\begin{document}
    \begin{tikzpicture}[damper/.style={thick,
            decorate,
            decoration={markings,  
                mark connection node=dmp,
                mark=at position 0.5 with 
                {
                    \node (dmp) [thick, inner sep=0pt, 
                    transform shape, 
                    rotate=-90, 
                    minimum width=15pt, 
                    minimum height=10pt, draw=none] {};
                    \draw [thick] ($(dmp.north east)+(4pt,0)$) -- 
                    (dmp.south east) -- (dmp.south west) -- 
                    ($(dmp.north west)+(4pt,0)$);
                    \draw [thick] ($(dmp.north)+(0,-8pt)$) -- 
                    ($(dmp.north)+(0,8pt)$);
        }}},]

        \draw (0,2) to[R=$R_a$,o-] ++(2,0) to[short,f=$i_a$] ++(0.1,0) to[L,cute inductor, l=$L_a$,]  ++(2,0)  to[short,  name=M1] ++(0,-2) to[short,-o] (0,0);
        \draw (M1) node[elmech,scale=0.7](M2){M};
        \path (0,2)node[below]{+} -- node[midway]{$E_a$} (0,0)node[above]{-};
        \draw[thick] (M2.east) -- pic[pic text={$T_m,\theta_m$}]{rotarrow} ++(1.5,0) -- +(0,0.5) node [anchor=south] {$N_1$} -- +(0,-0.5) coordinate (N1);

        \draw[thick] ([yshift=-2]N1) -- ++(0,-1.5) node [below] {$N_2$} ++(0,0.75) --  pic[xscale=-1,pic text={$\theta_L$}]{rotarrow} ++(1,0) node [cylinder, black, shape border rotate=180, draw,
        minimum height=2, minimum width=1, aspect=0.5,cylinder uses custom fill, cylinder end fill = black!70,anchor=west,xshift=-0.15cm, fill opacity=0.2,text opacity=1] (c) {Load Inertia};
        \draw [damper] (c.east) -- node[above=3mm] {$d_1$} ++(0:2)   node[draw, rectangle, minimum height=2cm, minimum width =0.5cm,anchor=west,preaction={fill=gray!10},pattern=north east lines,pattern=bricks]{};
    \end{tikzpicture}
\end{document}
nidhin
  • 7,932
  • Many thanks for your help. Would you please provide a full MWE to understand the implementation of point 1(c) and 3. – Diaa Oct 31 '19 at 15:42
  • 2
    @Diaa I have added the full code – nidhin Oct 31 '19 at 16:17
  • I appreciate your help. Is it possible to draw the horizontal line from the gear N2 to the center of the cylinder face (i.e. ( $(<name>.before top)!0.5!(<name>.after top)$ )) in one single step without having to draw the cylinder first before the horizontal line then refer to it when drawing the line? – Diaa Oct 31 '19 at 16:29
  • Furthermore, the current flow i_a is perfectly centered between the resistor and the inductance; is there a way to fix this? – Diaa Oct 31 '19 at 16:31
  • I meant i_a with its arrow to be horizontally aligned between the resistor and the inductance. – Diaa Oct 31 '19 at 18:26
  • It is my bad; the difference between the lengths of the left leg of the inductance and the right leg of the resistor deceived me. – Diaa Oct 31 '19 at 18:35
  • @Diaa see updated answer. – nidhin Oct 31 '19 at 19:03
  • Many thanks. May I know if xshift=-0.15cm is calculated or guessed? – Diaa Oct 31 '19 at 21:24
  • @Diaa I guessed the value – nidhin Nov 01 '19 at 02:02