From b09f4c82305bd96ee103616f3162a53ba6350771 Mon Sep 17 00:00:00 2001 From: lhausamm <loic_hausammann@hotmail.com> Date: Fri, 9 Mar 2018 09:26:43 +0100 Subject: [PATCH] Add over relaxation parameter --- examples/parameter_example.yml | 3 +++ src/cooling/grackle/cooling.h | 3 +-- src/cooling/grackle/cooling_io.h | 3 +++ src/cooling/grackle/cooling_struct.h | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index 7c81684432..ef5b44a0f4 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -189,6 +189,9 @@ GrackleCooling: ProvideSpecificHeatingRates: 0 # User provide specific heating rates SelfShieldingMethod: 0 # Grackle (<= 3) or Gear self shielding method OutputMode: 0 # Write in output corresponding primordial chemistry mode + MaxSteps: 10000 # (optional) Max number of step when computing the initial composition + ConvergenceLimit: 1e-2 # (optional) Convergence threshold (relative) for initial composition + Omega: 0.8 # (optional) Over relaxation coefficient for initial composition (< 1 avoid oscillation, > 1 speedup convergence) # Parameters related to chemistry models ----------------------------------------------- diff --git a/src/cooling/grackle/cooling.h b/src/cooling/grackle/cooling.h index 7104b9c9f4..0493b0a2b4 100644 --- a/src/cooling/grackle/cooling.h +++ b/src/cooling/grackle/cooling.h @@ -202,7 +202,6 @@ __attribute__((always_inline)) INLINE static void cooling_compute_equilibrium_fr /* a few constants */ const float limit = tmp_cooling.convergence_limit; const double dt = 0.01 * fabs(cooling_time(&tmp_cooling, p, xp)); - const float omega = 0.8; /* disable energy updates */ tmp_cooling.chemistry.with_radiative_cooling = 0; @@ -216,7 +215,7 @@ __attribute__((always_inline)) INLINE static void cooling_compute_equilibrium_fr /* compute cooling rate */ cooling_rate(NULL, NULL, &tmp_cooling, p, xp, dt); - cooling_over_relaxation(xp, &xp_1, omega); + cooling_over_relaxation(xp, &xp_1, cooling->omega); } while(!cooling_check_convergence(&xp_1, xp, limit) && step < tmp_cooling.max_step); diff --git a/src/cooling/grackle/cooling_io.h b/src/cooling/grackle/cooling_io.h index a6cbc65549..8457ee7d95 100644 --- a/src/cooling/grackle/cooling_io.h +++ b/src/cooling/grackle/cooling_io.h @@ -154,6 +154,9 @@ __attribute__((always_inline)) INLINE static void cooling_parse_arguments( cooling->convergence_limit = parser_get_opt_param_double(parameter_file, "GrackleCooling:ConvergenceLimit", 1e-2); + + cooling->convergence_limit = + parser_get_opt_param_double(parameter_file, "GrackleCooling:Omega", 0.8); } diff --git a/src/cooling/grackle/cooling_struct.h b/src/cooling/grackle/cooling_struct.h index f247b09a4b..b714690ce4 100644 --- a/src/cooling/grackle/cooling_struct.h +++ b/src/cooling/grackle/cooling_struct.h @@ -69,6 +69,9 @@ struct cooling_function_data { /* number of step max for first init */ int max_step; + + /* over relaxation parameter */ + float omega; }; /** -- GitLab