yt_astro_analysis.radmc3d_export.RadMC3DInterface.RadMC3DWriter

class yt_astro_analysis.radmc3d_export.RadMC3DInterface.RadMC3DWriter(ds, max_level=2)

This class provides a mechanism for writing out data files in a format readable by radmc3d. Currently, only the ASCII, “Layer” style file format is supported. For more information please see the radmc3d manual at: http://www.ita.uni-heidelberg.de/~dullemond/software/radmc-3d

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
>>> from yt.extensions.astro_analysis.radmc3d_export.api import RadMC3DWriter
>>> dust_to_gas = 0.01
>>> def _DustDensity(field, data):
...     return dust_to_gas*data["Density"]
>>> yt.add_field("DustDensity", function=_DustDensity)
>>> 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
>>> import unyt as un
>>> from yt.extensions.astro_analysis.radmc3d_export.api import RadMC3DWriter
>>> x_co = 1.0e-4
>>> mu_h = un.unyt_quantity(2.34e-24, 'g')
>>> def _NumberDensityCO(field, data):
...     return (x_co/mu_h)*data["gas", "density"]
>>> yt.add_field(
...    ("gas", "NumberDensityCO"),
...    function=_NumberDensityCO,
...    sampling_type="cell",
...    units="cm**-3",
... )
>>> ds = yt.load("galaxy0030/galaxy0030")
>>> writer = RadMC3DWriter(ds)
>>> 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")

__init__(ds[, max_level])

write_amr_grid()

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

write_dust_file(field, filename)

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

write_line_file(field, filename)

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

write_source_files(sources, wavelengths)

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