![]() |
The Open FUSION Toolkit 26.9
An open-source framework for fusion and plasma science and engineering
|
Coupled MUG/TokaMaker (mugtok_td) time-dependent simulation.
Built on top of an existing TokaMaker instance, whose mesh, finite-element representation, and active equilibrium are reused. The poloidal flux (psi) and coil currents live in the TokaMaker equilibrium; the MHD fields (velocity, pressure, F) live in this object.
Public Member Functions | |
| __del__ (self) | |
| Free the Fortran-side object (the borrowed equilibrium/mesh are left intact). | |
| __init__ (self, tokamaker) | |
| Create a combined MUG/TokaMaker simulation from an existing TokaMaker instance. | |
| get_field (self, name, cell_centered=False) | |
| Get the present values of a field at node points. | |
| plot_field (self, fig, ax, name, colormap=None, scale=1.0, clabel=None, colorbar=True, shared_scale=False, **kwargs) | |
| Plot a field on the mesh. | |
| save_to_dict (self, cell_centered=False) | |
| Collect every field at the current time into a single dictionary. | |
| setup (self, dt, lin_tol, nl_tol, mhd_dict, incomp=True, allow_toroidal_flow=False) | |
| Set up the coupled solver. | |
| step (self, time, dt, coil_currents=None) | |
| Advance the coupled solution by one timestep. | |
Public Attributes | |
| lc = None | |
| Triangle list [nc,3] for the main order fields (same as TokaMaker.lc). | |
| pressure_lc = None | |
| Triangle list [nc_p,3] for the (order-1) pressure field. | |
| pressure_r = None | |
| Node coordinates [np_p,3] for the (order-1) pressure field. | |
| pressure_reg = None | |
| Per-cell region IDs [nc_p] for the (order-1) pressure mesh. | |
| r = None | |
| Node coordinates [np,3] for the main order fields. | |
| reg = None | |
| Per-cell region IDs [nc] for the main order fields (same as TokaMaker.reg). | |
Protected Member Functions | |
| _get_current (self) | |
| Current density in the conducting structures, J [A/m^2]. | |
| _get_gradf (self) | |
| Fetch the projected poloidal gradient of F, (dF/dR, dF/dZ), at node points. | |
| _get_mug_field (self, field_id) | |
| Fetch a MUG-owned field (by augmented-vector block index) at node points. | |
| _load_pmesh (self) | |
| Load and cache the order-1 (pressure) plotting mesh. | |
| _zz_doxygen_dummy (self) | |
| _zz_doxygen_dummy (self) | |
Protected Attributes | |
| _mhd_dict = mhd_dict | |
| Per-region MHD properties as supplied to setup(). | |
| _mhd_flag = None | |
| Per-region MHD flag [nreg] (1 = MHD region); set by setup(). | |
| _oft_env = tokamaker._oft_env | |
| OpenFUSIONToolkit environment (See OFT_env). | |
| _plc = None | |
| _pr = None | |
| Cached order-1 (pressure) plotting mesh (loaded on first access). | |
| _preg = None | |
| _ptr = ctypes.c_void_p() | |
| C pointer to the Fortran-side combined simulation object. | |
| _tokamaker = tokamaker | |
| Parent TokaMaker object (mesh/equilibrium/coils borrowed from it). | |
| __init__ | ( | self, | |
| tokamaker ) |
| __del__ | ( | self | ) |
Free the Fortran-side object (the borrowed equilibrium/mesh are left intact).
|
protected |
Current density in the conducting structures, J [A/m^2].
Poloidal components come from the (projected) grad(F): J_pol = (grad F x phi_hat)/(mu0 R); the toroidal component and the conductor mask come from the TokaMaker equilibrium via calc_conductor_currents(psi).
|
protected |
Fetch the projected poloidal gradient of F, (dF/dR, dF/dZ), at node points.
|
protected |
Fetch a MUG-owned field (by augmented-vector block index) at node points.
|
protected |
Load and cache the order-1 (pressure) plotting mesh.
|
protected |
|
protected |
| get_field | ( | self, | |
| name, | |||
| cell_centered = False ) |
Get the present values of a field at node points.
| name | One of 'velocity', 'pressure', 'F' (MUG-owned), 'psi', or 'current density' |
| cell_centered | If True, return one value per mesh cell (averaged over the cell's vertices) instead of one per node |
Returned units by field:
The per-cell masks let each field be plotted only where it is physically defined:
| plot_field | ( | self, | |
| fig, | |||
| ax, | |||
| name, | |||
| colormap = None, | |||
| scale = 1.0, | |||
| clabel = None, | |||
| colorbar = True, | |||
| shared_scale = False, | |||
| ** | kwargs ) |
Plot a field on the mesh.
Wraps get_field and draws it with tripcolor, applying the field's mask so only the region where it is defined is shaded.
Vector fields are drawn as three separate colour maps, one per component, so ax must hold three axes for those.
| fig | Figure the axes belong to (needed for the colorbars) |
| ax | Axes to draw on. Scalar fields ('pressure', 'F', 'psi') take a single Axes; vector fields ('velocity', 'current density') take a sequence of three |
| name | Field name, as accepted by get_field |
| colormap | Colormap to use. By default 'velocity' and 'current density' use 'seismic' with limits symmetric about zero, since their sign carries direction; every other field uses 'viridis' over its own range. |
| scale | Multiplier applied to the values before plotting. Set clabel to match: e.g. scale=1.0E-6, clabel=r'$J$ [MA/m$^2$]'. |
| clabel | Label for the colorbars. None builds one per component from the field name and its base units. |
| colorbar | Draw colorbars (default True) |
| shared_scale | For vector fields, put all three components on a common colour scale so the panels are directly comparable, and draw a single colorbar. (default False) |
| save_to_dict | ( | self, | |
| cell_centered = False ) |
Collect every field at the current time into a single dictionary.
| cell_centered | If True, average each field over its cell vertices to give one value per cell. |
| setup | ( | self, | |
| dt, | |||
| lin_tol, | |||
| nl_tol, | |||
| mhd_dict, | |||
| incomp = True, | |||
| allow_toroidal_flow = False ) |
Set up the coupled solver.
| dt | Timestep [s] |
| lin_tol | Linear solver tolerance |
| nl_tol | Non-linear solver tolerance |
| mhd_dict | Dictionary of regions where the MHD (MUG) solve is active, keyed by region name. Each entry must provide: 'density' mass density [kg/m^3] 'viscosity' dynamic viscosity [Pa-s] e.g. {'CHANNEL': {'density': 9.4E3, 'viscosity': 1.5E-3}} Every named region must also be a TokaMaker conducting region, since that is where its resistivity comes from. May be empty, in which case no region is evolved by MUG. |
| incomp | Use incompressible flow (default: True). Compressible flow (incomp=False) is not currently supported and will throw an error. |
| allow_toroidal_flow | Allow toroidal (phi) flow in the MHD regions (default:False) |
| step | ( | self, | |
| time, | |||
| dt, | |||
| coil_currents = None ) |
Advance the coupled solution by one timestep.
| time | Time at the start of the step [s] |
| dt | Timestep size [s] |
| coil_currents | Coil currents as a dict of name->[A] (if None, the equilibrium's present currents are used) |
|
protected |
Per-region MHD properties as supplied to setup().
|
protected |
Per-region MHD flag [nreg] (1 = MHD region); set by setup().
|
protected |
OpenFUSIONToolkit environment (See OFT_env).
|
protected |
|
protected |
Cached order-1 (pressure) plotting mesh (loaded on first access).
|
protected |
|
protected |
C pointer to the Fortran-side combined simulation object.
|
protected |
Parent TokaMaker object (mesh/equilibrium/coils borrowed from it).
| lc = None |
Triangle list [nc,3] for the main order fields (same as TokaMaker.lc).
| pressure_lc = None |
Triangle list [nc_p,3] for the (order-1) pressure field.
| pressure_r = None |
Node coordinates [np_p,3] for the (order-1) pressure field.
| pressure_reg = None |
Per-cell region IDs [nc_p] for the (order-1) pressure mesh.
| r = None |
Node coordinates [np,3] for the main order fields.
These are the same tessellated node points as the parent TokaMaker.r, so the order-2 fields (and psi) can be plotted with self.r/self.lc.
| reg = None |
Per-cell region IDs [nc] for the main order fields (same as TokaMaker.reg).