Full API documentation¶
cgs module¶
configuration module¶
coordsys module¶
-
class
coordsys.CartesianCoordinates(x, y, z)[source]¶ Bases:
coordsys.CoordinatesBasic container class for Cartesian coordinates.
Parameters: - x – The x-coordinate; may be a float type or NumPy array
- y – The y-coordinate; may be a float type or NumPy array
- z – The z-coordinate; may be a float type or NumPy array
-
class
coordsys.Coordinates[source]¶ Bases:
objectBase class for coordinate containers. All coordinates are expected to be stored as Cartesian regardless of the coordinate system. This class is then responsible for converting to any supported coordinate system.
-
transformTo(sys)[source]¶ Transforms the coordinates stored in this container to the coordinate system specified.
Parameters: sys (Coordinates) – The coordinate system to transform to
-
-
class
coordsys.CylindricalCoordinates(s, phi, z)[source]¶ Bases:
coordsys.CoordinatesBasic container class for cylindrical coordinates.
Parameters: - s – The radial coordinate; may be a float type or NumPy array
- phi – The azimuthal coordinate; may be a float type or NumPy array
- z – The vertical coorindate; may be a float type or NumPy array
-
class
coordsys.SphericalCoordinates(r, theta, phi)[source]¶ Bases:
coordsys.CoordinatesBasic container class for spherical polar coordinates.
Parameters: - r – The radial coordinate; may be a float type or NumPy array
- theta – The latitudinal coordinate; may be a float type or NumPy array
- phi – The azimuthal coordinate; may be a float type or NumPy array
dust module¶
-
class
dust.Radmc3dDustContainer[source]¶ Container for a variable number of dust species. To support friendly naming of dust species, this class inherits from
dictso that new species can be added like so:>>> c = Radmc3dDustContainer() >>> c['some_name'] = SomeDustSpecies()
If a duplicate name is used, the previous species will be overwritten.
-
write(io, grid)[source]¶ Writes the current content of this container to input files for RADMC3D. This function uses the I/O context to determine the output format (binary or ASCII) and formats all files appropriately.
Parameters: - io (fileio.Radmc3dIo) – Current I/O context
- grid (grid.Radmc3dGrid) – Current grid definition
-
-
class
dust.Radmc3dDustSpecies[source]¶ Base class from which all dust species definitions should inherit. For example, to define a new (and fairly contrived) species with density everywhere equal to the square of the distance from the center:
import radmc3d as r3d class SomeDustSpecies(r3d.Radmc3dDustSpecies): def density(self, coords): rr, _, _ = coords.transformTo(r3d.SphericalCoordinates) return rr**2
-
density(coords)[source]¶ Evaluates the dust density (in \(\textrm{g} / \textrm{cm}^3\)) at each of the input coordinates. Vector operations are highly advised.
Parameters: coords (Coordinates) – The points at which to return the density Returns: An array of densities Return type: np.ndarray Raises: NotImplementedError – if the user does not define a density function
-
fileio module¶
-
class
fileio.Radmc3dIo[source]¶ Class defining common I/O operations needed by the module so that they can be carried out in a consistent way.
-
binary¶ Trueif input files should be binary;Falseif ASCII should be used instead. Note that this has no effect on the format of output files; for that setting, seerto_style().
-
clobber¶ Trueif existing files should be clobbered if they already exist,Falseotherwise.
-
dtype¶ Read-only; gives the current float data type as a NumPy dtype.
-
file_check_exists(target)[source]¶ Checks whether the given file exists.
Parameters: target (str) – A filename relative to the global output directory Returns: Trueif the file exists,FalseotherwiseReturn type: bool
-
file_open_read(target)[source]¶ Opens a file for reading; there is no need to check whether clobbering is safe in this case, because this is not a destructive operation.
Parameters: target (str) – A filename relative to teh global output directory Returns: A file pointer to the open file Return type: file
-
file_open_write(target)[source]¶ Opens a file for writing, checking whether it is safe to clobber any existing file by the same name before doing so.
Parameters: target (str) – A filename relative to the global output directory Returns: A file pointer to the open file Return type: file
-
fullpath(fname)[source]¶ Returns a “full path” (the concatenation of the output directory and given filename) to a file.
Parameters: fname (str) – The filename relative to the output directory Returns: The filename relative to the initial directory Return type: str
-
memmap(f, offset, dtype, shape, mode)[source]¶ Returns a memory map (in FORTRAN order, since RADMC3D uses this format exclusively) that can be used like an array but is written to a file in binary format.
Parameters: - f – A filename or file-like object; if a filename is given, it should be relative to the global output directory
- offset (int) – Offset in the file (in bytes) at which the map should begin
- dtype – The data type (
np.float64ornp.float32) of the mapped array - shape (tuple) – A tuple representing the shape of the mapped array
- mode (str) – The mode string, generally
w+for writing orrfor reading only
Returns: Memory map to the array
Return type: numpy.core.memmap.memmap
-
outdir¶ The output directory, relative to the initial directory
-
precis¶ Read-only; gives the number of bytes of the current float data type.
-
precision¶ Set to
doubleif double-precision input is desired; otherwise, set tosingle. Note that this has no effect on the format of output files; for that setting, seerto_single().
-
safe_check_clobber(target)[source]¶ Checks whether it is safe to clobber a file. If the user has specified that file clobbering is allowed or if the file does not exist, this method has no effect; otherwise, the user is prompted for each existing file and must approve clobbering to continue.
Parameters: target (str) – A filename relative to the global output directory Raises: RuntimeError – if the user aborts clobbering
-
grid module¶
-
class
grid.Radmc3dGrid[source]¶ Represents a RADMC3D grid. Currently, only regular grids are supported, but AMR and oct-tree grids may be added later.
-
cellcoords¶ Read-only; gives the cell coordinates of this grid. Currently, these are defined simply to be the midpoints of each dimension of the point coordinates.
-
coordsys¶ Set to one of CartesianCoordinates, SphericalCoordinates, or CylindricalCoordinates. Note that cylindrical coordinates, though documented in the RADMC3D manual, do not seem to be supported yet.
-
nrcells¶ Read-only; gives the total number of cells in this grid.
-
nu¶ Read-only; gives the number of cells in the u dimension.
-
nv¶ Read-only; gives the number of cells in the v dimension.
-
nw¶ Read-only; gives the number of cells in the w dimension.
-
ptcoords¶ Read-only; gives the point coordinates of this grid.
-
u¶ The first coordinate of the grid. This is called
xin the RADMC3D manual; we useuhere to avoid confusion with true Cartesian coordinates. Expects a NumPy array.
-
update_coords()[source]¶ Private function. Updates the definitions of the point and cell coordinates after a change to one of the coordinate arrays.
-
v¶ The first coordinate of the grid. This is called
yin the RADMC3D manual; we usevhere to avoid confusion with true Cartesian coordinates. Expects a NumPy array.
-
w¶ The first coordinate of the grid. This is called
zin the RADMC3D manual; we usewhere to avoid confusion with true Cartesian coordinates. Expects a NumPy array.
-
render module¶
-
class
render.Radmc3dVtkRender[source]¶ Renders the current input and output files as VTK output that can be visualized with VisIt and other VTK visualization software.
-
read_dust_density(io, grid)[source]¶ Private function. Reads the current dust density input file.
Parameters: - io (Radmc3dIo) – Current I/O context
- grid (Radmc3dGrid) – Current grid definition
Returns: A dictionary of name-array pairs for each dust species
Return type: dict
Raises: IOError – if a required file is not found
-
read_dust_temperature(io, grid)[source]¶ Private function. Reads the current dust temperature output file.
Parameters: - io (Radmc3dIo) – Current I/O context
- grid (Radmc3dGrid) – Current grid definition
Returns: A dictionary of name-array pairs for each dust species
Return type: dict
Raises: IOError – if a required file is not found
-
render(io, grid)[source]¶ Writes the VTK file for all variables that can be found in the output directory.
Parameters: - io (Radmc3dIo) – Current I/O context
- grid (Radmc3dGrid) – Current grid definition
-
simulation module¶
-
class
simulation.Radmc3dSimulation[source]¶ Primary class for carrying out simulations with RADMC3D.
-
commit()[source]¶ Writes the encapsulated data to files in the output directory, to be read by RADMC3D.
-
config¶ Accessor to the underlying configuration object.
-
dust¶ Accessor to the underlying dust container object.
-
grid¶ Accessor to the underlying grid object.
-
io¶ Accessor to the underlying I/O context object.
-
lmbda¶ Array of wavelengths at which to perform the simulation.
-
star¶ Accessor to the underlying star container object.
-
star module¶
-
class
star.Radmc3dBlackbodyStar(Teff=0.0, **kwargs)[source]¶ Bases:
star.Radmc3dStarDefines an ideal blackbody star, which is parametrized by only its effective temperature.
Parameters: Teff (float) – Effective temperature in Kelvin -
Teff¶ Effective temperature of this star
-
-
class
star.Radmc3dStar(center=<coordsys.CartesianCoordinates object>, mass=0.0, radius=0.0)[source]¶ Bases:
objectBase class for a star definition.
Parameters: - center (Coordinates) – The coordinates of the center (can use any coordinate system; defaults to (0,0,0)
- mass (float) – The mass of the star
- radius (float) – The radius of the star
-
center¶ The coordinates of the center of this star; expects a subclass of
Coordinates.
-
mass¶ The mass of this star
-
radius¶ The radius of this star
-
class
star.Radmc3dStarContainer[source]¶ Bases:
dictContainer for a variable number of stars. To support friendly naming of stars, this class inherits from
dictso that new stars can be added like so:>>> c = Radmc3dStarContainer() >>> c[0] = Radmc3dBlackbodyStar() >>> c[0].Teff = 5700.
String names can also be used instead of numeric indices. If a duplicate name is used, the previous star will be overwritten.
-
write(io, lmbda, grid)[source]¶ Writes the current content of this container to input files for RADMC3D. This function uses the I/O context to determine the output format (binary or ASCII) and formats all files appropriately.
Parameters: - io (fileio.Radmc3dIo) – Current I/O context
- lmbda (np.ndarray) – Wavelength array
- grid (grid.Radmc3dGrid) – Current grid definition
-