Interested in particle astrophysics and plasma astrophysics. This blog is my research/private notebook.
Thursday, June 6, 2024
Levi-Civita symbol and cross product
Wednesday, August 30, 2023
Average over a sphere surface
The surface integral of the function $f$ over the surface $S$ is denoted by
\[ \int\int_S f dS \]
$dS$ is the area of an infinitesimal piece of the surface $S$.
Average over the sphere is
\[ <f> = \frac{1}{4\pi} \int_0^{2\pi} d\phi \int_0^{\pi} f \sin(\theta)d\theta ,\]
where $dS=\sin(\theta)d\theta d\phi$. This can be seen as a weight average, the weight is surface area.
\[ <\cos^2(\theta)>=1/3 \]
\[<\sin(\theta)>=2/3.\]
Friday, December 11, 2020
A simple guide to Install scikit ODES
Here is a simple guid to install scikit-odes. Odes is a scikit toolkit for scipy to add extra ode solvers. Specifically it interfaces the Sundials solvers cvode, cvodes, ida and idas.
>sudo apt-get install libopenblas-dev liblapack-dev
>wget https://computing.llnl.gov/projects/sundials/download/sundials-5.1.0.tar.gz
>tar xvf sundials-5.1.0.tar.gz
>mkdir builder
>cd builder
>cmake ../../sundials-5.1.0/ -DLAPACK_ENABLE=ON
>make
>sudo make install
c) Install scikits odesadd export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/bin to .bashrc
>source ~/.bashrc
>sudo pip install scikits.odes
Reference:
https://scikits-odes.readthedocs.io/en/latest/installation.html
Tuesday, August 25, 2020
Compute Jacobian matrix by Sympy
Computing the Jacobian matrix is not easy, but we can use the python symbolical package Sympy to get it.
Here is a simple example.
import sympy as sym
from sysmpy import init_printing
from sympy import sin,cos,Matrix
init_printing()
x,y=sym.symbols('x y')
F=Matrix([x*cos(y),x*sin(y),x**2])
X=Matrix([x,y])
print(F.jacobian(X))
print(F.jacbian(X).subs([(x,0),(y,1)]))
Reference:
https://docs.sympy.org/latest/modules/matrices/matrices.html
https://www.sympy.org/scipy-2017-codegen-tutorial/notebooks/20-ordinary-differential-equations.html