Skip to content

Commit

Permalink
🐛 unused comparison operator in assigning Galaxy_Population
Browse files Browse the repository at this point in the history
  • Loading branch information
smutch committed Jan 23, 2024
1 parent ac16e5c commit e15c458
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/core/galaxies.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ galaxy_t* new_galaxy(int snapshot, unsigned long halo_ID)
gal->MvirCrit_MC = 0.0;
gal->MergerBurstMass = 0.0;
gal->MergerStartRadius = 0.0;

#if USE_MINI_HALOS
gal->StellarMass_II = 0.;
gal->StellarMass_III = 0.;
Expand All @@ -78,27 +78,29 @@ galaxy_t* new_galaxy(int snapshot, unsigned long halo_ID)
gal->Metal_Probability = 0.0;
gal->Metals_IGM = 0.0;
gal->Gas_IGM = 0.0;
gal->Metallicity_IGM = -50.0;
gal->Metallicity_IGM = -50.0;
gal->RmetalBubble = 0.0;
gal->PrefactorBubble = 0.0;
gal->TimeBubble = 0.0;
gal->AveBubble = 0.;
gal->MaxBubble = 0.;
gal->Flag_ExtMetEnr = 0;
gal->GalMetal_Probability = gsl_rng_uniform(run_globals.random_generator);

if (run_globals.params.Flag_IncludeMetalEvo == false) // If you don't have the external metal enrichment all galaxies will start as pristine (Pop.III forming)
gal-> Galaxy_Population == 3;
#else //If you are not computing PopIII , all the galaxies are PopII. Again you need to initialize the variable otherwise star_formation.c will fail!
gal->Galaxy_Population == 2;

if (run_globals.params.Flag_IncludeMetalEvo ==
false) // If you don't have the external metal enrichment all galaxies will start as pristine (Pop.III forming)
gal->Galaxy_Population = 3;

This comment has been minimized.

Copy link
@smutch

smutch Jan 23, 2024

Author Owner

@EMventura - I think this was a bug. Can you confirm?

This comment has been minimized.

Copy link
@EMventura

EMventura Jan 23, 2024

Collaborator

Mmmm it's not a bug because if we turn off the minihalo flag compiler we want to run meraxes as it was before the minihalos so assuming that all the halos are Pop. II (previously metal enriched)

This comment has been minimized.

Copy link
@smutch

smutch Jan 23, 2024

Author Owner

I mean the use of a comparison (==) operator instead of an assignment (=). 😃

This comment has been minimized.

Copy link
@smutch

smutch Jan 23, 2024

Author Owner

What you had with the comparison operator is a no-op I think. It doesn't do anything.

This comment has been minimized.

Copy link
@EMventura

EMventura Jan 23, 2024

Collaborator

Ah yeah of course! Sorry I misread that :)

#else // If you are not computing PopIII , all the galaxies are PopII. Again you need to initialize the variable
// otherwise star_formation.c will fail!
gal->Galaxy_Population = 2;

This comment has been minimized.

Copy link
@smutch

smutch Jan 23, 2024

Author Owner

@EMventura - ditto here...

This comment has been minimized.

Copy link
@EMventura

EMventura Jan 23, 2024

Collaborator

Same as above

#endif

for (int ii = 0; ii < 3; ii++) {
gal->Pos[ii] = (float)-99999.9;
gal->Vel[ii] = (float)-99999.9;
}

for (int ii = 0; ii < N_HISTORY_SNAPS; ii++){
for (int ii = 0; ii < N_HISTORY_SNAPS; ii++) {
gal->NewStars[ii] = 0.0;
#if USE_MINI_HALOS
gal->NewStars_II[ii] = 0.0;
Expand Down Expand Up @@ -183,13 +185,13 @@ void reset_galaxy_properties(galaxy_t* gal, int snapshot)
}

// roll over the baryonic history arrays
for (int ii = N_HISTORY_SNAPS - 1; ii > 0; ii--){
for (int ii = N_HISTORY_SNAPS - 1; ii > 0; ii--) {
gal->NewStars[ii] = gal->NewStars[ii - 1];
#if USE_MINI_HALOS
gal->NewStars_II[ii] = gal->NewStars_II[ii - 1];
gal->NewStars_III[ii] = gal->NewStars_III[ii - 1];
#endif
}
}

for (int ii = N_HISTORY_SNAPS - 1; ii > 0; ii--)
gal->NewMetals[ii] = gal->NewMetals[ii - 1];
Expand Down Expand Up @@ -349,4 +351,4 @@ void kill_galaxy(galaxy_t* gal, galaxy_t* prev_gal, int* NGal, int* kill_counter
free(gal);
*NGal = *NGal - 1;
*kill_counter = *kill_counter + 1;
}
}

0 comments on commit e15c458

Please sign in to comment.