SEVN
Loading...
Searching...
No Matches
remnant.h
Go to the documentation of this file.
1//
2// Created by iorio on 7/5/21.
3//
4
5//Notice, the Mass property in staremnant returns just the mass of the star, there are no variables
6//to internally track the current mass of the star inside the class. The member Mremnant_at_born just track
7//the mass of the systems when it is created.
8
9
10#ifndef SEVN_REMNANT_H
11#define SEVN_REMNANT_H
12
13#include <iostream>
14#include <sevnlog.h>
15#include <utilities.h>
16#include <lookup_and_phases.h>
17#include <random>
18
19class Star;
20
21
22
24public:
25
26 Staremnant(_UNUSED Star *s, double Mremnant, double time) : born_time(time), Mremnant_at_born(Mremnant){}
27 Staremnant(Star *s, double Mremnant);
29
30 virtual ~Staremnant()=default;
31
32 inline double get_born_time() const {return born_time;}
33 inline double get_Mremnant_at_born() const {return Mremnant_at_born;}
34
35 virtual double Mass(_UNUSED Star *s) const;
36 virtual double Radius(_UNUSED Star *s) const = 0; //Pure virtual
37 virtual double Luminosity(_UNUSED Star *s) const = 0; //Pure virtual
38 virtual double OmegaRem(_UNUSED Star *s) const = 0; //Pure virtual
39 virtual double Inertia(_UNUSED Star *s) const = 0; //Pure virtual
40 virtual double Bmag(_UNUSED Star *s) const = 0; //Pure virtual
41 virtual double Xspin(_UNUSED Star *s) const = 0; //Pure virtual
42
49 double get(Star* s, size_t ID) const;
50
52
58 double age(Star *s) const;
59
60 double InertiaSphere(Star *s) const;
61
62protected:
64
65private:
66
67 double born_time;
70};
71
72
73
74
75class BHrem : public Staremnant{
76
77public:
78
79 BHrem(_UNUSED Star *s, double Mremnant, double time) : Staremnant(s, Mremnant, time) {
81 }
82 BHrem(Star *s, double Mremnant) : Staremnant(s,Mremnant){
84 };
85
87 double Radius(_UNUSED Star *s) const override;
89 double Luminosity(_UNUSED Star *s) const override { return 1e-10;}
90 double OmegaRem(_UNUSED Star *s) const override {return 0.;}
91 double Inertia(_UNUSED Star *s) const override {return InertiaSphere(s);}
92 double Bmag(_UNUSED Star *s) const override {return 0.;}
93 double Xspin(_UNUSED Star *s) const override;
94
96 int apply_Bavera_correction_to_Xspin(double period, double mass_wr);
97
98protected:
99
100 void default_initialiser(Star *s);
101
107 inline int set_Xspin(double value){
108 if (value<0 or value>1){
109 svlog.critical("Xspin in Bhrem has to be between 0 and 1, current value is "
110 + utilities::n2s(value,__FILE__,__LINE__),__FILE__,__LINE__,sevnstd::sanity_error());
111 }
112 xspin=value;
113 return EXIT_SUCCESS;
114 }
115
116
117
118
124 double estimate_Xspin(_UNUSED Star *s) const;
125
132 inline double XspinGeneva(const double z0, const double mco) const {
133
134 double a, b, m1, m2, alow;
135
136 a = -0.088;
137 if (z0 > 0.01)
138 b = 2.258, m1 = 16.0, alow = 0.13; //m2 = 24.2
139 else if (z0 > 0.004) // 0.004 < z0 <= 0.01
140 b = 3.578, m1 = 31.0, alow = 0.25; //m2 = 37.8
141 else if (z0 > 0.0012) // 0.0012 < z0 <= 0.004
142 b = 2.434, m1 = 18.0, alow = 0.0; //m2 = 27.7
143 else // z0 <= 0.0012
144 b = 3.666, m1 = 32.0, alow = 0.25; //m2 = 38.8
145
146 m2 = (alow - b) / a;
147 if (mco <= m1)
148 return 0.85;
149 else if (mco < m2)
150 return a * mco + b;
151 else
152 return alow;
153 }
154
164 inline double XspinMESA(const double z0, const double mco) const {
165 //TODO Check with Gaston the metallicity bounadry used in this function
166
167 double a1{0.}, b1{0.};
168
169 if (z0 > 0.0012 && z0 <= 0.004){
170 if (mco <= 12.09)
171 a1 = 0.0076, b1 = 0.05;
172 else
173 a1 = -0.0019, b1 = 0.165;
174 }
175 else if (z0 > 0.01)
176 a1 = -0.0016, b1 = 0.115;
177 else if (z0 > 0.004) // 0.004 < z0 <= 0.01
178 a1 = -0.0006, b1 = 0.105;
179 else // z0 <= 0.0012
180 a1 = -0.0010, b1 = 0.125;
181
182 //Fig. 2 of Belczynski1+20 (https://www.aanda.org/articles/aa/pdf/2020/04/aa36528-19.pdf) shows
183 //that the fitting equations are valid only up to approx a MCO mass of 70 Msun, but Xspin seems
184 //to drop to 0 for large MCO, therefore we just extraploate putting a lower limit at 0 Msun
185 return std::max(a1 * mco + b1,0.0);
186 }
187
194 inline double XspinFuller() const {
195 return 0.01;
196 }
197
203 inline double XspinMaxwellian(const double sigma_xspin) const {
204
205 double x1, x;
206
207 std::normal_distribution<double> gaussian_xspin{0.0, sigma_xspin};
208
209 x1 = gaussian_xspin(utilities::mtrand);
210 x1 *= x1;
211 x = gaussian_xspin(utilities::mtrand);
212 x *= x;
213 x += x1;
214 x1 = gaussian_xspin(utilities::mtrand);
215 x1 *= x1;
216 x += x1;
217
218 x = sqrt(x);
219 if (x > 1.0) /* Just in case the distribution throws x > 1 (possible although not too probable?)*/
220 x = 1.0;
221
222 return x;
223 }
224
229 inline double XspinZeros() const {return 0.0;}
230
231 //TODO This option is a test, we have to decide if keep it or no
232 //TODO In case we keep it, myabe we have to think to a better implementation (using processes since here the anchges are due to mass acretion)
242 double XspinAccretion(Star *s) const;
243
244private:
245 double xspin=std::nan(""); // Value of the BH spin.
246};
247
248
249
250class NSrem : public Staremnant{
251
252public:
253
254 NSrem(_UNUSED Star *s, double Mremnant, double time) : Staremnant(s, Mremnant, time), root_distribution(0.,1.0) {
256
257
258 }
259 NSrem(Star *s, double Mremnant) : Staremnant(s,Mremnant), root_distribution(0.,1.0) {
261 };
262
263
264 double Radius(_UNUSED Star *s) const override {return Rns;}
271 double Luminosity(_UNUSED Star *s) const override;
272 double OmegaRem(_UNUSED Star *s) const override;
273 double Inertia(_UNUSED Star *s) const override;
274 double Bmag(_UNUSED Star *s) const override;
275 double Xspin(_UNUSED Star *s) const override {return std::nan("");}
276
281 inline double get_alpha() const{return std::asin(sinalpha);}
282
287 inline double get_salpha() const{return sinalpha;}
288
293 inline double get_Bmin() const{return Bmin;}
294
295protected:
296
297 std::uniform_real_distribution<double> root_distribution;
298
299 inline double generate_uniform(double a, double b){
300 return root_distribution(utilities::mtrand)*(b-a) + a;
301 }
302
304
306
307public:
308 constexpr static double Rns = 11*utilities::km_to_RSun; //Neutron star radius 11 km in Rsun, from Hurley, 2000
309
310private:
311 double sinalpha; //sin of the angle between the rotation axis and the magnetic ax
312 double B0, Bmin; //Initial and minimum magnetic field in Gauss
313 double Omega0; //Initial Spin
314 double tau_magnetic; //Magnetic field decay time scale in Myr
315
316};
317
318class NSCCrem : public NSrem {
319
320public:
321 NSCCrem(_UNUSED Star *s, double Mremnant, double time) : NSrem(s, Mremnant, time) {
323 }
324 NSCCrem(Star *s, double Mremnant) : NSrem(s,Mremnant){
326 };
327};
328
329class NSECrem : public NSrem {
330
331public:
332 NSECrem(_UNUSED Star *s, double Mremnant, double time) : NSrem(s, Mremnant, time) {
335 }
336 NSECrem(Star *s, double Mremnant) : NSrem(s,Mremnant){
339 };
340};
341
342class WDrem : public Staremnant{
343
344public:
345
346 WDrem(_UNUSED Star *s, double Mremnant, double time) : Staremnant(s,Mremnant, time) {
348 }
349 WDrem(Star *s, double Mremnant) : Staremnant(s, Mremnant) {
351 }
352
358 double Radius(_UNUSED Star *s) const override;
364 double Luminosity(_UNUSED Star *s) const override;
365 double OmegaRem(_UNUSED Star *s) const override {return 0.;}
366 double Inertia(_UNUSED Star *s) const override {return InertiaSphere(s);};
367 double Bmag(_UNUSED Star *s) const override {return 0.;}
368 double Xspin(_UNUSED Star *s) const override {return 0.;}
369
370protected:
371 double A_luminosity; //To be used in the estimate of LWD (See Hurley+00 Sec. 6.2)
372
373 inline void default_initialiser(){}
374
375};
376
377class HeWDrem : public WDrem {
378
379public:
380
381 HeWDrem(_UNUSED Star *s, double Mremnant, double time) : WDrem(s, Mremnant, time){
383 }
384
385 HeWDrem(_UNUSED Star *s, double Mremnant) : WDrem(s, Mremnant){
387 }
388
389protected:
390
391 inline void default_initialiser() {
393 A_luminosity = 4; //From Hurley+00 Sec 6.2
394 }
395};
396
397class COWDrem : public WDrem {
398
399public:
400
401 COWDrem(_UNUSED Star *s, double Mremnant, double time) : WDrem(s, Mremnant, time){
403 }
404
405 COWDrem(_UNUSED Star *s, double Mremnant) : WDrem(s, Mremnant){
407 }
408
409protected:
410 inline void default_initialiser(){
412 A_luminosity = 15; //From Hurley+00 Sec 6.2
413 }
414};
415
416class ONeWDrem : public WDrem {
417
418public:
419
420 ONeWDrem(_UNUSED Star *s, double Mremnant, double time) : WDrem(s, Mremnant, time){
422 }
423
424 ONeWDrem(_UNUSED Star *s, double Mremnant) : WDrem(s, Mremnant){
426 }
427protected:
428 inline void default_initialiser() {
430 A_luminosity = 17; //From Hurley+00 Sec 6.2
431 }
432};
433
434
435/***
436 * A remnant class to handle objects that cannot be currently taken into account.
437 * For example stars that should jump in a track that is not available
438 */
439class Zombierem : public Staremnant{
440
441public:
442
443 Zombierem(Star *s, double Mremnant, double time) : Staremnant(s, Mremnant, time) {
444 initialise(s);
445 }
446
447 Zombierem(Star *s, double Mremnant) : Staremnant(s,Mremnant){
448 initialise(s);
449 };
450
451 double Radius(_UNUSED Star *s) const override { return radius;}
452 double Luminosity(_UNUSED Star *s) const override { return luminosity;}
453 double OmegaRem(_UNUSED Star *s) const override {return 0.;}
454 double Inertia(_UNUSED Star *s) const override {return InertiaSphere(s);}
455 double Bmag(_UNUSED Star *s) const override {return 0.;}
456 double Xspin(_UNUSED Star *s) const override {return 0.;}
457
458protected:
459
460 void initialise(Star *s);
461
462private:
464 double radius;
465};
466
467
468
469#endif //SEVN_REMNANT_H
#define _UNUSED
Definition: BinaryProperty.h:20
Definition: remnant.h:75
double XspinMESA(const double z0, const double mco) const
Definition: remnant.h:164
double XspinAccretion(Star *s) const
Definition: remnant.cpp:121
double OmegaRem(_UNUSED Star *s) const override
Definition: remnant.h:90
double XspinFuller() const
Definition: remnant.h:194
void default_initialiser(Star *s)
Definition: remnant.cpp:93
double XspinGeneva(const double z0, const double mco) const
Definition: remnant.h:132
double XspinZeros() const
Definition: remnant.h:229
BHrem(Star *s, double Mremnant)
Definition: remnant.h:82
double XspinMaxwellian(const double sigma_xspin) const
Definition: remnant.h:203
BHrem(_UNUSED Star *s, double Mremnant, double time)
Definition: remnant.h:79
double Bmag(_UNUSED Star *s) const override
Definition: remnant.h:92
int set_Xspin(double value)
Definition: remnant.h:107
double Inertia(_UNUSED Star *s) const override
Definition: remnant.h:91
int apply_Bavera_correction_to_Xspin(double period, double mass_wr)
Definition: remnant.cpp:98
double estimate_Xspin(_UNUSED Star *s) const
Definition: remnant.cpp:59
double xspin
Definition: remnant.h:245
double Luminosity(_UNUSED Star *s) const override
Definition: remnant.h:89
Definition: property.h:1451
Definition: remnant.h:397
COWDrem(_UNUSED Star *s, double Mremnant, double time)
Definition: remnant.h:401
void default_initialiser()
Definition: remnant.h:410
COWDrem(_UNUSED Star *s, double Mremnant)
Definition: remnant.h:405
Definition: remnant.h:377
void default_initialiser()
Definition: remnant.h:391
HeWDrem(_UNUSED Star *s, double Mremnant)
Definition: remnant.h:385
HeWDrem(_UNUSED Star *s, double Mremnant, double time)
Definition: remnant.h:381
Inertia.
Definition: property.h:999
Definition: property.h:921
Definition: property.h:776
Definition: remnant.h:318
NSCCrem(Star *s, double Mremnant)
Definition: remnant.h:324
NSCCrem(_UNUSED Star *s, double Mremnant, double time)
Definition: remnant.h:321
Definition: remnant.h:329
NSECrem(_UNUSED Star *s, double Mremnant, double time)
Definition: remnant.h:332
NSECrem(Star *s, double Mremnant)
Definition: remnant.h:336
Definition: remnant.h:250
NSrem(_UNUSED Star *s, double Mremnant, double time)
Definition: remnant.h:254
double Radius(_UNUSED Star *s) const override
Definition: remnant.h:264
double generate_uniform(double a, double b)
Definition: remnant.h:299
double B0
Definition: remnant.h:312
double get_alpha() const
Definition: remnant.h:281
double tau_magnetic
Definition: remnant.h:314
double get_salpha() const
Definition: remnant.h:287
double get_Bmin() const
Definition: remnant.h:293
void default_initialiser(_UNUSED Star *s)
Definition: remnant.cpp:204
double Xspin(_UNUSED Star *s) const override
Definition: remnant.h:275
double Bmin
Definition: remnant.h:312
std::uniform_real_distribution< double > root_distribution
Definition: remnant.h:297
static constexpr double Rns
Definition: remnant.h:308
void print_log_message(_UNUSED Star *s)
Definition: remnant.cpp:241
double sinalpha
Definition: remnant.h:311
NSrem(Star *s, double Mremnant)
Definition: remnant.h:259
double Omega0
Definition: remnant.h:313
Definition: remnant.h:416
void default_initialiser()
Definition: remnant.h:428
ONeWDrem(_UNUSED Star *s, double Mremnant)
Definition: remnant.h:424
ONeWDrem(_UNUSED Star *s, double Mremnant, double time)
Definition: remnant.h:420
Definition: property.h:1476
Definition: property.h:697
Definition: star.h:39
Definition: remnant.h:23
virtual double Xspin(_UNUSED Star *s) const =0
virtual ~Staremnant()=default
double Mremnant_at_born
Definition: remnant.h:68
Lookup::Remnants remnant_type
Definition: remnant.h:63
virtual double Luminosity(_UNUSED Star *s) const =0
virtual double OmegaRem(_UNUSED Star *s) const =0
double get_born_time() const
Definition: remnant.h:32
double get(Star *s, size_t ID) const
Definition: remnant.cpp:11
SevnLogging svlog
Definition: remnant.h:28
Staremnant(_UNUSED Star *s, double Mremnant, double time)
Definition: remnant.h:26
double age(Star *s) const
Definition: remnant.cpp:37
double born_time
Definition: remnant.h:67
double InertiaSphere(Star *s) const
Definition: remnant.cpp:33
virtual double Bmag(_UNUSED Star *s) const =0
double get_Mremnant_at_born() const
Definition: remnant.h:33
virtual double Inertia(_UNUSED Star *s) const =0
virtual double Radius(_UNUSED Star *s) const =0
Lookup::Remnants get_remnant_type() const
Definition: remnant.h:51
Definition: remnant.h:342
double Bmag(_UNUSED Star *s) const override
Definition: remnant.h:367
double OmegaRem(_UNUSED Star *s) const override
Definition: remnant.h:365
double Xspin(_UNUSED Star *s) const override
Definition: remnant.h:368
double A_luminosity
Definition: remnant.h:371
double Inertia(_UNUSED Star *s) const override
Definition: remnant.h:366
void default_initialiser()
Definition: remnant.h:373
WDrem(Star *s, double Mremnant)
Definition: remnant.h:349
WDrem(_UNUSED Star *s, double Mremnant, double time)
Definition: remnant.h:346
Definition: property.h:1973
Definition: remnant.h:439
double Luminosity(_UNUSED Star *s) const override
Definition: remnant.h:452
double Inertia(_UNUSED Star *s) const override
Definition: remnant.h:454
double radius
Definition: remnant.h:464
void initialise(Star *s)
Definition: remnant.cpp:268
double Bmag(_UNUSED Star *s) const override
Definition: remnant.h:455
double luminosity
Definition: remnant.h:463
double Radius(_UNUSED Star *s) const override
Definition: remnant.h:451
double Xspin(_UNUSED Star *s) const override
Definition: remnant.h:456
double OmegaRem(_UNUSED Star *s) const override
Definition: remnant.h:453
Zombierem(Star *s, double Mremnant)
Definition: remnant.h:447
Zombierem(Star *s, double Mremnant, double time)
Definition: remnant.h:443
Definition: sevnlog.h:43
void critical(std::string errstate, const char *file_input=nullptr, int line_input=-1) const
Definition: sevnlog.cpp:85
Definition: errhand.h:167
Remnants
NOTICE, the order is important (mass ordered): WD, NS, BH.
Definition: lookup_and_phases.h:78
@ COWD
Definition: lookup_and_phases.h:83
@ HeWD
Definition: lookup_and_phases.h:82
@ ONeWD
Definition: lookup_and_phases.h:84
@ NS_ECSN
Definition: lookup_and_phases.h:85
const std::string n2s(T val, const char *file_input, const int line_input, const unsigned int precision=6)
Definition: utilities.h:144
constexpr double km_to_RSun
Definition: utilities.h:74
std::mt19937_64 mtrand
Definition: utilities.cpp:9