[pstricks] Power Balance Schemes
Herbert Voss
Herbert.Voss at alumni.TU-Berlin.DE
Sat Jan 17 12:32:07 CET 2004
Matteo Gattanini wrote:
> In "Politecnico of Milan" we sometimes describe power balances with
> graphical schemes representing the power main flux and losses.
> LaTeX and PStricks give a good way to automate the drawing of such
> schemes; the following code seems to work, and perhaps may be useful for
> someone (even if it can be improved).
> An annoying thing is that isn't possible to put PS code in `nodesep'
> option; to perform some multiplications `fp.sty' is loaded, I don't find
> a better way. How can be avoided the use of additional calculation
> packages?
use dimension registers
Herbert
\documentclass{report}
\usepackage{amsmath}
\usepackage{pstricks,pst-node}
\SpecialCoor
%___ POWER SCHEME ___
%
% \begin{PSpic_PowSch}{`width'}{`height'}{`label pow-in'}{`label
pow-out'}
% \PowLoss[`inter pow flux label']{`relative horizontal
position'}{`loss relative amount'}{`label'}
% ...
% \end{PSpic_PowSch}
%
\makeatletter
\newcommand{\PowLoss}[4][ ]{%
% CALCULATIONS NEEDED: NO PS IN `nodesep'
\pst at dimb=#2pt\pst at dima=\Lrgh\pst at dimb
\def\DeltaX{\pst at number\pst at dima}
\pst at dimc=#3pt\pst at dimd=\PW\pst at dimc
\edef\DeltaY{\pst at number\pst at dimd}
\pst at dimc=.5\pst at dimd
\def\HalfDeltaY{\strip at pt\pst at dimc}
\pst at dimc=\rCur\pst at dimd
\def\SmallRadius{\strip at pt\pst at dimc}
\pst at dimc=\rLarr\pst at dimd
\def\ArrowFly{\strip at pt\pst at dimc}
\pst at dimc=\rHarr\pst at dimd
\def\ArrowPeak{\strip at pt\pst at dimc}
% NODE DEFINITIONS
\pnode(CurPoint){PrevPoint}
\pnode(\DeltaX,0|PrevPoint){PointRelX}
\pnode([nodesep=\DeltaY,angle=-90]PrevPoint){PointRelY}
\pnode(PointRelX|PointRelY){CurPoint}
\pnode([nodesep=\SmallRadius,angle=90]PointRelX){PointRadius}
\pnode([nodesep=\SmallRadius,angle=0]PointRadius){PointOne}
\pnode([nodesep=\ArrowFly,angle=180]PointOne){PointTwo}
\pnode([nodesep=\DeltaY,angle=0]PointOne){PointThree}
\pnode([nodesep=\ArrowFly,angle=0]PointThree){PointFour}
\pnode([nodesep=\HalfDeltaY,angle=0]PointOne|[nodesep=\ArrowPeak,angle=90]PointOne){PointPeak}
% DRAWING ARROW
\psline(PrevPoint)(PointRelX)
\ncarc[arcangle=-45]{-}{PointRelX}{PointOne}
\ncarc[arcangle=-45]{-}{CurPoint}{PointThree}
\psline(PointOne)(PointTwo)(PointPeak)(PointFour)(PointThree)
\nput[labelsep=.2]{90}{PointPeak}{#4}% loss label
% OPTIONAL POWER FLUX LABEL
\ifx#1 \relax % if no label do nothing
\else\ncline[linestyle=none]{-}{PrevPoint}{PointRelX}\ncput{\pnode{MPointUp}}
\pnode(MPointUp|0,0){MPointDwn}
\ncline[linestyle=solid,linewidth=.5pt,nodesep=.05]{<->}{MPointUp}{MPointDwn}\naput{#1}\fi
}
\newenvironment{PSpic_PowSch}[4]{% >>> OPENING ENVIRONMENT
\psset{unit=1cm,linestyle=solid,linewidth=.035}
% DIMENSIONAL PARAMETERS DEFINITION
\def\Lrgh{#1}\def\Altz{#2}% PSpicture dimensions
\def\Hcoeff{.65}
\pst at dimc=\Hcoeff pt\pst at dimd=\Altz\pst at dimc
\edef\PW{\pst at number\pst at dimd}% pow-in relative value (`fp.sty' needed)
\def\rHarr{.8}\def\rLarr{.35}% loss arrows relative dimensions
\def\rCur{1}% arrows curvature radius relative value
\def\Punta{.5}% in-out peak dimension
% PICTURE
\begin{pspicture}(\Lrgh,\Altz)
\pnode(!0 \Hcoeff\space \Altz\space mul){StartPoint}
\pnode(StartPoint){CurPoint}
\pnode(!\Punta\space \Hcoeff\space \Altz\space mul 2 div){MiddleSx}
\psline(0,0)(MiddleSx)(StartPoint)
\nput[labelsep=.3]{0}{MiddleSx}{#3}% pow-in label
\def\potUlabel{#4}}% pow-out label
{% >>> CLOSING ENVIRONMENT
\pnode(\Lrgh,0){ExtPointDxDown}
\pnode(ExtPointDxDown|CurPoint){ExtPointDxUp}
\ncline[linestyle=none]{-}{ExtPointDxUp}{ExtPointDxDown}\ncput{\pnode{MiddleDx}}
\psline(CurPoint)([nodesep=\Punta,angle=180]ExtPointDxUp)(MiddleDx)%
([nodesep=\Punta,angle=180]ExtPointDxDown)(0,0)
\newlength{\ObjWidth}\settowidth{\ObjWidth}{\potUlabel}
\pnode([nodesep=\ObjWidth,angle=180]MiddleDx){LabelDx}
\nput[labelsep=-.3]{0}{LabelDx}{\potUlabel}
\end{pspicture}}
\makeatother
%¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
\begin{document}
In figure~\ref{fig:power-scheme} there's the output; the choosed
dimensions are \(12cm \times 6cm\).
\begin{figure}[h]\centering
\begin{PSpic_PowSch}{12}{6}{\(P_e\)}{\(P_u\)}
\PowLoss{.18}{.12}{\(R_s \, I_s2\)} % Joule
\PowLoss{.35}{.08}{\(G_{Fe} \, E_s^{\phantom{.}2}\)} % iron
\PowLoss[\(P_{tr}=\dfrac{\omega}{n} C_e\)]{.62}{.13}{\(R_R \,
I_r2\)} % Joule
\PowLoss[\(\dfrac{\omega_m}{n} C_e\)]{.79}{.09}{\textit{attr}}
% mec
\end{PSpic_PowSch}
\caption{A power scheme for the asyncronous
motor}\label{fig:power-scheme}
\end{figure}
\end{document}
--
http://www.pstricks.de/
More information about the PSTricks
mailing list