Code to export from yt to RadMC3D

class yt.analysis_modules.radmc3d_export.RadMC3DInterface.RadMC3DLayer(level, parent, unique_id, LE, RE, dim)[source]

Bases: object

This class represents an AMR “layer” of the style described in the radmc3d manual. Unlike yt grids, layers may not have more than one parent, so level L grids will need to be split up if they straddle two or more level L - 1 grids.

get_overlap_with(grid)[source]

Returns the overlapping region between two Layers, or a layer and a grid. RE < LE means in any direction means no overlap.

overlaps(grid)[source]

Returns whether or not this layer overlaps a given grid

class yt.analysis_modules.radmc3d_export.RadMC3DInterface.RadMC3DSource(radius, mass, position, temperature)[source]

Bases: object

A class that contains the data associated with a single RadMC3D photon source. This is designed to help export data about the stars in a dataset into a format that can be read in by RadMC3D. Although RadMC3D can handle non-blackbody sources, here we assume that the source is a blackbody with a given temperature.

Parameters: radius (float) – The size of the source in cm mass (float) – The mass of the source in g position (list of floats) – The x, y, and z coordinates of the source, in cm temperature (float) – The blackbody temperature of the source, in K
class yt.analysis_modules.radmc3d_export.RadMC3DInterface.RadMC3DWriter(ds, max_level=2)[source]

Bases: object

Parameters: ds (Dataset) – This is the dataset object corresponding to the simulation output to be written out. max_level (int) – An int corresponding to the maximum number of levels of refinement to include in the output. Often, this does not need to be very large as information on very high levels is frequently unobservable. Default = 2.

Examples

This will create a field called “DustDensity” and write it out to the file “dust_density.inp” in a form readable by RadMC3D.

>>> import yt

>>> dust_to_gas = 0.01
>>> def _DustDensity(field, data):
...     return dust_to_gas*data["Density"]

>>> ds = yt.load("galaxy0030/galaxy0030")

>>> writer = RadMC3DWriter(ds)
>>> writer.write_amr_grid()
>>> writer.write_dust_file("DustDensity", "dust_density.inp")


This example will create a field called “NumberDensityCO” and write it out to the file “numberdens_co.inp”. It will also write out information about the gas velocity to “gas_velocity.inp” so that this broadening may be included in the radiative transfer calculation by radmc3d:

>>> import yt

>>> x_co = 1.0e-4
>>> mu_h = yt.Quantity(2.34e-24, 'g')
>>> def _NumberDensityCO(field, data):
...     return (x_co/mu_h)*data["Density"]

>>> ds = yt.load("galaxy0030/galaxy0030")

>>> writer.write_amr_grid()
>>> writer.write_line_file("NumberDensityCO", "numberdens_co.inp")
>>> velocity_fields = ["velocity_x", "velocity_y", "velocity_z"]
>>> writer.write_line_file(velocity_fields, "gas_velocity.inp")

write_amr_grid()[source]

This routine writes the “amr_grid.inp” file that describes the mesh radmc3d will use.

write_dust_file(field, filename)[source]

This method writes out fields in the format radmc3d needs to compute thermal dust emission. In particular, if you have a field called “DustDensity”, you can write out a dust_density.inp file.

Parameters: field (string) – The name of the field to be written out filename (string) – The name of the file to write the data to. The filenames radmc3d expects for its various modes of operations are described in the radmc3d manual.
write_line_file(field, filename)[source]

This method writes out fields in the format radmc3d needs to compute line emission.

Parameters: field (string or list of 3 strings) – If a string, the name of the field to be written out. If a list, three fields that will be written to the file as a vector quantity. filename (string) – The name of the file to write the data to. The filenames radmc3d expects for its various modes of operation are described in the radmc3d manual.
write_source_files(sources, wavelengths)[source]

This function creates the stars.inp and wavelength_micron.inp files that RadMC3D uses for its dust continuum calculations.

Parameters: sources (a list of RadMC3DSource objects) – A list that contains all the sources you would like yt to create wavelengths (np.array of float values) – An array listing the wavelength points you would like to use the radiative transfer calculation