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
circuit_coil_forces
cached
property
¶
[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
¶
[T/A] with shape (ncirc X nr X nz), Circuit flux density (B-field) tables, r- and z- components
circuit_flux_tables
cached
property
¶
[Wb/A] with shape (ncirc X nr X nz), Circuit flux tables
circuit_mutual_inductances
cached
property
¶
[H] with shape (ncirc X ncirc), Circuit-circuit mutual inductance
circuit_resistances
cached
property
¶
[ohm] with shape (ncirc X ncirc), Resistance of circuits as diagonal matrix
circuit_structure_mode_mutual_inductances
cached
property
¶
[H] with shape (ncirc X nmodes), Circuit-to-structure-mode mutual inductance
circuit_structure_mutual_inductances
cached
property
¶
[H] with shape (ncirc X nstruct), Circuit-structure mutual inductance
coil_coil_forces
cached
property
¶
[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
¶
([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
¶
[T/A] with shape (ncoils X nr X nz), Coil flux density (B-field) tables, r- and z- components
coil_flux_tables
cached
property
¶
[Wb/A] with shape (ncoils X nr X nz), Coil flux tables
coil_index_dict
cached
property
¶
A map from coil names to indices in tables and self.coils
coil_mutual_inductances
cached
property
¶
[H] with shape (ncoil X ncoil), Coil-coil mutual inductance
coil_resistances
cached
property
¶
[ohm] with shape (ncoil X ncoil), Resistance of coils as diagonal matrix
coil_structure_mode_mutual_inductances
cached
property
¶
[H] with shape (ncoil X nmodes), Coil-to-structure-mode mutual inductance
coil_structure_mutual_inductances
cached
property
¶
[H] (ncoil X nstruct) Coil-structure mutual inductance
extent
cached
property
¶
[m] The (rmin, rmax, zmin, zmax) extent of the grid cell centers
extent_for_plotting
cached
property
¶
[m] The (rmin, rmax, zmin, zmax) extent of the grid cell edges
flux_solver
cached
property
¶
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
¶
List of full flux loop sensors
grids
cached
property
¶
[m] with shape ((nr), (nz)) 1D grids
gridspec
property
¶
Exact alternative to min_extent. Only one of min_extent or gridspec should be provided.
limiter
cached
property
¶
[m] Plasma-facing first-wall contour defined as a closed path around the plasma
limiter_mask
cached
property
¶
Mask with shape (nr, nz) indicating which parts of the mesh are inside the limiter
max_nmodes
property
¶
Maximum number of (eigen)modes to keep in the passive structure model reduction
meshes
cached
property
¶
[m] Shape: ((nr, nz), (nr, nz)) 2D meshgrids over domain
min_extent
property
¶
[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
¶
Choice of passive structure state-space model dimensionality reduction method
ods
property
¶
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
¶
List of partial flux loop sensors
plasma_coil_forces
cached
property
¶
[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
¶
[Wb/A] with shape (nr*nz X nr X nz), Plasma flux tables
poloidal_field_probes
cached
property
¶
List of poloidal B-field probe sensors
show_prog
property
¶
Whether terminal progressbar will be displayed during some calcs
structure_coil_forces
cached
property
¶
[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
¶
[T/A] with shape (nstruct X nr X nz), Structure flux density (B-field) tables, r- and z- components
structure_flux_tables
cached
property
¶
[Wb/A] with shape (nstruct X nr X nz), Structure flux tables
structure_mode_coil_forces
cached
property
¶
[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
¶
[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
¶
[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
¶
[Wb/A] with shape (nmodes X nr X nz), Structure mode flux tables
structure_mode_mutual_inductances
cached
property
¶
[H] with shape (nmodes X nmodes), Structure mode-mode mutual inductance
structure_mode_resistances
cached
property
¶
[H] with shape (ncoil X nstruct), Coil-structure mutual inductance
structure_model_reduction
cached
property
¶
[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
¶
[H] with shape (nstruct X nstruct), Structure-structure mutual inductance
structure_resistances
cached
property
¶
[ohm] (nstruct X nstruct) Resistance of structure fils, diagonal
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
calc_plasma_flux_density ¶
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
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
get_coil_index_dict ¶
Get a map from coil names to indices in tables and self.coils
get_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
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |