Previous topic

hyperion.util.constants

Next topic

hyperion.model.AnalyticalYSOModel

This Page

hyperion.model.Model

class hyperion.model.Model(name=None)

Adding sources

add_source(source)
add_point_source(*args, **kwargs)
add_spherical_source(*args, **kwargs)
add_external_spherical_source(*args, **kwargs)
add_external_box_source(*args, **kwargs)
add_map_source(*args, **kwargs)
add_plane_parallel_source(*args, **kwargs)

Setting the grid

set_grid(grid)
set_cartesian_grid(x_wall, y_wall, z_wall)
set_cylindrical_polar_grid(w_wall, z_wall, ...)
set_spherical_polar_grid(r_wall, t_wall, p_wall)
set_octree_grid(x, y, z, dx, dy, dz, refined)
set_amr_grid(description)
use_geometry(filename) Use the grid from an existing output or input file

Setting quantities

add_density_grid(density, dust[, ...]) Add a density grid to the model
use_quantities(filename[, quantities, ...]) Use physical quantities from an existing output file

Images/SEDs

add_peeled_images(**kwargs)
add_binned_images(**kwargs)

Configuration

set_seed(seed) Set the seed for the random number generation
set_propagation_check_frequency(frequency) Set how often to check that the photon is in the right cell
set_monochromatic(monochromatic[, ...]) Set whether to do the radiation transfer at specific frequencies/wavelengths.
set_minimum_temperature(temperature) Set the minimum temperature for the dust
set_minimum_specific_energy(specific_energy) Set the minimum specific energy for the dust
set_n_initial_iterations(n_iter) Set the number of initial iterations for computing the specific energy in each cell.
set_raytracing(raytracing) Set whether to use raytracing for the non-scattered flux
set_max_interactions(inter_max) Set the maximum number of interactions a photon can have.
set_max_reabsorptions(reabs_max) Set the maximum number of successive reabsorptions by a source that a photon can have.
set_pda(pda) Set whether to use the Partial Diffusion Approximation (PDA)
set_mrw(mrw[, gamma, inter_max]) Set whether to use the Modified Random Walk (MRW) approximation
set_convergence(convergence[, percentile, ...]) Set whether to check for convergence over the initial iterations
set_kill_on_absorb(kill_on_absorb) Set whether to kill absorbed photons
set_forced_first_scattering(...) Set whether to ensure that photons scatter at least once before escaping the grid.
set_output_bytes(io_bytes) Set whether to output physical quantity arrays in 32-bit or 64-bit
set_sample_sources_evenly(sample_sources_evenly) If set to ‘True’, sample evenly from all sources and apply
set_enforce_energy_range(enforce) Set how to deal with cells that have specific energy rates that are below or above that provided in the mean opacities and emissivities.
set_copy_input(copy) Set whether to copy the input data into the output file.

Running

write([filename, compression, copy, ...]) Write the model input parameters to an HDF5 file
run([filename, logfile, mpi, n_processes, ...])

Methods (detail)

add_source(source)
add_point_source(*args, **kwargs)
add_spherical_source(*args, **kwargs)
add_external_spherical_source(*args, **kwargs)
add_external_box_source(*args, **kwargs)
add_map_source(*args, **kwargs)
add_plane_parallel_source(*args, **kwargs)
set_grid(grid)
set_cartesian_grid(x_wall, y_wall, z_wall)
set_cylindrical_polar_grid(w_wall, z_wall, p_wall)
set_spherical_polar_grid(r_wall, t_wall, p_wall)
set_octree_grid(x, y, z, dx, dy, dz, refined)
set_amr_grid(description)
use_geometry(filename)

Use the grid from an existing output or input file

Parameters :

filename : str

The file to read the grid from. This can be either the input or output file from a radiation transfer run.

add_density_grid(density, dust, specific_energy=None, merge_if_possible=False)

Add a density grid to the model

Parameters :

density : np.ndarray or grid quantity

The density of the dust. This can be specified either as a 3-d Numpy array for cartesian, cylindrical polar, or spherical polar grids, as a 1-d array for octree grids, or as a grid quantity object for all grid types. Grid quantity objects are obtained by taking an instance of a grid class (e.g. AMRGrid, CartesianGrid, ...) and specifying the quantity as an index, e.g. amr['density'] where amr is an AMRGrid object.

dust : str or dust instance

The dust properties, specified either as a string giving the filename of the dust properties, or a as an instance of a dust class (e.g. SphericalDust, IsotropicDust, ...).

specific_energy : np.ndarray or grid quantity, optional

The specific energy of the density grid. Note that in order for this to be useful, the number of initial iterations should be set to zero, otherwise these values will be overwritten after the first initial iteration.

merge_if_possible : bool

Whether to merge density arrays that have the same dust type

use_quantities(filename, quantities=['density', 'specific_energy'], use_minimum_specific_energy=True, use_dust=True)

Use physical quantities from an existing output file

Parameters :

filename : str

The file to read the quantities from. This should be the output file of a radiation transfer run.

quantities : list

Which physical quantities to read in. Can include ‘density’ and ‘specific_energy’.

copy : bool

Whether to copy the quantities into the new input file, or whether to just link to them.

use_minimum_specific_energy : bool

Whether to also use the minimum specific energy values from the file specified

use_dust : bool

Whether to also use the dust properties from the file specified

add_peeled_images(**kwargs)
add_binned_images(**kwargs)
set_seed(seed)

Set the seed for the random number generation

Parameters :

seed : int

The seed with which to initialize the random number generation. This should be negative.

set_propagation_check_frequency(frequency)

Set how often to check that the photon is in the right cell

During photon propagation, it is possible that floating point issues cause a photon to end up in the wrong cell. By default, the code will randomly double check the position and cell of a photon for every 1 in 1000 cell wall crossings, but this can be adjusted with this method. Note that values higher than around 0.001 will cause the code to slow down.

Parameters :

frequency : float

How often the photon position and cell should be double-checked (1 is always, 0 is never).

set_monochromatic(monochromatic, frequencies=None, wavelengths=None)

Set whether to do the radiation transfer at specific frequencies/wavelengths.

Parameters :

monochromatic : bool

Whether to carry out radiation transfer at specific frequencies or wavelengths

frequencies : iterable of floats, optional

The frequencies to compute the radiation transfer for, in Hz

wavelengths : iterable of floats, optional

The wavelengths to compute the radiation transfer for, in microns

If `monochromatic` is True, then one of `frequencies` or :

`wavelengths` is required :

set_minimum_temperature(temperature)

Set the minimum temperature for the dust

Parameters :temperature : float, list, tuple, or Numpy array

Notes

This method should not be used in conjunction with set_minimum_specific_energy - only one of the two should be used.

set_minimum_specific_energy(specific_energy)

Set the minimum specific energy for the dust

Parameters :specific_energy : float, list, tuple, or Numpy array

Notes

This method should not be used in conjunction with set_minimum_temperature - only one of the two should be used.

set_n_initial_iterations(n_iter)

Set the number of initial iterations for computing the specific energy in each cell.

Parameters :

n_iter : int

The number of initial iterations

set_raytracing(raytracing)

Set whether to use raytracing for the non-scattered flux

If enabled, only scattered photons are peeled off in the iteration following the initial iterations, and an additional final iteration is carrried out, with raytracing of the remaining flux (sources and thermal and non-thermal dust emission).

Parameters :

raytracing : bool

Whether or not to use raytracing in the final iteration

set_max_interactions(inter_max)

Set the maximum number of interactions a photon can have.

Parameters :

inter_max : int

Maximum number of interactions for a single photon. This can be used to prevent photons from getting stuck in very optically thick regions, especially if the modified random walk is not used.

set_max_reabsorptions(reabs_max)

Set the maximum number of successive reabsorptions by a source that a photon can have.

Parameters :

reabs_max : int

Maximum number of reabsorptions for a single photon.

set_pda(pda)

Set whether to use the Partial Diffusion Approximation (PDA)

If enabled, the PDA is used to compute the specific energy in cells which have seen few or no photons by formally solving the diffusion equations, using the cells with valid specific energies as boundary conditions.

Parameters :

pda : bool

Whether or not to use the PDA

References

Min et al. 2009, Astronomy and Astrophysics, 497, 155

set_mrw(mrw, gamma=1.0, inter_max=1000)

Set whether to use the Modified Random Walk (MRW) approximation

If enabled, the MRW speeds up the propagation of photons in very optically thick regions by locally setting up a spherical diffusion region.

Parameters :

mrw : bool

Whether or not to use the MRW

gamma : float, optional

The parameter describing the starting criterion for the MRW. The MRW is carried out if the distance to the closest cell is larger than gamma times the Rosseland mean free path.

inter_max : int, optional

Maximum number of interactions during a single random walk. This can be used to prevent photons from getting stuck in the corners of cells in very optically thick regions, where the MRW stars to become inefficient itself.

References

Min et al. 2009, Astronomy and Astrophysics, 497, 155

set_convergence(convergence, percentile=100.0, absolute=0.0, relative=0.0)

Set whether to check for convergence over the initial iterations

If enabled, the code will check whether the specific energy absorbed in each cell has converged. First, the ratio between the previous and current specific energy absorbed in each cell is computed in each cell, and the value at the specified percentile (percentile) is found. Then, convergence has been achieved if this value is less than an absolute threshold (absolute), and if it changed by less than a relative threshold ratio (relative).

Parameters :

convergence : bool

Whether or not to check for convergence.

percentile : float, optional

The percentile at which to check for convergence.

absolute : float, optional

The abolute threshold below which the percentile value of the ratio has to be for convergence.

relative : float, optional

The relative threshold below which the ratio in the percentile value has to be for convergence.

set_kill_on_absorb(kill_on_absorb)

Set whether to kill absorbed photons

Parameters :

kill_on_absorb : bool

Whether to kill absorbed photons

set_forced_first_scattering(forced_first_scattering)

Set whether to ensure that photons scatter at least once before escaping the grid.

Parameters :

forced_first_scattering : bool

Whether to force at least one scattering before escaping the grid

References

Wood & Reynolds, 1999, The Astrophysical Journal, 525, 799

set_output_bytes(io_bytes)

Set whether to output physical quantity arrays in 32-bit or 64-bit

Parameters :

io_bytes : int

The number of bytes for the output. This should be either 4 (for 32-bit) or 8 (for 64-bit).

set_sample_sources_evenly(sample_sources_evenly)

If set to ‘True’, sample evenly from all sources and apply probability weight based on relative luminosities. Otherwise, sample equal energy photons from sources with probability given by relative luminosities.

Parameters :

sample_evenly : bool

Whether to sample different sources evenly

set_enforce_energy_range(enforce)

Set how to deal with cells that have specific energy rates that are below or above that provided in the mean opacities and emissivities.

Parameters :

enforce : bool

Whether or not to reset specific energies that are above or below the range of values used to specify the mean opacities and emissivities to the maximum or minimum value of the range. Setting this to True modifies the energy in the simulation, but ensures that the emissivities are consistent with the energy in the cells. Setting this to False means that the total energy in the grid will be correct, but that the emissivities may be inconsistent with the energy in the cells (if an energy is out of range, the code will pick the closest available one). In both cases, warnings will be displayed to notify the user whether this is happening.

set_copy_input(copy)

Set whether to copy the input data into the output file.

Parameters :

copy : bool

Whether to copy the input data into the output file (True) or whether to link to it (False)