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

cache the initial XHc

parent 7ba85366
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ void MINT_init_store(struct store_t * store)
store->MINT_tables[i] = NULL;
store->MINT_data_available[i] = NULL;
store->MINT_data_map[i] = NULL;
store->MINT_initial_coordinate[i] = -1.0;
}
store->MINT_loaded = FALSE;
}
......
......@@ -4,40 +4,49 @@ No_empty_translation_unit_warning;
#ifdef MINT
#include "MINT.h"
double MINT_initial_XHc(struct stardata_t * const stardata)
{
/*
* Determine the initial central hydrogen abundance
* in the MINT models
*/
/*
const double MINT_offset = 0.7 - 0.6985;
const double Z = Max(0.0,
0.760 - 3.0 * stardata->common.metallicity - MINT_offset);
return Z;
*/
if(stardata->store->MINT_initial_coordinate[MINT_TABLE_MS] < -TINY)
{
const size_t nperline =
stardata->store->MINT_tables[MINT_TABLE_MS]->ndata +
stardata->store->MINT_tables[MINT_TABLE_MS]->nparam;
double * const pmin = stardata->store->MINT_tables[MINT_TABLE_MS]->data + MINT_MS_CENTRAL_HYDROGEN;
double * const pmax = pmin + nperline * (1 + stardata->store->MINT_tables[MINT_TABLE_MS]->nlines);
int i = 1; // XHC column
const int nperline =
stardata->store->MINT_tables[MINT_TABLE_MS]->ndata +
stardata->store->MINT_tables[MINT_TABLE_MS]->nparam;
/*
* While the abundance is increasing, keep looping through
* lines of data. XHc will increase, but then when you
* get to the next star (or the end of the table) it will decrease.
*
* The pointer p points to the hydrogen abundance at each line.
* You should increment this by nperline.
*
* Note that pmax is the last value +1 line because p<pmax (not <=).
*/
double * p = pmin;
double prev_XHC0 = *p;
while(p < pmax && *p >= prev_XHC0)
{
prev_XHC0 = *p;
p += nperline;
}
double * p = stardata->store->MINT_tables[MINT_TABLE_MS]->data + i;
double * const pmin = p;
double * const pmax = p + nperline * stardata->store->MINT_tables[MINT_TABLE_MS]->nlines;
/* we've overshot */
p -= nperline;
const double XHC0 = *p; /* first value */
/* make sure we haven't wrapped back around the first value */
p = Max(p, pmin);
/*
* While the abundance is increasing, keep looping through
* lines of data. When it
*/
while(p < pmax && *p >= XHC0)
{
p += nperline;
Dprint("Initial hydrogen abundance %g\n",*p);
stardata->store->MINT_initial_coordinate[MINT_TABLE_MS] = *p;
}
p = Max(p - nperline, pmin);
return *p;
/* hence return the central hydrogen */
return stardata->store->MINT_initial_coordinate[MINT_TABLE_MS];
}
#endif //MINT
......@@ -363,6 +363,7 @@ struct store_t {
struct mint_header_t * MINT_headers[MINT_TABLE_NUMBER];
unsigned int * MINT_data_map[MINT_TABLE_NUMBER];
unsigned int MINT_tables_nscalars[MINT_TABLE_NUMBER];
Abundance MINT_initial_coordinate[MINT_TABLE_NUMBER];
#endif//MINT
int * mint_generic_map[NUMBER_OF_STELLAR_TYPES];
......
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