#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "stub.h"
#include <libgadget/config.h>
#include <libgenic/thermal.h>
Go to the source code of this file.
◆ main()
Definition at line 72 of file test_thermal.c.
73 const struct CMUnitTest tests[] = {
77 return cmocka_run_group_tests_mpi(tests, NULL, NULL);
static void test_thermal_vel(void **state)
static void test_mean_velocity(void **state)
References test_mean_velocity(), and test_thermal_vel().
◆ test_mean_velocity()
static void test_mean_velocity |
( |
void ** |
state | ) |
|
|
static |
Definition at line 18 of file test_thermal.c.
21 assert_true(fabs(
NU_V0(1, 1, 1e3) - 100*
NU_V0(1, 1, 1e5)) < 1e-6);
23 assert_true(fabs(10*
NU_V0(1, 0.1, 1e5) -
NU_V0(1, 1, 1e5)) < 1e-6);
25 assert_true(fabs(0.5*
NU_V0(0.5, 1, 1e5) -
NU_V0(1, 1, 1e5)) < 1e-6);
double NU_V0(const double Time, const double kBTNubyMNu, const double UnitVelocity_in_cm_per_s)
References NU_V0().
Referenced by main().
◆ test_thermal_vel()
static void test_thermal_vel |
( |
void ** |
state | ) |
|
|
static |
Definition at line 29 of file test_thermal.c.
36 assert_true(fabs(nu_vels.fermi_dirac_vel[0]) < 1e-6);
41 while(nu_vels.fermi_dirac_cumprob[ii] < 0.5) {
44 assert_true(fabs(nu_vels.fermi_dirac_vel[ii] - 2.839075) < 0.002);
51 int64_t MaxID = 100000;
52 gsl_rng * g_rng = gsl_rng_alloc(gsl_rng_ranlxd1);
53 for (nsample=0; nsample < MaxID; nsample++)
56 double v2 = sqrt(Vel[0]*Vel[0]+Vel[1]*Vel[1]+Vel[2]*Vel[2]);
62 memset(Vel, 0, 3*
sizeof(
float));
67 assert_true(fabs(mean - 3*pow(M_PI,4)/90./1.202057*(7./8)/(3/4.)*100) < 1);
double init_thermalvel(struct thermalvel *thermals, const double v_amp, double max_fd, const double min_fd)
void add_thermal_speeds(struct thermalvel *thermals, gsl_rng *g_rng, float Vel[])
#define LENGTH_FERMI_DIRAC_TABLE
References add_thermal_speeds(), thermalvel::fermi_dirac_cumprob, thermalvel::fermi_dirac_vel, init_thermalvel(), LENGTH_FERMI_DIRAC_TABLE, and MAX_FERMI_DIRAC.
Referenced by main().