Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Star mass ramp #68

Merged
merged 16 commits into from Jun 11, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

first commit for evolving stellar mass ramp

  • Loading branch information...
bwoshea committed Apr 23, 2019
commit ba6a6cb2c75458970251a9228d45229cde77644e
@@ -128,6 +128,8 @@ int MagneticFieldResetter(LevelHierarchyEntry *LevelArray[], int ThisLevel,
void PrintMemoryUsage(char *str);
int SetEvolveRefineRegion(FLOAT time);

int SetStellarMassThreshold(FLOAT time);

#ifdef MEM_TRACE
Eint64 mused(void);
#endif
@@ -463,6 +465,12 @@ int EvolveHierarchy(HierarchyEntry &TopGrid, TopGridData &MetaData,
ENZO_FAIL("Error in SetEvolveRefineRegion.");
}

/* If required, set evolving stellar mass threshold */
if (StarMakerMinimumMassRamp > 0) {
if (SetStellarMassThreshold(MetaData.Time) == FAIL)
ENZO_FAIL("Error in SetStellarMassThreshold.");
}

/* Evolve the stochastic forcing spectrum and add
* the force to the acceleration fields */
if (DrivenFlowProfile)
@@ -792,6 +792,7 @@ OBJS_CONFIG_LIB = \
SetDefaultGlobalValues.o \
SetLevelTimeStep.o \
SetEvolveRefineRegion.o \
SetSetStellarMassThreshold.o \
sgi_st1_fft64.o \
ShearingBoxInitialize.o \
ShearingBox2DInitialize.o \
@@ -890,11 +891,6 @@ OBJS_CONFIG_LIB = \
uuid/unpack.o \
uuid/unparse.o \
uuid/uuid_time.o \
libconfig/grammar.o \
libconfig/libconfig.o \
libconfig/scanctx.o \
libconfig/scanner.o \
libconfig/strbuf.o \
wall_clock.o \
WavePoolInitialize.o \
wrapper1d.o \
@@ -1068,6 +1068,17 @@ int ReadParameterFile(FILE *fptr, TopGridData &MetaData, float *Initialdt)
ret += sscanf(line, "H2StarMakerColdGasTemperature = %"FSYM,
&H2StarMakerColdGasTemperature);

ret += sscanf(line, "StarMakerMinimumMassRamp = %"ISYM,
&StarMakerMinimumMassRamp);
ret += sscanf(line, "StarMakerMinimumMassRampStartTime = %"FSYM,
&StarMakerMinimumMassRampStartTime);
ret += sscanf(line, "StarMakerMinimumMassRampStartMass = %"FSYM,
&StarMakerMinimumMassRampStartMass);
ret += sscanf(line, "StarMakerMinimumMassRampEndTime = %"FSYM,
&StarMakerMinimumMassRampEndTime);
ret += sscanf(line, "StarMakerMinimumMassRampEndMass = %"FSYM,
&StarMakerMinimumMassRampEndMass);

/* Read Movie Dump parameters */

ret += sscanf(line, "MovieSkipTimestep = %"ISYM, &MovieSkipTimestep);
@@ -2083,6 +2094,19 @@ int ReadParameterFile(FILE *fptr, TopGridData &MetaData, float *Initialdt)

CheckShearingBoundaryConsistency(MetaData);

/* Check that all of the parameters are set for minimum mass ramp*/
if(StarMakerMinimumMassRamp > 0){
if(StarMakerMinimumMassRampStartTime == FLOAT_UNDEFINED ||
StarMakerMinimumMassRampStartMass == FLOAT_UNDEFINED ||
StarMakerMinimumMassRampEndTime == FLOAT_UNDEFINED ||
StarMakerMinimumMassRampEndMass == FLOAT_UNDEFINED){
fprintf("You're using StarMakerMinimumMassRamp but need to set ALL of your start and end times and masses!\n");
my_exit(EXIT_FAILURE);
}
} // if(StarMakerMinimumMassRamp > 0)



return SUCCESS;
#endif /* ndef CONFIG_USE_LIBCONFIG */
}
@@ -732,6 +732,12 @@ int SetDefaultGlobalValues(TopGridData &MetaData)
H2StarMakerH2FloorInColdGas = 0.0;
H2StarMakerColdGasTemperature = 1e4;

StarMakerMinimumMassRamp = 0;
StarMakerMinimumMassRampStartTime = FLOAT_UNDEFINED;
StarMakerMinimumMassRampStartMass = FLOAT_UNDEFINED;
StarMakerMinimumMassRampEndTime = FLOAT_UNDEFINED;
StarMakerMinimumMassRampEndMass = FLOAT_UNDEFINED;

NumberOfParticleAttributes = INT_UNDEFINED;
AddParticleAttributes = FALSE;
LastSupernovaTime = FLOAT_UNDEFINED;
@@ -0,0 +1,119 @@
/*------------------------------------------------------------------------
SET EVOLVING STELLAR MASS THRESHOLD
By Brian O'Shea
History:
23 April 2019 : BWO -- Created
Note:
StarMakerMinimumMassRamp = 0 is off
StarMakerMinimumMassRamp = 1 is linear evolution of mass in time
StarMakerMinimumMassRamp = 2 is linear evolution of mass in redshift
StarMakerMinimumMassRamp = 3 is exponential evolution of mass in time
StarMakerMinimumMassRamp = 4 is exponential evolution of mass in redshift
If StarMakerMinimumMassRamp > 0, all values of the ramp parameters are set in
ReadParameterFile.C and tests are made to ensure that they're not the standard
values!
------------------------------------------------------------------------*/

#include <stdlib.h>
#include <stdio.h>
#include "preincludes.h"
#include "macros_and_parameters.h"
#include "typedefs.h"
#include "global_data.h"
#include "CosmologyParameters.h"

void my_exit(int status);

int CosmologyComputeExpansionFactor(FLOAT time, FLOAT *a, FLOAT *dadt);

int SetStellarMassThreshold(FLOAT time)
{

int timestep, i;
FLOAT a, dadt, redshift;
float early_mass, late_mass, current_mass;

/* Return if not used */
if (StarMakerMinimumMassRamp == 0)
return SUCCESS;

/* If TimeType is redshift, calculate redshift */

if (ComovingCoordinates) {
CosmologyComputeExpansionFactor(time, &a, &dadt);
redshift = (1 + InitialRedshift)/a - 1;
}

if(StarMakerMinimumMassRamp == 1 || StarMakerMinimumMassRamp == 3){ // interpolation in time

/* set early and late masses in linear or log */
if(StarMakerMinimumMassRamp == 1){ // mass evolution linear in time
early_mass = StarMakerMinimumMassRampStartMass;
late_mass = StarMakerMinimumMassRampEndMass;
} else { // mass evolution exponential in time
early_mass = log10(StarMakerMinimumMassRampStartMass);
late_mass = log10(StarMakerMinimumMassRampEndMass);
}

/* set current stellar minimum mass threshold */
if(time < StarMakerMinimumMassRampStartTime){
current_mass = early_mass;
} else if (time > StarMakerMinimumMassRampEndTime){
current_mass = late_mass;
} else {
current_mass = early_mass + (time - StarMakerMinimumMassRampStartTime)
* (late_mass-early_mass)/(StarMakerMinimumMassRampEndTime-StarMakerMinimumMassRampStartTime);
}

/* set StarMakerMinimumMass correctly */
if(StarMakerMinimumMassRamp == 1){
StarMakerMinimumMass = current_mass;
} else {
StarMakerMinimumMass = POW(10.0,current_mass);
}

} else if(StarMakerMinimumMassRamp == 2 || StarMakerMinimumMassRamp == 4){ // interpolation in redshift

/* set early and late masses in linear or log */
if(StarMakerMinimumMassRamp == 2){ // mass evolution linear in redshift
early_mass = StarMakerMinimumMassRampStartMass;
late_mass = StarMakerMinimumMassRampEndMass;
} else { // mass evolution exponential in time
early_mass = log10(StarMakerMinimumMassRampStartMass);
late_mass = log10(StarMakerMinimumMassRampEndMass);
}

/* set current stellar minimum mass threshold */
if(redshift > StarMakerMinimumMassRampStartTime){
current_mass = early_mass;
} else if (redshift < StarMakerMinimumMassRampEndTime){
current_mass = late_mass;
} else {
current_mass = early_mass + (redshift - StarMakerMinimumMassRampStartTime)
* (late_mass-early_mass)/(StarMakerMinimumMassRampEndTime-StarMakerMinimumMassRampStartTime);
}

/* set StarMakerMinimumMass correctly */
if(StarMakerMinimumMassRamp == 3){
StarMakerMinimumMass = current_mass;
} else {
StarMakerMinimumMass = POW(10.0,current_mass);
}

} else { // user has made a poor choice
fprintf(stderr,"SetStellarMassThreshold: StarMakerMinimumMassRamp improperly set!\n");
my_exit(EXIT_FAILURE);
}

if(debut){
printf("SetStellarMassThreshold: StarMakerMinimumMass set to %"FSYM" at time %"PSYM"\n",
StarMakerMinimumMass,time);
}

return SUCCESS;

}
@@ -136,4 +136,11 @@ SPEXTERN float minStarLifetime;
SPEXTERN FLOAT LastSupernovaTime;
SPEXTERN float *IMFData;

/* for star particle minimum mass ramp */
SPEXTERN int StarMakerMinimumMassRamp;
SPEXTERN float StarMakerMinimumMassRampStartTime;
SPEXTERN float StarMakerMinimumMassRampStartMass;
SPEXTERN float StarMakerMinimumMassRampEndTime;
SPEXTERN float StarMakerMinimumMassRampEndMass;

#endif
@@ -1070,6 +1070,12 @@ int WriteParameterFile(FILE *fptr, TopGridData &MetaData, char *name = NULL)
fprintf(fptr, "H2StarMakerH2FloorInColdGas = %"GSYM"\n\n", H2StarMakerH2FloorInColdGas);
fprintf(fptr, "H2StarMakerColdGasTemperature = %"GSYM"\n\n", H2StarMakerColdGasTemperature);

fprintf(fptr, "StarMakerMinimumMassRamp = %"ISYM"\n", StarMakerMinimumMassRamp);
fprintf(fptr, "StarMakerMinimumMassRampStartTime = %"GSYM"\n", StarMakerMinimumMassRampStartTime);
fprintf(fptr, "StarMakerMinimumMassRampStartMass = %"GSYM"\n", StarMakerMinimumMassRampStartMass);
fprintf(fptr, "StarMakerMinimumMassRampEndTime = %"GSYM"\n", StarMakerMinimumMassRampEndTime);
fprintf(fptr, "StarMakerMinimumMassRampEndMass = %"GSYM"\n", StarMakerMinimumMassRampEndMass);

/* Most Stanford additions: */

fprintf(fptr, "UseHydro = %"ISYM"\n", UseHydro);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.