/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
* 2018 Folkert Nobels (nobels@strw.leidenuniv.nl)
* 2019 Joel Pfeffer (joel.pfeffer@uwa.edu.au)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
******************************************************************************/
#ifndef SWIFT_MOSAICS_STAR_PART_H
#define SWIFT_MOSAICS_STAR_PART_H
/* Some standard headers. */
#include
/* Read additional aubgrid models */
#include "chemistry_struct.h"
#include "feedback_struct.h"
#include "particle_splitting_struct.h"
#include "star_formation_struct.h"
#include "tracers_struct.h"
/**
* @brief Particle fields for the star particles.
*
* All quantities related to gravity are stored in the associate #gpart.
*/
struct spart {
/*! Particle ID. */
long long id;
/*! Pointer to corresponding gravity part. */
struct gpart* gpart;
/*! Particle position. */
double x[3];
/* Offset between current position and position at last tree rebuild. */
float x_diff[3];
/* Offset between current position and position at last tree rebuild. */
float x_diff_sort[3];
/*! Particle velocity. */
float v[3];
/*! Star mass */
float mass;
/*! Particle smoothing length. */
float h;
struct {
/* Number of neighbours. */
float wcount;
/* Number of neighbours spatial derivative. */
float wcount_dh;
} density;
/*! Union for the birth time and birth scale factor */
union {
/*! Birth time */
float birth_time;
/*! Birth scale factor */
float birth_scale_factor;
};
/*! Scale-factor / time at which this particle last did enrichment */
float last_enrichment_time;
/*! Initial star mass */
float mass_init;
/*! SNII Feedback energy fraction */
float SNII_f_E;
/*! SNIa Feedback energy fraction */
float SNIa_f_E;
/*! SNIa rate */
double SNIa_rate;
/*! The physical birth density */
float birth_density;
/*! The birth temperature */
float birth_temperature;
/*! last time an HII region was built (age of star in Myr) */
float HIIregion_last_rebuild;
/*! current time-step length of star particle */
float star_timestep;
/*! HII mass available for ionization (current) */
float HIIregion_mass_to_ionize;
/*! mass in kernel when HII region is built (for debugging) */
float HIIregion_mass_in_kernel;
/*! Star formation struct */
struct star_formation_spart_data sf_data;
/*! Feedback structure */
struct feedback_spart_data feedback_data;
/*! Tracer structure */
struct tracers_spart_data tracers_data;
/*! Chemistry structure */
struct chemistry_spart_data chemistry_data;
/*! Splitting structure */
struct particle_splitting_data split_data;
/*! Particle time bin */
timebin_t time_bin;
/*! Tree-depth at which size / 2 <= h * gamma < size */
char depth_h;
/*! Number of time-steps since the last enrichment step */
char count_since_last_enrichment;
/* -------------- Now the MOSAICS data ---------------- */
/*! Did the star form at this timestep? */
char new_star;
/*! Current star cluster mass */
float cl_mass[MOSAICS_MULTIPHYS][MOSAICS_MAX_CLUSTERS];
/*! Initial star cluster mass */
float cl_initial_mass[MOSAICS_MULTIPHYS][MOSAICS_MAX_CLUSTERS];
/*! Time of cluster disruption */
float cl_disruption_time[MOSAICS_MULTIPHYS][MOSAICS_MAX_CLUSTERS];
/*! mass loss from tidal shocks */
float cl_dmshock[MOSAICS_MULTIPHYS][MOSAICS_MAX_CLUSTERS];
/* No longer resort so don't need cluster IDs */
/* Unique cluster ID within particle */
/* int cl_id[MOSAICS_MULTIPHYS][MOSAICS_MAX_CLUSTERS]; */
/* Removed to save space. Can be obtained from from the total mass loss
* (shocks + evap + stellar_evo) */
/* mass loss from evaporation */
/* float cl_dmevap[MOSAICS_MULTIPHYS][MOSAICS_MAX_CLUSTERS]; */
/* Don't have size evolution yet...
// Current star cluster size
float cl_rh[MOSAICS_MULTIPHYS][MOSAICS_MAX_CLUSTERS];
// Initial star cluster size
float cl_rh_init[MOSAICS_MULTIPHYS][MOSAICS_MAX_CLUSTERS];
*/
/*! Current surviving number of clusters */
int num_clusters[MOSAICS_MULTIPHYS];
/*! Number of clusters tried to form */
int initial_num_clusters[MOSAICS_MULTIPHYS];
/*! Number of clusters formed above mass limit */
int initial_num_clusters_evo[MOSAICS_MULTIPHYS];
/*! Sum of initial cluster masses */
float initial_cluster_mass_total[MOSAICS_MULTIPHYS];
/*! Sum of initial cluster masses above evolution mass limit */
float initial_cluster_mass_evo[MOSAICS_MULTIPHYS];
/*! Field mass component of star */
float field_mass[MOSAICS_MULTIPHYS];
/*! Star mass at the previous timestep */
float mass_prev_timestep;
/*! Second derivative of gravitational potential */
/* upper symmetric 3*3 matrix:
* tt[0] == xx
* tt[1] == yy
* tt[2] == zz
* tt[3] == xy == yx
* tt[4] == xz == zx
* tt[5] == yz == zy
*/
float tidal_tensor[3][6];
/*! Cluster formation efficiency */
float CFE[MOSAICS_MULTIPHYS];
/*! Exponential truncation to mass function */
float Mcstar[MOSAICS_MULTIPHYS];
/*! Epicyclic frequency at formation */
float kappa_birth;
/*! Circular frequency at formation */
float Omega_birth;
/*! Local Toomre mass */
float Toomre_mass;
/*! Fraction of Mtoomre that may collapse to a GMC */
float frac_collapse;
/*! Gas fraction within cell */
float cell_gas_fraction;
/*! Cell width when gas fraction was calculated */
float cell_width;
/*! Birth subgrid sound speed */
float sound_speed_subgrid;
/*! Birth pressure */
float birth_pressure;
/* Tidal shock properties */
/*! Tidal shock duration */
float shock_duration[6];
/*! Tidal shock duration indicator */
char shock_indicator[6];
/*! Integral of tidal heating */
float heatsum[6];
/*! Time of last maximum */
float tmaxsh[6];
/*! Value of tidal tensor component at last maximum */
float tidmax[6];
/*! Time of last minimum for all tensor components */
float tminsh[6];
/*! Value of tidal tensor component at last minimum */
float tidmin[6];
/*! Indicates whether last extreme was maximum: true/false */
char extreme_max[6];
#ifdef SWIFT_DEBUG_CHECKS
/* Time of the last drift */
integertime_t ti_drift;
/* Time of the last kick */
integertime_t ti_kick;
#endif
#ifdef DEBUG_INTERACTIONS_STARS
/*! Number of interactions in the density SELF and PAIR */
int num_ngb_density;
/*! List of interacting particles in the density SELF and PAIR */
long long ids_ngbs_density[MAX_NUM_OF_NEIGHBOURS_STARS];
/*! Number of interactions in the force SELF and PAIR */
int num_ngb_force;
/*! List of interacting particles in the force SELF and PAIR */
long long ids_ngbs_force[MAX_NUM_OF_NEIGHBOURS_STARS];
#endif
} SWIFT_STRUCT_ALIGN;
#define eagle_stars_lum_tables_N_Z 6
#define eagle_stars_lum_tables_N_ages 221
/**
* @brief The luminosity bands written in snapshots
*/
enum luminosity_bands {
luminosity_GAMA_u_band,
luminosity_GAMA_g_band,
luminosity_GAMA_r_band,
luminosity_GAMA_i_band,
luminosity_GAMA_z_band,
luminosity_GAMA_Y_band,
luminosity_GAMA_J_band,
luminosity_GAMA_H_band,
luminosity_GAMA_K_band,
luminosity_bands_count,
};
/**
* @brief Contains all the constants and parameters of the stars scheme
*/
struct stars_props {
/*! Resolution parameter */
float eta_neighbours;
/*! Target weighted number of neighbours (for info only)*/
float target_neighbours;
/*! Smoothing length tolerance */
float h_tolerance;
/*! Tolerance on neighbour number (for info only)*/
float delta_neighbours;
/*! Maximal number of iterations to converge h */
int max_smoothing_iterations;
/*! Maximal change of h over one time-step */
float log_max_h_change;
/*! Are we overwriting the stars' birth time read from the ICs? */
int overwrite_birth_time;
/*! Are we overwriting the stars' birth density read from the ICs? */
int overwrite_birth_density;
/*! Are we overwriting the stars' birth temperature read from the ICs? */
int overwrite_birth_temperature;
/*! Value to set birth time of stars read from ICs */
float spart_first_init_birth_time;
/*! Value to set birth density of stars read from ICs */
float spart_first_init_birth_density;
/*! Value to set birth temperature of stars read from ICs */
float spart_first_init_birth_temperature;
/*! Maximal time-step length of young stars (internal units) */
double max_time_step_young;
/*! Maximal time-step length of old stars (internal units) */
double max_time_step_old;
/*! Age threshold for the young/old transition (internal units) */
double age_threshold;
/*! Age threshold for the transition to unlimited time-step size (internal
* units) */
double age_threshold_unlimited;
/*! The metallicities (metal mass frac) for the luminosity interpolations */
float* lum_tables_Z[luminosity_bands_count];
/*! The age (in Gyr) for the luminosity interpolations */
float* lum_tables_ages[luminosity_bands_count];
/*! The luminosities */
float* lum_tables_luminosities[luminosity_bands_count];
/*! Conversion factor to luminosities */
double lum_tables_factor;
/* ------------- Global MOSAICS parameters ------------ */
/*! King 1966 density profile parameter */
float W0;
/*! Fixed cluster half-mass radii (pc) */
float rh;
/*! Turn on evaporation mass loss? */
int cluster_evap;
/*! Turn on tidal shock mass loss? */
int cluster_shocks;
/*! Add the Spitzer isolated term to evaporation? */
int spitzer_evap_term;
/*! Add metallicity (BH fraction) dependence to evaporation? */
int met_dep_evaporation;
/*! Use Omega^2 = -lambda_2, otherwise sum(-lambda/3) */
int Omega_is_lambda2;
/*! Minimum cell width for gas fraction calculation */
float min_fgas_cell_width;
/*! Use only the subgrid turbulent component for velocity dispersion */
int subgrid_gas_vel_disp;
/* --- Initial cluster mass function parameters --- */
/*! Use a power-law mass function (default Schechter) */
int power_law_clMF[MOSAICS_MULTIPHYS];
/*! Value for a fixed Mcstar */
float fixed_Mcstar[MOSAICS_MULTIPHYS];
/*! Cluster mass function power-law index */
float clMF_slope[MOSAICS_MULTIPHYS];
/*! Cluster mass function minimum (Msun) */
float clMF_min;
/*! Initial lowest cluster mass to evolve (Msun) */
float clMF_min_evolve;
/*! Cluster mass function maximum (Msun) */
float clMF_max;
/*! Star formation efficiency for Mcstar */
float GMC_SFE;
/*! Calculate GMC mass from Larson-type M-sigma relation M = c * sigma^m */
int Mgmc_Larson_relation;
/*! Power law index for Larson-type M-sigma relation */
float GMC_m_sigma_index;
/*! Constant for Larson-type M-sigma relation (Msun) */
float GMC_m_sigma_const;
/* ------ Cluster formation efficiency parameters ----- */
/*! Value for a fixed CFE */
float fixed_CFE[MOSAICS_MULTIPHYS];
/*! Sound speed of cold ISM (m/s) */
float fixed_cs;
/*! star formation law */
int sflaw;
/*! Value of constant specific star formation rate per free-fall time */
float const_sfrff;
/*! GMC virial parameter */
float qvir;
/*! time of first SN (Myr) */
float tsn;
/*! time of determining the CFE (Myr) */
float tview;
/*! GMC surface density (Msun/pc^2) */
float surfGMC_min;
/*! maximum (protostellar core) SFE */
float ecore;
/*! turbulent/magnetic pressure ratio */
float beta0;
/*! SN/radiative feedback mode. 0=supernova, 1=radiative, 2=both */
int radfb;
/*! Cruel cradle effect */
int cruel_cradle;
/*! Critical overdensity for cruel cradle effect */
float xsurv;
/*! CFE feedback efficiency constant (0.16 cm^2 s^-3) */
float const_phifb;
/*! CFE radiative feedback opacity constant (2.4e-5 m^2 kg^-1 K^-2) */
float const_kappa0;
/*! CFE radiative feedback light-to-mass ratio constant (0.3 m^2 s^-3) */
float const_psi;
/*! Metallicity-dependent local bound fraction for CFE calculation */
int CFE_met_dep_fbound;
/*! Saturation value for metallicity-dependent fbound */
float fbound_saturation;
/*! Scale SFE value for metallicity-dependent fbound */
float fbound_scale;
/*! Shape parameter for metallicity-dependent fbound */
float fbound_beta;
/*! Low SFE power law indices for metallicity-dependent fbound */
float fbound_alpha[2];
/*! Total metal mass fraction corresponding to alpha values for
* metallicity-dependent fbound */
float fbound_Z[2];
/*! Logarithm of metal mass fraction Z corresponding to fbound alpha values */
float fbound_logZ[2];
/* ------ Cluster evolution parameters ----- */
/*! Evaporation law exponent for W0 = 5 King profile */
float gamma_W5;
/*! Evaporation law exponent for W0 = 7 King profile */
float gamma_W7;
/*! Maximum value of metallicity-dependent evaporation exponent gamma */
float gamma_max_Zdep;
/*! Total metal mass fraction at maximum gamma value */
float Z_gamma_max;
/*! Total metal mass fraction at minimum gamma value */
float Z_gamma_min;
/*! Logarithm of metal mass fraction Z at maximum gamma value */
float logZ_gamma_max;
/*! Logarithm of metal mass fraction Z at minimum gamma value */
float logZ_gamma_min;
/*! Fixed evaporation disruption time (Myr) */
float fixed_t0evap;
/*! Dissolution timescales for King profile W0=5 (21.3 Myr) */
float const_t0evapsunW5;
/*! Dissolution timescales for King profile W0=7 (10.7 Myr) */
float const_t0evapsunW7;
/*! Tidal field strength at Solar radius (7.005e-4 Myr^-2) */
float const_tidesun;
};
#endif /* SWIFT_MOSAICS_STAR_PART_H */