Giter VIP home page Giter VIP logo

seba's Introduction

SeBa is a software package to simulate the evolution of single and binary stars from the zero-age main-sequence up to and including remnant phases.It is valid for masses in the range 0.01-100 Msun with variable metallicity. SeBa includes prescriptions for mass loss by stellar winds, supernova and binary interactions.

This document contains following parts:

Compilation

Simple examples

Understanding the SeBa output

References

Compilation

SeBa can be compiled as following:

make clean
make
cd dstar 
make

Simple examples of runs

Single system

To evolve a single system with the parameters primary mass M=2 solar mass, secondary mass m=1 solar mass, eccentricy e=0.2, orbital separation a=200 solar radii, time T=13500 Myrs, metallicity z=0.001, you need to run:

./SeBa -M 2 -m 1 -e 0.2 -a 200 -T 13500 -z 0.001

Multiple systems with specified parameters

If you need to follow the binary stellar evolution for multiple systems with parameters which are already specified you can start SeBa multiple times, e.g.

./SeBa -M 2 -m 1 -e 0.2 -a 200 -T 13500 -z 0.001
./SeBa -M 2.5 -m 1.5 -e 0.5 -a 500 -T 500 -z 0.02

This is probably not handy for more than 5 systems. Although this can be added in e.g. a shell or Python script. For example a file named run.sh, should contain the lines for the example given above:

./SeBa -M 2 -m 1 -e 0.2 -a 200 -T 13500
./SeBa -M 2.5 -m 1.5 -e 0.5 -a 500 -T 500

Note:Check permissions of run.sh file; it should be executable by the owner. If not: type ' chmod 744 run.sh ' in command line. To run the shell script: ./run.sh

Another option is to use an input file:

./SeBa -I 'SeBa_input.txt'

which contains following information a e M m z, e.g.

200 0.2 2 1 0.001
500 0.5 2.5 1.5 0.02

Random population

Monte Carlo based approach

./SeBa -R -n 200
./SeBa -R -n 250000 -m 0.96 -M 11 -q 1e-4 -Q 1 -A 1e6 -f 4 -T 13500

with following parameters:

-R SeBa generates randomly the initial parameters -n number of systems simulated
-m -M min/max primary mass
-q -Q min/max mass ratio
-e -E min/max eccentricity
-a -A min/max orbital separation
-T time in Myr in the simulation of the binaries. Same time for all binaries 
-z metallicity of binary stars. All binaries have the same metallicity.
   To vary the metallicity, multiple simulations should be run. 
-N initial ID number of first simulated binary
(Default: 0, may come in handy for stitching together production runs)   

(Experimental)

-C Initial stellar type primary star [default is main_sequence]
-c Initial stellar type secondary star [default is main_sequence]
Starts at beginning of specified phase. Options are planet, brown_dwarf, main_sequence, hertzsprung_gap, sub_giant, horizontal_branch, super_giant, helium_star, helium_giant, hyper_giant, carbon_star, thorn_zytkow, helium_dwarf, carbon_dwarf, oxygen_dwarf, xray_pulsar, radio_pulsar, neutron_star, black_hole, Disintegrated

The initial parameters are drawn from distributions:

-x mass function exponent in case of power law [-2.35] 
-F/f mass function option: 
	0) Equal mass
	1) Power-law [default] 
	2) Miller & Scalo
	3) Scalo
	4) Kroupa

Option -F requires one of the following strings: (mf_Power_Law, Miller_Scalo, Scalo, Kroupa)
-f requires the appropriate interger (see mkmass.C)

-y exponent for a power-law distribution [0] (flat in log)
-G/g Semi major axis option: 
	0) Equal_sma 
	1) Power Law [default]
	2) Duquennoy & Mayor (1987) Option -G requires one of the following strings:
	(Equal_sma, sma_Power_Law, Duquennoy_Mayor) -g requires appropriate integer (see double_star.h)

-v exponent for a power-law distribution
-U/u eccentricity option: 
	0) Equal eccentricity
	1) Power Law
	2) Thermal distribution [default] Option -U requires one of the following strings:
	(Equal_ecc, ecc_Power_Law, Thermal_Distribution) -u requires appropriate interger (see double_star.h)

-w exponent for a power-law distribution
-P/p mass ratio option: 0) constant mass ratio
	1) Flat_q
	2) Power Law
	3) Hogeveen (1992)
Option -P requires one of the following strings: (Equal_q, Flat_q, qf_Power_Law, Hogeveen)
-p requires appropriate interger (see double_star.h)

Understanding the SeBa output

SeBa adds the evolutionary history of each binary in the SeBa.data file. Every line represents a moment in the evolution of the binary when something interesting happened, for example one of the star transitions from the main-sequence to the hertzsprung gap, or mass transfer starts or stops. The meaning of the columns is defined below. The first column represents a unique identifier for each binary.

Structure of SeBa.data file

columns (starting at column 1):
column 1 binary identity number 
column 2 binary type
column 3 mass transfer type
column 4 time
column 5 separation in Solar radii
column 6 eccentricity
column 7 & 13 stellar identity number (either 0 or 1)
column 8 & 14 star type
column 9 & 15 stellar mass in Solar mass
column 10 & 16 stellar radius in Solar radii
column 11 & 17 log of effective temperature
column 12 & 18 core mass in Solar mass

Binary types

2 detached
3 semi detached + stable mass transfer 
4 contact
5 CE (gamma)
6 double spiral-in
7 merged
8 disrupted
9 CE (alpha)

Mass transfer types

1 on nuclear time scale
2 on angular momentum loss timescale (either gravitational waves &
magnetic braking)
3 on thermal time scale
4 CE due to dynamics
5 CE due to Darwin Riemann instability

Stellar types

1 planet
2 brown dwarf
3 main sequence
5 hertzsprung gap
6 sub-giant
7 core helium burning star 
8 agb
10 helium star
11 helium giant
12 carbon-oxygen white dwarf 
13 helium white dwarf
14 oxygen-neon white dwarf 
18 neutron star
19 black hole
20 disintegrated

References

See the following publications:

  • Portegies Zwart S.F. & Verbunt F., 1996, A&A, 309, 179: "Population synthesis of high-mass binaries"
  • Toonen, S., Nelemans, G., Portegies Zwart S.F., 2012, A&A, 546A, 70T: "Supernova Type Ia progenitors from merging double white dwarfs. Using a new population synthesis model"

seba's People

Contributors

floriskummer avatar nelemans avatar rieder avatar silviatoonen avatar spzwart avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seba's Issues

error in SeBa interface regarding recall_memory_one_step

I believe there is a bug in the SeBa interface when using the function recall_memory_one_step.
The interface uses a parameter called seba_time. Every timestep this parameter is updated to the end_time (see the function evolve_system in interface.cc). However, when recall_memory_one_step is called it is not reset. As a result I'm running into the situation that after the recall, when the new needed timestep is calculated in evolve_system, the timestep is negative. Consequently SeBa keeps on running as the end_time is never reached (while loop is never broken).

Suggested solution: I suggest we set the seba_time to the current_time at the end of the recall_memory_one_step function, e.g.:
seba_time = seba_node->get_starbase()->get_current_time() - seba_node->get_starbase()->get_time_offset();

eccentricity power law distribution produces nan

When running the code with the option -U Power_Law, the output file SeBa.data contains -nan in place of the separation and the eccentricity (columns 5 and 6).
It could be caused by a bug at line 560 of initdouble.c
I believe it could be fixed by changing
ecc = get_random_eccentricity(e_min, e_max, ef, m_prim+m_sec);
to
ecc = get_random_eccentricity(e_min, e_max, ef, e_exp);

optimisation coded, but not used

The Makefiles of SeBa include the optimisation flag -O through CFLAGS += -O
However CFLAGS is not used.

My suggestion: add a flag: CXXFLAGS += -O (or -O2)

Any objections of why not to do this?

Wrong parameter in mass ratio distribution

In file initdouble.c, lines 165-186:

char* type_string(mass_ratio_distribution qf) {

    local char  qf_name[SEED_STRING_LENGTH];
    switch(qf) {
       case Equal_q:
            sprintf(qf_name, "Equal_q"); 
        break;	    
       case Flat_q:
            sprintf(qf_name, "Flat_q"); 
        break;	    
       case qf_Power_Law:
            sprintf(qf_name, "Power_Law"); 
        break;	    
       case Thermal_Distribution:
            sprintf(qf_name, "Hogeveen"); 
        break;	    
       default:
            sprintf(qf_name, "Unknown_qf"); 
        break;
    }
    return qf_name;
}

I believe that line 178 should be case Hogeveen instead of case Thermal_Distribution, because Thermal distribution is a type of eccentricity distribution, not mass ratio.

As of now, this does not create problems, because Thermal_Distribution and Hogeveen are both equal to 3. But if the issue Wrong values of the eccentricity distribution -u parameter #14 is resolved in the way I suggested, then Thermal_Distribution would become 2, and this would break the code.

Wrong values of the eccentricity distribution -u parameter

The documentation says:

-U/u eccentricity option:
.0) Equal eccentricity
.1) Power Law
.2) Thermal distribution [default] Option -U requires one of the following strings:
(Equal_ecc, ecc_Power_Law, Thermal_Distribution) -u requires appropriate interger (see double_star.h)

But what really happens when setting the value of u is:

.0) Unknown_eccf
.1) Equal_ecc
.2) ecc_Power_Law
.3) Thermal_Distribution

I believe it could be fixed by setting Unknown_eccf=-1 at line 190 of starbase.h

Wrong string values for the parameter -U

The documentation says that the parameter -U needs one of the following strings to be passed:

Equal_ecc, ecc_Power_Law, Thermal_Distribution

Actually, the code only accepts one of the following strings:

Equal_ecc, Unknown_eccf, Power_Law

Therefore, to set a power law distribution, one needs to write -U Power_Law, not -U ecc_Power_Law, as indicated in the documentation. Furthermore, it is currently impossible to set a thermal distribution using the -U parameter.

Reference: extract_eccentricity_distribution_type_string function in initdouble.C

Buffer overflow in SeBa.C, paramlog string

The paramlog string is set to contain 90 characters (line 261). But the formatting string on line 353 is about 120 characters long; well over those 90 characters. This can cause a buffer overflow.

Previous versions didn't have the CT_method section of the formatting string, making it shorter (possibly just about 90 characters, depending on the floating point values having 1 or multiple digits on the left side of the decimal dot), so the problem will likely not have shown. This part of the string was introduced in a recent commit, bbd9187.

In addition, certainly in non-optimised compiled code, strings often have some leeway that they can run over their allocated buffer (unintentionally, and basically undefined behaviour), so this may also cause some people to not have come across this error yet (for example, clang 15 on macOS happily runs SeBa, while gcc 11 on Ubuntu 22.04 will throw a buffer overflow error).

One fix is to increase the buffer size, to e.g. 150. In addition, it might be good to use snprintf instead of sprintf, which makes its intention clearer to a future programmer that extends the formatting string. Given that this is C++ code, it may also be useful to use std::string instead, but that probably requires a C++11 flag for the compiler and restructuring more code.

Note that seedlog does not have (yet) this problem, eyeballing the length of the formatting string in line 376.

Here's the actual error (gcc 11 on Ubuntu 22.04):

$ ./SeBa -M 2 -m 1 -e 0.2 -a 200 -T 13500 -z 0.001
random number generator seed = 1714574797
*** buffer overflow detected ***: terminated
zsh: IOT instruction (core dumped)  ./SeBa -M 2 -m 1 -e 0.2 -a 200 -T 13500 -z 0.001

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.