From 4d25d4046c7c9aa74254382fb43942bf5c26f5fa Mon Sep 17 00:00:00 2001 From: MBradley1985 <2496844@student.swin.edu.au> Date: Wed, 19 Feb 2025 11:50:34 +1100 Subject: [PATCH] Fixing Makefile and ensuring first attempt works --- Makefile | 4 ++-- src/core_init.c | 8 ++++++++ src/model_misc.c | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1d40e487..8bcca884 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -#USE-MPI := yes # set this if you want to run in embarrassingly parallel (automatically set if the compiler (i.e., the CC variable) is set to `mpicc`) +USE-MPI := yes # set this if you want to run in embarrassingly parallel (automatically set if the compiler (i.e., the CC variable) is set to `mpicc`) USE-HDF5 := yes # set this if you want to read in hdf5 trees (requires hdf5 libraries) #MEM-CHECK = yes # Set this if you want to check sanitize pointers/memory addresses. Slowdown of ~2x is expected. @@ -28,7 +28,7 @@ LIBSRC := sage.c core_read_parameter_file.c core_init.c core_io_tree.c \ core_tree_utils.c model_infall.c model_cooling_heating.c model_starformation_and_feedback.c \ model_disk_instability.c model_reincorporation.c model_mergers.c model_misc.c \ io/read_tree_lhalo_binary.c io/read_tree_consistentrees_ascii.c io/ctrees_utils.c \ - io/save_gals_binary.c io/forest_utils.c io/buffered_io.c + io/save_gals_binary.c io/forest_utils.c io/buffered_io.c ./model_h2_formation.c \ LIBINCL := $(LIBSRC:.c=.h) LIBINCL += io/parse_ctrees.h diff --git a/src/core_init.c b/src/core_init.c index 8c61dd62..52f4980b 100644 --- a/src/core_init.c +++ b/src/core_init.c @@ -30,6 +30,14 @@ void init(struct params *run_params) #endif run_params->Age = mymalloc(ABSOLUTEMAXSNAPS*sizeof(run_params->Age[0])); + + // Initialize H2 fraction parameters with default values if not set + if(run_params->H2FractionFactor <= 0.0) { + run_params->H2FractionFactor = 1.0; // Default value from DarkSAGE + } + if(run_params->H2FractionExponent <= 0.0) { + run_params->H2FractionExponent = 0.92; // Default value from DarkSAGE + } set_units(run_params); diff --git a/src/model_misc.c b/src/model_misc.c index 7723ad22..dbdab335 100644 --- a/src/model_misc.c +++ b/src/model_misc.c @@ -7,6 +7,7 @@ #include "core_allvars.h" #include "model_misc.h" +#include "model_h2_formation.h" // Add this line void init_galaxy(const int p, const int halonr, int *galaxycounter, const struct halo_data *halos, struct GALAXY *galaxies, const struct params *run_params) @@ -44,6 +45,8 @@ void init_galaxy(const int p, const int halonr, int *galaxycounter, const struct galaxies[p].deltaMvir = 0.0; galaxies[p].ColdGas = 0.0; + galaxies[p].H2_gas = 0.0; // Initialize H2 gas + galaxies[p].HI_gas = 0.0; // Initialize HI gas galaxies[p].StellarMass = 0.0; galaxies[p].BulgeMass = 0.0; galaxies[p].HotGas = 0.0; @@ -51,6 +54,9 @@ void init_galaxy(const int p, const int halonr, int *galaxycounter, const struct galaxies[p].BlackHoleMass = 0.0; galaxies[p].ICS = 0.0; + // Initialize H2 fractions + init_gas_components(&galaxies[p]); + galaxies[p].MetalsColdGas = 0.0; galaxies[p].MetalsStellarMass = 0.0; galaxies[p].MetalsBulgeMass = 0.0;