The Open FUSION Toolkit 26.9
An open-source framework for fusion and plasma science and engineering
Loading...
Searching...
No Matches
mugtok_f Module Reference

Detailed Description

Fortran part of Python wrapper for coupled MUG/TokaMaker (mugtok_td) functionality.

Data Types

type  mugtok_instance
 MUG/TokaMaker wrapper object for the Python API. More...

Functions/Subroutines

subroutine mugtok_alloc (mugtok_ptr, equil_ptr, error_str)
 Allocate the combined MUG/TokaMaker simulation object from an existing equilibrium.
logical function mugtok_ccast (mugtok_cptr, sim_obj, error_str)
 Cast a C pointer back to the Fortran MUG/TokaMaker wrapper object.
subroutine mugtok_destroy (mugtok_ptr, error_str)
 Destroy the combined simulation object (the borrowed equilibrium/mesh are left intact).
subroutine mugtok_get_field (mugtok_ptr, field_id, vals, error_str)
 Get the current values of a MUG-owned solution field at node points.
subroutine mugtok_get_gradf (mugtok_ptr, gr, gz, error_str)
 Get the projected poloidal gradient of F at node points (dF/dR, dF/dZ).
subroutine mugtok_get_pmesh (mugtok_ptr, np, r_loc, nc, lc_loc, reg_loc, error_str)
 Get the order-1 (pressure) plotting mesh: node coordinates and triangle connectivity.
subroutine mugtok_setup (mugtok_ptr, dt, lin_tol, nl_tol, mhd_flag_ptr, dens_ptr, visc_ptr, nreg, incomp, toroidal_flow, error_str)
 Set up the combined simulation (mesh/FE are reused from the equilibrium's device).
subroutine mugtok_step (mugtok_ptr, curr_ptr, ncoils, time, dt, nl_its, lin_its, nretry, error_str)
 Advance the coupled solution by one timestep.

Function/Subroutine Documentation

◆ mugtok_alloc()

subroutine mugtok_alloc ( type(c_ptr), intent(out) mugtok_ptr,
type(c_ptr), intent(in), value equil_ptr,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Allocate the combined MUG/TokaMaker simulation object from an existing equilibrium.

Parameters
[out]mugtok_ptrPointer to new MUG/TokaMaker object
[in]equil_ptrPointer to active TokaMaker equilibrium (gs_equil)
[out]error_strError string (empty if no error)

◆ mugtok_ccast()

logical function mugtok_ccast ( type(c_ptr), intent(in) mugtok_cptr,
type(mugtok_instance), intent(out), pointer sim_obj,
character(kind=c_char), dimension(oft_error_slen), intent(out), optional error_str )

Cast a C pointer back to the Fortran MUG/TokaMaker wrapper object.

Parameters
[in]mugtok_cptrC pointer to wrapper object
[out]sim_objFortran wrapper object
[out]error_strError string (empty if no error)

◆ mugtok_destroy()

subroutine mugtok_destroy ( type(c_ptr), intent(in), value mugtok_ptr,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Destroy the combined simulation object (the borrowed equilibrium/mesh are left intact).

Parameters
[in]mugtok_ptrPointer to MUG/TokaMaker object
[out]error_strError string (empty if no error)

◆ mugtok_get_field()

subroutine mugtok_get_field ( type(c_ptr), intent(in), value mugtok_ptr,
integer(c_int), intent(in), value field_id,
type(c_ptr), intent(in), value vals,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Get the current values of a MUG-owned solution field at node points.

Parameters
[in]mugtok_ptrPointer to MUG/TokaMaker object
[in]field_idField index (1=n,2/3/4=vel,5=P,7=F)
[in]valsOutput array (size = field's FE block DOFs)
[out]error_strError string (empty if no error)

◆ mugtok_get_gradf()

subroutine mugtok_get_gradf ( type(c_ptr), intent(in), value mugtok_ptr,
type(c_ptr), intent(in), value gr,
type(c_ptr), intent(in), value gz,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Get the projected poloidal gradient of F at node points (dF/dR, dF/dZ).

Parameters
[in]mugtok_ptrPointer to MUG/TokaMaker object
[in]grOutput dF/dR array
[in]gzOutput dF/dZ array
[out]error_strError string (empty if no error)

◆ mugtok_get_pmesh()

subroutine mugtok_get_pmesh ( type(c_ptr), intent(in), value mugtok_ptr,
integer(c_int), intent(out) np,
type(c_ptr), intent(out) r_loc,
integer(c_int), intent(out) nc,
type(c_ptr), intent(out) lc_loc,
type(c_ptr), intent(out) reg_loc,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Get the order-1 (pressure) plotting mesh: node coordinates and triangle connectivity.

Parameters
[in]mugtok_ptrPointer to MUG/TokaMaker object
[out]npNumber of pressure node points
[out]r_locNode coordinate list pointer
[out]ncNumber of cells
[out]lc_locCell (triangle) list pointer
[out]reg_locPer-cell region ID list pointer
[out]error_strError string (empty if no error)

◆ mugtok_setup()

subroutine mugtok_setup ( type(c_ptr), intent(in), value mugtok_ptr,
real(c_double), intent(in), value dt,
real(c_double), intent(in), value lin_tol,
real(c_double), intent(in), value nl_tol,
type(c_ptr), intent(in), value mhd_flag_ptr,
type(c_ptr), intent(in), value dens_ptr,
type(c_ptr), intent(in), value visc_ptr,
integer(c_int), intent(in), value nreg,
logical(c_bool), intent(in), value incomp,
logical(c_bool), intent(in), value toroidal_flow,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set up the combined simulation (mesh/FE are reused from the equilibrium's device).

Parameters
[in]mugtok_ptrPointer to MUG/TokaMaker object
[in]dtTimestep [s]
[in]lin_tolLinear solver tolerance
[in]nl_tolNon-linear solver tolerance
[in]mhd_flag_ptrPer-region MHD flag (int32, 1=MHD region)
[in]dens_ptrPer-region density (<0 where unused)
[in]visc_ptrPer-region kinematic viscosity (<0 where unused)
[in]nregNumber of mesh regions
[in]incompIncompressible flow?
[in]toroidal_flowAllow toroidal (phi) flow in the MHD regions?
[out]error_strError string (empty if no error)

◆ mugtok_step()

subroutine mugtok_step ( type(c_ptr), intent(in), value mugtok_ptr,
type(c_ptr), intent(in), value curr_ptr,
integer(c_int), intent(in), value ncoils,
real(c_double), intent(inout) time,
real(c_double), intent(inout) dt,
integer(c_int), intent(out) nl_its,
integer(c_int), intent(out) lin_its,
integer(c_int), intent(out) nretry,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Advance the coupled solution by one timestep.

Parameters
[in]mugtok_ptrPointer to MUG/TokaMaker object
[in]curr_ptrCoil currents [A] at end of step
[in]ncoilsNumber of coils
[in,out]timeCurrent simulation time [s]
[in,out]dtTimestep size [s]
[out]nl_itsNumber of nonlinear iterations
[out]lin_itsNumber of linear iterations
[out]nretryNumber of retries
[out]error_strError string (empty if no error)