SMILE  v2.5
Schwarzschild Modelling Interactive expLoratory Environment
Macros | Functions | Variables
energydiff.cpp File Reference

Tool: Measure the rate of energy diffusion in N-body simulation. More...

#include <stdlib.h>
#include <stdinc.h>
#include <getparam.h>
#include <io_nemo.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_fit.h>
#include "massmodel.h"
#include "utils.h"
Include dependency graph for energydiff.cpp:

Macros

#define TimeBit   (1 << 0)
 
#define MassBit   (1 << 1)
 
#define PotentialBit   (1<<3)
 
#define DensBit   (1<<15)
 

Functions

int my_fit_mul (const double *x, const size_t, const double *y, const size_t, const size_t num, double *coef1, double *, double *sumsq)
 a modification of linear regression fit with zero intercept, which is more robust against outliers
 
int main (int argc, char **argv)
 

Variables

string defv []
 
string usage =const_cast<char*>("plot average energy and angular momentum change vs. time as a function of energy bin (measure relaxation rate)")
 

Detailed Description

Tool: Measure the rate of energy diffusion in N-body simulation.

Author
EV
Date
2010-2013

This program is used to determine the rate of energy diffusion of particles in an N-body simulation of a system that is assumed to be in self-consistent equilibrium, and compare it against analytical prediction from the theory of two-body relaxation.

Input file in the NEMO format contains multiple time snapshots. The program computes the squared change of particle energy, averaged over particles in a number of energy bins, as a function of time. For a diffusion process, this change should grow linearly with time, so a best-fit slope estimate is taken to be the energy diffusion rate. Output consists of the diffusion rates and their uncertainties, computed for each energy bin. It can be compared with the analytical estimate of diffusion coefficient from a smooth mass model, scaled to the appropriate number of particles.

Variable Documentation

string defv[]
Initial value:
=
{
const_cast<char*>("in=???\n input snapshot"),
const_cast<char*>("nbins=100\n number of bins for which to calculate energy diffusion"),
const_cast<char*>("minbin=0\n fraction of mass in the innermost bin (most bound particles) [default 1/nbins]"),
const_cast<char*>("rel=f\n output relative energy change (dE/E)^2 instead of (dE)^2 and rel.ang.mom."),
const_cast<char*>("tab=\n spherical mass model (for calculation of relative ang.mom.), if not given compute from first snapshot"),
const_cast<char*>("mbh=0\n additional point mass (black hole) at origin (which is not in snapshot)"),
const_cast<char*>("outdelta=\n output file for the time evolution of deltaE,L for each bin (default $in.delta)"),
const_cast<char*>("outcoef=\n output file for fitted diffusion coefficients deltaE,L/dt(E) (default $in.difcoef)"),
const_cast<char*>("VERSION=1.02\n"__DATE__" EV"),
NULL
}