| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2009 by Enrico Gregorio |
| 4 |
% <Enrico dot Gregorio (at) univr dot it> |
| 5 |
% --------------------------------------- |
| 6 |
% |
| 7 |
% This file may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 9 |
% of this license or (at your option) any later version. |
| 10 |
% The latest version of this license is in: |
| 11 |
% |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 15 |
% version 2005/12/01 or later. |
| 16 |
% |
| 17 |
% This work consists of the files steinmetz.dtx and steinmetz.ins |
| 18 |
% and the derived files steinmetz.sty and steinmetz-test.tex |
| 19 |
% |
| 20 |
% \fi |
| 21 |
% |
| 22 |
% \iffalse |
| 23 |
%<*driver> |
| 24 |
\ProvidesFile{steinmetz.dtx} |
| 25 |
%</driver> |
| 26 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 27 |
%<package>\ProvidesPackage{steinmetz} |
| 28 |
%<*package> |
| 29 |
[2009/06/14 v1.0 Steinmetz symbol for electrotechnics] |
| 30 |
%</package> |
| 31 |
% |
| 32 |
%<*driver> |
| 33 |
\documentclass[a4paper]{ltxdoc} |
| 34 |
\IfFileExists{steinmetz.sty}{\usepackage{steinmetz}}{} |
| 35 |
\newcommand{\cmdname}[1]{\texttt{\char`\\#1}} |
| 36 |
\newcommand{\bigstrut}{\vphantom{\vrule height 1.5\normalbaselineskip |
| 37 |
width 0pt}} |
| 38 |
\providecommand{\phase}[2][]{\mbox{?}} |
| 39 |
\EnableCrossrefs |
| 40 |
\CodelineIndex |
| 41 |
\RecordChanges |
| 42 |
\begin{document} |
| 43 |
\DocInput{steinmetz.dtx} |
| 44 |
\end{document} |
| 45 |
%</driver> |
| 46 |
% \fi |
| 47 |
% |
| 48 |
% \CheckSum{166} |
| 49 |
% |
| 50 |
% \catcode`\@=12 |
| 51 |
% \CharacterTable |
| 52 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 53 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 54 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 55 |
% Exclamation \! Double quote \" Hash (number) \# |
| 56 |
% Dollar \$ Percent \% Ampersand \& |
| 57 |
% Acute accent \' Left paren \( Right paren \) |
| 58 |
% Asterisk \* Plus \+ Comma \, |
| 59 |
% Minus \- Point \. Solidus \/ |
| 60 |
% Colon \: Semicolon \; Less than \< |
| 61 |
% Equals \= Greater than \> Question mark \? |
| 62 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 63 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 64 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 65 |
% Right brace \} Tilde \~} |
| 66 |
% |
| 67 |
% |
| 68 |
% \changes{v1.0}{2009/06/04}{Initial version} |
| 69 |
% |
| 70 |
% \GetFileInfo{steinmetz.dtx} |
| 71 |
% |
| 72 |
% \DoNotIndex{\newcommand,\newenvironment,\advance,\begin,\box,\dimen@} |
| 73 |
% \DoNotIndex{\displaystyle,\textstyle,\scriptstyle,\scriptscriptstyle} |
| 74 |
% \DoNotIndex{\dp,\edef,\end,\fi,\hbox,\ht,\ifcase,\newlength,\newsavebox} |
| 75 |
% \DoNotIndex{\or,\raise,\relax,\RequirePackage,\sbox,\setbox,\setlength} |
| 76 |
% \DoNotIndex{\vbox,\vss,\wd,\z@} |
| 77 |
% |
| 78 |
% |
| 79 |
% \title{The \textsf{steinmetz} |
| 80 |
% package\thanks{This document corresponds to |
| 81 |
% \textsf{steinmetz}~\fileversion, dated \filedate.}} |
| 82 |
% |
| 83 |
% \author{Enrico Gregorio \\ |
| 84 |
% \texttt{Enrico dot Gregorio (at) univr dot it}} |
| 85 |
% |
| 86 |
% \date{\filedate} |
| 87 |
% |
| 88 |
% \maketitle |
| 89 |
% |
| 90 |
% \section{Introduction} |
| 91 |
% |
| 92 |
% In electrotechnics it is common a notation for variables taking on |
| 93 |
% complex values. First of all any nonzero complex number $z$ admits a |
| 94 |
% unique representation as |
| 95 |
% \[ |
| 96 |
% z=\varrho(\cos\alpha+i\sin\alpha) |
| 97 |
% \] |
| 98 |
% where $\varrho$ is a positive real number and $\alpha$ is a real |
| 99 |
% number in the interval $[0,2\pi)$. In technical applications $\alpha$ |
| 100 |
% is expressed in degrees, with figures such as $30^{\circ}$. The |
| 101 |
% conversion is very easy by considering $^{\circ}$ as the |
| 102 |
% multiplicative constant $\pi/180$. By Euler formulas, we can write |
| 103 |
% \[ |
| 104 |
% z=\varrho(\cos\alpha+i\sin\alpha)=\varrho e^{i\alpha} |
| 105 |
% \] |
| 106 |
% but Steinmetz, in the nineteenth century, started to express this in a |
| 107 |
% simplified form: |
| 108 |
% \[ |
| 109 |
% z=\varrho\angle\alpha |
| 110 |
% \] |
| 111 |
% which has however the disadvantage to be difficult to interpret when |
| 112 |
% the angle is the result of some algebraic expression. This is where |
| 113 |
% this package helps: indeed we can write |
| 114 |
% \iffalse |
| 115 |
%<*verb> |
| 116 |
% \fi |
| 117 |
\begin{verbatim} |
| 118 |
z=\varrho\phase{\alpha+\beta} |
| 119 |
\end{verbatim} |
| 120 |
% \iffalse |
| 121 |
%</verb> |
| 122 |
% \fi |
| 123 |
% which gives |
| 124 |
% \[ |
| 125 |
% z=\varrho\phase{\alpha+\beta} |
| 126 |
% \] |
| 127 |
% making it clear what is the angle to consider. Some textbooks in |
| 128 |
% electrotechnics use this notation and some users asked how to |
| 129 |
% produce it in {\LaTeX}. |
| 130 |
% |
| 131 |
% |
| 132 |
% \subsection*{Dependencies} |
| 133 |
% |
| 134 |
% Note that this package requires \textsf{pict2e}, so a fairly recent |
| 135 |
% version of {\LaTeX} is needed. In order to typeset this document, |
| 136 |
% you have to generate the package file, by running {\LaTeX} on |
| 137 |
% \texttt{steinmetz.ins}, unless it's already in your distribution. |
| 138 |
% |
| 139 |
% \section{Commands} |
| 140 |
% |
| 141 |
% \DescribeMacro{\phase} |
| 142 |
% This package provides only one command, \cmdname{phase}, which takes |
| 143 |
% as argument the angle to be enclosed in the Steinmetz symbol. It may |
| 144 |
% receive also an optional argument, an integer number from $0$ to $3$ |
| 145 |
% (default~$1$). This optional argument tells {\LaTeX} to typeset the |
| 146 |
% angle in the various mathematical styles, as exemplified in |
| 147 |
% table~\ref{optional}. |
| 148 |
% |
| 149 |
% \begin{table} |
| 150 |
% \caption{Results from the various choices of the optional argument |
| 151 |
% to \protect\cmdname{phase}}\label{optional} |
| 152 |
% \medskip\centering\let\?\bigstrut |
| 153 |
% \begin{tabular}{ll} |
| 154 |
% \hline |
| 155 |
% Command & Result\\ |
| 156 |
% \hline |
| 157 |
% \?\verb|A\phase{\alpha}| & $\phase{\alpha}$ \\ |
| 158 |
% \?\verb|A\phase{30^{\circ}}| & $A\phase{30^{\circ}}$ \\ |
| 159 |
% \?\verb|A\phase[0]{\alpha}| & $A\phase[0]{\alpha}$ \\ |
| 160 |
% \?\verb|A\phase[1]{\alpha}| & $A\phase[1]{\alpha}$ \\ |
| 161 |
% \?\verb|A\phase[2]{\alpha}| & $A\phase[2]{\alpha}$ \\ |
| 162 |
% \?\verb|A\phase[3]{\alpha}| & $A\phase[3]{\alpha}$ \\ |
| 163 |
% \?\verb|A\phase[0]{\frac{\alpha}{2}}| & |
| 164 |
% $A\phase[0]{\frac{\alpha}{2}}$ \\ |
| 165 |
% \?\verb|A\phase[1]{\frac{\alpha}{2}}| & |
| 166 |
% $A\phase[1]{\frac{\alpha}{2}}$ \\ |
| 167 |
% \?\verb|A\phase[2]{\frac{\alpha}{2}}| & |
| 168 |
% $A\phase[2]{\frac{\alpha}{2}}$ \\ |
| 169 |
% \?\verb|A\phase[3]{\frac{\alpha}{2}}| & |
| 170 |
% $A\phase[3]{\frac{\alpha}{2}}$ \\ |
| 171 |
% \hline |
| 172 |
% \end{tabular} |
| 173 |
% \end{table} |
| 174 |
% |
| 175 |
% Recall that the command \cmdname{phase} should be given only in math |
| 176 |
% mode. Since the command is usually written in display or text style, |
| 177 |
% it should be uncommon to need the optional argument, unless you have |
| 178 |
% to force a particular style for fractions. |
| 179 |
% |
| 180 |
% If you have more than one of these symbols in a row, it can help |
| 181 |
% alignment to put \cmdname{mathstrut} in the argument. |
| 182 |
% |
| 183 |
% \section{Acknowledgments} |
| 184 |
% |
| 185 |
% The macro has been developed based on ideas of Stefano Di Gennaro |
| 186 |
% (Universit\`a dell'Aquila, Italy) and his student Andrea |
| 187 |
% Tonelli. Both have suffered from the earthquake of April~5, 2009: I |
| 188 |
% wish them, their families and their university a prompt recover. |
| 189 |
% |
| 190 |
% \StopEventually{\PrintChanges\PrintIndex} |
| 191 |
% |
| 192 |
% \section{Implementation} |
| 193 |
% \iffalse |
| 194 |
%<*package> |
| 195 |
% \fi |
| 196 |
% \begin{macrocode} |
| 197 |
\RequirePackage{pict2e}[2004/07/06] |
| 198 |
% \end{macrocode} |
| 199 |
% \iffalse |
| 200 |
%</package> |
| 201 |
% \fi |
| 202 |
% We need the extended slopes provided by \textsf{pict2e}. |
| 203 |
% |
| 204 |
% \begin{macro}{\stm@phasebox} |
| 205 |
% \begin{macro}{\stm@phasedp} |
| 206 |
% \begin{macro}{\stm@phaseht} |
| 207 |
% \begin{macro}{\stm@phasetot} |
| 208 |
% \begin{macro}{\stm@phasewd} |
| 209 |
% We reserve some registers. |
| 210 |
% \iffalse |
| 211 |
%<*package> |
| 212 |
% \fi |
| 213 |
% \begin{macrocode} |
| 214 |
\newsavebox{\stm@phasebox} |
| 215 |
\newlength{\stm@phasedp} |
| 216 |
\newlength{\stm@phaseht} |
| 217 |
\newlength{\stm@phasetot} |
| 218 |
\newlength{\stm@phasewd} |
| 219 |
% \end{macrocode} |
| 220 |
% \end{macro} |
| 221 |
% \end{macro} |
| 222 |
% \end{macro} |
| 223 |
% \end{macro} |
| 224 |
% \end{macro} |
| 225 |
% \begin{macro}{\phase} |
| 226 |
% This is the main (and unique) command provided at user level. |
| 227 |
% \begin{macrocode} |
| 228 |
\newcommand\phase[2][1]{% |
| 229 |
\sbox\stm@phasebox{% |
| 230 |
$\ifcase#1\relax |
| 231 |
\displaystyle\or\textstyle\or\scriptstyle\or\scriptscriptstyle |
| 232 |
\fi#2$} |
| 233 |
% \end{macrocode} |
| 234 |
% We set the box register to a formula containing the argument in the |
| 235 |
% style chosen by the optional argument (default is text style). |
| 236 |
% \begin{macrocode} |
| 237 |
\stm@phaseht=\ht\stm@phasebox |
| 238 |
\stm@phasedp=\dp\stm@phasebox |
| 239 |
\stm@phasetot=\stm@phasedp \advance\stm@phasetot .35ex |
| 240 |
\advance\stm@phasetot\stm@phaseht |
| 241 |
\stm@phasewd=\wd\stm@phasebox |
| 242 |
\advance\stm@phasewd .5\stm@phasetot |
| 243 |
% \end{macrocode} |
| 244 |
% We do some measuring; the name of the registers should be |
| 245 |
% self-explaining. |
| 246 |
% \begin{macrocode} |
| 247 |
\setbox\stm@phasebox=\vbox to\stm@phaseht{ |
| 248 |
\hbox{\setlength{\unitlength}{1pt}\linethickness{.6pt}% |
| 249 |
\edef\ph@x{\strip@pt\stm@phasewd}\edef\ph@y{\strip@pt\stm@phasetot}% |
| 250 |
\dimen@ .5\stm@phasetot \edef\ph@dx{\strip@pt\dimen@}% |
| 251 |
% \end{macrocode} |
| 252 |
% In the reserved box register we put a vbox and set inside it the |
| 253 |
% unit length for the picture environment to $1\,$pt; since we have to |
| 254 |
% use pure numbers, we strip the unit from the lengths. |
| 255 |
% \begin{macrocode} |
| 256 |
\begin{picture}(\ph@x,\ph@y) |
| 257 |
\put(0,0){\circle*{.4}} |
| 258 |
\put(0,0){\line(1,0){\ph@x}}\put(0,0){\line(1,2){\ph@dx}} |
| 259 |
\put(\ph@dx,1.5){\raise\stm@phasedp\vbox{\box\stm@phasebox}} |
| 260 |
\end{picture}% |
| 261 |
% \end{macrocode} |
| 262 |
% The picture environment draws the angle. In its vertex we put a |
| 263 |
% small circle to masquerade the connections. Inside the angle we |
| 264 |
% print the expression given as argument, freeing the box register so |
| 265 |
% that it can be used again (by the macro itself). |
| 266 |
% \begin{macrocode} |
| 267 |
}\vss}% |
| 268 |
\advance\stm@phasedp .35ex \advance\stm@phasedp .6pt |
| 269 |
\dp\z@=\stm@phasedp \box\stm@phasebox} |
| 270 |
% \end{macrocode} |
| 271 |
% \iffalse |
| 272 |
%</package> |
| 273 |
% \fi |
| 274 |
% We close the vbox, correct its depth and print it. |
| 275 |
% \end{macro} |
| 276 |
% |
| 277 |
% |
| 278 |
% \section{An example} |
| 279 |
% The following will generate an example file. |
| 280 |
% \iffalse |
| 281 |
%<*example> |
| 282 |
% \fi |
| 283 |
% \begin{macrocode} |
| 284 |
\documentclass[a4paper]{article} |
| 285 |
\usepackage{steinmetz} |
| 286 |
|
| 287 |
\begin{document} |
| 288 |
|
| 289 |
We will indicate the amplitude and phase relationship through the use |
| 290 |
of complex notation: a complex number is used to indicate only the |
| 291 |
amplitude and phase of voltages and currents in the circuit (since the |
| 292 |
sinusoidal time variation factor is common to all terms). For |
| 293 |
example, a circuit described by the equation |
| 294 |
\[ |
| 295 |
i(t)=I_{0}\cos(\omega t+\theta) |
| 296 |
\] |
| 297 |
can be written in complex exponential form as |
| 298 |
\[ |
| 299 |
i(t)=\Re\{I_{0}e^{j(\omega t+\theta)}\}= |
| 300 |
\Re\{I_{0}e^{j\theta}e^{j\omega t}\}, |
| 301 |
\] |
| 302 |
and in polar complex form as |
| 303 |
\[ |
| 304 |
i(t)=\Re\{I_{0}\phase{\theta}e^{j\omega t}\}. |
| 305 |
\] |
| 306 |
Finally, we can simplify the notation by dropping the implied |
| 307 |
$e^{j\omega t}$ term and the $\Re\{~\}$ operator, leaving the phasor |
| 308 |
notation: |
| 309 |
\[ |
| 310 |
\mathbf{I}=I_{0}\phase{\theta}=I_{0}e^{j\theta}= |
| 311 |
I_{0}(\cos\theta+j\sin\theta), |
| 312 |
\] |
| 313 |
where the boldface $\mathbf{I}$ reminds us that the phasor quantity |
| 314 |
$\mathbf{I}$ is a complex number. The important advantage of this |
| 315 |
approach is that the mathematics involves mostly simple algebraic |
| 316 |
operations on the magnitudes and phases. |
| 317 |
|
| 318 |
It is interesting to look at the complex ratio of phasor voltage and |
| 319 |
phasor current, $\mathbf{V}\!/\mathbf{I}$, which is called the |
| 320 |
\emph{impedance}~$\mathbf{Z}$. For the basic circuit elements we |
| 321 |
find: |
| 322 |
\begin{itemize} |
| 323 |
\item Resistor, $R$: $\mathbf{Z}=R$, |
| 324 |
\item Inductor, $L$: $\mathbf{Z}=j\omega L= |
| 325 |
\omega L\phase{90^{\circ}}$, |
| 326 |
\item Capacitor, $C$: $\displaystyle\mathbf{Z}=\frac{1}{j\omega C}= |
| 327 |
-j\frac{1}{\omega C}=\frac{1}{\omega C}\phase{-90^{\circ}}$. |
| 328 |
\end{itemize} |
| 329 |
\end{document} |
| 330 |
% \end{macrocode} |
| 331 |
% \iffalse |
| 332 |
%</example> |
| 333 |
% \fi |
| 334 |
% |
| 335 |
% \Finale |
| 336 |
\endinput |