Skip to content

A C++ program that solve the Bonnor-Ebert differential equation, and a Jupyter Lab notebook that plot it.

License

Notifications You must be signed in to change notification settings

foglienimatteo/BonnorEbert

Repository files navigation

Bonnor-Ebert

All Contributors

Operating Systems License Pulls Top Language Version Commits Size

Bonnor-Ebert is a simple C++ program that solves the Bonnor-Ebert differential equation

Bonnor-Ebert_equation

with two possible algorithms: Euler and classic Runge-Kutta. The output file Bonnor-Ebert_Eulero.dat/ Bonnor-Ebert_RK.dat contains also the values of the first derivate ψ'(ξ) , concentration parameter g_0 and f_0. This data may be easily visualize thanks to the Jupyter Notebook file Bonnor-Ebert.ipynb.

Table of contents

Requirements

In order to build the software from the source code here provided, you will need:

  • cmake (version >= 3.12);
  • A C++17 compiler;

This project uses the header-only Argh! library, which is already included in this repository in include/argh.h;therefore, you do not need to install it on your system.

Installation

First of all, copy the source code provided in this repository on your OS. You may clone the repository where it is built in, running in the command line

git clone https://github.com/foglienimatteo/BonnorEbert

or download the source code from the webpage https://github.com/foglienimatteo/BonnorEbert.

Hereafter, run the following shell commands from the project directory:

mkdir build
cd build
cmake ..
make

The executable file Bonnor_Ebert is generated in the build directory.

Usage

In order to execute the Bonnor_Ebert file (inside the build directory), the syntax is the standar one:

./Bonnor_Ebert {euler/rungekutta} [options]

The command euler tells the program to solve the differential equation with the Euler method, while rungekutta with the classic Runge-Kutta one. You have to specify which between these two algorithms must be used.

The actual available options, for both euler and rungekutta commands, are the following:

  • -h, --help: print the help message;
  • -s <step>, --step=<step>: set the step measure to be used solving the differential equation;
  • -b <begin>, --begin=<begin>: set the beginning value of ξ, where the algothims starts;
  • -e <end>, --end=<end>: set the ending value of ξ, where the algorithm ends;
  • -c <cut>, --cut=<cut>: set the ξ value at which we wants to cut the Bonnor-Ebert sphere.

Output file

Depending on the algorithm choosen, the output file (saved in the build directory) will be Bonnor-Ebert_Eulero.dat or Bonnor-Ebert_RK.dat. For each of these files, the output data are organized in 6 columns; from left to right, they are:

  • the iteration index of the algorithm i=0,1,2,...
  • the corresponding ξ value
  • the function value in that point, i.e. ψ(ξ)
  • the first function derivate in that point, i.e. ψ'(ξ)
  • the concentration parameter g_0 if the cut of the Bonnor-Ebert sphere occurs at ξ_0=ξ;
  • the parameter f_0 if the cut of the Bonnor-Ebert sphere occurs at ξ_0=ξ;

In a table form, the data are disposed like this:

i xi psi psip g_0 f_0
0 0.0001 0 0 0.9999 0
1 0.00011 0 1e-05 0.99989 1.21e-13
2 0.00012 1e-10 1.81818e-05 0.99988 2.61818e-13
3 0.00013 2.81818e-10 2.51515e-05 0.99987 4.25061e-13
... ... ... ... ... ...

Here we rememeber the definition of g_0 and f_0:

g_0 f_0

Visualization of the data

In the main directory, it is provided a JupyterLab Notebook, called Bonnor-Ebert.ipynb, where the skeleton of the data plotting and analysis is provided. Unfortunately, the notous curl in the p_0/p_s vs (R_0/R_s)^3 does not appear clearly, probably for a computational mistake somewhere in the source code.

Mathematical treatment

The original equation can be rewrited in this simple system:

BE_system

So, with the basic treatment of the differential equation numerical solutions:

BE_system

License

Bonnor-Ebert is free software, and it is released under version 3 of the GNU General Public License.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Matteo Zeccoli Marazzini

🤔 🔧

This project follows the all-contributors specification. Contributions of any kind welcome!

About

A C++ program that solve the Bonnor-Ebert differential equation, and a Jupyter Lab notebook that plot it.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published