gravity_properties.h 5.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*******************************************************************************
 * This file is part of SWIFT.
 * Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
 *
 * 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 <http://www.gnu.org/licenses/>.
 *
 ******************************************************************************/
#ifndef SWIFT_GRAVITY_PROPERTIES
#define SWIFT_GRAVITY_PROPERTIES

/* Config parameters. */
#include "../config.h"

#if defined(HAVE_HDF5)
#include <hdf5.h>
#endif

29 30
/* Forward declarations */
struct cosmology;
31
struct phys_const;
32 33
struct swift_params;

34 35 36 37 38
/**
 * @brief Contains all the constants and parameters of the self-gravity scheme
 */
struct gravity_props {

39
  /* -------------- Softening for the regular particles ---------------- */
40

41 42 43 44 45 46 47
  /*! Co-moving softening length for high-res. DM particles at the current
   * redshift.  */
  float epsilon_DM_cur;

  /*! Co-moving softening length for high-res. baryon particles at the current
   * redshift.  */
  float epsilon_baryon_cur;
48

49
  /* -------------- Softening for the background DM -------------------- */
50

51 52 53
  /*! Conversion factor from cbrt of particle mass to softening assuming
   * a constant fraction of the mean inter-particle separation at that mass. */
  float epsilon_background_fac;
54

55
  /* -------------- Properties of the FFM gravity ---------------------- */
56

57
  /*! What MAC are we currently using? */
58
  int use_advanced_MAC;
59

60
  /*! Are we using the adaptive opening angle? (as read from param file) */
61
  int use_adaptive_tolerance;
62

63 64
  /*! Accuracy parameter of the advanced MAC */
  float adaptive_tolerance;
65

66 67
  /*! Tree opening angle (Multipole acceptance criterion) */
  double theta_crit;
68

69 70 71
  /*! Are we allowing tree gravity below softening? */
  int use_tree_below_softening;

72 73 74
  /*! Are we applying long-range truncation to the forces in the MAC? */
  int consider_truncation_in_MAC;

75
  /* ------------- Properties of the softened gravity ------------------ */
76

77 78
  /*! Co-moving softening length for for high-res. DM particles */
  float epsilon_DM_comoving;
79

80 81 82 83 84 85
  /*! Maximal softening length in physical coordinates for the high-res.
   * DM particles */
  float epsilon_DM_max_physical;

  /*! Co-moving softening length for for high-res. baryon particles */
  float epsilon_baryon_comoving;
86

87
  /*! Maximal softening length in physical coordinates for the high-res.
88 89
   * baryon particles */
  float epsilon_baryon_max_physical;
90

91 92 93
  /*! Fraction of the mean inter particle separation corresponding to the
   * co-moving softening length of the low-res. particles (DM + baryons) */
  float mean_inter_particle_fraction_high_res;
94

95
  /* ------------- Properties of the time integration  ----------------- */
96

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
  /*! Frequency of tree-rebuild in units of #gpart updates. */
  float rebuild_frequency;

  /*! Time integration dimensionless multiplier */
  float eta;

  /* ------------- Properties of the mesh-based gravity ---------------- */

  /*! Periodic long-range mesh side-length */
  int mesh_size;

  /*! Mesh smoothing scale in units of top-level cell size */
  float a_smooth;

  /*! Distance below which the truncated mesh force is Newtonian in units of
   * a_smooth */
  float r_cut_min_ratio;

  /*! Distance above which the truncated mesh force is negligible in units of
   * a_smooth */
  float r_cut_max_ratio;
118

119 120
  /*! Long-range gravity mesh scale. */
  float r_s;
121

122 123 124
  /*! Inverse of the long-range gravity mesh scale. */
  float r_s_inv;

125 126
  /* ------------- Physical constants ---------------------------------- */

127 128 129
  /*! Gravitational constant (in internal units, copied from the physical
   * constants) */
  float G_Newton;
130 131 132
};

void gravity_props_print(const struct gravity_props *p);
Matthieu Schaller's avatar
Matthieu Schaller committed
133
void gravity_props_init(struct gravity_props *p, struct swift_params *params,
134
                        const struct phys_const *phys_const,
135
                        const struct cosmology *cosmo, const int with_cosmology,
136
                        const int with_external_potential,
137
                        const int has_baryons, const int has_DM,
138 139
                        const int is_zoom_simulation, const int periodic,
                        const double dim[3]);
140 141
void gravity_props_update(struct gravity_props *p,
                          const struct cosmology *cosmo);
142
void gravity_props_update_MAC_choice(struct gravity_props *p);
143 144 145 146 147
#if defined(HAVE_HDF5)
void gravity_props_print_snapshot(hid_t h_grpsph,
                                  const struct gravity_props *p);
#endif

148 149
/* Dump/restore. */
void gravity_props_struct_dump(const struct gravity_props *p, FILE *stream);
150
void gravity_props_struct_restore(struct gravity_props *p, FILE *stream);
151

152
#endif /* SWIFT_GRAVITY_PROPERTIES */