Commit fdf6cc98 authored by Stefan Arridge's avatar Stefan Arridge
Browse files

Successfully compiled

parent e740b7aa
......@@ -457,7 +457,7 @@ int main(int argc, char *argv[]) {
struct engine e;
engine_init(&e, &s, params, nr_nodes, myrank, nr_threads, with_aff,
engine_policies, talking, &us, &prog_const, &hydro_properties,
&potential);
&potential, &cooling);
if (myrank == 0) {
clocks_gettime(&toc);
message("engine_init took %.3f %s.", clocks_diff(&tic, &toc),
......
......@@ -64,6 +64,9 @@
#define EXTERNAL_POTENTIAL_POINTMASS
//#define EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
/* Cooling properties */
#define CONST_COOLING
/* Are we debugging ? */
//#define SWIFT_DEBUG_CHECKS
......
......@@ -24,7 +24,9 @@
#include "../config.h"
/* This object's header. */
#include "potentials.h"
#include "cooling.h"
#include "hydro.h"
#include "adiabatic_index.h"
/**
* @brief Initialises the cooling properties in the internal system
......@@ -57,7 +59,7 @@ void cooling_print(const struct cooling_data* cooling) {
message(
"Cooling properties are (lambda, min_energy, tstep multiplier) %g %g %g ",
cooling->const_cooling.lambda,
cooling->const_cooling.min_energy
cooling->const_cooling.min_energy,
cooling->const_cooling.cooling_tstep_mult);
#endif /* CONST_COOLING */
}
......@@ -73,14 +75,15 @@ void update_entropy(const struct cooling_data* cooling,
float old_entropy = p->entropy;
float rho = p->rho;
u_old = old_entropy/(GAMMA_MINUS1) * pow(rho,GAMMA_MINUS1);
u_new = calculate_new_thermal_energy(u_old,dt,cooling):
new_entropy = u_new/pow(rho,GAMMA_MINUS1) * GAMMA_MINUS1;
p->entropy = new_entropy
// u_old = old_entropy/(GAMMA_MINUS1) * pow(rho,GAMMA_MINUS1);
u_old = hydro_get_internal_energy(p,0); // dt = 0 because using current entropy
u_new = calculate_new_thermal_energy(u_old,dt,cooling);
new_entropy = u_new*pow_minus_gamma_minus_one(rho) * hydro_gamma_minus_one;
p->entropy = new_entropy;
}
float calculate_new_thermal_energy(float u_old, double 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
......@@ -88,11 +91,11 @@ float calculate_new_thermal_energy(float u_old, double dt, const struct cooling_
float du_dt = cooling->const_cooling.lambda;
float u_floor = cooling->const_cooling.min_energy;
float u_new;
if (u_old - du_dt*dt > min_energy){
if (u_old - du_dt*dt > u_floor){
u_new = u_old - du_dt*dt;
}
else{
u_new = min_energy;
u_new = u_floor;
}
return u_new;
......
......@@ -32,6 +32,7 @@
/* Local includes. */
#include "const.h"
#include "error.h"
#include "hydro.h"
#include "parser.h"
#include "part.h"
#include "physical_constants.h"
......@@ -64,28 +65,12 @@ cooling_timestep(const struct cooling_data* cooling,
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;
const float cooling_rate = cooling->const_cooling.lambda;
const float internal_energy = hydro_get_internal_energy(p,0);// dt = 0 because using current entropy
return cooling->const_cooling.cooling_tstep_mult * internal_energy / cooling_rate;
}
/* /\** */
/* * @brief Updates the internal energy of a particle due to cooling. */
/* * */
/* * @param cooling The #cooling_data used in the run. */
/* * @param phys_const The physical constants in internal units. */
/* * @param p Pointer to the particle data. */
/* *\/ */
/* __attribute__((always_inline)) INLINE static float */
/* cooling_update_entropy(const struct cooling_data* cooling, */
/* const struct phys_const* const phys_const, */
/* const dt, */
/* struct part* p) { */
/* const float old_entropy = p->Entropy */
/* const float cooling_rate = get_cooling_rate( p->density, p->internal_energy, cooling ); */
/* // do other quanitities need to be updated as well?? */
/* p->internal_energy -= dt * cooling_rate; */
/* } */
/* #endif /\* CONST_COOLING *\/ */
#endif /* CONST_COOLING */
/* Now, some generic functions, defined in the source file */
......
......@@ -38,6 +38,7 @@
/* Includes. */
#include "clocks.h"
#include "cooling.h"
#include "parser.h"
#include "partition.h"
#include "potentials.h"
......@@ -222,7 +223,8 @@ void engine_init(struct engine *e, struct space *s,
const struct UnitSystem *internal_units,
const struct phys_const *physical_constants,
const struct hydro_props *hydro,
const struct external_potential *potential);
const struct external_potential *potential,
const struct cooling_data *cooling);
void engine_launch(struct engine *e, int nr_runners, unsigned int mask,
unsigned int submask);
void engine_prepare(struct engine *e);
......
......@@ -42,6 +42,7 @@
#include "atomic.h"
#include "cell.h"
#include "const.h"
#include "cooling.h"
#include "debug.h"
#include "drift.h"
#include "engine.h"
......@@ -148,7 +149,7 @@ void runner_do_cooling(struct runner *r, struct cell *c, int timer) {
struct part *restrict parts = c->parts;
const int count = c->count;
const int ti_current = r->e->ti_current;
const struct cooling_data *cooling = r->e->cooling;
const struct cooling_data *cooling = r->e->cooling_data;
const struct phys_const *constants = r->e->physical_constants;
const double timeBase = r->e->timeBase;
double dt;
......
......@@ -57,6 +57,7 @@ enum {
timer_qsteal,
timer_runners,
timer_step,
timer_do_cooling,
timer_count,
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment