main.cu
This page documents the functions defined in main.cu. main.cu contains the main starting functions as well as some small initializing and reporting functions.
Functions
Functions
-
__host__ int main(int argc, char *argv[])
Entry point for the GPUmonty.
This function manages the high-level execution flow of the application.
- Parameters:
argc – Argument count.
argv – Argument vector (parameters and model file paths).
- Returns:
0 on successful completion.
-
__host__ void set_units(Params params)
Initializes and synchronizes physical units between the Host and the Device.
This function defines the transformation scales between “code units” (dimensionless values used in the GRMHD simulation) and “CGS units” (physical values). The scaling parameters are defined as follows:
Mass Scaling ( \( M_{\rm unit} \)): User-defined mass unit to scale density and other mass-related quantities.
Black Hole Mass ( \( M_{\rm BH} \)): Mass of the central black hole, used to define length and time scales.
Length scale ( \( L_{\rm unit} \)): Defined as the gravitational radius \( R_g = GM_{BH}/c^2 \).
Time scale ( \( T_{\rm unit} \)): Defined as the light-crossing time \( R_g/c \).
Density scale ( \( \rho_{\rm unit} \)): Calculated as \( M_{\rm unit}/L_{\rm unit}^3 \).
Magnetic Field scale ( \( B_{\rm unit} \)): Scaled such that the magnetic pressure \( B^2/4\pi \) matches the energy density scale \( \rho c^2 \) in Gaussian units.
Energy Density Unit ( \( U_{\rm unit} \)): Defined as \( \rho_{ \rm unit} c^2 \).
Number Density scale ( \( N_{e,\rm unit} \)): Assumes a fully ionized hydrogen plasma ( \( m_p + m_e \)).
- Parameters:
params – The simulation parameters containing the Black Hole mass ( \(M_{BH}\)) and the mass scaling unit ( \(M_{\rm unit}\)).
- Returns:
void
-
__host__ void init_model(char *args[])
Organizes the main CPU tasks of initialization of the simulation environment and precomputed tables.
This function is the primary setup routine for the simulation. It prepares the physical units, loads the fluid model, initializes the spacetime geometry (metric), and generates the lookup tables (LUTs).
Routine:
Set Unit Scaling: Establishes the relationship between code units and CGS physical units by means of the function
set_units().Data & Geometry: Loads the GRMHD fluid snapshots and precomputes metric coefficients across the grid by means of the functions
init_model()andinit_geometry().Table Generation: Precomputes LUTs in the following order: Cross section table, emissivity table, weight table and solid angle integrated emissivity table. This is computed by means of the functions
init_hotcross(),init_emiss_tables(),init_weight_table()andinit_nint_table().
- Parameters:
args – Command line arguments.
-
__host__ void init_geometry()
Precomputes the spacetime metric components across the simulation grid.
This function populates the global geometry array (
geom) with the covariant metric, contravariant metric, and the metric determinant.Note
This function assumes axisymmetry, where the geometry does not change with the azimuthal angle \(\phi\) (represented by index \(k\)), therefore geom is a 2D array.
- Returns:
void
-
__host__ void report_spectrum(unsigned long long N_superph_made, struct of_spectrum spect[N_THBINS][N_EBINS], const char *filename)
Processes energy and angled binned simulation data to generate and save the final spectrum.
This function converts the raw energy and photon counts accumulated in the spectral grid into physical units. It calculates the SED across different inclination angles, determines the average optical depths, and computes global simulation diagnostics such as total luminosity and accretion efficiency.
- Parameters:
N_superph_made – Total number of superphotons generated during the run.
spect – 2D array containing the accumulated spectral data (Energy/Theta bins).
filename – Name of the output file (saved in the
./output/directory).