<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.3">Jekyll</generator><link href="https://kursatyurt.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kursatyurt.com/" rel="alternate" type="text/html" /><updated>2024-01-25T11:58:42+01:00</updated><id>https://kursatyurt.com/feed.xml</id><title type="html">Kürşat Yurt</title><subtitle>| Programming | CFD | HPC |</subtitle><author><name>Kürşat Yurt</name></author><entry><title type="html">A simple cheatsheet to tmux</title><link href="https://kursatyurt.com/linux/Tmux-Cheatsheet/" rel="alternate" type="text/html" title="A simple cheatsheet to tmux" /><published>2022-05-15T00:00:00+02:00</published><updated>2022-05-15T00:00:00+02:00</updated><id>https://kursatyurt.com/linux/Tmux-Cheatsheet</id><content type="html" xml:base="https://kursatyurt.com/linux/Tmux-Cheatsheet/">&lt;p&gt;I have never remember such a damn beautiful but easy to forget tool like tmux. Everytime I need a search it on Google and than just forgot about everything. I thought a small cheatsheet would be useful for me, but also you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CTRL-B&lt;/strong&gt; is default prefix to execute commands.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;&amp;lt;prefix&amp;gt;+Command&lt;/th&gt;
      &lt;th&gt;Explanation&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;c&lt;/td&gt;
      &lt;td&gt;Creates a new session&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;d&lt;/td&gt;
      &lt;td&gt;Detach from a session&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;[0-9]&lt;/td&gt;
      &lt;td&gt;Move between sessions&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;,&lt;/td&gt;
      &lt;td&gt;Rename a window&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;p&lt;/td&gt;
      &lt;td&gt;Previous window&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;n&lt;/td&gt;
      &lt;td&gt;Next window&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;w&lt;/td&gt;
      &lt;td&gt;Shows all windows&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;amp;&lt;/td&gt;
      &lt;td&gt;Kill current window&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;”&lt;/td&gt;
      &lt;td&gt;Split pane horizontally&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;%&lt;/td&gt;
      &lt;td&gt;Split pane vertically&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Arrows&lt;/td&gt;
      &lt;td&gt;Move between panels&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;x&lt;/td&gt;
      &lt;td&gt;Kill current panel&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Spacebar&lt;/td&gt;
      &lt;td&gt;Toogle between horizontal and vertical panels&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;some-small-adjustments&quot;&gt;Some small adjustments&lt;/h2&gt;

&lt;p&gt;If you like to use mouse like me or want to adjust panel height/width quickly following tmux config file would be helpful&lt;/p&gt;

&lt;div class=&quot;language-tex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;set -g mouse on
bind -n C-k resize-pane -U 5
bind -n C-j resize-pane -D 5
bind -n C-h resize-pane -L 5
bind -n C-l resize-pane -R 5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After adding to tmux config only thing you need would be just sourcing the config file&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tmux source-file ~/.tmux.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Have a nice day&lt;/p&gt;</content><author><name>Kürşat Yurt</name></author><category term="Linux" /><category term="linux" /><category term="commandline" /><category term="tmux" /><summary type="html">I have never remember such a damn beautiful but easy to forget tool like tmux. Everytime I need a search it on Google and than just forgot about everything. I thought a small cheatsheet would be useful for me, but also you.</summary></entry><entry><title type="html">How to Draw Your Graphs using Tikz and Pgfplots</title><link href="https://kursatyurt.com/latex/tikz/Latex-Tikz/" rel="alternate" type="text/html" title="How to Draw Your Graphs using Tikz and Pgfplots" /><published>2021-06-08T00:00:00+02:00</published><updated>2021-06-08T00:00:00+02:00</updated><id>https://kursatyurt.com/latex/tikz/Latex-Tikz</id><content type="html" xml:base="https://kursatyurt.com/latex/tikz/Latex-Tikz/">&lt;h1 id=&quot;which-packages-are-reqiured-&quot;&gt;Which packages are reqiured ?&lt;/h1&gt;

&lt;p&gt;In followign example we will use tikz and pgfplots packages for plotting 2D graphs in a latex document.&lt;/p&gt;

&lt;div class=&quot;language-latex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;\usepackage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;tikz&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;\usepackage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;pgfplots&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This blog post only demonstrate basics and common things. Further more options please check pgfplots&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; and tikz manuals&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h1 id=&quot;plotting-equations&quot;&gt;Plotting Equations&lt;/h1&gt;

&lt;p&gt;Let’s start with a quick example to see how easy it is to do. In the following snippet. This is provide an entry point to us.&lt;/p&gt;

&lt;p&gt;First we begin with tikzpicture environment. For 2D plots we are use axis. Inside squared brackets we define axis properties like xlabel, label. Since we will be use mathematical expressions in this example we will define a domain lying from -10 to 10 in x axis and we will take 20 sampling point along this path.&lt;/p&gt;

&lt;div class=&quot;language-latex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;\begin{tikzpicture}&lt;/span&gt;
 &lt;span class=&quot;nt&quot;&gt;\begin{axis}&lt;/span&gt;
  [
  xlabel=&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;,
  ylabel=&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;,
  domain=-10:10,
  samples=20,
  ]
  &lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;2&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
 &lt;span class=&quot;nt&quot;&gt;\end{axis}&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;\end{tikzpicture}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It will produce following graph.&lt;/p&gt;

&lt;figure class=&quot;align-center&quot;&gt;
  &lt;img src=&quot;https://kursatyurt.com/assets/images/x2_graph.png&quot; width=&quot;100&quot; height=&quot;100&quot; /&gt;
  &lt;center&gt;
  &lt;figcaption&gt;A sample graph using pgfplots.&lt;/figcaption&gt;
  &lt;/center&gt;
&lt;/figure&gt;

&lt;h2 id=&quot;adding-more-options&quot;&gt;Adding more options&lt;/h2&gt;

&lt;p&gt;Let’s add a grid, change grid to a thinner and lighter version, move the thicks to outside of axes. Also let’s define ytick settings and xticks settings. We can defined how often we will have ticks.&lt;/p&gt;

&lt;div class=&quot;language-latex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;grid=both,
major grid style=&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;thin,color=black!10&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;,
tick align=outside,
ytick=&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;0,10,...,100&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;,
xtick=&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;-10,-7,...,10&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;,
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure class=&quot;align-center&quot;&gt;
  &lt;img src=&quot;https://kursatyurt.com/assets/images/x2_graph_2.png&quot; width=&quot;100&quot; height=&quot;100&quot; /&gt;
  &lt;center&gt;
  &lt;figcaption&gt;An improved graph.&lt;/figcaption&gt;
  &lt;/center&gt;
&lt;/figure&gt;

&lt;p&gt;We can also specify color of lines,marker and thickness. Here some examples.&lt;/p&gt;

&lt;div class=&quot;language-latex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [no markers, color=black] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;2&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [mark = x,color=red,very thin] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;2+5&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [mark = otimes,color=blue,thick] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [mark = diamond,color=pink, very thick] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x+50&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure class=&quot;align-center&quot;&gt;
  &lt;img src=&quot;https://kursatyurt.com/assets/images/multi_graph.png&quot; width=&quot;100&quot; height=&quot;100&quot; /&gt;
  &lt;center&gt;
  &lt;figcaption&gt;More improved graph.&lt;/figcaption&gt;
  &lt;/center&gt;
&lt;/figure&gt;

&lt;p&gt;Oh, we are adding more equations but there is no legend. How can one know which is which equation right?&lt;/p&gt;

&lt;p&gt;We can add legend entries at after adding a new plot there is 2 style is available&lt;/p&gt;

&lt;div class=&quot;language-latex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [no markers, color=black] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;2&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [mark = x,color=red,very thin] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;2+5&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [mark = otimes,color=blue,thick] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [mark = diamond,color=pink, very thick] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x+50&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Or&lt;/p&gt;

&lt;div class=&quot;language-latex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [no markers, color=black] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;2&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [mark = x,color=red,very thin] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;2+5&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [mark = otimes,color=blue,thick] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [mark = diamond,color=pink, very thick] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;x+50&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Default position for legend entry is north east, one can override that settings adding legend pos option to axis options. This is based on geographical locations.
It can be placed on south west|south east|north west|north east|outer north east.
By default legends are boxed, using legend style option {draw=none} we can remove outer box of a legend.&lt;/p&gt;

&lt;div class=&quot;language-latex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[
legend pos=outer north east,
legend style=&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;draw=none&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;,
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure class=&quot;align-center&quot;&gt;
  &lt;img src=&quot;https://kursatyurt.com/assets/images/legend_graph.png&quot; width=&quot;100&quot; height=&quot;100&quot; /&gt;
  &lt;center&gt;
  &lt;figcaption&gt;A graph with legend.&lt;/figcaption&gt;
  &lt;/center&gt;
&lt;/figure&gt;

&lt;h1 id=&quot;plotting-csv-files&quot;&gt;Plotting CSV Files&lt;/h1&gt;

&lt;p&gt;Generally we deal with plotting some data obtained from another source. One can easily store those values in a CSV file like below&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;x,entry1,entry2,entry3
0,1,0,0
1,2.71828182845904,1,0.25
2,7.38905609893065,8,4
3,20.0855369231877,27,20.25
4,54.5981500331442,64,64
5,148.413159102577,125,156.25
6,403.428793492735,216,324
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here we have 4 columns they are seperated by comma and first line gives the header for the values.&lt;/p&gt;

&lt;p&gt;Plotting such kind of data is a really easy task to do.&lt;/p&gt;

&lt;div class=&quot;language-latex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [plot options] table [table options] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;./path/to/data.csv&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Plot options are similar to what we have done above. The new entry table basicly need 3 option. We need to speficy header of x values, y values, and the column seperator used in data file.&lt;/p&gt;

&lt;p&gt;Here an example.&lt;/p&gt;

&lt;div class=&quot;language-latex highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [no markers, color=black, very thick] table [x=x, y=entry1, col sep=comma] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;./data.csv&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [no markers, color=red, very thick] table [x=x, y=entry2, col sep=comma] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;./data.csv&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addplot&lt;/span&gt; [no markers, color=blue, very thick] table [x=x, y=entry3, col sep=comma] &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;./data.csv&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;;
&lt;span class=&quot;k&quot;&gt;\addlegendentry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{$&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;$}&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure class=&quot;align-center&quot;&gt;
  &lt;img src=&quot;https://kursatyurt.com/assets/images/csv_graph.png&quot; width=&quot;100&quot; height=&quot;100&quot; /&gt;
  &lt;center&gt;
  &lt;figcaption&gt;A graph created using CSV.&lt;/figcaption&gt;
  &lt;/center&gt;
&lt;/figure&gt;
&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;http://mirrors.ctan.org/graphics/pgf/contrib/pgfplots/doc/pgfplots.pdf&quot;&gt;pgfplots manual&lt;/a&gt; &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf&quot;&gt;tikz manual&lt;/a&gt; &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content><author><name>Kürşat Yurt</name></author><category term="latex" /><category term="tikz" /><category term="latex" /><category term="tikz" /><category term="pgfplot" /><summary type="html">Which packages are reqiured ?</summary></entry><entry><title type="html">Introduction to Linux Command Line</title><link href="https://kursatyurt.com/linux/Introduction-to-Linux-Command-Line/" rel="alternate" type="text/html" title="Introduction to Linux Command Line" /><published>2021-06-07T00:00:00+02:00</published><updated>2021-06-07T00:00:00+02:00</updated><id>https://kursatyurt.com/linux/Introduction-to-Linux-Command-Line</id><content type="html" xml:base="https://kursatyurt.com/linux/Introduction-to-Linux-Command-Line/">&lt;p&gt;Whenever it comes to some serious stuff like using a cluster or open-source software like OpenFOAM people are faced with the famous Linux command line. It was scary at the first sight but later on, when you get used to him, he will be your best friend.&lt;/p&gt;

&lt;p&gt;Here some basic commands that it as a good start point&lt;/p&gt;

&lt;p&gt;When you open a terminal you might only see a blinking cursor&lt;/p&gt;

&lt;p&gt;If you type pwd, this will give you your current working directory’s absolute path&lt;/p&gt;

&lt;p&gt;Here my current terminal output&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;
/home/kursayurt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now I know that I am on my home directory. I want to know which files or directories inside this directory. Simply typing ls is gives you that ones&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;ls
 &lt;/span&gt;Blog
 Desktop
 Documents
 Downloads
 hello.cpp
 Pictures
 Project
 Public
 Templates
 TUM
 Videos
 yd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As you see here is a &lt;em&gt;hello.cpp&lt;/em&gt; file and some other directories are around here&lt;/p&gt;

&lt;p&gt;Let’s go to my Desktop directory using cd command&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;Desktop
&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;
/home/kursatyurt/Desktop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now as you see I have changed the current directory to my Desktop&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;ls
&lt;/span&gt;Ch8Sub.pdf               worksheet2.pdf
cfdlab-lecture-notes.pdf
ws-navier-stokes.pdf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There is pdf files around. If I want to open one of them I can simply open them using xdg-open command which is open any type of file using default software defined by the system&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xdg-open woorksheet2.pdf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To go back we can type&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ..
&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;
/home/kursatyurt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This take us one directory back.&lt;/p&gt;

&lt;p&gt;Now if I want to copy a file from my Desktop to Home directory, I can follow this thing.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; ./Desktop/worksheet2.pdf &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here &lt;em&gt;cp&lt;/em&gt; command takes two arguments first one is the source and the second one is the destination&lt;/p&gt;

&lt;p&gt;&lt;em&gt;./&lt;/em&gt; denotes from current directory by this way we can espace from writing absolute path. Also in the second argument &lt;em&gt;.&lt;/em&gt; means here.&lt;/p&gt;

&lt;p&gt;If we want to move a folder or file we use &lt;em&gt;mv&lt;/em&gt; command which is similar to &lt;em&gt;cp&lt;/em&gt;, one important thing about copy is you cannot copy a folder using &lt;em&gt;cp&lt;/em&gt; command alone you need to give recursive flag &lt;em&gt;-r&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; /source/directory /destination/directory
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;By this way one can copy a folder.&lt;/p&gt;

&lt;p&gt;In order to create a new directory, we are using mkdir command&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;directoryname
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This creates a new directory under our current directory as like any other linux command we can do operation other than our current directory giving absolute path&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; /absolute/path/to/directory
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now take a look at removing files/directories. An important thing about removing is that this operation is irreversible, no Trash Bin deleted files from command line goes.&lt;/p&gt;

&lt;p&gt;Let’s first look into deleting files&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;rm &lt;/span&gt;FileName
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Removing directories are requires a recursive operation&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; DirectoryName
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;One other important thing is of course when you are doing an operation or running a program you might want to cancel that process. For this purpose &lt;em&gt;[Control]+c&lt;/em&gt; is used.&lt;/p&gt;</content><author><name>Kürşat Yurt</name></author><category term="Linux" /><category term="linux" /><category term="commandline" /><summary type="html">Whenever it comes to some serious stuff like using a cluster or open-source software like OpenFOAM people are faced with the famous Linux command line. It was scary at the first sight but later on, when you get used to him, he will be your best friend.</summary></entry><entry><title type="html">A simple ODE Solver Using Python</title><link href="https://kursatyurt.com/numerics/python/ODE-Solver/" rel="alternate" type="text/html" title="A simple ODE Solver Using Python" /><published>2021-06-07T00:00:00+02:00</published><updated>2021-06-07T00:00:00+02:00</updated><id>https://kursatyurt.com/numerics/python/ODE-Solver</id><content type="html" xml:base="https://kursatyurt.com/numerics/python/ODE-Solver/">&lt;p&gt;In this blog post we will understand what is an ODE and how to solve it numerically using Python.&lt;/p&gt;

&lt;h1 id=&quot;what-is-an-ode&quot;&gt;What is an ODE?&lt;/h1&gt;

&lt;p&gt;In mathematics, an ordinary differential equation (ODE) is a differential equation containing one or more functions of one independent variable and the derivatives of those functions &lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; .&lt;/p&gt;

&lt;h1 id=&quot;why-do-we-need-numerical-methods&quot;&gt;Why do we need numerical methods?&lt;/h1&gt;

&lt;p&gt;Numerical methods are techniques to approximate mathematical procedures. Here we are approximate an time integral. We use numerical methods when an analytical solution does not exist (e.g. Navier Stokes Equations), or an analytical method is intractable.&lt;/p&gt;

&lt;h1 id=&quot;fundamental-approach-eulers-method&quot;&gt;Fundamental Approach: Euler’s Method&lt;/h1&gt;

&lt;p&gt;Here we want to solve an ODE in the form of&lt;/p&gt;

\[\frac{dx}{dt} = f(x,t)\]

&lt;p&gt;Using Taylor series expansion around \(x(t_0)\) we can write following equation&lt;/p&gt;

\[x(t_0+dt) = x(t_0) + dt \cdot x'(t_0) + O(dt^2)\]

&lt;p&gt;This method is called (Explicit) Euler’s method.&lt;/p&gt;

&lt;h1 id=&quot;physical-problem&quot;&gt;Physical Problem&lt;/h1&gt;

&lt;p&gt;Let’s consider the falling of a parachute jumper. Governing equation for this problem is \(F=m*a\) . To model the drag force we choose simple model \(F_{drag}=\frac{1}{2}\rho A C_D V^2\), where \(C_D\) is drag coefficent, \(A\) is area of parachute and \(\rho\) is air density. The other forces acting on the jumper is gravitationa force which is given by \(F_G=g*m\), where \(g\) is gravitational acceleration and \(m\) is mass. Resulting governing equation is the this problem is:&lt;/p&gt;

\[m \cdot g - \frac{1}{2}\rho A C_D V^2 = m \cdot a\]

\[a = g- \frac{\rho A C_D V^2}{2m}\]

&lt;p&gt;In other words,&lt;/p&gt;

\[\frac{dV}{dt} = g- \frac{\rho A C_D V^2}{2m}\]

&lt;h1 id=&quot;lets-code-it&quot;&gt;Let’s code it&lt;/h1&gt;

&lt;p&gt;First of all we need to import libraries to python. In this project we will use 2 libraries called numpy and matplotlib.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;matplotlib&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After importing libraries we will define the ODE’s function&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;dvdt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;V&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rho&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;V&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Since this is a rather simple ODE we have an analytical solution, which we will be use to check accuracy of solution.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;def analyticalsol(t):
    v = (21.0262 * np.exp(0.933124 * t) -21.0262) / (np.exp(0.933124 * t) + 1)
    return v
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This gives us the derivation of function at the a known point.&lt;/p&gt;

&lt;p&gt;Let’s initialize the variables&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;v_0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;       &lt;span class=&quot;c1&quot;&gt;#m/s    initial velocity
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t_0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;       &lt;span class=&quot;c1&quot;&gt;#s      initial time
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t_end&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#s      end time
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;#kg     mass
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;3.14&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;#m^2    area
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.15&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;#       drag coefficent
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rho&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.229&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#kg/m^3 air density
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;g&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;9.81&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# m/s^2 gravitational acceleration
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;      &lt;span class=&quot;c1&quot;&gt;#s      timestep
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#empty of numerical results
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;#empy list of numerical time series
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now lets write the main solution loop&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v_0&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#Initialize Velocity
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t_0&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#Initialize Time
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t_end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;            &lt;span class=&quot;c1&quot;&gt;#Store Current Time
&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;          &lt;span class=&quot;c1&quot;&gt;#Store Current Velocity
&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;acceleration&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dvdt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#Get Acceleration
&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;acceleration&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dt&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;#Advance velocity
&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dt&lt;/span&gt;                   &lt;span class=&quot;c1&quot;&gt;#Advance time
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;a_time&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numpy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;linspace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t_0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t_end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#Sample 50 Point betwen t_0 and t_end
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a_result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;analyticalsol&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a_time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;                &lt;span class=&quot;c1&quot;&gt;#Get the solution
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#Plot Analytical Solution
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a_time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a_result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Analytical Solution&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#Plot Numerical Solution
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;time&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Numerical Solution&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;#Add Legend
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;grid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;#Add Grid
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;#Show plot on the screen
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can download the python script that I used to produce result below from &lt;a href=&quot;https://kursatyurt.com/files/euler_ode.py&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;results&quot;&gt;Results&lt;/h1&gt;

&lt;figure class=&quot;align-center&quot;&gt;
  &lt;img src=&quot;https://kursatyurt.com/assets/images/ode_euler.png&quot; width=&quot;100&quot; height=&quot;100&quot; /&gt;
  &lt;center&gt;
  &lt;figcaption&gt;Comparision of Solution.&lt;/figcaption&gt;
  &lt;/center&gt;
&lt;/figure&gt;

&lt;p&gt;Here we can clearly see that as we decrease the timestep we get a more accurate solution. There is a limit we can decrease the timestep, while decreasing we error.
Using too small or too big timesteps causes inaccurate results.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Dennis G. Zill . A First Course in Differential Equations with Modeling Applications. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content><author><name>Kürşat Yurt</name></author><category term="numerics" /><category term="python" /><category term="numerics" /><category term="numericalmethods" /><category term="ode" /><category term="python" /><summary type="html">In this blog post we will understand what is an ODE and how to solve it numerically using Python.</summary></entry><entry><title type="html">Hello World!</title><link href="https://kursatyurt.com/HelloWorld/" rel="alternate" type="text/html" title="Hello World!" /><published>2021-06-06T00:00:00+02:00</published><updated>2021-06-06T00:00:00+02:00</updated><id>https://kursatyurt.com/HelloWorld</id><content type="html" xml:base="https://kursatyurt.com/HelloWorld/">&lt;p&gt;Hey there welcome to my blog page. I am Kürşat. Currently, I am studying Computational Science and Engineering at Technical University of Munich.&lt;/p&gt;

&lt;p&gt;In this blog I will share some &lt;em&gt;interesting&lt;/em&gt; posts that are related to engineering, programming, some daily useful tools and so on.&lt;/p&gt;

&lt;p&gt;I hope you will enjoy!&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-fortran highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello World!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Kürşat Yurt</name></author><summary type="html">Hey there welcome to my blog page. I am Kürşat. Currently, I am studying Computational Science and Engineering at Technical University of Munich.</summary></entry></feed>