diff --git a/src/cooling.c b/src/cooling.c index 6bbf8445978ed7eb5cab56c31da266afe21bb813..d9349f16e07facb967925b625007bc9a10768b0a 100644 --- a/src/cooling.c +++ b/src/cooling.c @@ -61,11 +61,12 @@ void cooling_print(const struct cooling_data* cooling) { cooling->const_cooling.cooling_tstep_mult); #endif /* CONST_COOLING */ } -int update_entropy(const struct cooling_data* cooling, - const struct phys_const* const phys_const, struct part* p, float dt){ + +void update_entropy(const struct cooling_data* cooling, + const struct phys_const* const phys_const, struct part* p, + float dt){ /*updates the entropy of a particle after integrating the cooling equation*/ - int status == 0; float u_old; float u_new; float new_entropy; @@ -73,34 +74,32 @@ int update_entropy(const struct cooling_data* cooling, float rho = p->rho; u_old = old_entropy/(GAMMA_MINUS1) * pow(rho,GAMMA_MINUS1); - status = calculate_new_thermal_energy(u_old,&u_new,dt,cooling): - - if (status == 0){ - new_entropy = u_new/pow(rho,GAMMA_MINUS1) * GAMMA_MINUS1; - p->entropy = new_entropy - } - else - message("Error with cooling, particle's entropy has not been updated"); - - return status; + u_new = calculate_new_thermal_energy(u_old,dt,cooling): + new_entropy = u_new/pow(rho,GAMMA_MINUS1) * GAMMA_MINUS1; + p->entropy = new_entropy } -#ifdef CONST_COOLING -int calculate_new_thermal_energy(float u_old, float* u_new, float dt, const struct cooling_data* cooling){ +float calculate_new_thermal_energy(float u_old, float dt, const struct cooling_data* cooling){ +#ifdef CONST_COOLING //This function integrates the cooling equation, given the initial thermal energy and the timestep dt. //Returns 0 if successful and 1 if not int status = 0; float du_dt = cooling->const_cooling.lambda; float u_floor = cooling->const_cooling.min_energy; - if (u_old - du_dt*dt > min_energy): - *u_new = u_old - du_dt*dt; - else: - *u_new = min_energy + float u_new; + if (u_old - du_dt*dt > min_energy){ + u_new = u_old - du_dt*dt; + } + else{ + u_new = min_energy; + } + + return u_new; +#endif /*CONST_COOLING*/ +} - return status} -#endif /*CONST_COOLING diff --git a/src/cooling.h b/src/cooling.h index 227d03cc0199a8113561a74a411e109ecf6a4b19..59558856802e5150f786249376747102cf7dd805 100644 --- a/src/cooling.h +++ b/src/cooling.h @@ -61,7 +61,8 @@ struct cooling_data { */ __attribute__((always_inline)) INLINE static float cooling_timestep(const struct cooling_data* cooling, - const struct phys_const* const phys_const, const struct part* const p) { + const struct phys_const* const phys_const, + const struct part* const p) { const float cooling_rate = get_cooling_rate( p->density, p->internal_energy, cooling ); return cooling->const_cooling.cooling_tstep_mult * p->internal_energy / cooling_rate; @@ -93,5 +94,8 @@ void cooling_init(const struct swift_params* parameter_file, struct cooling_data* cooling); void cooling_print(const struct cooling_data* cooling); - +float calculate_new_thermal_energy(float u_old, float dt, const struct cooling_data* cooling); +void update_entropy(const struct cooling_data* cooling, + const struct phys_const* const phys_const, struct part* p, + float dt); #endif /* SWIFT_COOLING_H */