Skip to content

API

device_inductance.DeviceInductance

DeviceInductance(
    ods: ODS,
    *,
    show_prog: bool = False,
    max_nmodes: int = 40,
    min_extent: Extent | None = None,
    gridspec: GridSpec | None = None,
    dxgrid: tuple[float, float] = (0.05, 0.05),
    model_reduction_method: Literal[
        "eigenmode", "stabilized eigenmode"
    ] = "eigenmode",
    plasma_coil_force_method: Literal[
        "tables", "mask"
    ] = "mask",
    n_radial_slices: int = 30,
    **kwargs,
)

Thin wrapper to provide methods and properties on a device description ODS. Extracts geometries and calculates inductance matrices as well as flux fields and B-fields on the generated regular grid.

Note

The contents of an instance of this class must be treated as immutable, as it relies on caching results to eliminate repeated computations along different paths through the analysis. Do not modify the supplied ODS after initialization or modify any of the values returned from methods or properties of this class!

Parameters:

Name Type Description Default
ods ODS

OMAS data object in the format produced by device_description

required
show_prog bool

Whether to display terminal progress bars during expensive calculations

False
max_nmodes int

Maximum number of structure modes to retain

40
min_extent Extent | None

[m] rmin, rmax, zmin, zmax extent of computational domain. This will be updated during mesh initialization, during which it may be adjusted to satisfy the required spatial resolution.

None
gridspec GridSpec | None

Exact alternative to min_extent. Only one of min_extent or gridspec should be provided.

None
dxgrid tuple[float, float]

[m] spatial resolution of computational grid

(0.05, 0.05)
plasma_coil_force_method Literal['tables', 'mask']

Whether to interpolate B-field on the fully-realized mesh tables, or do direct filament calculations from points inside the limiter mask. Defaults to "mask", which is faster and uses less memory, but only includes nonzero entries inside the limiter, which requires a valid limiter geometry.

'mask'
n_radial_slices int

Number of radial slices to use for chunking large structures. Each slice is centered at the limiter centroid.

30
Source code in src/device_inductance/device.py
def __init__(
    self,
    ods: ODS,
    *,
    show_prog: bool = False,
    max_nmodes: int = 40,
    min_extent: Extent | None = None,
    gridspec: GridSpec | None = None,
    dxgrid: tuple[float, float] = (0.05, 0.05),
    model_reduction_method: Literal["eigenmode", "stabilized eigenmode"] = "eigenmode",
    plasma_coil_force_method: Literal["tables", "mask"] = "mask",
    n_radial_slices: int = 30,
    **kwargs,  # For backwards compatibility with `extent` kwarg only
):
    """
    Attach a new DeviceInductance instance to an existing ODS description.

    Args:
        ods: OMAS data object in the format produced by device_description
        show_prog: Whether to display terminal progress bars during expensive calculations
        max_nmodes: Maximum number of structure modes to retain
        min_extent: [m] rmin, rmax, zmin, zmax extent of computational domain.
                This will be updated during mesh initialization, during which it
                may be adjusted to satisfy the required spatial resolution.
        gridspec: Exact alternative to min_extent. Only one of min_extent or gridspec should be provided.
        dxgrid: [m] spatial resolution of computational grid
        plasma_coil_force_method: Whether to interpolate B-field on the fully-realized mesh tables,
                                  or do direct filament calculations from points inside the limiter mask.
                                  Defaults to "mask", which is faster and uses less memory, but only
                                  includes nonzero entries inside the limiter, which requires a valid
                                  limiter geometry.
        n_radial_slices: Number of radial slices to use for chunking large structures.
                         Each slice is centered at the limiter centroid.
    """
    if not logger_is_set_up():
        logger_setup_default()

    if "extent" in kwargs:
        # Backwards compatibility with `extent` kwarg name only
        log().warning("`extent` input is deprecated; use `min_extent` or `gridspec` instead")
        min_extent = kwargs.pop("extent")

    if len(kwargs) != 0:
        log().warning(f"DeviceInductance init ignoring extra kwargs: {kwargs}")

    self._ods = ods
    self._max_nmodes = max_nmodes
    self._min_extent = min_extent
    self._gridspec = gridspec
    self._dxgrid = dxgrid
    self._model_reduction_method = model_reduction_method
    self._show_prog = show_prog
    self._plasma_coil_force_method = plasma_coil_force_method
    self._n_radial_slices = n_radial_slices

    self.__post_init__()

circuit_coil_forces cached property

circuit_coil_forces: tuple[NDArray[F64], NDArray[F64]]

[N/A^2] with shape (ncirc X ncoils), Circuit-coil force tables, r- and z- components.

Note that analytic force estimates include a variety of sources of error, including geometric differences between analysis and real hardware, discretization error, numerical summation error, and so on. Due to the importance of loads analysis, it is always recommended to double-check force results with at least one other tool, preferably of meaningfully distinct design - for example, cross-check an analytic method with a finite-element method.

Because the accuracy of force estimates depends heavily on problem setup and geometry, no particular claims are made here about the accuracy of the force calculations, and they should never be used for human safety applications.

circuit_flux_density_tables cached property

circuit_flux_density_tables: tuple[
    NDArray[F64], NDArray[F64]
]

[T/A] with shape (ncirc X nr X nz), Circuit flux density (B-field) tables, r- and z- components

circuit_flux_tables cached property

circuit_flux_tables: NDArray[F64]

[Wb/A] with shape (ncirc X nr X nz), Circuit flux tables

circuit_mutual_inductances cached property

circuit_mutual_inductances: NDArray[F64]

[H] with shape (ncirc X ncirc), Circuit-circuit mutual inductance

circuit_resistances cached property

circuit_resistances: NDArray[F64]

[ohm] with shape (ncirc X ncirc), Resistance of circuits as diagonal matrix

circuit_structure_mode_mutual_inductances cached property

circuit_structure_mode_mutual_inductances: NDArray[F64]

[H] with shape (ncirc X nmodes), Circuit-to-structure-mode mutual inductance

circuit_structure_mutual_inductances cached property

circuit_structure_mutual_inductances: NDArray[F64]

[H] with shape (ncirc X nstruct), Circuit-structure mutual inductance

circuits cached property

circuits: list[CoilSeriesCircuit]

Info about coils wired in series

coil_coil_forces cached property

coil_coil_forces: tuple[NDArray[F64], NDArray[F64]]

[N/A^2] with shape (ncoils X ncoils), Coil-coil force tables, r- and z- components.

Note that analytic force estimates include a variety of sources of error, including geometric differences between analysis and real hardware, discretization error, numerical summation error, and so on. Due to the importance of loads analysis, it is always recommended to double-check force results with at least one other tool, preferably of meaningfully distinct design - for example, cross-check an analytic method with a finite-element method.

Because the accuracy of force estimates depends heavily on problem setup and geometry, no particular claims are made here about the accuracy of the force calculations, and they should never be used for human safety applications.

coil_filament_rzn cached property

coil_filament_rzn: list[list[tuple[float, float, float]]]

([m], [m], [dimensionless]) r,z,n of each coil's filaments, where n is number of turns. Provided to prevent repeatedly assembling this representation when evaluating plasma inductances.

coil_flux_density_tables cached property

coil_flux_density_tables: tuple[NDArray[F64], NDArray[F64]]

[T/A] with shape (ncoils X nr X nz), Coil flux density (B-field) tables, r- and z- components

coil_flux_tables cached property

coil_flux_tables: NDArray[F64]

[Wb/A] with shape (ncoils X nr X nz), Coil flux tables

coil_index_dict cached property

coil_index_dict: dict[str, int]

A map from coil names to indices in tables and self.coils

coil_mutual_inductances cached property

coil_mutual_inductances: NDArray[F64]

[H] with shape (ncoil X ncoil), Coil-coil mutual inductance

coil_names cached property

coil_names: list[str]

Coil names in the same order as their indices

coil_resistances cached property

coil_resistances: NDArray[F64]

[ohm] with shape (ncoil X ncoil), Resistance of coils as diagonal matrix

coil_structure_mode_mutual_inductances cached property

coil_structure_mode_mutual_inductances: NDArray[F64]

[H] with shape (ncoil X nmodes), Coil-to-structure-mode mutual inductance

coil_structure_mutual_inductances cached property

coil_structure_mutual_inductances: NDArray[F64]

[H] (ncoil X nstruct) Coil-structure mutual inductance

coils cached property

coils: list[Coil]

Info about coil name and filaments

dxgrid property

dxgrid: tuple[float, float]

[m] (dr, dz) grid cell spacing

extent cached property

extent: Extent

[m] The (rmin, rmax, zmin, zmax) extent of the grid cell centers

extent_for_plotting cached property

extent_for_plotting: Extent

[m] The (rmin, rmax, zmin, zmax) extent of the grid cell edges

flux_solver cached property

flux_solver: Callable[[NDArray[F64]], NDArray[F64]]

Linear solver for extracting a flux field from a toroidal current density distribution using a 4th-order finite difference approximation of the Grad-Shafranov PDE. For jtor toroidal current density shaped like (nr, nz), call like psi = flux_solver(rhs) to get psi in [Wb] or [V-s], where rhs = -2.0 * np.pi * mu_0 * rmesh * jtor with the boundary values set to the circular-filament solved flux.

full_flux_loops cached property

full_flux_loops: list[FullFluxLoop]

List of full flux loop sensors

grids cached property

grids: tuple[NDArray[F64], NDArray[F64]]

[m] with shape ((nr), (nz)) 1D grids

gridspec property

gridspec: GridSpec | None

Exact alternative to min_extent. Only one of min_extent or gridspec should be provided.

limiter cached property

limiter: Polygon

[m] Plasma-facing first-wall contour defined as a closed path around the plasma

limiter_mask cached property

limiter_mask: NDArray[F64]

Mask with shape (nr, nz) indicating which parts of the mesh are inside the limiter

max_nmodes property

max_nmodes: int

Maximum number of (eigen)modes to keep in the passive structure model reduction

meshes cached property

meshes: tuple[NDArray[F64], NDArray[F64]]

[m] Shape: ((nr, nz), (nr, nz)) 2D meshgrids over domain

min_extent property

min_extent: Extent

[m] (rmin, rmax, zmin, zmax) minimum extent requested at init. The actual extent of the mesh bounds this minimum, while respecting the required grid resolution (and possibly gridspec) exactly.

model_reduction_method property

model_reduction_method: Literal[
    "eigenmode", "stabilized eigenmode"
]

Choice of passive structure state-space model dimensionality reduction method

n_circuits cached property

n_circuits: int

Number of coil series circuits

n_coils cached property

n_coils: int

Number of coils

n_structure_modes cached property

n_structure_modes: int

Number of structure modes retained

n_structures cached property

n_structures: int

Number of structure filaments

nr cached property

nr: int

Number of r-discretizations in mesh

nz cached property

nz: int

Number of z-discretizations in mesh

ods property

ods: ODS

The ODS description object with the device description. This object must not be edited after the DeviceInductance object is initialized!

partial_flux_loops cached property

partial_flux_loops: list[PartialFluxLoop]

List of partial flux loop sensors

plasma_coil_forces cached property

plasma_coil_forces: tuple[NDArray[F64], NDArray[F64]]

[N/A^2] with shape (nr*nz X ncoils), Mesh-coil force tables, r- and z- components.

Note that analytic force estimates include a variety of sources of error, including geometric differences between analysis and real hardware, discretization error, numerical summation error, and so on. Due to the importance of loads analysis, it is always recommended to double-check force results with at least one other tool, preferably of meaningfully distinct design - for example, cross-check an analytic method with a finite-element method.

Because the accuracy of force estimates depends heavily on problem setup and geometry, no particular claims are made here about the accuracy of the force calculations, and they should never be used for human safety applications.

plasma_flux_tables cached property

plasma_flux_tables: NDArray[F64]

[Wb/A] with shape (nr*nz X nr X nz), Plasma flux tables

poloidal_field_probes cached property

poloidal_field_probes: list[PoloidalFieldProbe]

List of poloidal B-field probe sensors

show_prog property

show_prog: bool

Whether terminal progressbar will be displayed during some calcs

structure_coil_forces cached property

structure_coil_forces: tuple[NDArray[F64], NDArray[F64]]

[N/A^2] with shape (nstruct X ncoils), Structure filament-coil force tables, r- and z- components.

Note that analytic force estimates include a variety of sources of error, including geometric differences between analysis and real hardware, discretization error, numerical summation error, and so on. Due to the importance of loads analysis, it is always recommended to double-check force results with at least one other tool, preferably of meaningfully distinct design - for example, cross-check an analytic method with a finite-element method.

Because the accuracy of force estimates depends heavily on problem setup and geometry, no particular claims are made here about the accuracy of the force calculations, and they should never be used for human safety applications.

structure_flux_density_tables cached property

structure_flux_density_tables: tuple[
    NDArray[F64], NDArray[F64]
]

[T/A] with shape (nstruct X nr X nz), Structure flux density (B-field) tables, r- and z- components

structure_flux_tables cached property

structure_flux_tables: NDArray[F64]

[Wb/A] with shape (nstruct X nr X nz), Structure flux tables

structure_mode_coil_forces cached property

structure_mode_coil_forces: tuple[
    NDArray[F64], NDArray[F64]
]

[N/A^2] with shape (nmodes X ncoils), Structure mode-coil force tables, r- and z- components.

Note that analytic force estimates include a variety of sources of error, including geometric differences between analysis and real hardware, discretization error, numerical summation error, and so on. Due to the importance of loads analysis, it is always recommended to double-check force results with at least one other tool, preferably of meaningfully distinct design - for example, cross-check an analytic method with a finite-element method.

Because the accuracy of force estimates depends heavily on problem setup and geometry, no particular claims are made here about the accuracy of the force calculations, and they should never be used for human safety applications.

structure_mode_eigenvalues cached property

structure_mode_eigenvalues: NDArray[F64]

[s] with shape (neig), eigenvalues of structure model reduction, kept for comparison purposes only, as these are not needed in order to use the structure model reduction.

structure_mode_flux_density_tables cached property

structure_mode_flux_density_tables: tuple[
    NDArray[F64], NDArray[F64]
]

[T/A] with shape (nstruct X nr X nz), Structure mode flux density (B-field) tables, r- and z- components

structure_mode_flux_tables cached property

structure_mode_flux_tables: NDArray[F64]

[Wb/A] with shape (nmodes X nr X nz), Structure mode flux tables

structure_mode_mutual_inductances cached property

structure_mode_mutual_inductances: NDArray[F64]

[H] with shape (nmodes X nmodes), Structure mode-mode mutual inductance

structure_mode_resistances cached property

structure_mode_resistances: NDArray[F64]

[H] with shape (ncoil X nstruct), Coil-structure mutual inductance

structure_model_reduction cached property

structure_model_reduction: NDArray[F64]

[dimensionless] with shape (nstruct X neig), structure model-reduction matrix.

Each column is a normalized vector of unit length.

Apply this transform like a_transformed = a @ tuv for matrices with a.shape == (..., nstruct).

In the case of diagonalized structure filament resistances,

the transform is applied like r_transformed = tuv.T @ (r @ tuv).

structure_mutual_inductances cached property

structure_mutual_inductances: NDArray[F64]

[H] with shape (nstruct X nstruct), Structure-structure mutual inductance

structure_resistances cached property

structure_resistances: NDArray[F64]

[ohm] (nstruct X nstruct) Resistance of structure fils, diagonal

structures cached property

structures: list[PassiveStructureLoop]

Info about structure filaments

calc_plasma_flux

calc_plasma_flux(
    current_density: NDArray[F64],
    calc_method: Literal["table", "solve"] = "table",
) -> NDArray

Calculate the flux field associated with a given plasma current density distribution, either by summing over baked flux tables or by solving the Grad-Shafranov PDE.

This calculation is most commonly used for the plasma, but is in fact more general, and applies to anything with an equivalent toroidal current density and axisymmetry.

Parameters:

Name Type Description Default
current_density NDArray[F64]

[A/m^2], shape (nr, nz), toroidal current density on finite-difference mesh

required
calc_method Literal['table', 'solve']

Whether to sum over baked tables (memory-intensive, but reliable) or perform Grad-Shafranov linear solve (lean, but fragile). Defaults to "table".

'table'

Returns:

Type Description
NDArray

poloidal flux field, [Wb] with shape (nr, nz)

Source code in src/device_inductance/device.py
def calc_plasma_flux(
    self,
    current_density: NDArray[F64],
    calc_method: Literal["table", "solve"] = "table",
) -> NDArray:
    """
    Calculate the flux field associated with a given plasma current density distribution,
    either by summing over baked flux tables or by solving the Grad-Shafranov PDE.

    This calculation is most commonly used for the plasma, but is in fact more general,
    and applies to anything with an equivalent toroidal current density and axisymmetry.

    Args:
        current_density: [A/m^2], shape (nr, nz), toroidal current density on finite-difference mesh
        calc_method: Whether to sum over baked tables (memory-intensive, but reliable)
                     or perform Grad-Shafranov linear solve (lean, but fragile). Defaults to "table".

    Returns:
        poloidal flux field, [Wb] with shape (nr, nz)
    """
    assert current_density.shape == self.meshes[0].shape, (
        "Supplied current density shape does not match tables"
    )
    if calc_method == "table":
        dr, dz = self.dxgrid  # [m] grid discretization
        area = dr * dz  # [m^2] cross-sectional area of grid cell
        psi = np.zeros_like(current_density)  # [Wb]
        for i, jtor_cell in enumerate(current_density.flatten()):  # [A/m^2]
            psi_table_part = self.plasma_flux_tables[i, :, :]  # [Wb/A]
            current = jtor_cell * area  # [A]
            psi += current * psi_table_part  # [Wb]
    elif calc_method == "solve":
        psi = solve_flux_axisymmetric(self.grids, self.meshes, current_density, self.flux_solver)

    return psi  # [Wb]

calc_plasma_flux_density

calc_plasma_flux_density(
    plasma_flux: NDArray[F64],
) -> tuple[NDArray[F64], NDArray[F64]]

Calculate a 4th-order estimate of the plasma's B-field via finite difference on the flux field.

Parameters:

Name Type Description Default
plasma_flux NDArray[F64]

[Wb] with shape (nr, nz), Solved (or summed) plasma poloidal flux

required

Returns:

Type Description
tuple[NDArray[F64], NDArray[F64]]

(br, bz) [T/A] with shape (nr, nz), plasma flux density (B-field)

Source code in src/device_inductance/device.py
def calc_plasma_flux_density(
    self,
    plasma_flux: NDArray[F64],
) -> tuple[NDArray[F64], NDArray[F64]]:
    """
    Calculate a 4th-order estimate of the plasma's B-field via finite
    difference on the flux field.

    Args:
        plasma_flux: [Wb] with shape (nr, nz), Solved (or summed) plasma poloidal flux

    Returns:
        (br, bz) [T/A] with shape (nr, nz), plasma flux density (B-field)
    """
    return calc_flux_density_from_flux(plasma_flux, *self.meshes)

calc_plasma_self_inductance

calc_plasma_self_inductance(
    plasma_current: float,
    plasma_poloidal_flux: NDArray[F64],
    br_plasma: NDArray[F64],
    bz_plasma: NDArray[F64],
    plasma_surface: tuple[NDArray[F64], NDArray[F64]],
    plasma_mask: NDArray[F64],
) -> tuple[float, float, float]

Calculate the plasma's instantaneous poloidal self-inductance from two components addressing the energy stored inside and outside the plasma volume, returning both components and the total because the components are sometimes used for other calcs.

See self.calc_plasma_flux(), self.calc_plasma_flux_density(), and device_inductance.contour.trace_contour() for methods to build the inputs to this function.

This method is of marginal use on its own; because any change in current in the inductive system will result in motion of the plasma current distribution, which changes the plasma self-inductance, the instantaneous self-inductance only provides one of two terms in determining the loop voltage response of the plasma.

With a system of just the plasma and examining only inductive voltage for clarity:

V_loop = I*(dL/dt) + L*(dI/dt) = I*(dL/dI)*(dI/dt) + L*(dI/dt)
                     ^                ^
                     |                |
   This formula's L  -                - This quantity is also needed
                                        for a linear treatment

This extends to coupled systems with multiple inductors in a similar way.

Details of the method used can be found in the docs for cfsem.

Parameters:

Name Type Description Default
plasma_current float

[A] total toroidal current in the plasma

required
plasma_poloidal_flux NDArray[F64]

[Wb] solved plasma flux field

required
br_plasma NDArray[F64]

[T] solved plasma magnetic flux density, R-component

required
bz_plasma NDArray[F64]

[T] solved plasma magnetic flux density, Z-component

required
plasma_surface tuple[NDArray[F64], NDArray[F64]]

[m] r,z coordinates of plasma last closed flux surface (aka LCFS, aka bounding contour)

required
plasma_mask NDArray[F64]

[dimensionless] binary mask of plasma interior points. 1 inside, 0 outside.

required

Returns:

Type Description
tuple[float, float, float]

(Lt, Li, Le) [H] total, internal, and external instantaneous self-inductances

Source code in src/device_inductance/device.py
def calc_plasma_self_inductance(
    self,
    plasma_current: float,
    plasma_poloidal_flux: NDArray[F64],
    br_plasma: NDArray[F64],
    bz_plasma: NDArray[F64],
    plasma_surface: tuple[NDArray[F64], NDArray[F64]],
    plasma_mask: NDArray[F64],
) -> tuple[float, float, float]:
    """
    Calculate the plasma's instantaneous poloidal self-inductance from two components
    addressing the energy stored inside and outside the plasma volume, returning both
    components and the total because the components are sometimes used for other calcs.

    See `self.calc_plasma_flux()`, `self.calc_plasma_flux_density()`, and
    `device_inductance.contour.trace_contour()` for methods to build the inputs
    to this function.

    This method is of marginal use on its own; because any change in current in
    the inductive system will result in motion of the plasma current distribution,
    which changes the plasma self-inductance, the instantaneous self-inductance only
    provides one of two terms in determining the loop voltage response of the plasma.

    With a system of just the plasma and examining only inductive voltage for clarity:

    ```
    V_loop = I*(dL/dt) + L*(dI/dt) = I*(dL/dI)*(dI/dt) + L*(dI/dt)
                         ^                ^
                         |                |
       This formula's L  -                - This quantity is also needed
                                            for a linear treatment
    ```

    This extends to coupled systems with multiple inductors in a similar way.

    Details of the method used can be found in the
    [docs for cfsem.](https://cfsem-py.readthedocs.io/en/latest/python/inductance/#cfsem.self_inductance_distributed_axisymmetric_conductor)

    Args:
        plasma_current: [A] total toroidal current in the plasma
        plasma_poloidal_flux: [Wb] solved plasma flux field
        br_plasma: [T] solved plasma magnetic flux density, R-component
        bz_plasma: [T] solved plasma magnetic flux density, Z-component
        plasma_surface: [m] r,z coordinates of plasma last closed flux surface
                        (aka LCFS, aka bounding contour)
        plasma_mask: [dimensionless] binary mask of plasma interior points. 1 inside, 0 outside.

    Returns:
        (Lt, Li, Le) [H] total, internal, and external instantaneous self-inductances
    """
    total_inductance, internal_inductance, external_inductance = (
        self_inductance_distributed_axisymmetric_conductor(
            current=plasma_current,
            grid=self.grids,
            mesh=self.meshes,
            b_part=(br_plasma, bz_plasma),
            psi_part=plasma_poloidal_flux,
            mask=plasma_mask,
            edge_path=plasma_surface,
        )
    )

    return total_inductance, internal_inductance, external_inductance  # [H]

get_coil_index_dict

get_coil_index_dict() -> dict[str, int]

Get a map from coil names to indices in tables and self.coils

Source code in src/device_inductance/device.py
def get_coil_index_dict(self) -> dict[str, int]:
    """Get a map from coil names to indices in tables and self.coils"""
    # Leaving this function in for backwards compatibility
    return self.coil_index_dict

get_coil_names

get_coil_names() -> list[str]

Get coil names in the same order as their indices

Source code in src/device_inductance/device.py
def get_coil_names(self) -> list[str]:
    """Get coil names in the same order as their indices"""
    # Leaving this function in for backwards compatibility
    return self.coil_names

device_inductance.typical

typical(
    ods: ODS,
    min_extent: Extent | None = None,
    dxgrid: Resolution = (0.0, 0.0),
    max_nmodes: int = 40,
    model_reduction_method: Literal[
        "eigenmode", "stabilized eigenmode"
    ] = "eigenmode",
    show_prog: bool = True,
    plasma_coil_force_method: Literal[
        "tables", "mask"
    ] = "mask",
    n_radial_slices: int = 30,
    gridspec: GridSpec | None = None,
    **kwargs,
) -> TypicalOutputs

Generate a typical set of outputs, notably excluding the plasma flux tables which usually require much more run time than the rest of the outputs combined.

Note: during initialization, the extent of the computational grid may be adjusted to achieve the target spatial resolution. The adjusted extent will always bound the requested extent.

Parameters:

Name Type Description Default
ods ODS

An OMAS object in the format produced by device_description

required
min_extent Extent | None

[m] rmin, rmax, zmin, zmax extent of computational domain. This will be updated during mesh initialization, during which it may be adjusted to satisfy the required spatial resolution.

None
dxgrid Resolution

[m] Spatial resolution of computational grid

(0.0, 0.0)
max_nmodes int

Maximum number of structure modes to keep. Defaults to 40.

40
show_prog bool

Whether to show terminal progress bars. Defaults to True.

True
plasma_coil_force_method Literal['tables', 'mask']

Whether to interpolate B-field on the fully-realized mesh tables, or do direct filament calculations from points inside the limiter mask. Defaults to "mask", which is faster and uses less memory, but only includes nonzero entries inside the limiter, which requires a valid limiter geometry.

'mask'
n_radial_slices int

Number of radial slices to use for chunking large structures. Each slice is centered at the limiter centroid.

30
gridspec GridSpec | None

Exact alternative to min_extent. Only one of min_extent or gridspec should be provided.

None

Returns:

Type Description
TypicalOutputs

A fully-computed set of matrices and tables covering the needs of a typical workflow

Source code in src/device_inductance/__init__.py
def typical(
    ods: ODS,
    min_extent: Extent | None = None,
    dxgrid: Resolution = (0.0, 0.0),
    max_nmodes: int = 40,
    model_reduction_method: Literal["eigenmode", "stabilized eigenmode"] = "eigenmode",
    show_prog: bool = True,
    plasma_coil_force_method: Literal["tables", "mask"] = "mask",
    n_radial_slices: int = 30,
    gridspec: GridSpec | None = None,  # Appended to avoid breaking change
    **kwargs,  # For backwards compatibility with `extent` kwarg only
) -> TypicalOutputs:
    """
    Generate a typical set of outputs,
    notably excluding the plasma flux tables which usually require much more
    run time than the rest of the outputs combined.

    Note: during initialization, the extent of the computational grid may be
    adjusted to achieve the target spatial resolution. The adjusted extent
    will always bound the requested extent.

    Args:
        ods: An OMAS object in the format produced by device_description
        min_extent: [m] rmin, rmax, zmin, zmax extent of computational domain.
                    This will be updated during mesh initialization, during which it
                    may be adjusted to satisfy the required spatial resolution.
        dxgrid: [m] Spatial resolution of computational grid
        max_nmodes: Maximum number of structure modes to keep. Defaults to 40.
        show_prog: Whether to show terminal progress bars. Defaults to True.
        plasma_coil_force_method: Whether to interpolate B-field on the fully-realized mesh tables,
                                  or do direct filament calculations from points inside the limiter mask.
                                  Defaults to "mask", which is faster and uses less memory, but only includes
                                  nonzero entries inside the limiter, which requires a valid limiter geometry.
        n_radial_slices: Number of radial slices to use for chunking large structures. Each slice is centered
                            at the limiter centroid.
        gridspec: Exact alternative to min_extent. Only one of min_extent or gridspec should be provided.

    Returns:
        A fully-computed set of matrices and tables covering the needs of a typical workflow
    """
    if not logger_is_set_up():
        logger_setup_default()

    if "extent" in kwargs:
        # Backwards compatibility with `extent` kwarg name only
        log().warning("`extent` input is deprecated; use `min_extent` or `gridspec` instead")
        min_extent = kwargs.pop("extent")

    device = DeviceInductance(
        ods=ods,
        max_nmodes=max_nmodes,
        min_extent=min_extent,
        gridspec=gridspec,
        dxgrid=dxgrid,
        model_reduction_method=model_reduction_method,
        show_prog=show_prog,
        plasma_coil_force_method=plasma_coil_force_method,
        n_radial_slices=n_radial_slices,
    )

    out = TypicalOutputs(
        device=device,
        extent=device.extent,
        dxgrid=device.dxgrid,
        meshes=device.meshes,
        grids=device.grids,
        extent_for_plotting=device.extent_for_plotting,
        mcc=device.coil_mutual_inductances,
        mss=device.structure_mutual_inductances,
        mcs=device.coil_structure_mutual_inductances,
        r_s=device.structure_resistances,
        r_c=device.coil_resistances,
        r_modes=device.structure_mode_resistances,
        tuv=device.structure_model_reduction,
        nmodes=device.n_structure_modes,
        psi_c=device.coil_flux_tables,
        psi_s=device.structure_flux_tables,
        psi_modes=device.structure_mode_flux_tables,
    )
    return out