API Reference#

Complete API reference for all astroMUGS modules.

Pipeline#

class astromugs.pipeline.Interface[source]#

Bases: Pipeline

High-level interface for assembling radiative transfer models.

Provides methods to add physical components (star, disk, envelope, interstellar radiation field) and chemical models to a grid, building on the base Pipeline class.

add_chemical_path(chemicalpath)[source]#

Set the path to the chemical data directory.

Parameters:

chemicalpath (str) – Path to the directory containing chemical model files.

add_thermal_path(thermalpath)[source]#

Set the path to the thermal dust opacity data directory.

Parameters:

thermalpath (str) – Path to the directory containing thermal dust opacity files.

add_star()[source]#

Add a central star to the grid using thermal parameters.

Reads mass, luminosity, temperature, and position from self.thermalparams.star and creates a Star instance on the grid.

add_isrf(cut=0.2, d78=True, vdb82=True)[source]#

Add an interstellar radiation field (ISRF) to the grid.

Parameters:
  • cut (float, optional) – Short-wavelength cutoff for the ISRF, in microns. Default is 0.2 microns.

  • d78 (bool, optional) – Include the Draine (1978) UV component. Default is True.

  • vdb82 (bool, optional) – Include the van Dishoeck & Black (1982) component. Default is True.

add_disk(dust=None, **kwargs)[source]#

Add a disk component and its dust density to the grid.

Parameters:
  • dust (object or None, optional) – Dust opacity model. If it has a path attribute set to 'thermal/', the path is replaced by self.thermalpath.

  • **kwargs – Keyword arguments forwarded as overrides to the default disk parameters (e.g., rin, rout, mass).

add_internalheating(**kwargs)[source]#

Add viscous accretion heating to the grid.

Parameters:

**kwargs – Keyword arguments forwarded as overrides to the default disk parameters (e.g., mdot, alpha).

add_chemdisk(dust=None, **kwargs)[source]#

Add a disk component for chemical modeling on the chemistry grid.

Populates the chemistry grid with dust number density, gas number density, gas temperature, scale height, and vertical visual extinction.

Parameters:
  • dust (object or None, optional) – Dust opacity model. If it has a path attribute set to 'thermal/', the path is replaced by self.thermalpath.

  • **kwargs – Keyword arguments forwarded as overrides to the default disk parameters.

add_envelope(dust=None, **kwargs)[source]#

Add an envelope component and its dust density to the grid.

Parameters:
  • dust (object or None, optional) – Dust opacity model. If it has a path attribute set to 'thermal/', the path is replaced by self.thermalpath. The dust density is only added to the grid when dust is not None.

  • **kwargs – Keyword arguments forwarded as overrides to the default envelope parameters.

add_chemistry(chempath=None, itime=-1)[source]#

Read chemistry output and store results on the model.

Auto-detects whether chempath is a single chemistry run (0-D or single 1-D) or a disk model composed of multiple radial folders ending with AU/.

In single mode, self.chemistry is a dict with an xarray abundances DataArray containing all species and timesteps.

In disk mode, self.chemistry is a dict keyed by radius (int, in AU), where each value has the same structure. self.grid.chemmodel is also populated so that convert_nautilus2radmc() works out of the box.

Parameters:
  • chempath (str or None, optional) – Path to the chemistry output directory. Defaults to self.chempath.

  • itime (int, optional) – Timestep index used to build the grid-level chemistry model (self.grid.chemmodel) for disk mode. Negative indices follow NumPy convention (-1 = last timestep). Default is -1.

convert_nautilus2radmc(species='CO', dust_density=False, dust_temperature=False, numberdens=False)#

Convert Nautilus chemistry output to RADMC-3D input files.

Interpolates chemistry model results onto the radiative transfer grid and writes the corresponding RADMC-3D input files. The chemistry model must first be attached via add_chemistry(). An amr_grid.inp file must already exist (or the grid must be set) because the chemistry grid is typically at lower resolution than the RT grid and requires interpolation.

Parameters:
  • species (str or list of str, optional) – Chemical species to convert (e.g., ‘CO’, ‘H2O’). Used for creating numberdens_XX.inp. Default is ‘CO’.

  • dust_density (bool, optional) – If True, write a dust_density.inp file. Default is False.

  • dust_temperature (bool, optional) – If True, write a dust_temperature.inp file. Default is False.

  • numberdens (bool, optional) – If True, write a numberdens_XX.inp file for the given species. Default is False.

run_chemistry(verbose=True, timelimit=None)#

Run the NMGC gas-grain chemistry simulation.

Calls nmgc run in self.chempath, which must already contain all required NMGC input files. Set self.nmgc_cmd beforehand if the nmgc binary is not on PATH.

Parameters:
  • verbose (bool, optional) – If True, NMGC output streams to the terminal. If False, it is redirected to <chempath>/nmgc.out. Default is True.

  • timelimit (float or None, optional) – Timeout in seconds. None means no timeout. Default is None.

run_chemistry_custompath(custom_path, verbose=True, timelimit=None)#

Run the NMGC gas-grain chemistry simulation.

Calls nmgc run in custom_path, which must already contain all required NMGC input files. Set self.nmgc_cmd beforehand if the nmgc binary is not on PATH.

Parameters:
  • verbose (bool, optional) – If True, NMGC output streams to the terminal. If False, it is redirected to <chempath>/nmgc.out. Default is True.

  • timelimit (float or None, optional) – Timeout in seconds. None means no timeout. Default is None.

run_continuum(write_control=False, **keywords)#

Run dust continuum radiative transfer and compute area-weighted temperature.

Executes the RADMC-3D Monte Carlo dust radiative transfer, reads the resulting dust temperature, and computes the surface-area-weighted temperature self.Ta. If the output files already exist they are read directly; missing files produce a warning but do not halt execution (useful when running chemistry without a dust structure).

Parameters:
  • write_control (bool, optional) – If True, write the RADMC-3D control file before running. Default is False.

  • **keywords – Additional keyword arguments forwarded to run_thermal_radmc3d.

run_image_radmc3d(npix=300, lambda_micron=None, iline=None, incl=None, verbose=True)#

Run RADMC-3D to produce a synthetic image.

Parameters:
  • npix (int, optional) – Number of pixels per side of the image. Default is 300.

  • lambda_micron (float or None, optional) – Wavelength of the image in microns. Default is None.

  • iline (int or None, optional) – Line transition index. Default is None.

  • incl (float or None, optional) – Inclination angle in degrees. Default is None.

  • verbose (bool, optional) – If True, print RADMC-3D output to stdout. Default is True.

run_line(make_image=True, write_control=False, lines_format='leiden', path='chemistry/', incl=90, npix=800, iline=None, lambda_micron=None, widthkms=10, linenlam=100, itime=59, species='CO', **keywords)#

Run line radiative transfer and optionally produce a channel map image.

Parameters:
  • make_image (bool, optional) – If True, generate a synthetic image via RADMC-3D. Default is True.

  • write_control (bool, optional) – If True, write the RADMC-3D control file before running. Default is False.

  • lines_format (str, optional) – Format of the molecular data file (e.g., ‘leiden’). Default is ‘leiden’.

  • path (str, optional) – Relative or absolute path to the chemistry model directory. Default is ‘chemistry/’.

  • incl (float, optional) – Disk inclination angle in degrees. Default is 90.

  • npix (int, optional) – Number of pixels per side of the output image. Default is 800.

  • iline (int or None, optional) – Line transition index for RADMC-3D. Default is None.

  • lambda_micron (float or None, optional) – Wavelength in microns at which to produce the image. Default is None.

  • widthkms (float, optional) – Velocity width of the line channel map in km/s. Default is 10.

  • linenlam (int, optional) – Number of wavelength channels across the line. Default is 100.

  • itime (int, optional) – Index of the chemistry time output to use. Default is 59.

  • species (str, optional) – Chemical species for the line transfer (e.g., ‘CO’). Default is ‘CO’.

  • **keywords – Additional keyword arguments forwarded to run_image_radmc3d.

run_localfield(nphot_mono=None, write_mcmono=False, run=True, **keywords)#

Compute the local mean radiation field with RADMC-3D monochromatic Monte Carlo.

Optionally writes the monochromatic wavelength file, runs the RADMC-3D monochromatic Monte Carlo, and reads the resulting mean_intensity.out into self.grid.localfield.

Parameters:
  • nphot_mono (int or None, optional) – Number of monochromatic photon packages. If None, RADMC-3D uses its default. Default is None.

  • write_mcmono (bool, optional) – If True, write the mcmono_wavelength_micron.inp file before running. Default is False.

  • run (bool, optional) – If True, execute the RADMC-3D monochromatic run. Set to False to skip execution and only read existing output. Default is True.

  • **keywords – Additional keyword arguments forwarded to write_continuum.

run_localfield_radmc3d(nphot_mono=None, verbose=True, timelimit=7200)#

Run the RADMC-3D monochromatic Monte Carlo for the local radiation field.

Parameters:
  • nphot_mono (int or None, optional) – Number of monochromatic photon packages. If None, RADMC-3D uses its default. Default is None.

  • verbose (bool, optional) – If True, print RADMC-3D output to stdout. Default is True.

  • timelimit (int, optional) – Maximum wall-clock time in seconds. Default is 7200 (2 hours).

run_thermal_radmc3d(verbose=True, timelimit=7200, nice=None, **keywords)#

Run the RADMC-3D thermal Monte Carlo dust radiative transfer.

Parameters:
  • verbose (bool, optional) – If True, print RADMC-3D output to stdout. Default is True.

  • timelimit (int, optional) – Maximum wall-clock time in seconds before the run is killed. Default is 7200 (2 hours).

  • nice (int or None, optional) – Unix nice priority for the RADMC-3D process. Default is None.

  • **keywords – Additional keyword arguments (currently unused).

write_continuum(dens=False, grid=False, opac=False, control=False, stars=False, wave=False, mcmono=False, ext=False)#

Write RADMC-3D input files for dust continuum radiative transfer.

Each boolean flag controls whether the corresponding input file is written. If no flags are set to True, a warning is printed. The thermal directory is created if it does not exist.

Parameters:
  • dens (bool, optional) – Write dust_density.inp. Default is False.

  • grid (bool, optional) – Write amr_grid.inp. Default is False.

  • opac (bool, optional) – Write dustopac.inp (reads existing dustkap* files in the thermal directory). Default is False.

  • control (bool, optional) – Write radmc3d.inp control file. Default is False.

  • stars (bool, optional) – Write stars.inp with stellar properties. Default is False.

  • wave (bool, optional) – Write wavelength_micron.inp. Default is False.

  • mcmono (bool, optional) – Write mcmono_wavelength_micron.inp for monochromatic Monte Carlo. Default is False.

  • ext (bool, optional) – Write external_source.inp for the interstellar radiation field. Default is False.

write_line(control=False, line=False, gasvelocity=False, gastemp=False, microturb=False, line_format='leiden', species='CO', star_mass=1)#

Write RADMC-3D input files for line radiative transfer.

Parameters:
  • control (bool, optional) – Write radmc3d.inp control file. Default is False.

  • line (bool, optional) – Write lines.inp molecular line data file. Default is False.

  • gasvelocity (bool, optional) – Write gas_velocity.inp assuming Keplerian rotation. Default is False.

  • gastemp (bool or str, optional) – Controls gas temperature handling.

    • False (default): no gas_temperature.inp is written. Use pipe.thermalparams.control.tgas_eq_tdust = 1 before write_line(control=True) to let RADMC-3D equate gas and dust temperatures internally.

    • '1D_static': read the gas temperature column Tg from each <radius>AU/1D_static.dat file in the chemistry directory, remap it to the spherical RADMC-3D grid via bilinear interpolation (the same method as convert_nautilus2radmc()), and write gas_temperature.inp. This reproduces the gas temperature that was actually fed into Nautilus and is independent of the chemical timestep.

  • microturb (bool, optional) – Write microturbulence file (not yet implemented). Default is False.

  • line_format (str, optional) – Format of the molecular data file (e.g., ‘leiden’). Default is ‘leiden’.

  • species (str, optional) – Chemical species for the line file. Default is ‘CO’.

  • star_mass (float, optional) – Stellar mass in solar masses, used for Keplerian velocity computation. Default is 1.

write_nautilus(sizes=array([[0.1]]), uv_ref=3400, nH_to_AV_conversion=1.6e+21, rsingle=0.1, dtogas=0.01, ref_radius=100, stop_time=3000000.0, nb_outputs=64, tunneling=1, is_h2_formation_rate=0, min_gas_density=1.0, min_av=0.01, max_uv=None, cap_uv_floor=True, cut_cap=True, max_inv_ab=None, exclude_bins=None, temp_gas='dust', static=True, param=True, element=True, abundances='atomic', network=True, multi_grain=True, tempdecoup=True, coupling_dens=False, coupling_temp=True, coupling_av=True, **keywords)#

Write Nautilus chemistry input files for each radial point.

Reads the RADMC-3D thermal output (grid, dust density, dust temperature, local radiation field), couples the physical quantities onto the chemistry grid, and writes one set of Nautilus input files per radial grid point inside the chemistry directory. The existing chemistry directory is removed and recreated.

When coupling_dens is True the code derives dust and gas number densities from the RADMC-3D dust density rather than from an analytically added disk/envelope structure.

Parameters:
  • sizes (ndarray, optional) – Grain size array in microns, shape (n_structures, n_bins). Default is np.array([[0.1]]).

  • uv_ref (float, optional) – Reference UV field strength in Habing units. Default is 3400.

  • nH_to_AV_conversion (float, optional) – Column density to visual extinction conversion factor in cm^-2. Default is 1.6e21.

  • rsingle (float, optional) – Single representative grain radius in microns. Default is 0.1.

  • dtogas (float, optional) – Dust-to-gas mass ratio. Default is 1e-2.

  • ref_radius (float, optional) – Reference radius in AU for the UV scaling. Default is 100.

  • stop_time (float, optional) – Chemical evolution stop time in years. Default is 3e6.

  • nb_outputs (int, optional) – Number of time outputs written by Nautilus. Default is 64.

  • tunneling (int, optional) – Tunneling flag for Nautilus (0 or 1). Default is 1.

  • is_h2_formation_rate (int, optional) – H2 formation rate flag for Nautilus. Default is 0.

  • min_gas_density (float, optional) – Minimum gas number density in cm^-3 enforced in the chemistry input. Default is 1.

  • min_av (float, optional) – Minimum visual extinction in mag enforced in the chemistry input. Default is 1e-2.

  • max_uv (float or None, optional) – Maximum UV field value. If None, no cap is applied. Default is None.

  • cap_uv_floor (bool, optional) – If True (default), cap the UV factor at 10 Habing for cells at the gas density floor. Set to False to keep the full geometric UV value in those cells (removes the discontinuity at the floor-density boundary visible when plotting the uv column).

  • temp_gas (str, optional) – Gas temperature source: ‘dust’ uses the area-weighted dust temperature, ‘param’ uses a parametrized gas temperature added to the grid. Default is ‘dust’.

  • static (bool, optional) – Write the 1D_static.dat (or multi-grain equivalent) input file. Default is True.

  • param (bool, optional) – Write the Nautilus parameters.in file. Default is True.

  • element (bool, optional) – Write the element.in file. Default is True.

  • abundances (str, optional) – Initial abundances preset name (e.g., ‘atomic’). Default is ‘atomic’ for solar-composition. It can also be a filepath.

  • network (bool or str, optional) – Controls network file copying. False skips it entirely. True (default) copies from the built-in astromugs/nautilus/network/ directory. A string path copies from that directory instead (e.g. network='/path/to/my_network').

  • multi_grain (bool, optional) – If True, use multi-grain chemistry mode (NMGC). Default is True.

  • tempdecoup (bool, optional) – If True, compute a separate area-weighted dust temperature from the full size distribution. If False, use the single-bin temperature. Default is True.

  • coupling_dens (bool, optional) – If True, derive dust and gas densities from the RADMC-3D dust density file. Default is False.

  • coupling_temp (bool, optional) – If True, interpolate dust temperature from the RADMC-3D output onto the chemistry grid. Default is True.

  • coupling_av (bool, optional) – If True, compute visual extinction from the local radiation field. Default is True.

  • **keywords – Any keyword argument accepted by parameters_nmgc() can be passed here and will be forwarded verbatim to that function. This lets you override any entry in the parameters.in file without subclassing. See Other Parameters below for the full list.

Other Parameters:
  • phase (int, optional) – Chemical phase model. 0 = 2-phase, 1 = 3-phase (default 1).

  • cr_ionisation_rate (float, optional) – Cosmic-ray ionisation rate [s⁻¹]. Default 1.3e-17.

  • x_ionisation_rate (float, optional) – X-ray ionisation rate [s⁻¹]. Default 0.0.

  • is_photodesorb (int, optional) – Photodesorption of ices: 1 = on (default), 0 = off.

  • is_crid (int, optional) – Cosmic-ray induced diffusion (CRID): 1 = on, 0 = off (default).

  • is_er_cir (int, optional) – Eley-Rideal and complex-induced reactions: 1 = on, 0 = off (default).

  • is_absorption_h2 (int, optional) – H₂ self-shielding (Lee & Herbst 1996): 1 = on (default).

  • is_absorption_co (int, optional) – CO self-shielding method. 1 = Lee & Herbst (1996), 2 = Visser et al. (2009) (default 2).

  • is_absorption_n2 (int, optional) – N₂ self-shielding (Li et al. 2013): 1 = on (default).

  • nb_active_lay (float, optional) – Number of chemically active grain surface layers. Default 2.0.

  • diff_binding_ratio_surf (float, optional) – Ratio of diffusion barrier to binding energy for surface species. Default 0.4.

  • diff_binding_ratio_mant (float, optional) – Ratio of diffusion barrier to binding energy for mantle species. Default 0.8.

  • cr_peak_grain_temp (float, optional) – Peak grain temperature reached during a cosmic-ray heating event [K]. Default 70.0.

  • cr_peak_duration (float, optional) – Duration of a cosmic-ray heating peak [s]. Default 1e-5.

  • Fe_ionisation_rate (float, optional) – Cosmic Fe-ion–grain encounter rate [s⁻¹ grain⁻¹]. Default 3e-14.

  • sticking_coeff_neutral (float, optional) – Sticking coefficient for neutral species. Default 1.0.

  • sticking_coeff_positive (float, optional) – Sticking coefficient for positively charged species. Default 0.0.

  • sticking_coeff_negative (float, optional) – Sticking coefficient for negatively charged species. Default 0.0.

  • surface_site_density (float, optional) – Surface site density on a grain [cm⁻²]. Default 8e14.

  • chemical_barrier_thickness (float, optional) – Grain reaction activation energy barrier width [cm]. Default 1e-8.

  • relative_tolerance (float, optional) – Relative tolerance of the ODE solver. Default 1e-4.

  • output_type (str, optional) – Output time spacing: 'log' (default) or 'linear'.

  • start_time (float, optional) – First output time [yr]. Default 1.0.

  • modify_rate_flag (int, optional) – Rate modification flag. 0 = none (default), 1 = H only, 2 = H + H₂, 3 = all species.

  • ED_H2 (float, optional) – H₂ binding energy on itself [K]. Default 23.0.

  • vib_to_dissip_freq_ratio (float, optional) – Ratio of surface-bond vibrational frequency to energy dissipation frequency (RRK desorption mechanism). Default 1e-2.

class astromugs.pipeline.Pipeline[source]#

Bases: object

Main user-facing class for setting up and running disk models.

Orchestrates the full modeling pipeline: dust continuum radiative transfer with RADMC-3D, line radiative transfer, local radiation field computation, and chemical modeling with Nautilus. Holds the grid, structural parameters, thermal parameters, and provides methods to read, write, and run each modeling stage.

params#

Structural parameters for the disk model.

Type:

StructureParams

thermalparams#

Thermal and wavelength parameters for radiative transfer.

Type:

ThermalParams

thermalpath#

Relative path to the directory containing thermal / RADMC-3D files.

Type:

str

chempath#

Relative path to the directory containing chemistry (Nautilus) files.

Type:

str

radmc3d_cmd#

Command used to invoke RADMC-3D (can be overridden to point to a specific binary).

Type:

str

grid#

The spatial grid object holding coordinates, dust, and field data.

Type:

Grid

nautilus#

Reference to the Nautilus chemistry module.

Type:

module

Ta#

Surface-area-weighted dust temperature array, populated after run_continuum or write_nautilus.

Type:

ndarray

run_continuum(write_control=False, **keywords)[source]#

Run dust continuum radiative transfer and compute area-weighted temperature.

Executes the RADMC-3D Monte Carlo dust radiative transfer, reads the resulting dust temperature, and computes the surface-area-weighted temperature self.Ta. If the output files already exist they are read directly; missing files produce a warning but do not halt execution (useful when running chemistry without a dust structure).

Parameters:
  • write_control (bool, optional) – If True, write the RADMC-3D control file before running. Default is False.

  • **keywords – Additional keyword arguments forwarded to run_thermal_radmc3d.

run_line(make_image=True, write_control=False, lines_format='leiden', path='chemistry/', incl=90, npix=800, iline=None, lambda_micron=None, widthkms=10, linenlam=100, itime=59, species='CO', **keywords)[source]#

Run line radiative transfer and optionally produce a channel map image.

Parameters:
  • make_image (bool, optional) – If True, generate a synthetic image via RADMC-3D. Default is True.

  • write_control (bool, optional) – If True, write the RADMC-3D control file before running. Default is False.

  • lines_format (str, optional) – Format of the molecular data file (e.g., ‘leiden’). Default is ‘leiden’.

  • path (str, optional) – Relative or absolute path to the chemistry model directory. Default is ‘chemistry/’.

  • incl (float, optional) – Disk inclination angle in degrees. Default is 90.

  • npix (int, optional) – Number of pixels per side of the output image. Default is 800.

  • iline (int or None, optional) – Line transition index for RADMC-3D. Default is None.

  • lambda_micron (float or None, optional) – Wavelength in microns at which to produce the image. Default is None.

  • widthkms (float, optional) – Velocity width of the line channel map in km/s. Default is 10.

  • linenlam (int, optional) – Number of wavelength channels across the line. Default is 100.

  • itime (int, optional) – Index of the chemistry time output to use. Default is 59.

  • species (str, optional) – Chemical species for the line transfer (e.g., ‘CO’). Default is ‘CO’.

  • **keywords – Additional keyword arguments forwarded to run_image_radmc3d.

convert_nautilus2radmc(species='CO', dust_density=False, dust_temperature=False, numberdens=False)[source]#

Convert Nautilus chemistry output to RADMC-3D input files.

Interpolates chemistry model results onto the radiative transfer grid and writes the corresponding RADMC-3D input files. The chemistry model must first be attached via add_chemistry(). An amr_grid.inp file must already exist (or the grid must be set) because the chemistry grid is typically at lower resolution than the RT grid and requires interpolation.

Parameters:
  • species (str or list of str, optional) – Chemical species to convert (e.g., ‘CO’, ‘H2O’). Used for creating numberdens_XX.inp. Default is ‘CO’.

  • dust_density (bool, optional) – If True, write a dust_density.inp file. Default is False.

  • dust_temperature (bool, optional) – If True, write a dust_temperature.inp file. Default is False.

  • numberdens (bool, optional) – If True, write a numberdens_XX.inp file for the given species. Default is False.

run_localfield(nphot_mono=None, write_mcmono=False, run=True, **keywords)[source]#

Compute the local mean radiation field with RADMC-3D monochromatic Monte Carlo.

Optionally writes the monochromatic wavelength file, runs the RADMC-3D monochromatic Monte Carlo, and reads the resulting mean_intensity.out into self.grid.localfield.

Parameters:
  • nphot_mono (int or None, optional) – Number of monochromatic photon packages. If None, RADMC-3D uses its default. Default is None.

  • write_mcmono (bool, optional) – If True, write the mcmono_wavelength_micron.inp file before running. Default is False.

  • run (bool, optional) – If True, execute the RADMC-3D monochromatic run. Set to False to skip execution and only read existing output. Default is True.

  • **keywords – Additional keyword arguments forwarded to write_continuum.

run_thermal_radmc3d(verbose=True, timelimit=7200, nice=None, **keywords)[source]#

Run the RADMC-3D thermal Monte Carlo dust radiative transfer.

Parameters:
  • verbose (bool, optional) – If True, print RADMC-3D output to stdout. Default is True.

  • timelimit (int, optional) – Maximum wall-clock time in seconds before the run is killed. Default is 7200 (2 hours).

  • nice (int or None, optional) – Unix nice priority for the RADMC-3D process. Default is None.

  • **keywords – Additional keyword arguments (currently unused).

run_chemistry(verbose=True, timelimit=None)[source]#

Run the NMGC gas-grain chemistry simulation.

Calls nmgc run in self.chempath, which must already contain all required NMGC input files. Set self.nmgc_cmd beforehand if the nmgc binary is not on PATH.

Parameters:
  • verbose (bool, optional) – If True, NMGC output streams to the terminal. If False, it is redirected to <chempath>/nmgc.out. Default is True.

  • timelimit (float or None, optional) – Timeout in seconds. None means no timeout. Default is None.

run_chemistry_custompath(custom_path, verbose=True, timelimit=None)[source]#

Run the NMGC gas-grain chemistry simulation.

Calls nmgc run in custom_path, which must already contain all required NMGC input files. Set self.nmgc_cmd beforehand if the nmgc binary is not on PATH.

Parameters:
  • verbose (bool, optional) – If True, NMGC output streams to the terminal. If False, it is redirected to <chempath>/nmgc.out. Default is True.

  • timelimit (float or None, optional) – Timeout in seconds. None means no timeout. Default is None.

run_localfield_radmc3d(nphot_mono=None, verbose=True, timelimit=7200)[source]#

Run the RADMC-3D monochromatic Monte Carlo for the local radiation field.

Parameters:
  • nphot_mono (int or None, optional) – Number of monochromatic photon packages. If None, RADMC-3D uses its default. Default is None.

  • verbose (bool, optional) – If True, print RADMC-3D output to stdout. Default is True.

  • timelimit (int, optional) – Maximum wall-clock time in seconds. Default is 7200 (2 hours).

run_image_radmc3d(npix=300, lambda_micron=None, iline=None, incl=None, verbose=True)[source]#

Run RADMC-3D to produce a synthetic image.

Parameters:
  • npix (int, optional) – Number of pixels per side of the image. Default is 300.

  • lambda_micron (float or None, optional) – Wavelength of the image in microns. Default is None.

  • iline (int or None, optional) – Line transition index. Default is None.

  • incl (float or None, optional) – Inclination angle in degrees. Default is None.

  • verbose (bool, optional) – If True, print RADMC-3D output to stdout. Default is True.

write_continuum(dens=False, grid=False, opac=False, control=False, stars=False, wave=False, mcmono=False, ext=False)[source]#

Write RADMC-3D input files for dust continuum radiative transfer.

Each boolean flag controls whether the corresponding input file is written. If no flags are set to True, a warning is printed. The thermal directory is created if it does not exist.

Parameters:
  • dens (bool, optional) – Write dust_density.inp. Default is False.

  • grid (bool, optional) – Write amr_grid.inp. Default is False.

  • opac (bool, optional) – Write dustopac.inp (reads existing dustkap* files in the thermal directory). Default is False.

  • control (bool, optional) – Write radmc3d.inp control file. Default is False.

  • stars (bool, optional) – Write stars.inp with stellar properties. Default is False.

  • wave (bool, optional) – Write wavelength_micron.inp. Default is False.

  • mcmono (bool, optional) – Write mcmono_wavelength_micron.inp for monochromatic Monte Carlo. Default is False.

  • ext (bool, optional) – Write external_source.inp for the interstellar radiation field. Default is False.

write_line(control=False, line=False, gasvelocity=False, gastemp=False, microturb=False, line_format='leiden', species='CO', star_mass=1)[source]#

Write RADMC-3D input files for line radiative transfer.

Parameters:
  • control (bool, optional) – Write radmc3d.inp control file. Default is False.

  • line (bool, optional) – Write lines.inp molecular line data file. Default is False.

  • gasvelocity (bool, optional) – Write gas_velocity.inp assuming Keplerian rotation. Default is False.

  • gastemp (bool or str, optional) – Controls gas temperature handling.

    • False (default): no gas_temperature.inp is written. Use pipe.thermalparams.control.tgas_eq_tdust = 1 before write_line(control=True) to let RADMC-3D equate gas and dust temperatures internally.

    • '1D_static': read the gas temperature column Tg from each <radius>AU/1D_static.dat file in the chemistry directory, remap it to the spherical RADMC-3D grid via bilinear interpolation (the same method as convert_nautilus2radmc()), and write gas_temperature.inp. This reproduces the gas temperature that was actually fed into Nautilus and is independent of the chemical timestep.

  • microturb (bool, optional) – Write microturbulence file (not yet implemented). Default is False.

  • line_format (str, optional) – Format of the molecular data file (e.g., ‘leiden’). Default is ‘leiden’.

  • species (str, optional) – Chemical species for the line file. Default is ‘CO’.

  • star_mass (float, optional) – Stellar mass in solar masses, used for Keplerian velocity computation. Default is 1.

write_nautilus(sizes=array([[0.1]]), uv_ref=3400, nH_to_AV_conversion=1.6e+21, rsingle=0.1, dtogas=0.01, ref_radius=100, stop_time=3000000.0, nb_outputs=64, tunneling=1, is_h2_formation_rate=0, min_gas_density=1.0, min_av=0.01, max_uv=None, cap_uv_floor=True, cut_cap=True, max_inv_ab=None, exclude_bins=None, temp_gas='dust', static=True, param=True, element=True, abundances='atomic', network=True, multi_grain=True, tempdecoup=True, coupling_dens=False, coupling_temp=True, coupling_av=True, **keywords)[source]#

Write Nautilus chemistry input files for each radial point.

Reads the RADMC-3D thermal output (grid, dust density, dust temperature, local radiation field), couples the physical quantities onto the chemistry grid, and writes one set of Nautilus input files per radial grid point inside the chemistry directory. The existing chemistry directory is removed and recreated.

When coupling_dens is True the code derives dust and gas number densities from the RADMC-3D dust density rather than from an analytically added disk/envelope structure.

Parameters:
  • sizes (ndarray, optional) – Grain size array in microns, shape (n_structures, n_bins). Default is np.array([[0.1]]).

  • uv_ref (float, optional) – Reference UV field strength in Habing units. Default is 3400.

  • nH_to_AV_conversion (float, optional) – Column density to visual extinction conversion factor in cm^-2. Default is 1.6e21.

  • rsingle (float, optional) – Single representative grain radius in microns. Default is 0.1.

  • dtogas (float, optional) – Dust-to-gas mass ratio. Default is 1e-2.

  • ref_radius (float, optional) – Reference radius in AU for the UV scaling. Default is 100.

  • stop_time (float, optional) – Chemical evolution stop time in years. Default is 3e6.

  • nb_outputs (int, optional) – Number of time outputs written by Nautilus. Default is 64.

  • tunneling (int, optional) – Tunneling flag for Nautilus (0 or 1). Default is 1.

  • is_h2_formation_rate (int, optional) – H2 formation rate flag for Nautilus. Default is 0.

  • min_gas_density (float, optional) – Minimum gas number density in cm^-3 enforced in the chemistry input. Default is 1.

  • min_av (float, optional) – Minimum visual extinction in mag enforced in the chemistry input. Default is 1e-2.

  • max_uv (float or None, optional) – Maximum UV field value. If None, no cap is applied. Default is None.

  • cap_uv_floor (bool, optional) – If True (default), cap the UV factor at 10 Habing for cells at the gas density floor. Set to False to keep the full geometric UV value in those cells (removes the discontinuity at the floor-density boundary visible when plotting the uv column).

  • temp_gas (str, optional) – Gas temperature source: ‘dust’ uses the area-weighted dust temperature, ‘param’ uses a parametrized gas temperature added to the grid. Default is ‘dust’.

  • static (bool, optional) – Write the 1D_static.dat (or multi-grain equivalent) input file. Default is True.

  • param (bool, optional) – Write the Nautilus parameters.in file. Default is True.

  • element (bool, optional) – Write the element.in file. Default is True.

  • abundances (str, optional) – Initial abundances preset name (e.g., ‘atomic’). Default is ‘atomic’ for solar-composition. It can also be a filepath.

  • network (bool or str, optional) – Controls network file copying. False skips it entirely. True (default) copies from the built-in astromugs/nautilus/network/ directory. A string path copies from that directory instead (e.g. network='/path/to/my_network').

  • multi_grain (bool, optional) – If True, use multi-grain chemistry mode (NMGC). Default is True.

  • tempdecoup (bool, optional) – If True, compute a separate area-weighted dust temperature from the full size distribution. If False, use the single-bin temperature. Default is True.

  • coupling_dens (bool, optional) – If True, derive dust and gas densities from the RADMC-3D dust density file. Default is False.

  • coupling_temp (bool, optional) – If True, interpolate dust temperature from the RADMC-3D output onto the chemistry grid. Default is True.

  • coupling_av (bool, optional) – If True, compute visual extinction from the local radiation field. Default is True.

  • **keywords – Any keyword argument accepted by parameters_nmgc() can be passed here and will be forwarded verbatim to that function. This lets you override any entry in the parameters.in file without subclassing. See Other Parameters below for the full list.

Other Parameters:
  • phase (int, optional) – Chemical phase model. 0 = 2-phase, 1 = 3-phase (default 1).

  • cr_ionisation_rate (float, optional) – Cosmic-ray ionisation rate [s⁻¹]. Default 1.3e-17.

  • x_ionisation_rate (float, optional) – X-ray ionisation rate [s⁻¹]. Default 0.0.

  • is_photodesorb (int, optional) – Photodesorption of ices: 1 = on (default), 0 = off.

  • is_crid (int, optional) – Cosmic-ray induced diffusion (CRID): 1 = on, 0 = off (default).

  • is_er_cir (int, optional) – Eley-Rideal and complex-induced reactions: 1 = on, 0 = off (default).

  • is_absorption_h2 (int, optional) – H₂ self-shielding (Lee & Herbst 1996): 1 = on (default).

  • is_absorption_co (int, optional) – CO self-shielding method. 1 = Lee & Herbst (1996), 2 = Visser et al. (2009) (default 2).

  • is_absorption_n2 (int, optional) – N₂ self-shielding (Li et al. 2013): 1 = on (default).

  • nb_active_lay (float, optional) – Number of chemically active grain surface layers. Default 2.0.

  • diff_binding_ratio_surf (float, optional) – Ratio of diffusion barrier to binding energy for surface species. Default 0.4.

  • diff_binding_ratio_mant (float, optional) – Ratio of diffusion barrier to binding energy for mantle species. Default 0.8.

  • cr_peak_grain_temp (float, optional) – Peak grain temperature reached during a cosmic-ray heating event [K]. Default 70.0.

  • cr_peak_duration (float, optional) – Duration of a cosmic-ray heating peak [s]. Default 1e-5.

  • Fe_ionisation_rate (float, optional) – Cosmic Fe-ion–grain encounter rate [s⁻¹ grain⁻¹]. Default 3e-14.

  • sticking_coeff_neutral (float, optional) – Sticking coefficient for neutral species. Default 1.0.

  • sticking_coeff_positive (float, optional) – Sticking coefficient for positively charged species. Default 0.0.

  • sticking_coeff_negative (float, optional) – Sticking coefficient for negatively charged species. Default 0.0.

  • surface_site_density (float, optional) – Surface site density on a grain [cm⁻²]. Default 8e14.

  • chemical_barrier_thickness (float, optional) – Grain reaction activation energy barrier width [cm]. Default 1e-8.

  • relative_tolerance (float, optional) – Relative tolerance of the ODE solver. Default 1e-4.

  • output_type (str, optional) – Output time spacing: 'log' (default) or 'linear'.

  • start_time (float, optional) – First output time [yr]. Default 1.0.

  • modify_rate_flag (int, optional) – Rate modification flag. 0 = none (default), 1 = H only, 2 = H + H₂, 3 = all species.

  • ED_H2 (float, optional) – H₂ binding energy on itself [K]. Default 23.0.

  • vib_to_dissip_freq_ratio (float, optional) – Ratio of surface-bond vibrational frequency to energy dissipation frequency (RRK desorption mechanism). Default 1e-2.

class astromugs.pipeline.Grid(params: DiskParams, wave: WaveParams)[source]#

Bases: object

Spatial and wavelength grid for young stellar object modeling.

Holds the coordinate system, physical quantities (density, temperature, radiation field), and optional chemistry sub-grids used by radiative transfer and chemical codes.

params#

Disk/envelope structural parameters (radii, resolution, etc.).

Type:

DiskParams

wave#

Wavelength grid parameters.

Type:

WaveParams

density#

Total (gas + dust) density components, in g/cm^3.

Type:

list of ndarray

dustdensity#

Dust density components for radiative transfer, in g/cm^3.

Type:

list of ndarray

gasdensity_chem#

Gas density components for chemistry, in g/cm^3.

Type:

list of ndarray

dustdensity_chem#

Dust density components for chemistry, in g/cm^3.

Type:

list of ndarray

dustdensity_single_chem#

Single-grain-population dust density for chemistry, in g/cm^3.

Type:

list of ndarray

hg_chem#

Gas scale height arrays for the chemistry grid, in AU.

Type:

list of ndarray

tgas_chem#

Gas temperature arrays for the chemistry grid, in K.

Type:

list of ndarray

temperature#

Dust temperature components, in K.

Type:

list of ndarray

localfield#

Local radiation field components.

Type:

list of ndarray

avz#

Vertical visual extinction components, in mag.

Type:

list of ndarray

stars#

Stellar source objects.

Type:

list

isrf#

Interstellar radiation field components.

Type:

list

dust#

Dust opacity/property objects.

Type:

list

accretionheating#

Viscous accretion heating rate components.

Type:

list of ndarray

chemradii#

Radial coordinate arrays imported from existing chemistry models, in AU.

Type:

list of ndarray

chemparam#

Parameter sets imported from existing chemistry models.

Type:

list

chemmodel#

Chemical abundance grids keyed by species name.

Type:

dict

add_star(star)[source]#

Append a stellar source to the grid.

Parameters:

star (object) – Stellar source object containing luminosity, temperature, etc.

add_isrf(isrf)[source]#

Append an interstellar radiation field component.

Parameters:

isrf (object) – Interstellar radiation field specification.

add_temperature(temperature)[source]#

Append a dust temperature component.

Parameters:

temperature (ndarray) – Dust temperature array, in K.

add_localfield(localfield)[source]#

Append a local radiation field component.

Parameters:

localfield (ndarray) – Local radiation field array.

add_density(density)[source]#

Append a total density component.

Parameters:

density (ndarray) – Total (gas + dust) density array, in g/cm^3.

add_dustdensity(density)[source]#

Append a dust density component for radiative transfer.

Parameters:

density (ndarray) – Dust density array, in g/cm^3.

add_dustdensity_chem(density)[source]#

Append a dust density component for chemistry.

Parameters:

density (ndarray) – Dust density array for the chemistry grid, in g/cm^3.

add_dustdensity_single_chem(density)[source]#

Append a single-grain-population dust density for chemistry.

Parameters:

density (ndarray) – Single-grain dust density array for the chemistry grid, in g/cm^3.

add_gasdensity_chem(density)[source]#

Append a gas density component for chemistry.

Parameters:

density (ndarray) – Gas density array for the chemistry grid, in g/cm^3.

add_gastemperature_chem(gas_temperature)[source]#

Append a gas temperature component for chemistry.

Parameters:

gas_temperature (ndarray) – Gas temperature array for the chemistry grid, in K.

add_hg_chem(hg)[source]#

Append a gas scale height array for chemistry.

Parameters:

hg (ndarray) – Gas scale height array, in AU.

add_avz(av_z)[source]#

Append a vertical visual extinction component.

Parameters:

av_z (ndarray) – Vertical visual extinction array, in mag.

add_dust(dust)[source]#

Append a dust opacity/property object.

Parameters:

dust (object) – Dust opacity or property specification.

add_accretionheating(q_visc)[source]#

Append a viscous accretion heating rate component.

Parameters:

q_visc (ndarray) – Viscous heating rate array.

add_existingchemradii(existingchemradii)[source]#

Append radial coordinates from an existing chemistry model.

Parameters:

existingchemradii (ndarray) – Array of radial and vertical grid points from an existing chemistry model, in AU.

add_existingchemparam(existingchemparam)[source]#

Append parameters from an existing chemistry model.

Parameters:

existingchemparam (object) – Parameter set from an existing chemistry model.

add_existingchemmodel(existingchemmodel, species)[source]#

Store abundance data from an existing chemistry model for a species.

Parameters:
  • existingchemmodel (ndarray) – Abundance grid for the given species.

  • species (str) – Chemical species name used as the dictionary key.

set_cartesian_grid(xmin, xmax, nx)[source]#

Build a uniform Cartesian grid and return edges and cell centres.

The same range is used for all three axes (x, y, z).

Parameters:
  • xmin (float) – Minimum coordinate value, in AU.

  • xmax (float) – Maximum coordinate value, in AU.

  • nx (int) – Number of grid edges along each axis.

Returns:

  • edges (ndarray, shape (3, nx)) – Cell edge coordinates stacked as (x, y, z).

  • centres (ndarray, shape (3, nx-1)) – Cell centre coordinates stacked as (w1, w2, w3).

set_spherical_grid(r_edge=None, theta_edge=None, phi_edge=None, log=True)[source]#

Set the spherical grid.

If edge arrays are provided (e.g. read from an existing amr_grid.inp), use them directly. Otherwise, compute edges from the DiskParams (rin, rout, nr, ntheta, nphi).

Parameters:
  • r_edge (array-like, optional) – Radial cell edges in au. If None, computed from params.

  • theta_edge (array-like, optional) – Polar cell edges in radians. If None, computed from params.

  • phi_edge (array-like, optional) – Azimuthal cell edges in radians. If None, computed from params.

  • log (bool) – Use logarithmic spacing for radial edges (only when computing from params).

set_chemdisk_grid(r, max_H=4, nz_chem=64, stretch=1.0)[source]#

Build a vertical chemistry grid for a disk model.

The vertical coordinate runs from max_H scale heights down to the midplane. Spacing is uniform by default; setting stretch redistributes the same number of points so that resolution is concentrated near the midplane or near the disk surface.

Parameters:
  • r (array_like) – Radial positions, in AU.

  • max_H (float, optional) – Upper limit of the grid expressed in gas scale heights.

  • nz_chem (int, optional) – Number of vertical grid points (same at all radii).

  • stretch (float, optional) – Power-law exponent controlling the vertical spacing. stretch=1.0 (default) gives uniform spacing. stretch>1.0 concentrates points near the midplane (z=0), useful when high chemical resolution is needed inside the disk. stretch<1.0 concentrates points near the disk surface (z=max_H), useful when the atmosphere needs finer sampling.

set_chem_grid(r, z0=0, zmax=None, msize=None, nbcells=70, stretch=1.0)[source]#

Build a custom spatial grid for chemistry (disk, envelope, etc.).

Two modes are available. If zmax is given, the vertical extent is uniform at all radii. If msize is given, the maximum altitude at each radius follows a spherical envelope boundary. Vertical coordinates are stored in decreasing order as required by Nautilus.

Parameters:
  • r (ndarray) – 1-D array of radial positions, in AU. Must lie within the RADMC-3D model domain.

  • z0 (float, optional) – Minimum altitude, in AU.

  • zmax (float, optional) – Maximum altitude applied uniformly at all radii, in AU.

  • msize (float, optional) – Model size (sphere radius) in AU. When provided, the maximum altitude at each radius is computed as sqrt(msize^2 - r^2).

  • nbcells (int, optional) – Number of vertical cells (same for all radii).

  • stretch (float, optional) – Power-law exponent controlling the vertical spacing. stretch=1.0 (default) gives uniform spacing. stretch>1.0 concentrates points near the midplane (z=z0), useful when high chemical resolution is needed inside the disk. stretch<1.0 concentrates points near the surface (z=zmax), useful when the atmosphere needs finer sampling.

set_wavelength_grid(log=True)[source]#

Build the wavelength grid used by the radiative transfer.

Parameters:

log (bool, optional) – If True, use logarithmic spacing; otherwise linear spacing.

set_mcmonowavelength_grid(log=True)[source]#

Build the monochromatic Monte Carlo wavelength grid.

Parameters:

log (bool, optional) – If True, use logarithmic spacing; otherwise linear spacing.

Modeling#

astromugs.modeling.Disk(params[, dust])

Static flared disk model for radiative transfer and chemistry simulations.

astromugs.modeling.Star([mass, luminosity, ...])

astromugs.modeling.Envelope(params[, dust])

Nautilus interface#

Dust models#

Plotting#

Utilities#