Advertisement
Guest User

ClarkePark

a guest
Jun 29th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 14.00 KB | None | 0 0
  1. \documentclass[tikz,border=10pt]{standalone}
  2. \usepackage{pgfplots}
  3. \usepackage{amsmath} % Required for \varPsi below
  4. \usepackage{tikz}
  5. \usetikzlibrary{calc}
  6. \pgfplotsset{compat=1.9}
  7.  
  8. \newcommand{\gettikzxy}[3]{%
  9.   \tikz@scan@one@point\pgfutil@firstofone#1\relax
  10.   \edef#2{\the\pgf@x}%
  11.   \edef#3{\the\pgf@y}%
  12. }
  13.  
  14.  
  15. \begin{document}
  16.  
  17.     \begin{tikzpicture}
  18.    
  19.    
  20.    
  21.     %Definitions - These can be changed to create new figures%
  22.     %===========================================================
  23.     \def \Vs {4}; %Magnitude of space vector in cm
  24.     \def \Angle {100}; %Angle with regards to phase A
  25.     \def \Osv {35}; %Angle of d-axis wrt space vector
  26.     \def \R {2.5}; %Magnitude of rotor flux in cm
  27.    
  28.    
  29.    
  30.     %Calculated variables. These should not be changed unless you know what you are doing%
  31.     %===========================================================
  32.     \pgfmathsetmacro \MaxLin {\Vs * cos{30}}; %Magnitude before overmodulation
  33.     \pgfmathsetmacro \Qmag {\Vs * sin{\Osv})}; %Magnitude of Q axis
  34.     \pgfmathsetmacro \Dmag {\Vs * cos{\Osv})}; %Magnitude of Q axis
  35.     \pgfmathsetmacro \Marker {\Angle/45)};
  36.     \pgfmathsetmacro \Vmax {\Vs * 2/3}; %Max phase voltage
  37.     \def \Axisheight {\Vmax *3};
  38.     \pgfmathsetmacro \Va {\Vmax * sin{(\Angle+0)}}; %Magnitude of phase A at angle \Angle
  39.     \pgfmathsetmacro \Vb {\Vmax * sin{(\Angle+120)}}; %Magnitude of phase B at angle \Angle
  40.     \pgfmathsetmacro \Vc {\Vmax * sin{(\Angle+240)}}; %Magnitude of phase C at angle \Angle
  41.     \pgfmathsetmacro \Radius {\Vmax}; %Radius of maximum line to line voltage output
  42.    
  43.    
  44.     %Locations%
  45.     %===========================================================
  46.     \def \OrigoX {-6 cm}; % If you want to move the circle relative to the wave forms (default -5cm)
  47.     \def \OrigoY {0 cm};
  48.     \def \OrigoYb {-12 cm};
  49.     \def \OrigoYc {-24 cm};
  50.     \coordinate (origo) at (\OrigoX,\OrigoY); %Center of top phasor diagram
  51.     \coordinate (origob) at (\OrigoX,\OrigoYb); %Center of center phasor diagram
  52.     \coordinate (origoc) at (\OrigoX,\OrigoYc); %Center of bottom phasor diagram
  53.     \coordinate (phase_a) at (0:\Va cm); %Tip of phase A
  54.     \coordinate (phase_b) at (120:\Vb cm); %Tip of phase B
  55.     \coordinate (phase_c) at (240:\Vc cm) ; %Tip of phase C
  56.     \coordinate (Y) at (\OrigoX+\Vs cm ,\OrigoY+0); %Where to start the Hexagon
  57.    
  58.    
  59.     %Circle background rings%
  60.     %===========================================================
  61.     \node at (origo) [circle,thick,draw=black!80,fill=red!0, inner sep=0pt,minimum size=\Vs*2 cm] {}; %Top Circle with radius 128%
  62.     \node at (origob) [circle,thick,draw=black!80,fill=red!0, inner sep=0pt,minimum size=\Vs*2 cm] {}; %Center Circle with radius 128%
  63.     \node at (origoc) [circle,thick,draw=black!80,fill=red!0, inner sep=0pt,minimum size=\Vs*2 cm] {}; %Center Circle with radius 128%
  64.    
  65.     %Left axis to top circle
  66.     \draw[<->] (2.05*\OrigoX,-1.1*\Vs cm) -- (2.05*\OrigoX,1.1*\Vs cm) node[anchor=south, distance=0.2cm]{$I$};
  67.     \draw [color=black,dotted](\OrigoX,\Vs cm)--(2.1*\OrigoX,\Vs cm) node[anchor=east, distance=0.5cm] {$\frac{4}{\pi}I_{max} - 127,32\%$};
  68.     \draw [color=red,dotted] (\OrigoX,\MaxLin cm) -- (2.1*\OrigoX,\MaxLin cm) node[anchor=east, distance=0.5cm] {$\frac{2}{\sqrt{3}}I_{max} - 115,47\%$};
  69.     \draw [color=black,dotted](\OrigoX,\Vmax cm) -- (2.1*\OrigoX,\Vmax cm) node[anchor=east] {$I_{max} - 100,00\%$};
  70.     \draw [color=black,dotted](\OrigoX,0 cm) -- (2.1*\OrigoX,0 cm) node[anchor=east] {$0\%$};
  71.    
  72.    
  73.     %Hexagon Framing around phasors%
  74.     %===========================================================
  75.     \draw[-, color=black!50,thin,dashed] (Y) -- ++(120:\Vs cm) -- ++(180:\Vs cm) -- ++(240:\Vs cm) -- ++(300:\Vs cm) -- ++(360:\Vs cm) -- ++(60:\Vs cm); % Six step hexagon
  76.     \node at (origo) [circle,draw=red!80, inner sep=0pt,minimum size=\MaxLin*2 cm, dashed] {}; %Circle with radius 115%
  77.        
  78.    
  79.    
  80.     %Black guide lines with angle notation
  81.     \foreach \x in {45,90,...,360} {
  82.         \draw[-,color=black,dotted, thin] (origo)  -- ++(\x:\Vs cm) node[label={[label distance=-0.18cm]\x: $\x^{\circ}$}] {};
  83.     } \foreach \x in {45,90,...,360} {
  84.         \draw[-,color=black,dotted, thin] (origob)  -- ++(\x:\Vs cm) node[label={[label distance=-0.18cm]\x: $\x^{\circ}$}] {};
  85.     } \foreach \x in {45,90,...,360} {
  86.         \draw[-,color=black,dotted, thin] (origoc)  -- ++(\x:\Vs cm) node[label={[label distance=-0.18cm]\x: $\x^{\circ}$}] {};
  87.     }
  88.      
  89.    
  90.    
  91.    
  92.    
  93.     %=============================================================================================================
  94.     %Actual three phase phasors%
  95.     %=============================================================================================================
  96.     \node at (origo) [circle,thick,draw=black!80, inner sep=0pt,minimum size=\Vmax*2 cm] {}; %Circle with radius 100%
  97.     \draw[->,color=red, very thick] (origo)  -- ++(phase_a); %Phase A phasor
  98.     \draw[->,color=blue, very thick] (origo)  -- ++(phase_b); %Phase B phasor
  99.     \draw[->,color=green, very thick] (origo)  -- ++(phase_c); %Phase C phasor
  100.    
  101.     \draw[color=red,thick,smooth,domain=0:8] plot(\x,{\Vmax * sin(\x*45)}); % Phase A
  102.     \draw[color=blue,thick,,smooth,domain=0:8] plot(\x,{\Vmax * sin((\x*45)+120)}); %Phase B
  103.     \draw[color=green,thick,,smooth,domain=0:8] plot(\x,{\Vmax * sin((\x*45)+240)}); % Phase C
  104.    
  105.     \draw[color=red,dashed] (\Marker,\Va) -- (-0.3,\Va)  node[anchor=east] {$i_a$};; %A phase line to Y-axis
  106.     \draw[color=blue,dashed] (\Marker,\Vb)-- (-0.3,\Vb)  node[anchor=east] {$i_b$};; %B phase line to Y-axis
  107.     \draw[color=green,dashed] (\Marker,\Vc)-- (-0.3,\Vc)  node[anchor=east] {$i_c$};; %C phase line to Y-axis
  108.    
  109.     %SPACE VECTOR %
  110.     \draw[->,ultra thick,black] (origo) -- ++($(phase_a) + (phase_b) + (phase_c)$) coordinate(Vstip); %Space vector resultant
  111.     \pgfgetlastxy{\XCoord}{\YCoord}; % X and Y coordinates of Space vector tip
  112.    
  113.     %Find space vector angle
  114.     \pgfmathanglebetweenpoints{\pgfpointanchor{origo}{center}}{\pgfpointanchor{Vstip}{center}}
  115.     \let\PhaseBlack\pgfmathresult;
  116.    
  117.     %Phasor guide lines%
  118.     \draw[-,color=red, dashed] (origo)  -- ++(0:\Vmax cm)  node[anchor=west] {\large $i_a$};
  119.     \draw[-,color=blue, dashed] (origo) -- ++(120:\Vmax cm) node[anchor=south] {\large $i_b$};
  120.     \draw[-,color=green, dashed] (origo)  -- ++(240:\Vmax cm) node[anchor=north] {\large $i_c$};
  121.    
  122.     \draw[-,color=red, dashed] (origo)  -- ++(0:-\Vmax cm) node[anchor=east] {$-i_a$};
  123.     \draw[-,color=blue, dashed] (origo) -- ++(120:-\Vmax cm)  node[anchor=north] {$-i_b$};
  124.     \draw[-,color=green, dashed] (origo)  -- ++(240:-\Vmax cm) node[anchor=south] {$-i_c$};
  125.    
  126.     \draw[->,color=blue, thin] (origo) ++(phase_a) -> ++(phase_b); %Resultant help lines
  127.     \draw[->,color=green, thin] (origo) ++(phase_a) ++(phase_b) -> ++(phase_c); %Resultant help lines
  128.    
  129.     \draw[color=gray] (\OrigoX,\Vmax) -- (9,\Vmax) ; %X axis TOP inner
  130.     \draw[color=gray] (\OrigoX,-\Vmax) -- (9,-\Vmax) ; %X axis bottom inner
  131.    
  132.    
  133.     %% Rotor Flux Vector%
  134.     %\coordinate (rfluxtip) at (\PhaseBlack-\Osv:\R); %Tip of rotor flux
  135.     %\draw[->,color=gray] (origo)  -- ++(rfluxtip)  node[label={[label distance=-0.18cm]\PhaseBlack-\Osv: $\lambda_r$}] {}; %Rotor Flux Phasor
  136.    
  137.    
  138.     %Wave form
  139.     \draw[->, color=black] (0,0) -- (9,0) node[anchor=west] {$\theta$}; %X axis
  140.     \draw[->, color=black] (0,-\Vs) -- (0,\Vs) node[anchor=south] {$i$}; %Y axis
  141.     %\draw[help lines] (0,-\Vs) grid (9 ,\Vs); %Grid
  142.    
  143.     %X Axis tick marks
  144.     \foreach \x in {1, 2,...,8} {
  145.         \pgfmathsetmacro \tick {\x * 45};
  146.         \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {\small\pgfmathprintnumber[fixed, precision=10]{\tick}$^{\circ}$};
  147.         }
  148.    
  149.     %Marker to illustrate angle position over wave forms
  150.     \draw[color=black] (\Marker cm, \Vs cm) -- (\Marker cm, -\Vs cm) node[anchor=north,align=center]{Current \\ position: \\ $\Angle^{\circ}$};
  151.    
  152.     %Top and bottom border, extending to circle top and and bottom
  153.     \draw[color=gray] (\OrigoX,\Vs) -- (9,\Vs) ; %X axis TOP outer
  154.     \draw[color=gray] (\OrigoX,-\Vs) -- (9,-\Vs) ; %X axis bottom outer
  155.    
  156.    
  157.    
  158.    
  159.    
  160.    
  161.    
  162.    
  163.    
  164.    
  165.     %=============================================================================================================
  166.     %Alpha and Beta Phasors
  167.     %=============================================================================================================
  168.    
  169.     %SPACE VECTOR %
  170.     \draw[->,ultra thick,black] (origob) -- ++($(phase_a) + (phase_b) + (phase_c)$) coordinate(Vstipb); %Space vector resultant
  171.     \pgfgetlastxy{\XCoordb}{\YCoordb}; % X and Y coordinates of Space vector tip
  172.    
  173.     %Find space vector angle
  174.     \pgfmathanglebetweenpoints{\pgfpointanchor{origob}{center}}{\pgfpointanchor{Vstipb}{center}}
  175.     \let\PhaseBlackb\pgfmathresult;
  176.    
  177.     %Green Axis system rotated to rotor angle
  178.     \draw[-,color=green] (\OrigoX,\OrigoYb-\Vs cm) -- ++(90:2*\Vs cm);
  179.     \draw[-,color=green] (\OrigoX+\Vs cm,\OrigoYb)  -- ++(0:-2*\Vs cm);
  180.    
  181.     \draw[->,color=orange, thin, dashed] (\OrigoX, \YCoordb) -> (Vstipb); %Alpha help Line
  182.     \draw[->,color=violet, thin, dashed] (\XCoordb, \OrigoYb) -> (Vstipb); %Beta help Line
  183.    
  184.     \draw[->,color=orange, very thick] (origob)  -- ++(0,\YCoordb-\OrigoYb) node[anchor=north east] {\large $i_\alpha$}; %Phase alpha phasor
  185.     \draw[->,color=violet, very thick] (origob)  -- ++(\XCoordb-\OrigoX,0) node[anchor=north] {\large $i_\beta$}; %Phase beta phasor
  186.    
  187.     \coordinate (origobb) at (0,\OrigoYb); %Center of center phasor diagram
  188.     \draw[color=orange,thick,smooth,domain=0:8, shift=(origobb)]  plot(\x,{\Vs * sin((\x*45)+90)}); % Alpha
  189.     \draw[color=violet,thick,smooth,domain=0:8, shift=(origobb)]  plot(\x,{\Vs * sin((\x*45)+0)}); % Beta
  190.    
  191.     \draw[color=orange,dashed] (\Marker,\YCoordb)-- (-0.3,\YCoordb)  node[anchor=east] {$i_\alpha$};; %Alpha line to alpha-axis
  192.     \draw[color=violet,dashed] (\Marker,\XCoordb-\OrigoX+\OrigoYb)-- (-0.3,\XCoordb-\OrigoX+\OrigoYb)  node[anchor=east] {$i_\beta$};; %Beta line to beta-axis
  193.    
  194.     %Wave form
  195.     \draw[->, color=black] (0,\OrigoYb) -- (9,\OrigoYb) node[anchor=west] {$\theta$}; %X axis middle
  196.     \draw[->, color=black] (0,\OrigoYb-\Vs cm) -- (0,\OrigoYb+\Vs cm) node[anchor=south] {$i$}; %Y axis middle
  197.     \draw[help lines] (0,\OrigoYb-\Vs cm) grid (9 ,\OrigoYb+\Vs cm); %Grid middle
  198.    
  199.     %X Axis tick marks
  200.     \foreach \x in {1, 2,...,8} {
  201.         \pgfmathsetmacro \tick {\x * 45};
  202.         \draw (\x cm,\OrigoYb-1pt) -- (\x cm,\OrigoYb+1pt) node[anchor=north] {\small\pgfmathprintnumber[fixed, precision=10]{\tick}$^{\circ}$};
  203.         }
  204.    
  205.     %Marker to illustrate angle position over wave forms
  206.     \draw[color=black] (\Marker cm,\OrigoYb+\Vs cm) -- (\Marker cm, \OrigoYb-\Vs cm) node[anchor=north,align=center]{Current \\ position: \\ $\Angle^{\circ}$};
  207.    
  208.     %Top and bottom border, extending to circle top and and bottom
  209.     \draw[color=gray] (\OrigoX,\OrigoYb+\Vs cm) -- (9,\OrigoYb+\Vs cm) ; %X axis TOP outer
  210.     \draw[color=gray] (\OrigoX,\OrigoYb-\Vs cm) -- (9,\OrigoYb-\Vs cm) ; %X axis bottom outer
  211.    
  212.    
  213.    
  214.    
  215.    
  216.    
  217.    
  218.    
  219.    
  220.     %=============================================================================================================
  221.     %%D and Q Phasors%
  222.     %=============================================================================================================
  223.    
  224.     %Space Vector
  225.     \draw[->,ultra thick,black] (origoc) -- ++($(phase_a) + (phase_b) + (phase_c)$) coordinate(Vstipc); %Space vector resultant
  226.     \pgfgetlastxy{\XCoordc}{\YCoordc}; % X and Y coordinates of Space vector tip
  227.    
  228.     %Find space vector angle
  229.     \pgfmathanglebetweenpoints{\pgfpointanchor{origoc}{center}}{\pgfpointanchor{Vstipc}{center}}
  230.     \let\PhaseBlackc\pgfmathresult;
  231.    
  232.     \coordinate (d1c) at (\PhaseBlackc-\Osv:\Vs cm) ; %Tip of d axis
  233.     \coordinate (d2c) at (\PhaseBlackc-\Osv:-\Vs cm) ; %Tip of d axis
  234.     \coordinate (q1c) at (\PhaseBlackc-\Osv+90:\Vs cm) ; %Tip of q axis
  235.     \coordinate (q2c) at (\PhaseBlackc-\Osv+90:-\Vs cm) ; %Tip of q axis
  236.    
  237.     \coordinate (d3c) at (\PhaseBlackc-\Osv+90:\Qmag) ; %Tip of d
  238.     \coordinate (q3c) at (\PhaseBlackc-\Osv:\Dmag) ; %Tip of q
  239.    
  240.     \draw[->,color=orange, thin, dashed] (origoc)  -- ++(d3c) -> (Vstipc); %Q help Line
  241.     \draw[->,color=violet, thin, dashed] (origoc)  -- ++(q3c) -> (Vstipc); %Q help Line
  242.    
  243.     \draw[-,color=green, thin] (origoc)  -- ++(d1c); %D axis help line
  244.     \draw[-,color=green, thin] (origoc)  -- ++(d2c); %D axis help line
  245.     \draw[-,color=green, thin] (origoc)  -- ++(q1c); %Q axis help line
  246.     \draw[-,color=green, thin] (origoc)  -- ++(q2c); %Q axis help line
  247.    
  248.     \draw[->,color=orange, very thick] (origoc)  -- ++(d3c) node {\large $i_q$}; %D phasor
  249.     \draw[->,color=violet, very thick] (origoc)  -- ++(q3c) node {\large $i_d$}; %Q phasor
  250.    
  251.     \coordinate (origocc) at (0,\OrigoYc); %Center of center phasor diagram
  252.     \draw[color=orange,thick,,smooth,domain=0:8, shift=(origocc)] plot(\x,{\Qmag}); % Q
  253.     \draw[color=violet,thick,,smooth,domain=0:8, shift=(origocc)] plot(\x,{\Dmag}); % D
  254.    
  255.     \draw[color=orange,dashed] (0,\OrigoYc+\Qmag cm)-- (-0.3,\OrigoYc+\Qmag cm)  node[anchor=east] {$i_q$}; %d line to y axis
  256.     \draw[color=violet,dashed] (0,\OrigoYc+\Dmag cm)-- (-0.3,\OrigoYc+\Dmag cm)  node[anchor=east] {$i_d$}; %q line to y axis
  257.    
  258.     %% Rotor Flux Vector%
  259.     \coordinate (rfluxtipc) at (\PhaseBlackc-\Osv:\R); %Tip of rotor flux
  260.     \draw[->,color=gray] (origoc)  -- ++(rfluxtipc)  node[label={[label distance=-0.18cm]\PhaseBlack-\Osv: $\lambda_r$}] {}; %Bottom Rotor Flux Phasor
  261.    
  262.    
  263.    
  264.    
  265.     %WAVE FORM%
  266.     \draw[->, color=black] (0,\OrigoYc) -- (9,\OrigoYc) node[anchor=west] {$\theta$}; %X axis bottom
  267.     \draw[->, color=black] (0,\OrigoYc-\Vs cm) -- (0,\OrigoYc+\Vs cm) node[anchor=south] {$i$}; %Y axis bottom
  268.     \draw[help lines] (0,\OrigoYc-\Vs cm) grid (9 ,\OrigoYc+\Vs cm); %Grid middle
  269.    
  270.     %X Axis tick marks
  271.     \foreach \x in {1, 2,...,8} {
  272.         \pgfmathsetmacro \tick {\x * 45};
  273.         \draw (\x cm,\OrigoYc-1pt) -- (\x cm,\OrigoYc+1pt) node[anchor=north] {\small\pgfmathprintnumber[fixed, precision=10]{\tick}$^{\circ}$};
  274.         }
  275.        
  276.     %Marker to illustrate angle position over wave forms
  277.     \draw[color=black] (\Marker cm,\OrigoYc+\Vs cm) -- (\Marker cm, \OrigoYc-\Vs cm) node[anchor=north,align=center]{Current \\ position: \\ $\Angle^{\circ}$};
  278.    
  279.     %Top and bottom border, extending to circle top and and bottom
  280.     \draw[color=gray] (\OrigoX,\OrigoYc+\Vs cm) -- (9,\OrigoYc+\Vs cm) ; %X axis TOP outer
  281.     \draw[color=gray] (\OrigoX,\OrigoYc-\Vs cm) -- (9,\OrigoYc-\Vs cm) ; %X axis bottom outer
  282.    
  283.    
  284.     \end{tikzpicture}
  285. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement