Skip to content
Snippets Groups Projects
Commit 5c9fad64 authored by Folkert Nobels's avatar Folkert Nobels
Browse files

Finishe the starformation backend

parent d1aa0de5
No related branches found
No related tags found
1 merge request!705Star formation following Schaye08
......@@ -141,6 +141,11 @@ void phys_const_init(const struct unit_system *us, struct swift_params *params,
internal_const->const_kennicutt_schmidt_units =
const_kennicutt_schmidt_units_cgs /
units_general_cgs_conversion_factor(us, dimension_ks);
const float dimension_M_per_pc2 = {1, -2, 0, 0, 0};
internal_const->const_solar_mass_per_parsec2 =
const_solar_mass_per_squared_parsec /
units_general_cgs_conversion_factor(us, dimension_M_per_pc2);
}
/**
......
......@@ -102,6 +102,9 @@ struct phys_const {
/*! Const of Kennicutt-Schmidt law */
double const_kennicutt_schmidt_units;
/*! Const Solar Mass per squared parsec */
double const_solar_mass_per_parsec2;
};
void phys_const_init(const struct unit_system* us, struct swift_params* params,
......
......@@ -105,5 +105,7 @@ const double const_reduced_hubble_cgs = 3.2407792894458e-18;
/*! Kennicutt-Schmidt law normalization units (i.e. Solar Mass / yr / kpc^2 ) */
const double const_kennicutt_schmidt_units_cgs = 6.62004339e-18;
/*! Solar mass per squared parsec (i.e. Solar Mass / pc^2) */
const double const_solar_mass_per_squared_parsec = 2.08908219e-4;
#endif /* SWIFT_PHYSICAL_CONSTANTS_CGS_H */
......@@ -20,6 +20,9 @@
#ifndef SWIFT_SCHAYE_STARFORMATION_H
#define SWIFT_SCHAYE_STARFORMATION_H
/* Some standard headers */
#include <stdlib.h>
/* Local includes */
#include "cosmology.h"
#include "physical_constants.h"
......@@ -53,6 +56,9 @@ struct star_formation {
/*! star formation normalization of schaye+08 */
double Astar;
/*! Inverse of RAND_MAX */
double inv_RAND_MAX;
};
......@@ -88,8 +94,8 @@ static int starformation_potential_to_become_star(
/* Calculate the abudance of Hydrogen and Helium */
/* Temporary part of the code!! */
const double X = ;
const double Y = ;
const double X = 0.75;
const double Y = 0.25;
/* Calculate the mean molecular mass using a simple model */
/* Temporary part of the code!! */
......@@ -120,9 +126,14 @@ static int starformation_potential_to_become_star(
*
* */
static void starformation_convert_to_gas(
const struct star_formation* starform
const struct star_formation* starform,
){
const int globalseed = 42;
const double prop = Astar * pressure * dt;
const double randomnumber = rand_r(&globalseed)*inv_RAND_MAX;
if (prop > randomnumber) {
message("Create a STAR!!");
}
}
/*
......@@ -172,11 +183,27 @@ static void starformation_init_backend(
/* Calculate the power law of the star formation */
starform->nstar = (starform->nks - 1.f)/2.f;
/* Calculate inverse of RAND_MAX */
starform->inv_RAND_MAX = 1.f / RAND_MAX;
/* Get the appropriate constant to calculate the
* star formation constant */
const double KS_const = phys_const->const_kennicutt_schmidt_units;
/* Get the Gravitational constant */
const double G_newton = phys_const->const_newton_G;
/* Get the surface density unit M_\odot / pc^2 */
const double M_per_pc2 = phys_const->const_solar_mass_per_parsec2;
/* Give the Kennicutt-Schmidt law the same units as internal units */
starform->A = normalization * KS_const;
/* Calculate the starformation prefactor with most terms */
starform->Astar = starform->A * pow(M_per_pc2, -starform->nks) *
pow( starform->gamma * starform->fg / G_newton, starform->nstar);
}
......@@ -198,5 +225,3 @@ static void starformation_print_backend(
#endif /* SWIFT_SCHAYE_STARFORMATION_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment