From 1aa9092e2bf599b627641a3e319c624491ab599d Mon Sep 17 00:00:00 2001 From: Oliver Zier <ozier@web.de> Date: Mon, 9 Nov 2020 20:49:33 +0100 Subject: [PATCH] Add new swtich for entropy in ICs --- Template-Config.sh | 1 + documentation/04_config-options.md | 7 ++++++- src/data/allvars.h | 1 - src/io/snap_io.cc | 9 ++++++--- src/main/init.cc | 12 ++++++------ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Template-Config.sh b/Template-Config.sh index d2f1be5..0a37a2e 100644 --- a/Template-Config.sh +++ b/Template-Config.sh @@ -109,6 +109,7 @@ DOUBLEPRECISION=1 # if activated and set to 1, use d #---------------------------------------- Output/Input options +INITIAL_CONDITIONS_CONTAIN_ENTROPY #OUTPUT_VELOCITY_GRADIENT # output velocity gradients #OUTPUT_PRESSURE # output gas pressure #OUTPUT_ENTROPY # output gas entropy diff --git a/documentation/04_config-options.md b/documentation/04_config-options.md index 8e42f0a..243fe57 100644 --- a/documentation/04_config-options.md +++ b/documentation/04_config-options.md @@ -598,6 +598,12 @@ formulation. This is only useful if `PRESSURE_ENTROPY_SPH` is used. ------- +**INITIAL_CONDITIONS_CONTAIN_ENTROPY** + +The intial conditions file contains entropy instead of the thermal energy. + +------ + **GAMMA** = 1.4 Sets the equation of state index in the ideal gas law that is normally @@ -871,7 +877,6 @@ you need to increase `NUMBER_OF_MPI_LISTENERS_PER_NODE`. Output/Input options {#io} ==================== - **POWERSPEC_ON_OUTPUT** Creates a power spectrum measurement for every output time, i.e. for diff --git a/src/data/allvars.h b/src/data/allvars.h index 435be92..65fbc24 100644 --- a/src/data/allvars.h +++ b/src/data/allvars.h @@ -97,7 +97,6 @@ struct global_data_all_processes : public parameters double InitGasU; /**< the same, but converted to thermal energy per unit mass */ double MinEgySpec; /**< the minimum allowed temperature expressed as energy per unit mass */ - int FlagICsContainedEntropy; /* some force counters */ diff --git a/src/io/snap_io.cc b/src/io/snap_io.cc index cae63b0..be03088 100644 --- a/src/io/snap_io.cc +++ b/src/io/snap_io.cc @@ -415,11 +415,14 @@ void snap_io::read_ic(const char *fname) Sp->NumPart += add_numpart; #endif - All.FlagICsContainedEntropy = 0; + #ifdef GADGET2_HEADER - if(header.flag_entropy_instead_u) - All.FlagICsContainedEntropy = 1; +#ifndef INITIAL_CONDITIONS_CONTAIN_ENTROPY + if(header.flag_entropy_instead_u) Terminate("Initial condition file contains entropy, but INITIAL_CONDITIONS_CONTAIN_ENTROPY is not set\n"); +#else + if(! header.flag_entropy_instead_u)Terminate("Initial condition file contains uthermal, but INITIAL_CONDITIONS_CONTAIN_ENTROPY is set\n"); +#endif #endif TIMER_STOP(CPU_SNAPSHOT); diff --git a/src/main/init.cc b/src/main/init.cc index addf4ea..198f9fe 100644 --- a/src/main/init.cc +++ b/src/main/init.cc @@ -129,7 +129,6 @@ void sim::init(int RestartSnapNum) Mem.myfree(tmp); - All.FlagICsContainedEntropy = 0; int count = 0; for(int i = 0; i < Sp.NumPart; i++) @@ -477,15 +476,16 @@ void sim::init(int RestartSnapNum) * Once the density has been computed, we can convert to entropy. */ #ifdef PRESSURE_ENTROPY_SPH - if(All.FlagICsContainedEntropy == 0) +#ifndef INITIAL_CONDITIONS_CONTAIN_ENTROPY NgbTree.setup_entropy_to_invgamma(); +#endif #endif double mass = 0; for(int i = 0; i < Sp.NumGas; i++) { - if(All.FlagICsContainedEntropy == 0) - { +#ifndef INITIAL_CONDITIONS_CONTAIN_ENTROPY + if(ThisTask == 0 && i == 0) printf("INIT: Converting u -> entropy\n"); @@ -493,8 +493,8 @@ void sim::init(int RestartSnapNum) Sp.SphP[i].Entropy = GAMMA_MINUS1 * Sp.SphP[i].Entropy / pow(Sp.SphP[i].Density * All.cf_a3inv, GAMMA_MINUS1); #endif Sp.SphP[i].EntropyPred = Sp.SphP[i].Entropy; - } - + +#endif /* The predicted entropy values have been already set for all SPH formulation */ /* so it should be ok computing pressure and csound now */ Sp.SphP[i].set_thermodynamic_variables(); -- GitLab