mockgallib/src

hod.h

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
29
30
31
32
33
34
35
#ifndef HOD_H
#define HOD_H 1

#include <cstdio>
#include <cmath>

struct Hod {
 public:
  static const int n=10;
  Hod();
  
  void compute_param_z(const double z) {
    double x= z - z0;
    logMmin= c[0] + (c[1] + (c[2] + c[3]*x)*x)*x;
    sigma=   c[4] + c[5]*x;
    M0=      pow(10.0, logMmin);
    M1=      pow(10.0, c[6] + c[7]*x);
    alpha=   c[8] + c[9]*x;
  }
    
  double ncen(const double M) const {
    return 0.5*(1.0 + erf((log10(M) - logMmin)/sigma));
  }
  double nsat(const double M) const {
    return M <= M0 ? 0.0 : pow((M - M0)/M1, alpha);
  }
  double c[n];
 private:  
  static const double z0;
  double logMmin, sigma, M0, M1, alpha;
};

  

#endif

hod.cpp

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
#include "hod.h"

// x= z - 0.5
// logMmin = c0 + c1*x + c2*x^2 + c3*x^3
// sigma   = c4 + c5*x
// M0      = Mmin
// logM1   = c6 + c7*x
// alpha   = c8 + c9*x

Hod::Hod()
{
  // Initial guess
  c[0]= 12.0;
  c[1]= 0.0;
  c[2]= 2.0;
  c[3]= 0.0;
  c[4]= 0.1;
  c[5]= 0.0;
  c[6]= 15.0;
  c[7]= 0.0;
  c[8]= 1.5;
  c[9]= 0.0;
}

const double Hod::z0= 0.5;