Skip to content
Snippets Groups Projects
Commit 315585cf authored by Izzard, Robert Dr (Maths & Physics)'s avatar Izzard, Robert Dr (Maths & Physics)
Browse files

add function to check if stellar type is exceeded

parent 9a29607b
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ int MINT_call_BSE_stellar_structure(struct stardata_t * const stardata, ...@@ -11,6 +11,7 @@ int MINT_call_BSE_stellar_structure(struct stardata_t * const stardata,
/* /*
* Call BSE stellar structure routine from MINT * Call BSE stellar structure routine from MINT
*/ */
printf("call bse\n");
int ret = newstar->stellar_type; int ret = newstar->stellar_type;
if(oldstar != NULL) if(oldstar != NULL)
{ {
...@@ -32,6 +33,22 @@ int MINT_call_BSE_stellar_structure(struct stardata_t * const stardata, ...@@ -32,6 +33,22 @@ int MINT_call_BSE_stellar_structure(struct stardata_t * const stardata,
newstar->derivative[DERIVATIVE_STELLAR_CENTRAL_CARBON] = 0.0; newstar->derivative[DERIVATIVE_STELLAR_CENTRAL_CARBON] = 0.0;
} }
/*
* Testing: allocate arrays
*/
if(newstar->luminosities == NULL)
{
newstar->luminosities = Malloc(sizeof(double)*LUMS_ARRAY_SIZE);
}
if(newstar->timescales == NULL)
{
newstar->timescales = Malloc(sizeof(double)*TSCLS_ARRAY_SIZE);
}
if(newstar->GB == NULL)
{
newstar->GB = Malloc(sizeof(double)*GB_ARRAY_SIZE);
}
printf("MINT call BSE stellar structure %p \n", printf("MINT call BSE stellar structure %p \n",
(void*)newstar->luminosities); (void*)newstar->luminosities);
......
...@@ -38,7 +38,7 @@ int MINT_stellar_structure(struct stardata_t * const stardata, ...@@ -38,7 +38,7 @@ int MINT_stellar_structure(struct stardata_t * const stardata,
newstar); newstar);
} }
if(vb) // if(vb)
printf("MINT model %d (%d %d)\n", printf("MINT model %d (%d %d)\n",
stardata->model.model_number, stardata->model.model_number,
oldstar->stellar_type, oldstar->stellar_type,
...@@ -70,12 +70,13 @@ int MINT_stellar_structure(struct stardata_t * const stardata, ...@@ -70,12 +70,13 @@ int MINT_stellar_structure(struct stardata_t * const stardata,
#ifdef NUCSYN #ifdef NUCSYN
newstar->TAMS_core_mass = newstar->TAMS_core_mass =
MINT_has_shells(newstar) ? MINT_has_shells(newstar) ?
MINT_core(newstar,XHe4,0.9) : 0.0; MINT_core(newstar,XHe4,0.99) :
0.0;
#else #else
newstar->TAMS_core_mass = 0.0; newstar->TAMS_core_mass = 0.0;
#endif// NUCSYN #endif// NUCSYN
newstar->tm = newstar->age; newstar->tm = newstar->age;
Dprint("MS ended : L=%g R=%g Mc=%g tm=%g\n", printf("MS ended : L=%g R=%g Mc=%g tm=%g\n",
newstar->TAMS_luminosity, newstar->TAMS_luminosity,
newstar->TAMS_radius, newstar->TAMS_radius,
newstar->TAMS_core_mass, newstar->TAMS_core_mass,
...@@ -95,6 +96,7 @@ int MINT_stellar_structure(struct stardata_t * const stardata, ...@@ -95,6 +96,7 @@ int MINT_stellar_structure(struct stardata_t * const stardata,
} }
} }
int ret = newstar->stellar_type; int ret = newstar->stellar_type;
#undef X #undef X
#define X(STELLAR_TYPE,FUNCTION,CALL_BSE) FUNCTION, #define X(STELLAR_TYPE,FUNCTION,CALL_BSE) FUNCTION,
...@@ -117,11 +119,20 @@ int MINT_stellar_structure(struct stardata_t * const stardata, ...@@ -117,11 +119,20 @@ int MINT_stellar_structure(struct stardata_t * const stardata,
* Call BSE before MINT? * Call BSE before MINT?
*/ */
const unsigned int action = call_bse_action[newstar->stellar_type]; const unsigned int action = call_bse_action[newstar->stellar_type];
if(vb)printf("MINT t=%g st = %d action = %u %s\n", vb=1;
if(vb)printf("MINT star %d : t=%30.20e st = %d action = %u %s X=%g Y=%g\n",
newstar->starnum,
stardata->model.time, stardata->model.time,
newstar->stellar_type, newstar->stellar_type,
call_bse_action[newstar->stellar_type], call_bse_action[newstar->stellar_type],
call_bse_action_strings[action]); call_bse_action_strings[action],
newstar->mint->XHc,
newstar->mint->XHec
);
if(stellar_type_exceeded(stardata,newstar) == TRUE)
{
return ret;
}
if(action == MINT_CALL_BSE_BEFORE || if(action == MINT_CALL_BSE_BEFORE ||
action == MINT_CALL_BSE_BOTH) action == MINT_CALL_BSE_BOTH)
...@@ -130,6 +141,10 @@ int MINT_stellar_structure(struct stardata_t * const stardata, ...@@ -130,6 +141,10 @@ int MINT_stellar_structure(struct stardata_t * const stardata,
oldstar, oldstar,
newstar, newstar,
caller_id); caller_id);
if(stellar_type_exceeded(stardata,newstar) == TRUE)
{
return ret;
}
} }
/* /*
...@@ -141,11 +156,10 @@ int MINT_stellar_structure(struct stardata_t * const stardata, ...@@ -141,11 +156,10 @@ int MINT_stellar_structure(struct stardata_t * const stardata,
oldstar, oldstar,
newstar, newstar,
caller_id); caller_id);
} if(stellar_type_exceeded(stardata,newstar) == TRUE)
{
if(newstar->stellar_type > stardata->preferences->max_stellar_type[newstar->starnum]) return ret;
{ }
return ret;
} }
/* /*
...@@ -158,9 +172,14 @@ int MINT_stellar_structure(struct stardata_t * const stardata, ...@@ -158,9 +172,14 @@ int MINT_stellar_structure(struct stardata_t * const stardata,
oldstar, oldstar,
newstar, newstar,
caller_id); caller_id);
if(stellar_type_exceeded(stardata,newstar) == TRUE)
{
return ret;
}
} }
if(vb)printf("MINT_stellar_structure return %d (stellar types %d %d)\n", // if(vb)
printf("MINT_stellar_structure return %d (stellar types %d %d)\n",
ret, ret,
oldstar->stellar_type, oldstar->stellar_type,
newstar->stellar_type); newstar->stellar_type);
......
...@@ -14,13 +14,7 @@ Boolean Pure_function check_for_evolution_stop(struct stardata_t * const stardat ...@@ -14,13 +14,7 @@ Boolean Pure_function check_for_evolution_stop(struct stardata_t * const stardat
* Check stellar type does not exceed the max stellar type * Check stellar type does not exceed the max stellar type
* but skip if MASSLESS_REMNANT and the max_stellar_type is negative * but skip if MASSLESS_REMNANT and the max_stellar_type is negative
*/ */
const Stellar_type max = if(stellar_type_exceeded(stardata,star) == TRUE)
stardata->preferences->max_stellar_type[star->starnum];
if((star->stellar_type != MASSLESS_REMNANT ||
max > 0)
&&
star->stellar_type > abs(max))
{ {
return TRUE; return TRUE;
} }
......
...@@ -106,5 +106,6 @@ int update_system_by_dt(struct stardata_t * RESTRICT const stardata, ...@@ -106,5 +106,6 @@ int update_system_by_dt(struct stardata_t * RESTRICT const stardata,
const Boolean update_time); const Boolean update_time);
void evolution_detect_stellar_type_change(struct stardata_t * const stardata); void evolution_detect_stellar_type_change(struct stardata_t * const stardata);
Boolean stellar_type_exceeded(struct stardata_t * const stardata,
struct star_t * const star);
#endif /* EVOLUTION_PROTOTYPES_H */ #endif /* EVOLUTION_PROTOTYPES_H */
#include "../binary_c.h"
No_empty_translation_unit_warning;
Boolean stellar_type_exceeded(struct stardata_t * const stardata,
struct star_t * const star)
{
/*
* return TRUE if the stellar type exceeds the
* max_stellar_type (set as an argument)
*/
const Stellar_type max =
stardata->preferences->max_stellar_type[star->starnum];
if((star->stellar_type != MASSLESS_REMNANT ||
max > 0)
&&
star->stellar_type > abs(max))
{
return TRUE;
}
else
{
return FALSE;
}
}
...@@ -21,7 +21,7 @@ int stellar_structure_BSE(struct stardata_t * const stardata, ...@@ -21,7 +21,7 @@ int stellar_structure_BSE(struct stardata_t * const stardata,
double * const luminosities, double * const luminosities,
double * const GB) double * const GB)
{ {
Dprint("stellar structure called from %s with age %g (star %d, type %d, timescales %p, luminosities %p, GB %p)\n", printf("stellar structure called from %s with age %g (star %d, type %d, timescales %p, luminosities %p, GB %p)\n",
Stellar_structure_caller_string(caller_id), Stellar_structure_caller_string(caller_id),
star->age, star->age,
star->starnum, star->starnum,
......
...@@ -20,7 +20,7 @@ Stellar_type stellar_structure_HG(struct star_t * RESTRICT const newstar, ...@@ -20,7 +20,7 @@ Stellar_type stellar_structure_HG(struct star_t * RESTRICT const newstar,
double rho,tau; double rho,tau;
const double thg = newstar->timescales[T_BGB] - newstar->tm; const double thg = newstar->timescales[T_BGB] - newstar->tm;
double mcbgbf; double mcbgbf;
printf("SHG\n");
#ifdef MINT #ifdef MINT
if(stardata->preferences->stellar_structure_algorithm == if(stardata->preferences->stellar_structure_algorithm ==
STELLAR_STRUCTURE_ALGORITHM_MINT) STELLAR_STRUCTURE_ALGORITHM_MINT)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment