diff --git a/examples/CoolingBox/coolingBox.yml b/examples/CoolingBox/coolingBox.yml index 61713f92ed2f37759570dfcefabd8c69ab0907eb..e13de6095066836853d9e9068330938f6260f38e 100644 --- a/examples/CoolingBox/coolingBox.yml +++ b/examples/CoolingBox/coolingBox.yml @@ -15,7 +15,7 @@ TimeIntegration: # Parameters governing the snapshots Snapshots: - basename: uniformBox # Common part of the name of output files + basename: coolingBox # Common part of the name of output files time_first: 0. # Time of the first output (in internal units) delta_time: 1.0e-1 # Time difference between consecutive outputs (in internal units) @@ -32,20 +32,13 @@ SPH: # Parameters related to the initial conditions InitialConditions: - file_name: ./uniformBox.hdf5 # The file to read + file_name: ./coolingBox.hdf5 # The file to read - - # External potential parameters -PointMass: - position_x: 50. # location of external point mass in internal units - position_y: 50. - position_z: 50. - mass: 1e10 # mass of external point mass in internal units - - # Cooling parameters (Creasey cooling) (always in cgs) -Cooling: - lambda: 0.0 - minimum_temperature: 1.0e4 - mean_molecular_weight: 0.59 - hydrogen_mass_abundance: 0.75 - cooling_tstep_mult: 1.0 \ No newline at end of file +# Dimensionless pre-factor for the time-step condition +LambdaCooling: + lambda: 0.0 # Cooling rate (in cgs units) + minimum_temperature: 1.0e4 # Minimal temperature (Kelvin) + mean_molecular_weight: 0.59 # Mean molecular weight + hydrogen_mass_abundance: 0.75 # Hydrogen mass abundance (dimensionless) + cooling_tstep_mult: 1.0 # Dimensionless pre-factor for the time-step condition + diff --git a/examples/CoolingBox/energy_plot.py b/examples/CoolingBox/energy_plot.py index 0533528d8aabfbf11e18da95911a5627db820b04..28cf9ab64decb5b56e98118a407221fac2bd4f16 100644 --- a/examples/CoolingBox/energy_plot.py +++ b/examples/CoolingBox/energy_plot.py @@ -4,7 +4,7 @@ import h5py as h5 import sys stats_filename = "./energy.txt" -snap_filename = "uniformBox_000.hdf5" +snap_filename = "coolingBox_000.hdf5" #plot_dir = "./" #some constants in cgs units @@ -24,10 +24,10 @@ unit_mass = units.attrs["Unit mass in cgs (U_M)"] unit_length = units.attrs["Unit length in cgs (U_L)"] unit_time = units.attrs["Unit time in cgs (U_t)"] parameters = f["Parameters"] -cooling_lambda = float(parameters.attrs["Cooling:lambda"]) -min_T = float(parameters.attrs["Cooling:minimum_temperature"]) -mu = float(parameters.attrs["Cooling:mean_molecular_weight"]) -X_H = float(parameters.attrs["Cooling:hydrogen_mass_abundance"]) +cooling_lambda = float(parameters.attrs["LambdaCooling:lambda"]) +min_T = float(parameters.attrs["LambdaCooling:minimum_temperature"]) +mu = float(parameters.attrs["LambdaCooling:mean_molecular_weight"]) +X_H = float(parameters.attrs["LambdaCooling:hydrogen_mass_abundance"]) #get number of particles header = f["Header"] diff --git a/examples/CoolingBox/makeIC.py b/examples/CoolingBox/makeIC.py index e1bfc28f063ff1d34dbdcbadce33df468ccce4ce..f35c9243d4fa71f872fd27520de14a23073c4b9d 100644 --- a/examples/CoolingBox/makeIC.py +++ b/examples/CoolingBox/makeIC.py @@ -33,7 +33,7 @@ rho = 3.2e3 # Density in code units (0.01 hydrogen atoms per cm^3) P = 4.5e6 # Pressure in code units (at 10^5K) gamma = 5./3. # Gas adiabatic index eta = 1.2349 # 48 ngbs with cubic spline kernel -fileName = "uniformBox.hdf5" +fileName = "coolingBox.hdf5" #--------------------------------------------------- numPart = L**3 diff --git a/examples/CoolingBox/run.sh b/examples/CoolingBox/run.sh index ea563fa43b94195b3296906d96f612c4feff63e0..18ece8fd3ece480ce8e4a9159b184175c04c6ff4 100755 --- a/examples/CoolingBox/run.sh +++ b/examples/CoolingBox/run.sh @@ -8,5 +8,3 @@ python makeIC.py 10 ../swift -s -t 1 coolingBox.yml -C python energy_plot.py 0 - -python add_energy_column diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index b1e106b94d4b42e51836ce1c36d733062746be6d..3f9ff75da3526d4a5fa2a117f0f8e20490c94d3c 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -63,7 +63,7 @@ DomainDecomposition: initial_grid_z: 10 repartition_type: b # (Optional) The re-decomposition strategy ("n", "b", "v", "e" or "x"). -# Parameters related to external potentials +# Parameters related to external potentials -------------------------------------------- # Point mass external potentials PointMass: @@ -73,6 +73,7 @@ PointMass: mass: 1e10 # mass of external point mass (internal units) timestep_mult: 0.03 # Dimensionless pre-factor for the time-step condition +# Isothermal potential parameters IsothermalPotential: position_x: 100. # Location of centre of isothermal potential (internal units) position_y: 100. @@ -80,9 +81,27 @@ IsothermalPotential: vrot: 200. # Rotation speed of isothermal potential (internal units) timestep_mult: 0.03 # Dimensionless pre-factor for the time-step condition +# Disk-patch potential parameters Disk-PatchPotential: surface_density: 10. # Surface density of the disk (internal units) scale_height: 100. # Scale height of the disk (internal units) z_disk: 200. # Disk height (internal units) timestep_mult: 0.03 # Dimensionless pre-factor for the time-step condition growth_time: 5. # (Optional) Time for the disk to grow to its final size (multiple of the dynamical time) + +# Parameters related to cooling function ---------------------------------------------- + +# Constant du/dt cooling function +ConstCooling: + cooling_rate: 1. # Cooling rate (du/dt) (internal units) + min_energy: 1. # Minimal internal energy per unit mass (internal units) + cooling_tstep_mult: 1. # Dimensionless pre-factor for the time-step condition + +# Constant lambda cooling function +LambdaCooling: + lambda: 2.0 # Cooling rate (in cgs units) + minimum_temperature: 1.0e4 # Minimal temperature (Kelvin) + mean_molecular_weight: 0.59 # Mean molecular weight + hydrogen_mass_abundance: 0.75 # Hydrogen mass abundance (dimensionless) + cooling_tstep_mult: 1.0 # Dimensionless pre-factor for the time-step condition + diff --git a/src/cooling/const_du/cooling.h b/src/cooling/const_du/cooling.h index 382352a31217c343810c66467747f86bc2cab84b..2c4f66d9385086eb13e0a029f9f1d972fd4d795e 100644 --- a/src/cooling/const_du/cooling.h +++ b/src/cooling/const_du/cooling.h @@ -119,11 +119,11 @@ INLINE void cooling_init(const struct swift_params* parameter_file, struct cooling_data* cooling) { cooling->cooling_rate = - parser_get_param_double(parameter_file, "Cooling:cooling_rate"); + parser_get_param_double(parameter_file, "ConstCooling:cooling_rate"); cooling->min_energy = - parser_get_param_double(parameter_file, "Cooling:min_energy"); - cooling->cooling_tstep_mult = - parser_get_param_double(parameter_file, "Cooling:cooling_tstep_mult"); + parser_get_param_double(parameter_file, "ConstCooling:min_energy"); + cooling->cooling_tstep_mult = parser_get_param_double( + parameter_file, "ConstCooling:cooling_tstep_mult"); } /** diff --git a/src/cooling/const_lambda/cooling.h b/src/cooling/const_lambda/cooling.h index e2ced7f1db450fd326e1eee72206e8a0596554d3..407c7c29436b4418dbf4615a3a3a6334bd12cf83 100644 --- a/src/cooling/const_lambda/cooling.h +++ b/src/cooling/const_lambda/cooling.h @@ -117,6 +117,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part( /* Calculate du_dt */ const float du_dt = cooling_rate(phys_const, us, cooling, p); + /* Intergrate cooling equation, but enforce energy floor */ float u_new; if (u_old + du_dt * dt > u_floor) { @@ -127,13 +128,13 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part( /* Update the internal energy */ hydro_set_internal_energy(p, u_new); - // const float u_new_test = hydro_get_internal_energy(p, 0.f); - /* if (-(u_new_test - u_old)/u_old > 1.0e-6){ */ - /* printf("Particle has successfully cooled: u_old = %g , du_dt = %g , dt = %g - * , du_dt*dt = %g, u_old + du_dt*dt = %g, u_new = - * %g\n",u_old,du_dt,dt,du_dt*dt,u_new,u_new_test); */ - /* exit(-1); */ - /* } */ + + /* if (-(u_new_test - u_old) / u_old > 1.0e-6) */ + /* error( */ + /* "Particle has not successfully cooled: u_old = %g , du_dt = %g , dt = + * " */ + /* "%g, du_dt*dt = %g, u_old + du_dt*dt = %g, u_new = %g\n", */ + /* u_old, du_dt, dt, du_dt * dt, u_new, u_new_test); */ } /** @@ -171,15 +172,16 @@ INLINE void cooling_init(const struct swift_params* parameter_file, const struct phys_const* phys_const, struct cooling_data* cooling) { - cooling->lambda = parser_get_param_double(parameter_file, "Cooling:lambda"); - cooling->min_temperature = - parser_get_param_double(parameter_file, "Cooling:minimum_temperature"); + cooling->lambda = + parser_get_param_double(parameter_file, "LambdaCooling:lambda"); + cooling->min_temperature = parser_get_param_double( + parameter_file, "LambdaCooling:minimum_temperature"); cooling->hydrogen_mass_abundance = parser_get_param_double( - parameter_file, "Cooling:hydrogen_mass_abundance"); - cooling->mean_molecular_weight = - parser_get_param_double(parameter_file, "Cooling:mean_molecular_weight"); - cooling->cooling_tstep_mult = - parser_get_param_double(parameter_file, "Cooling:cooling_tstep_mult"); + parameter_file, "LambdaCooling:hydrogen_mass_abundance"); + cooling->mean_molecular_weight = parser_get_param_double( + parameter_file, "LambdaCooling:mean_molecular_weight"); + cooling->cooling_tstep_mult = parser_get_param_double( + parameter_file, "LambdaCooling:cooling_tstep_mult"); /*convert minimum temperature into minimum internal energy*/ const float u_floor =