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

more attempts to clean up timesteps: now check the minimum timestep by...

more attempts to clean up timesteps: now check the minimum timestep by default, and have separate macros for when we don't want to

also fixed bug where nucsyn checkfuncs weren't wrapper with NUCSYN
parent 8e9846dc
No related branches found
No related tags found
No related merge requests found
#include "../binary_c.h" #include "../binary_c.h"
No_empty_translation_unit_warning; No_empty_translation_unit_warning;
#ifdef NUCSYN
Boolean nucsyn_helium_checkfunction(struct stardata_t * const stardata MAYBE_UNUSED, Boolean nucsyn_helium_checkfunction(struct stardata_t * const stardata MAYBE_UNUSED,
double * const N, double * const N,
const double temperature, const double temperature,
...@@ -13,3 +14,4 @@ Boolean nucsyn_helium_checkfunction(struct stardata_t * const stardata MAYBE_UNU ...@@ -13,3 +14,4 @@ Boolean nucsyn_helium_checkfunction(struct stardata_t * const stardata MAYBE_UNU
*/ */
return (N[XHe4]>TINY && temperature >= 0.8e8) ? TRUE : FALSE; return (N[XHe4]>TINY && temperature >= 0.8e8) ? TRUE : FALSE;
} }
#endif//NUCSYN
#include "../binary_c.h" #include "../binary_c.h"
No_empty_translation_unit_warning; No_empty_translation_unit_warning;
#ifdef NUCSYN
Boolean nucsyn_hydrogen_pp_checkfunction(struct stardata_t * const stardata MAYBE_UNUSED, Boolean nucsyn_hydrogen_pp_checkfunction(struct stardata_t * const stardata MAYBE_UNUSED,
double * const N, double * const N,
const double temperature, const double temperature,
...@@ -55,3 +57,5 @@ Boolean nucsyn_hydrogen_NeNaMgAl_checkfunction(struct stardata_t * const stardat ...@@ -55,3 +57,5 @@ Boolean nucsyn_hydrogen_NeNaMgAl_checkfunction(struct stardata_t * const stardat
N[XAl26]>TINY) N[XAl26]>TINY)
&& temperature >= 1e6) ? TRUE : FALSE; && temperature >= 1e6) ? TRUE : FALSE;
} }
#endif//NUCSYN
...@@ -6,25 +6,29 @@ No_empty_translation_unit_warning; ...@@ -6,25 +6,29 @@ No_empty_translation_unit_warning;
void nonstellar_timestep(struct stardata_t * const stardata, void nonstellar_timestep(struct stardata_t * const stardata,
double * const dtm) double * const dtm)
{ {
Foreach_star(star) /*
{ * Timesteps that don't depend on the properties
timestep_fixed_timesteps(stardata, * of the stars.
star, */
dtm);
}
/*
* Fixed timesteps: associate these with star 0
* which will always exist
*/
timestep_fixed_timesteps(stardata,
&stardata->star[0],
dtm);
/* /*
* Hard wired minimum : do not apply * Hard wired minimum : do not apply
* if the timestep is limited by a fixed timestep * if the timestep is limited by a fixed timestep
*/ */
Foreach_star(star) if(stardata->model.fixed_timestep_triggered == FALSE &&
stardata->star[0].dtlimiter != DT_LIMIT_FIXED_TIMESTEP)
{ {
if(stardata->model.fixed_timestep_triggered == FALSE && *dtm = Max(*dtm,
star->dtlimiter != DT_LIMIT_FIXED_TIMESTEP) MINIMUM_STELLAR_TIMESTEP);
{
*dtm = Max(*dtm,
MINIMUM_STELLAR_TIMESTEP);
}
} }
} }
...@@ -131,11 +131,11 @@ void stellar_timestep(Timestep_prototype_args) ...@@ -131,11 +131,11 @@ void stellar_timestep(Timestep_prototype_args)
} }
} }
nonstellar_timestep(stardata,dt);
timestep_limits(Timestep_call_args); timestep_limits(Timestep_call_args);
timestep_logging(Timestep_call_args); timestep_logging(Timestep_call_args);
timestep_modulation(Timestep_call_args); timestep_modulation(Timestep_call_args);
timestep_hard_limits(Timestep_call_args); timestep_hard_limits(Timestep_call_args);
//nonstellar_timestep(stardata,dt);
star->stellar_timestep = *dt; star->stellar_timestep = *dt;
......
...@@ -117,36 +117,70 @@ enum { FIXED_TIMESTEPS_LIST }; ...@@ -117,36 +117,70 @@ enum { FIXED_TIMESTEPS_LIST };
* a new logging variable. * a new logging variable.
*/ */
#define Set_timestep(DT,TO,IN,WHY) \ #define Set_timestep(DT,TO,IN,WHY) \
{ \ { \
(DT)=(TO); \ (DT)=Max(stardata->preferences->minimum_timestep, \
Dprint("Set timestep to %g why %d\n", \ (TO)); \
(TO), \ Dprint("Set timestep to %g why %d\n", \
(WHY)); \ (TO), \
if(WHY!=DT_LIMIT_MAXIMUM_TIMESTEP && \ (WHY)); \
WHY!=DT_LIMIT_MINIMUM_TIMESTEP) \ if(WHY!=DT_LIMIT_MAXIMUM_TIMESTEP && \
{ \ WHY!=DT_LIMIT_MINIMUM_TIMESTEP) \
(IN)->dtlimiter=(WHY); \ { \
} \ (IN)->dtlimiter=(WHY); \
} \
} }
#define Limit_timestep(DT,TO,IN,WHY) \ #define Set_timestep_no_minimum(DT,TO,IN,WHY) \
__extension__ \ { \
({ \ (DT)=(TO); \
Boolean _limited; \ Dprint("Set timestep to %g why %d\n", \
if((DT)>(TO)) \ (TO), \
{ \ (WHY)); \
Dprint("Limit timestep to %g why %d\n", \ if(WHY!=DT_LIMIT_MAXIMUM_TIMESTEP && \
(TO), \ WHY!=DT_LIMIT_MINIMUM_TIMESTEP) \
(WHY)); \ { \
Set_timestep((DT),(TO),(IN),(WHY)); \ (IN)->dtlimiter=(WHY); \
_limited = TRUE; \ } \
} \ }
else \
{ \ #define Limit_timestep(DT,TO,IN,WHY) \
_limited = FALSE; \ __extension__ \
} \ ({ \
_limited; \ Boolean _limited; \
if((DT)>Max(stardata->preferences->minimum_timestep, \
(TO))) \
{ \
Dprint("Limit timestep to %g why %d\n", \
(TO), \
(WHY)); \
Set_timestep((DT),(TO),(IN),(WHY)); \
_limited = TRUE; \
} \
else \
{ \
_limited = FALSE; \
} \
_limited; \
})
#define Limit_timestep_no_minimum(DT,TO,IN,WHY) \
__extension__ \
({ \
Boolean _limited; \
if((DT)>(TO)) \
{ \
Dprint("Limit timestep to %g why %d\n", \
(TO), \
(WHY)); \
Set_timestep_no_minimum((DT),(TO),(IN),(WHY)); \
_limited = TRUE; \
} \
else \
{ \
_limited = FALSE; \
} \
_limited; \
}) })
#define Floor_timestep(DT,TO,IN,WHY) \ #define Floor_timestep(DT,TO,IN,WHY) \
......
...@@ -46,10 +46,14 @@ void timestep_fixed_timesteps(struct stardata_t * const stardata, ...@@ -46,10 +46,14 @@ void timestep_fixed_timesteps(struct stardata_t * const stardata,
log10(stardata->model.time + dtlim))) log10(stardata->model.time + dtlim)))
); );
Limit_timestep(*dtm, /*
dtlim, * Limit the timestep, but do not impose
star, * the stardata->preferences->minimum_timestep
DT_LIMIT_FIXED_TIMESTEP); */
Limit_timestep_no_minimum(*dtm,
dtlim,
star,
DT_LIMIT_FIXED_TIMESTEP);
} }
} }
} }
......
...@@ -39,7 +39,7 @@ void timestep_hard_limits(Timestep_prototype_args) ...@@ -39,7 +39,7 @@ void timestep_hard_limits(Timestep_prototype_args)
/* /*
* If there has been an event, perhaps limit the next timestep? * If there has been an event, perhaps limit the next timestep?
*/ */
if(0 && stardata->common.n_events > 0) if(0&&stardata->common.n_events > 0)
{ {
Limit_timestep(*dt, Limit_timestep(*dt,
stardata->preferences->minimum_timestep, stardata->preferences->minimum_timestep,
......
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