TransWikia.com

Improving the Trace Determinant Diagram

TeX - LaTeX Asked on January 11, 2021

I am using the Trace Determinant Diagram provided in this answer.

Note that each phase portrait is created as follows,

newinlaysaddle{saddle}%
  {begin{tikzpicture}[scale=inlayscale]
     foreach sx in {+,-}
      {draw[flow] (sx4,0) -- (0,0);
       draw[flow] (0,0) -- (0,sx4);
       foreach sy in {+,-}
         foreach a/b/c/d in {2.8/0.3/0.7/0.6,3.9/0.4/1.3/1.1}
           draw[flow] (sxa,syb)
              .. controls (sxc,syd) and (sxd,syc)
              .. (sxb,sya);
      }

The complete code is

% Poincaré Diagram: Classification of Phase Portaits in the (det A,Tr A)-plane
% Author: Gernot Salzer
% Based on a drawing by Douglas R. Hundley, people.whitman.edu/~hundledr/courses/M244/Poincare.pdf
documentclass[border=1mm]{standalone}
usepackage{tikz}
usetikzlibrary{decorations.markings,arrows}

tikzset
  {every pin/.style={pin edge={<-}}
  ,>=stealth
  ,flow/.style=
    {decoration=
      {markings
      ,mark=at position #1 with {arrow{>}}
      }
    ,postaction={decorate}
    }
  ,flow/.default=0.5
  }
newcommandinlayscale{}
newcommandinlaycaption[1]{{sffamilyscriptsize#1}}
newcommandnewinlay[4][0.18]%
  {renewcommandinlayscale{#1}%
   newsavebox#2%
   savebox#2%
     {begin{tabular}{@{}c@{}}
        #4[-1ex]
        inlaycaption{#3}[-1ex]
      end{tabular}%
     }%
  }
newcommandinlay[1]{usebox{#1}}
newcommandTr{mathop{mathrm{Tr}}}

newinlaysaddle{saddle}%
  {begin{tikzpicture}[scale=inlayscale]
     foreach sx in {+,-}
      {draw[flow] (sx4,0) -- (0,0);
       draw[flow] (0,0) -- (0,sx4);
       foreach sy in {+,-}
         foreach a/b/c/d in {2.8/0.3/0.7/0.6,3.9/0.4/1.3/1.1}
           draw[flow] (sxa,syb)
              .. controls (sxc,syd) and (sxd,syc)
              .. (sxb,sya);
      }
   end{tikzpicture}%
  }

newinlaysink{sink}%
  {begin{tikzpicture}[scale=inlayscale]
    foreach sx in {+,-}
     {draw[flow] (sx4,0) -- (0,0);
      draw[flow] (0,sx4) -- (0,0);
      foreach sy in {+,-}
         foreach a/b in {2/1,3/0.44}
          draw[flow,domain=sxa:0] plot (x, {syb*x*x});
     }
   end{tikzpicture}%
  }

newinlaysource{source}%
  {begin{tikzpicture}[scale=inlayscale]
     foreach sx in {+,-}
      {draw[flow] (0,0) -- (sx4,0);
       draw[flow] (0,0) -- (0,sx4);
       foreach sy in {+,-}
         foreach a/b in {2/1,3/0.44}
           draw[flow,domain=0:sxa] plot (x, {syb*x*x});
      }
   end{tikzpicture}%
  }

newinlaystablefp{line of stable fixed points}%
  {begin{tikzpicture}[scale=inlayscale]
    draw (-4,0) -- (4,0);
    foreach s in {+,-}
     {draw[flow] (0,s4) -- (0,0);
      foreach x in {-3,-2,-1,1,2,3}
        draw[flow] (x,s3) -- (x,0);
     }
   end{tikzpicture}%
  }

newinlayunstablefp{line of unstable fixed points}%
  {begin{tikzpicture}[scale=inlayscale]
     draw (-4,0) -- (4,0);
     foreach s in {+,-}
      {draw[flow] (0,0) -- (0,s4);
       foreach x in {-3,-2,-1,1,2,3}
         draw[flow] (x,0) -- (x,s3);
      }
   end{tikzpicture}%
  }

newinlayspiralsink{spiral sink}%
  {begin{tikzpicture}[scale=inlayscale]
     draw (-4,0) -- (4,0);
     draw (0,-4) -- (0,4);
     draw[samples=100,smooth,domain=27:7] plot ({x r}: {0.005*x*x});
     draw[->] ({26 r}: {0.005*26*26}) -- +(0.01,-0.01);
   end{tikzpicture}%
  }

newinlayspiralsource{spiral source}%
  {begin{tikzpicture}[scale=inlayscale]
     draw (-4,0) -- (4,0);
     draw (0,-4) -- (0,4);
     draw [samples=100,smooth,domain=10:28] plot ({-x r}: {0.005*x*x});
     draw[<-] ({-27.5 r}: {0.005*27.5*27.5}) -- +(0.01,-0.008);
   end{tikzpicture}%
  }

newinlay[0.15]centre{center}%
  {begin{tikzpicture}[scale=inlayscale]
     draw (-4,0) -- (4,0);
     draw (0,-4) -- (0,4);
     foreach r in {1,2,3} draw[flow=0.63] (r,0) arc (0:-360:r cm);
   end{tikzpicture}%
  }

newinlaydegensink{degenerate sink}%
  {begin{tikzpicture}[scale=inlayscale]
     draw (0,-4) -- (0,4);
     draw[flow] (-4,0) -- (0,0);
     draw[flow] (4,0) -- (0,0);
     draw[flow] (-3.5,3.5) .. controls (4,1.5) and (4,1).. (0,0);
     draw[flow] (3.5,-3.5) .. controls (-4,-1.5) and (-4,-1) .. (0,0);
     draw[flow] (-3.5,2.5) .. controls (2,1) and (2,0.8).. (0,0);
     draw[flow] (3.5,-2.5) .. controls (-2,-1) and (-2,-0.8) .. (0,0);
   end{tikzpicture}%
  }

newinlaydegensource{degenerate source}%
  {begin{tikzpicture}[scale=inlayscale]
     draw (0,-4) -- (0,4);
     draw[flow] (0,0) -- (-4,0);
     draw[flow] (0,0) -- (4,0);
     draw[flow] (0,0) .. controls (4,1.5) and (4,1).. (-3.5,3.5);
     draw[flow] (0,0) .. controls (-4,-1.5) and (-4,-1) .. (3.5,-3.5);
     draw[flow] (0,0) .. controls (2,1) and (2,0.8).. (-3.5,2.5);
     draw[flow] (0,0) .. controls (-2,-1) and (-2,-0.8) .. (3.5,-2.5);
   end{tikzpicture}%
  }

begin{document}
begin{tikzpicture}[line cap=round,line join=round]
  % Main diagram
  draw[line width=1pt,->] (0,-0.3) -- (0, 4.7) coordinate (+y);
  draw[line width=1pt,->] (-5,0) -- ( 5,0) coordinate (+x);
  draw[line width=1pt, domain=-4:4] plot (x, {0.25*x*x});
  node at (+y) [label={[above,yshift=0.8cm]%
    {sffamilylarge Poincar'e Diagram: Classification of Phase Portaits
     in the $(det A,Tr A)$-plane}}] {};
  node at (+x) [label={[right,yshift=-0.5ex]$scriptstyleTr A$}] {}; 
  node at (+y) [label={[above]$scriptstyledet A$}] {};
  node at (-4,4) [pin={[above]$scriptstyleDelta=0$}] {};
  node at ( 4,4) [pin={[above,align=left]{%
    $scriptstyleDelta=0$:
    $scriptstyledet A=frac{1}{4}(Tr A)^2$}}] {};
  % inlays
  node at (0,-1.4) {inlaysaddle};
  node at (0,1.2)
    [pin={[draw,right,xshift=0.3cm]inlaycentre}] {};
  node at (0,0)
    [pin={[draw,above left,align=center,xshift=-0.3cm]%
    inlaycaption{uniform}[-1ex]inlaycaption{motion}}] {};
  node at (-4,1) {inlaysink};
  node at ( 4,1) {inlaysource}; 
  node at (-3,0) [pin={[draw,below,yshift=-1cm]inlaystablefp}] {};
  node at  (3,0) [pin={[draw,below,yshift=-1cm]inlayunstablefp}] {};
  node at (-1.8,3.7) {inlayspiralsink};
  node at ( 1.8,3.7) {inlayspiralsource};
  node at (-3.5,{0.25*3.5*3.5})
    [pin={[draw,left,xshift=-1.15cm,yshift=-0.3cm]inlaydegensink}] {};
  node at ( 3.5,{0.25*3.5*3.5})
    [pin={[draw,right,xshift=0.9cm,yshift=-0.3cm]inlaydegensource}] {};
end{tikzpicture}
end{document}

I tried to edit the code to create two other distinct phase portrait, but I couldn’t quite understand the code.

I was trying to create, for example, this phase portrait,

2 3

I would like to understand the code and how to create these examples.

One Answer

Desired phase trajectories is simple to draw with use of the polar coordinates and in preamble defined styles in tikzset:

documentclass[tikz, margin=3.14159mm]{standalone}
usetikzlibrary{decorations.markings}
tikzset{
                   > = stealth,
    every pin/.style = {pin edge = {<-}},
         flow/.style = {decoration = {markings, mark=at position #1 with {arrow{>}}},
                        postaction = {decorate}
                        },
       flow/.default = 0.5,
         main/.style = {color=#1, line width=1pt, line cap=round, line join=round},
       main/.default = black
                }

begin{document}
    begin{tikzpicture}
% axis
draw [->] (0,-3) -- (0,3) node [above]  {$y$};
draw [->] (-3,0) -- (3,0) node [right]  {$x$};
% phase trajectories
foreach i in {0, 22.5,...,360}
    draw[main=blue, flow]    (0,0) -- (i:2.5);
end{tikzpicture}

    begin{tikzpicture}
% axis
draw [->] (0,-3) -- (0,3) node [above]  {$y$};
draw [->] (-3,0) -- (3,0) node [right]  {$x$};
% phase trajectories
foreach i in {0, 22.5,...,360}
    draw[main=blue, flow]  (i:2.5) -- (0,0);
end{tikzpicture}

end{document}

enter image description here

In the your complex image of Poincare Diagram you can insert this images as are inserted other images: by store developed image code (from above MWE) in savebox with name of your choice:

newinlayXXX{XXX}% XXX name of savebox
  {
begin{tikzpicture}[scale=inlayscale]
% axis
draw [->] (0,-3) -- (0,3) node [above]  {$y$};
draw [->] (-3,0) -- (3,0) node [right]  {$x$};
% phase trajectories
foreach i in {0, 22.5,...,360}
    draw[main=blue, flow]  (i:2.5) -- (0,0);
end{tikzpicture}
}

and insert in the main image as content of node placed on desired coordinate as:

node at (<x-coordinate>,<y-coordinate>) {inlayXXX}; % XXX is name of your image save box

From above you can see a workflow in design of your final image:

  • First you develop code for sub image.
  • When code gives satisfactory result, you code of picture store in save box with selected name (as shown above).
  • use this save box as content of node in the main picture.

Is this helpful? For preamble in MWE is used preamble from (my answer) on your previous question.

Correct answer by Zarko on January 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP