<p>by default, this create a directory in your home <ttclass="docutils literal"><spanclass="pre">~/pnbody_examples</span></tt>.
The scripts are in the <ttclass="docutils literal"><spanclass="pre">~/pnbody_examples/ic</span></tt> directory.</p>
<divclass="section"id="spherical-coordinate">
<h2>Spherical coordinate<aclass="headerlink"href="#spherical-coordinate"title="Permalink to this headline">¶</a></h2>
<p>In spherical coordinates, supposing that the velocities are isotropics. the Jeans equations is reduced to one integral,
giving the value of the velocity dispertion of a component <imgclass="math"src="../_images/math/34857b3ba74ce5cd8607f3ebd23e9015908ada71.png"alt="i"/> :</p>
<h2>Example : Set a Plummer sphere to the jeans equilibrium<aclass="headerlink"href="#example-set-a-plummer-sphere-to-the-jeans-equilibrium"title="Permalink to this headline">¶</a></h2>
<spanclass="gp">>>></span><spanclass="n">nr</span><spanclass="o">=</span><spanclass="mi">128</span><spanclass="c"># number of radial bins</span>
</pre></div>
</div>
<p>Now, in order to decrease the noise in outer regions, it is usefull to
use a non linear grid. In this purpose, we need to define a function that
defines the new nodes of the grid. Here, we set it logarithmic. The inverse function
<spanclass="gp">>>></span><spanclass="n">g</span><spanclass="o">=</span><spanclass="k">lambda</span><spanclass="n">r</span><spanclass="p">:</span><spanclass="n">log</span><spanclass="p">(</span><spanclass="n">r</span><spanclass="o">/</span><spanclass="n">rc</span><spanclass="o">+</span><spanclass="mi">1</span><spanclass="p">)</span><spanclass="c"># the function</span>
<spanclass="gp">>>></span><spanclass="n">gm</span><spanclass="o">=</span><spanclass="k">lambda</span><spanclass="n">r</span><spanclass="p">:</span><spanclass="n">rc</span><spanclass="o">*</span><spanclass="p">(</span><spanclass="n">exp</span><spanclass="p">(</span><spanclass="n">r</span><spanclass="p">)</span><spanclass="o">-</span><spanclass="mi">1</span><spanclass="p">)</span><spanclass="c"># and its inverse</span>
</pre></div>
</div>
<p>Now it possible to invoque the magic function:</p>
<p>If <ttclass="docutils literal"><spanclass="pre">UseTree=True</span></tt> the function uses a <ttclass="docutils literal"><spanclass="pre">treecode</span></tt> to compute the potential at each node.
A new <ttclass="docutils literal"><spanclass="pre">nb</span></tt> object with velocities computed from the Jeans equation is returned. We also get the potential in each node
and some statistics. The potential <ttclass="docutils literal"><spanclass="pre">phi</span></tt> is usefull if we need to run the method for another component.</p>
<p>Using the <ttclass="docutils literal"><spanclass="pre">stats</span></tt> variable, it is possible to plot some interesting values used during the computation, like the velocity dispertion as a function of the radius:</p>
<h3>Radial velocity dispersion<aclass="headerlink"href="#radial-velocity-dispersion"title="Permalink to this headline">¶</a></h3>
<olclass="arabic simple">
<li>if <ttclass="docutils literal"><spanclass="pre">mode_sigma_r['name']='epicyclic_approximation'</span></tt>, we use the epicyclic approximation which hold:</li>
</div><p>the parameter <imgclass="math"src="../_images/math/04777e262a979166a6295fb67e24ca75bc42f3b6.png"alt="\beta^2"/> is set by the variable <ttclass="docutils literal"><spanclass="pre">mode_sigma_r['param']</span></tt> and takes usually a value around 1.</p>
<olclass="arabic simple"start="2">
<li>if <ttclass="docutils literal"><spanclass="pre">mode_sigma_r['name']='isothropic'</span></tt>, the value is simply:</li>
<li><pclass="first">if <ttclass="docutils literal"><spanclass="pre">mode_sigma_r['name']='toomre'</span></tt>, we determine the velocity dispersion uses the Safronov-Toomre parameter <imgclass="math"src="../_images/math/9866e3a998d628ba0941eb4fea0666ac391d149a.png"alt="Q"/>:</p>
<divclass="math">
<p><imgsrc="../_images/math/ded125c9d4c060477de06e79b24b3d76661fc17e.png"alt="\sigma_R = \frac{3.36 Q G \Sigma_i}{\kappa}"/></p>
</div><p><imgclass="math"src="../_images/math/9866e3a998d628ba0941eb4fea0666ac391d149a.png"alt="Q"/> is set with the variable <ttclass="docutils literal"><spanclass="pre">mode_sigma_r['param']</span></tt>.</p>
</li>
<li><pclass="first">if <ttclass="docutils literal"><spanclass="pre">mode_sigma_r['name']='constant'</span></tt>, the value is simply constant, given by the variable <ttclass="docutils literal"><spanclass="pre">mode_sigma_r['param']</span></tt>:</p>
<h3>Azimuthal velocity dispersion<aclass="headerlink"href="#azimuthal-velocity-dispersion"title="Permalink to this headline">¶</a></h3>
<olclass="arabic simple">
<li>if <ttclass="docutils literal"><spanclass="pre">mode_sigma_p['name']='epicyclic_approximation'</span></tt>, we use the epicyclic approximation which hold:</li>
<h2>Example : Set an exponnential disk to the jeans equilibrium<aclass="headerlink"href="#example-set-an-exponnential-disk-to-the-jeans-equilibrium"title="Permalink to this headline">¶</a></h2>
<p>Lest try to put an exponnential disk at the Jeans equilibrium.
<spanclass="gp">>>></span><spanclass="n">nr</span><spanclass="o">=</span><spanclass="mi">32</span><spanclass="c"># number of bins in r</span>
<spanclass="gp">>>></span><spanclass="n">nt</span><spanclass="o">=</span><spanclass="mi">2</span><spanclass="c"># number of bins in t</span>
<spanclass="gp">>>></span><spanclass="n">nz</span><spanclass="o">=</span><spanclass="mi">64</span><spanclass="o">+</span><spanclass="mi">1</span><spanclass="c"># number of bins in z</span>
</pre></div>
</div>
<dlclass="docutils">
<dt>Set some functions used to distort the grid along the radius::</dt>
<dd><divclass="first last highlight-python"><divclass="highlight"><pre><spanclass="gp">>>></span><spanclass="n">rc</span><spanclass="o">=</span><spanclass="n">Hr</span>
<p>The parameter <ttclass="docutils literal"><spanclass="pre">select='0'</span></tt> tells that we want to compute the velocities on particles of type 0, while
<ttclass="docutils literal"><spanclass="pre">disk=0</span></tt> tells that what we considere as the disk is only the particles 0. This is usefull when dealing with
multi-component models.</p>
<p>The latter function return <ttclass="docutils literal"><spanclass="pre">nb</span></tt> with the new velocities, a matrix <ttclass="docutils literal"><spanclass="pre">phi</span></tt> containing the potential at each node of the grid,
and a dictrionary <ttclass="docutils literal"><spanclass="pre">stats</span></tt> containing some physical usefull quantities. Lets plot some of them:</p>
<h3>Multi component systems<aclass="headerlink"href="#multi-component-systems"title="Permalink to this headline">¶</a></h3>
<p>Examples using multicomponents systems are provided in the <ttclass="docutils literal"><spanclass="pre">pnbody_examples/ic</span></tt> directory obtained
<li><aclass="reference internal"href="#example-set-a-plummer-sphere-to-the-jeans-equilibrium">Example : Set a Plummer sphere to the jeans equilibrium</a></li>
<li><aclass="reference internal"href="#example-set-an-exponnential-disk-to-the-jeans-equilibrium">Example : Set an exponnential disk to the jeans equilibrium</a><ul>