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

Detailed Description

Fortran part of Python wrapper for Grad-Shafranov functionality.

Authors
Chris Hansen
Date
May 2023

Data Types

type  tokamaker_instance
 TokaMaker wrapper object for Python API. More...
type  tokamaker_recon_settings_type
 TokaMaker reconstruction settings structure for passing settings between Python to Fortran. More...
type  tokamaker_settings_type
 TokaMaker settings structure for passing settings between Python to Fortran. More...

Functions/Subroutines

subroutine tokamaker_alloc (tmaker_ptr, mesh_ptr, error_str)
 Allocate TokaMaker wrapper object and initialize with mesh information.
subroutine tokamaker_apply_field_eval (tmaker_equil_ptr, int_obj, int_type, pt, fbary_tol, cell, dim, field)
 Evaluate a TokaMaker field with an interpolation object created by tokamaker_get_field_eval.
subroutine tokamaker_area_int (tmaker_ptr, vec_vals, reg_ind, result, error_str)
 Compute area integral of a scalar field over a specified region.
logical function tokamaker_ccast (tmaker_cptr, tmaker_obj, error_str)
 Cast C pointer to TokaMaker wrapper object.
subroutine tokamaker_destroy (tmaker_ptr, error_str)
 Destroy TokaMaker wrapper object and associated device object.
subroutine tokamaker_eig_td (tmaker_equil_ptr, omega, neigs, eigs, eig_vecs, include_bounds, eta_plasma, pm, error_str)
 Compute eigenvalues/eigenvectors of linearized plasma-conductor system.
subroutine tokamaker_eig_wall (tmaker_ptr, neigs, eigs, eig_vecs, pm, error_str)
 Compute eigenvalues/eigenvectors of conductor (wall) system.
logical function tokamaker_equil_ccast (tmaker_equil_cptr, tmaker_equil_obj, error_str)
 Cast C pointer to TokaMaker equilibrium object.
subroutine tokamaker_equil_copy (tmaker_ptr, old_equil_ptr, new_equil_ptr, error_str)
 Copy TokaMaker equilibrium object.
subroutine tokamaker_equil_destroy (tmaker_equil_ptr, error_str)
 Destroy TokaMaker equilibrium object.
subroutine tokamaker_equil_set (tmaker_ptr, new_equil_ptr, error_str)
 Set TokaMaker equilibrium object for use in TokaMaker wrapper object.
subroutine tokamaker_eval_green (n, r, z, rc, zc, vals)
 Evaluate Green's function for axisymmetric toroidal current loop.
subroutine tokamaker_flux_int (tmaker_equil_ptr, psi_vals, field_vals, nvals, result, error_str)
 Compute the area integral of a flux function over the plasma region.
subroutine tokamaker_get_coil_currents (tmaker_equil_ptr, currents, reg_currents, error_str)
 Get coil currents.
subroutine tokamaker_get_dels_curr (tmaker_equil_ptr, psi_vals, error_str)
 Compute current density from \( \psi \) using \( \Delta^* \psi \) operator.
subroutine tokamaker_get_field_eval (tmaker_equil_ptr, imode, int_obj, error_str)
 Create an interpolation object for tokamaker fields.
subroutine tokamaker_get_globals (tmaker_equil_ptr, itor, centroid, vol, pvol, dflux, tflux, bp_vol, error_str)
 Compute various global quantities for Grad-Shafranov equilibrium.
subroutine tokamaker_get_jtor (tmaker_equil_ptr, jtor, error_str)
 Compute plasma toroidal current density using G-S RHS source.
subroutine tokamaker_get_limiter (tmaker_ptr, np, r_loc, nloops, loop_ptr, error_str)
 Get limiter geometry information.
subroutine tokamaker_get_mesh (tmaker_ptr, np, r_loc, nc, lc_loc, reg_loc, error_str)
 Build tessellated plotting mesh and return pointers to mesh information.
subroutine tokamaker_get_plasma_lmat (tmaker_equil_ptr, lmat, error_str)
 Get mutual inductance matrix for coils and plasma.
subroutine tokamaker_get_profile_dofs (tmaker_equil_ptr, prof_type, dofs, error_str)
 Retrieve degrees of freedom for desired flux profile.
subroutine tokamaker_get_profile_ndofs (tmaker_equil_ptr, prof_type, ndofs, error_str)
 Retrieve degrees of freedom for desired flux profile.
subroutine tokamaker_get_profs (tmaker_equil_ptr, npsi, psi_in, f, fp, p, pp, error_str)
 Retrieve F and P profiles and their derivatives.
subroutine tokamaker_get_psi (tmaker_equil_ptr, psi_vals, psi_lim, psi_max, error_str)
 Get \( \psi \) values for equilibrium.
subroutine tokamaker_get_q (tmaker_equil_ptr, npsi, psi_q, qvals, ravgs, dl, rbounds, zbounds, error_str)
 Compute q profile and related quantities.
subroutine tokamaker_get_refs (tmaker_equil_ptr, o_point, lim_point, x_points, diverted, plasma_bounds, ffp_scale, p_scale, has_plasma, error_str)
 Get references to internal variables for direct access from Python.
subroutine tokamaker_get_vfixed (tmaker_equil_ptr, npts, pts, fluxes, error_str)
 Compute external flux needed to reproduce fixed boundary equilibrium at domain boundary.
subroutine tokamaker_gs_calc_vloop (tmaker_equil_ptr, vloop, error_str)
 Compute loop voltage required to maintain Grad-Shafranov equilibrium.
subroutine tokamaker_init_psi (tmaker_ptr, r0, z0, a, kappa, delta, rhs_source, error_str)
 Initialize \( \psi \) using a uniform or specified current source.
subroutine tokamaker_load_profiles (tmaker_equil_ptr, f_file, f_offset, p_file, eta_file, f_ni_file, error_str)
 Load profile specification files.
subroutine tokamaker_load_tokamaker (tmaker_equil_ptr, filename, error_str)
 Load equilibrium from native TokaMaker format.
subroutine tokamaker_recon_destroy (tmaker_ptr, error_flag)
 Perform an equilibrium reconstruction using TokaMaker.
subroutine tokamaker_recon_err (tmaker_ptr, vacuum, settings, error_mat, error_flag)
 Perform an equilibrium reconstruction using TokaMaker.
subroutine tokamaker_recon_run (tmaker_ptr, vacuum, settings, error_flag)
 Perform an equilibrium reconstruction using TokaMaker.
subroutine tokamaker_recon_setup (tmaker_ptr, settings, ncons, error_flag)
 Perform an equilibrium reconstruction using TokaMaker.
logical function tokamaker_require_equil (tmaker_obj, error_str)
 Require TokaMaker wrapper object to have TokaMaker equilibrium object allocated.
logical function tokamaker_require_td (tmaker_obj, error_str)
 Require TokaMaker wrapper object to have TokaMaker time-dependent solver object allocated.
subroutine tokamaker_sauter_fc (tmaker_equil_ptr, npsi, psi_saut, fc, r_avgs, modb_avgs, error_str)
 Evaluate Sauter trapped particle fraction and related quantities.
subroutine tokamaker_save_eqdsk (tmaker_equil_ptr, filename, nr, nz, rbounds, zbounds, run_info, psi_pad, rcentr, trunc_eq, lim_filename, lcfs_press, cocos, error_str)
 Save current equilibrium in gEQDSK format.
subroutine tokamaker_save_ifile (tmaker_equil_ptr, filename, npsi, ntheta, psi_pad, lcfs_press, pack_lcfs, single_prec, error_str)
 Save current equilibrium to iFile format.
subroutine tokamaker_save_mug (tmaker_equil_ptr, filename, error_str)
 Save current equilibrium in MUG transfer format.
subroutine tokamaker_save_tokamaker (tmaker_equil_ptr, filename, error_str)
 Save current equilibrium in native TokaMaker format (eg. for restarting).
subroutine tokamaker_set_coil_bounds (tmaker_ptr, coil_bounds, error_str)
 Set hard bounds on coil currents for a TokaMaker instance.
subroutine tokamaker_set_coil_current_dist (tmaker_ptr, icoil, curr_dist, dist_pointer, normalize, error_str)
 Overwrites default coil flux contribution to non-uniform current distribution.
subroutine tokamaker_set_coil_currents (tmaker_ptr, currents, error_str)
 Set coil currents for a TokaMaker instance.
subroutine tokamaker_set_coil_regmat (tmaker_ptr, nregularize, coil_reg_mat, coil_reg_targets, coil_reg_weights, error_str)
 Sets the regularization matrix for coil currents in a TokaMaker instance.
subroutine tokamaker_set_coil_vsc (tmaker_ptr, coil_gains, error_str)
 Define virtual VSC coil for a TokaMaker instance as a weighted sum of physical coils.
subroutine tokamaker_set_dipole_a (tmaker_ptr, dipole_a, error_str)
 Set parameters for dipole anisotropic pressure profile.
subroutine tokamaker_set_flux (tmaker_ptr, locations, targets, weights, ntargets, grad_wt_lim, error_str)
 Sets the flux targets for a TokaMaker instance.
subroutine tokamaker_set_isoflux (tmaker_ptr, targets, ref_points, weights, ntargets, grad_wt_lim, error_str)
 Sets isoflux targets for a TokaMaker instance.
subroutine tokamaker_set_mirnov (tmaker_ptr, locations, norms, targets, weights, ntargets, error_str)
 Sets the mirnov targets for a TokaMaker instance.
subroutine tokamaker_set_mirror_slosh (tmaker_ptr, mirror_n, mirror_bturn, mirror_zthroat, error_str)
 Set parameters for mirror anisotropic pressure profile.
subroutine tokamaker_set_profile_dofs (tmaker_equil_ptr, prof_type, dofs, error_str)
 Set degrees of freedom for desired flux profile.
subroutine tokamaker_set_psi (tmaker_equil_ptr, psi_vals, update_bounds, error_str)
 Set \( \psi \) values in TokaMaker equilibrium object.
subroutine tokamaker_set_psi_dt (tmaker_ptr, psi_vals, icoils, vcoils, dt, error_str)
 Set flux/coil current at previous time and coil voltage for quasi-static solve.
subroutine tokamaker_set_saddles (tmaker_ptr, targets, weights, ntargets, error_str)
 Sets the saddle point targets for a TokaMaker instance.
subroutine tokamaker_set_settings (tmaker_ptr, settings, error_str)
 Update TokaMaker settings.
subroutine tokamaker_set_targets (tmaker_ptr, ip_target, ip_ratio_target, pax_target, estore_target, dflux_target, r0_target, z0_target, error_str)
 Set global target values for equilibrium solve.
subroutine tokamaker_set_vcoil (tmaker_ptr, rcoils, error_str)
 Set Vcoils by defining non-zero resistance of coils.
subroutine tokamaker_setup (tmaker_ptr, order, full_domain, ncoils, coil_lmat, error_str)
 Complete setup of TokaMaker device/wrapper object and build FE representation.
subroutine tokamaker_setup_regions (tmaker_ptr, coil_file, reg_eta, contig_flag, xpoint_mask, coil_nturns, ncoils, error_str)
 Setup TokaMaker region representations based on coil, conductor, and other information.
subroutine tokamaker_setup_td (tmaker_ptr, dt, lin_tol, nl_tol, pre_plasma, error_str)
 Setup nonlinear time-dependent solver.
subroutine tokamaker_solve (tmaker_ptr, vacuum, nl_its, error_str)
 Perform nonlinear solve to find equilibrium solution for given profiles, targets, etc.
subroutine tokamaker_step_td (tmaker_ptr, curr_ptr, volt_ptr, time, dt, nl_its, lin_its, nretry, error_str)
 Advance the time-dependent solver by one time step.
subroutine tokamaker_trace_surf (tmaker_equil_ptr, psi_surf, points, npoints, error_str)
 Trace a flux surface at specified \( \psi \) value and return points defining the surface.
subroutine tokamaker_vac_solve (tmaker_ptr, psi_in, rhs_source, error_str)
 Perform linear solve to find vacuum solution for given BCs and current sources.

Function/Subroutine Documentation

◆ tokamaker_alloc()

subroutine tokamaker_alloc ( type(c_ptr), intent(out) tmaker_ptr,
type(c_ptr), intent(in), value mesh_ptr,
character(kind=c_char), dimension(oft_error_slen), intent(out), optional error_str )

Allocate TokaMaker wrapper object and initialize with mesh information.

Parameters
[out]tmaker_ptrPointer to TokaMaker object
[in]mesh_ptrPointer to mesh object
[out]error_strError string (empty if no error)

◆ tokamaker_apply_field_eval()

subroutine tokamaker_apply_field_eval ( type(c_ptr), intent(in), value tmaker_equil_ptr,
type(c_ptr), intent(in), value int_obj,
integer(c_int), intent(in), value int_type,
real(c_double), dimension(3), intent(in) pt,
real(c_double), intent(in), value fbary_tol,
integer(c_int), intent(inout) cell,
integer(c_int), intent(in), value dim,
real(c_double), dimension(dim), intent(out) field )

Evaluate a TokaMaker field with an interpolation object created by tokamaker_get_field_eval.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]int_objPointer to interpolation object
[in]int_typeField type (negative to destroy)
[in]ptLocation for evaluation [R,Z,0]
[in]fbary_tolTolerance for physical to logical mapping
[in,out]cellCell containing pt (starting guess on input)
[in]dimDimension of field
[out]fieldField at pt

◆ tokamaker_area_int()

subroutine tokamaker_area_int ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value vec_vals,
integer(c_int), intent(in), value reg_ind,
real(c_double), intent(out) result,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute area integral of a scalar field over a specified region.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]vec_valsValue of integrand at node points
[in]reg_indIndex of region to integrate over (reg_ind < 0 -> full domain)
[out]result\( \int f dA \)
[out]error_strError string (empty if no error)

◆ tokamaker_ccast()

logical function tokamaker_ccast ( type(c_ptr), intent(in) tmaker_cptr,
type(tokamaker_instance), intent(out), pointer tmaker_obj,
character(kind=c_char), dimension(oft_error_slen), intent(out), optional error_str )

Cast C pointer to TokaMaker wrapper object.

Parameters
[in]tmaker_cptrC pointer to TokaMaker object
[out]tmaker_objFortran TokaMaker object
[out]error_strError string (empty if no error)

◆ tokamaker_destroy()

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

Destroy TokaMaker wrapper object and associated device object.

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

◆ tokamaker_eig_td()

subroutine tokamaker_eig_td ( type(c_ptr), intent(in), value tmaker_equil_ptr,
real(c_double), intent(in), value omega,
integer(c_int), intent(in), value neigs,
type(c_ptr), intent(in), value eigs,
type(c_ptr), intent(in), value eig_vecs,
logical(c_bool), intent(in), value include_bounds,
real(c_double), intent(in), value eta_plasma,
logical(c_bool), intent(in), value pm,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute eigenvalues/eigenvectors of linearized plasma-conductor system.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]omegaShift parameter for eigenvalue solve
[in]neigsNumber of eigenvalues to compute
[in]eigsEigenvalues array
[in]eig_vecsEigenvectors array
[in]include_boundsInclude boundary conditions
[in]eta_plasmaPlasma resistivity
[in]pmReport solver progress?
[out]error_strError string (empty if no error)

◆ tokamaker_eig_wall()

subroutine tokamaker_eig_wall ( type(c_ptr), intent(in), value tmaker_ptr,
integer(c_int), intent(in), value neigs,
type(c_ptr), intent(in), value eigs,
type(c_ptr), intent(in), value eig_vecs,
logical(c_bool), intent(in), value pm,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute eigenvalues/eigenvectors of conductor (wall) system.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]neigsNumber of eigenvalues to compute
[in]eigsEigenvalues array
[in]eig_vecsEigenvectors array
[in]pmReport solver progress?
[out]error_strError string (empty if no error)

◆ tokamaker_equil_ccast()

logical function tokamaker_equil_ccast ( type(c_ptr), intent(in) tmaker_equil_cptr,
type(gs_equil), intent(out), pointer tmaker_equil_obj,
character(kind=c_char), dimension(oft_error_slen), intent(out), optional error_str )

Cast C pointer to TokaMaker equilibrium object.

Parameters
[in]tmaker_equil_cptrC pointer to TokaMaker equilibrium object
[out]error_strError string (empty if no error)

◆ tokamaker_equil_copy()

subroutine tokamaker_equil_copy ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value old_equil_ptr,
type(c_ptr), intent(out) new_equil_ptr,
character(kind=c_char), dimension(oft_error_slen), intent(out), optional error_str )

Copy TokaMaker equilibrium object.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]old_equil_ptrPointer to old equilibrium object
[out]new_equil_ptrPointer to new equilibrium object
[out]error_strError string (empty if no error)

◆ tokamaker_equil_destroy()

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

Destroy TokaMaker equilibrium object.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[out]error_strError string (empty if no error)

◆ tokamaker_equil_set()

subroutine tokamaker_equil_set ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value new_equil_ptr,
character(kind=c_char), dimension(oft_error_slen), intent(out), optional error_str )

Set TokaMaker equilibrium object for use in TokaMaker wrapper object.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]new_equil_ptrPointer to old equilibrium object
[out]error_strError string (empty if no error)

◆ tokamaker_eval_green()

subroutine tokamaker_eval_green ( integer(c_int), intent(in), value n,
type(c_ptr), intent(in), value r,
type(c_ptr), intent(in), value z,
real(c_double), intent(in), value rc,
real(c_double), intent(in), value zc,
type(c_ptr), intent(in), value vals )

Evaluate Green's function for axisymmetric toroidal current loop.

Parameters
[in]nNumber of evaluation points
[in]rcR coordinate of coil
[in]zcZ coordinate of coil
[in]rR coordinates for evaluation
[in]zZ coordinates for evaluation
[in]valsPsi values

◆ tokamaker_flux_int()

subroutine tokamaker_flux_int ( type(c_ptr), intent(in), value tmaker_equil_ptr,
type(c_ptr), intent(in), value psi_vals,
type(c_ptr), intent(in), value field_vals,
integer(c_int), intent(in), value nvals,
real(c_double), intent(out) result,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute the area integral of a flux function over the plasma region.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]psi_vals\( \psi \) values for flux function definition
[in]field_valsValue of the flux function at matching psi_vals
[in]nvalsNumber of values in psi_vals and field_vals
[out]resultIntegral result
[out]error_strError string (empty if no error)

◆ tokamaker_get_coil_currents()

subroutine tokamaker_get_coil_currents ( type(c_ptr), intent(in), value tmaker_equil_ptr,
type(c_ptr), intent(in), value currents,
type(c_ptr), intent(in), value reg_currents,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Get coil currents.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]currentsCoil currents by coil index
[in]reg_currentsCurrents in each region due to coils
[out]error_strError string (empty if no error)

◆ tokamaker_get_dels_curr()

subroutine tokamaker_get_dels_curr ( type(c_ptr), intent(in), value tmaker_equil_ptr,
type(c_ptr), intent(in), value psi_vals,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute current density from \( \psi \) using \( \Delta^* \psi \) operator.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]psi_vals\( \psi \) at node points
[out]error_strError string (empty if no error)

◆ tokamaker_get_field_eval()

subroutine tokamaker_get_field_eval ( type(c_ptr), intent(in), value tmaker_equil_ptr,
integer(kind=c_int), intent(in), value imode,
type(c_ptr), intent(out) int_obj,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Create an interpolation object for tokamaker fields.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker object
[in]imodeField type
[out]int_objPointer to interpolation object
[out]error_strError string (empty if no error)

◆ tokamaker_get_globals()

subroutine tokamaker_get_globals ( type(c_ptr), intent(in), value tmaker_equil_ptr,
real(c_double), intent(out) itor,
real(c_double), dimension(2), intent(out) centroid,
real(c_double), intent(out) vol,
real(c_double), intent(out) pvol,
real(c_double), intent(out) dflux,
real(c_double), intent(out) tflux,
real(c_double), intent(out) bp_vol,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute various global quantities for Grad-Shafranov equilibrium.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[out]itorToroidal current
[out]centroidPlasma current centroid (R,Z)
[out]volPlasma volume
[out]pvol\( \int P dV \)
[out]dfluxDiamagnetic flux
[out]tfluxToroidal flux contained within plasma
[out]bp_vol\( \int B_p^2 dV \)
[out]error_strError string (empty if no error)

◆ tokamaker_get_jtor()

subroutine tokamaker_get_jtor ( type(c_ptr), intent(in), value tmaker_equil_ptr,
type(c_ptr), intent(in), value jtor,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute plasma toroidal current density using G-S RHS source.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]jtor\( J_{\phi} \) at node points
[out]error_strError string (empty if no error)

◆ tokamaker_get_limiter()

subroutine tokamaker_get_limiter ( type(c_ptr), intent(in), value tmaker_ptr,
integer(c_int), intent(out) np,
type(c_ptr), intent(out) r_loc,
integer(c_int), intent(out) nloops,
type(c_ptr), intent(out) loop_ptr,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Get limiter geometry information.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[out]r_locLimiter vertex list pointer
[out]loop_ptrLimiter loops pointer
[out]npNumber of limiter vertices
[out]nloopsNumber of limiter loops
[out]error_strError string (empty if no error)

◆ tokamaker_get_mesh()

subroutine tokamaker_get_mesh ( type(c_ptr), intent(in), value tmaker_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 )

Build tessellated plotting mesh and return pointers to mesh information.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[out]lc_locCell list pointer
[out]r_locVertex list pointer
[out]reg_locRegion ID pointer
[out]npNumber of vertices
[out]ncNumber of cells
[out]error_strError string (empty if no error)

◆ tokamaker_get_plasma_lmat()

subroutine tokamaker_get_plasma_lmat ( type(c_ptr), intent(in), value tmaker_equil_ptr,
type(c_ptr), intent(in), value lmat,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Get mutual inductance matrix for coils and plasma.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]lmatInductance matrix
[out]error_strError string (empty if no error)

◆ tokamaker_get_profile_dofs()

subroutine tokamaker_get_profile_dofs ( type(c_ptr), intent(in), value tmaker_equil_ptr,
integer(c_int), intent(in), value prof_type,
type(c_ptr), intent(in), value dofs,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Retrieve degrees of freedom for desired flux profile.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]prof_typeType of profile (1: F*F', 2: P')
[in]dofsArray of degrees of freedom
[out]error_strError string (empty if no error)

◆ tokamaker_get_profile_ndofs()

subroutine tokamaker_get_profile_ndofs ( type(c_ptr), intent(in), value tmaker_equil_ptr,
integer(c_int), intent(in), value prof_type,
integer(c_int), intent(out) ndofs,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Retrieve degrees of freedom for desired flux profile.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]prof_typeType of profile (1: F*F', 2: P')
[out]ndofsNumber of degrees of freedom
[out]error_strError string (empty if no error)

◆ tokamaker_get_profs()

subroutine tokamaker_get_profs ( type(c_ptr), intent(in), value tmaker_equil_ptr,
integer(c_int), intent(in), value npsi,
real(c_double), dimension(npsi), intent(in) psi_in,
real(c_double), dimension(npsi), intent(out) f,
real(c_double), dimension(npsi), intent(out) fp,
real(c_double), dimension(npsi), intent(out) p,
real(c_double), dimension(npsi), intent(out) pp,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Retrieve F and P profiles and their derivatives.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]npsiEvaluation points
[in]psi_in\( \psi \) values to evaluate profiles
[out]f\( F( \psi ) \)
[out]fp\( F'( \psi ) \)
[out]p\( P( \psi ) \)
[out]pp\( P'( \psi ) \)
[out]error_strError string (empty if no error)

◆ tokamaker_get_psi()

subroutine tokamaker_get_psi ( type(c_ptr), intent(in), value tmaker_equil_ptr,
type(c_ptr), intent(in), value psi_vals,
real(c_double), intent(out) psi_lim,
real(c_double), intent(out) psi_max,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Get \( \psi \) values for equilibrium.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]psi_vals\( \psi \) values at node points
[out]psi_limPsi value at plasma boundary
[out]psi_maxPsi value at magnetic axis
[out]error_strError string (empty if no error)

◆ tokamaker_get_q()

subroutine tokamaker_get_q ( type(c_ptr), intent(in), value tmaker_equil_ptr,
integer(c_int), intent(in), value npsi,
real(c_double), dimension(npsi), intent(in) psi_q,
real(c_double), dimension(npsi), intent(out) qvals,
real(c_double), dimension(npsi,3), intent(out) ravgs,
real(c_double), intent(inout) dl,
real(c_double), dimension(2,2), intent(out) rbounds,
real(c_double), dimension(2,2), intent(out) zbounds,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute q profile and related quantities.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]npsiNumber of evaluation points
[in]psi_q\( \psi \) values to compute q and other fields
[out]qvalsq values
[out]ravgs<R>, <1/R>, and dV/dPsi
[in,out]dlLength of LCFS flux surface (psi_q(1))
[out]rboundsRadial bounds of LCFS
[out]zboundsVertical bounds of LCFS
[out]error_strError string (empty if no error)

◆ tokamaker_get_refs()

subroutine tokamaker_get_refs ( type(c_ptr), intent(in), value tmaker_equil_ptr,
type(c_ptr), intent(out) o_point,
type(c_ptr), intent(out) lim_point,
type(c_ptr), intent(out) x_points,
type(c_ptr), intent(out) diverted,
type(c_ptr), intent(out) plasma_bounds,
type(c_ptr), intent(out) ffp_scale,
type(c_ptr), intent(out) p_scale,
type(c_ptr), intent(out) has_plasma,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Get references to internal variables for direct access from Python.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[out]o_pointPointer to magnetic axis array
[out]lim_pointPointer to limiting point array
[out]x_pointsPointer to X-point array
[out]divertedPointer to diverted flag
[out]plasma_boundsPointer to plasma axis/LCFS values
[out]ffp_scalePointer to F*F' scale factor
[out]p_scalePointer to P' scale factor
[out]has_plasmaPointer to plasma/vacuum flag
[out]error_strError string (empty if no error)

◆ tokamaker_get_vfixed()

subroutine tokamaker_get_vfixed ( type(c_ptr), intent(in), value tmaker_equil_ptr,
integer(c_int), intent(out) npts,
type(c_ptr), intent(out) pts,
type(c_ptr), intent(out) fluxes,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute external flux needed to reproduce fixed boundary equilibrium at domain boundary.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[out]nptsNumber of node points on domain boundary
[out]ptsLocation of node points on domain boundary
[out]fluxesRequired flux at node points
[out]error_strError string (empty if no error)

◆ tokamaker_gs_calc_vloop()

subroutine tokamaker_gs_calc_vloop ( type(c_ptr), intent(in), value tmaker_equil_ptr,
real(c_double), intent(out) vloop,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Compute loop voltage required to maintain Grad-Shafranov equilibrium.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[out]vloopLoop voltage
[out]error_strError string (empty if no error)

◆ tokamaker_init_psi()

subroutine tokamaker_init_psi ( type(c_ptr), intent(in), value tmaker_ptr,
real(c_double), intent(in), value r0,
real(c_double), intent(in), value z0,
real(c_double), intent(in), value a,
real(c_double), intent(in), value kappa,
real(c_double), intent(in), value delta,
type(c_ptr), intent(in), value rhs_source,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Initialize \( \psi \) using a uniform or specified current source.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]r0Major radius
[in]z0Vertical position
[in]aMinor radius
[in]kappaElongation
[in]deltaTriangularity
[in]rhs_sourceCurrent source term (optional)
[out]error_strError string (empty if no error)

◆ tokamaker_load_profiles()

subroutine tokamaker_load_profiles ( type(c_ptr), intent(in), value tmaker_equil_ptr,
character(kind=c_char), dimension(oft_path_slen), intent(in) f_file,
real(c_double), intent(in), value f_offset,
character(kind=c_char), dimension(oft_path_slen), intent(in) p_file,
character(kind=c_char), dimension(oft_path_slen), intent(in) eta_file,
character(kind=c_char), dimension(oft_path_slen), intent(in) f_ni_file,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Load profile specification files.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]f_fileF*F' prof.in file
[in]p_fileP' prof.in file
[in]f_offsetVacuum F_0 value (must be > -1E98 to update)
[in]eta_fileResistivity (eta) profile specification file
[in]f_ni_fileNon-inductive F*F' profile specification file
[out]error_strError string (empty if no error)

◆ tokamaker_load_tokamaker()

subroutine tokamaker_load_tokamaker ( type(c_ptr), intent(in), value tmaker_equil_ptr,
character(kind=c_char), dimension(oft_path_slen), intent(in) filename,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Load equilibrium from native TokaMaker format.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]filenameFilename to load equilibrium from
[out]error_strError string (empty if no error)

◆ tokamaker_recon_destroy()

subroutine tokamaker_recon_destroy ( type(c_ptr), intent(in), value tmaker_ptr,
integer(c_int), intent(out) error_flag )

Perform an equilibrium reconstruction using TokaMaker.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[out]error_flagError flag (0 if no error)

◆ tokamaker_recon_err()

subroutine tokamaker_recon_err ( type(c_ptr), intent(in), value tmaker_ptr,
logical(c_bool), intent(in), value vacuum,
type(tokamaker_recon_settings_type), intent(in), value settings,
type(c_ptr), intent(in), value error_mat,
integer(c_int), intent(out) error_flag )

Perform an equilibrium reconstruction using TokaMaker.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]vacuumReconstruct vacuum equilibrium (no plasma)?
[in]settingsReconstruction settings struct
[in]error_matPointer to error matrix or void to write to file
[out]error_flagError flag (0 if no error)

◆ tokamaker_recon_run()

subroutine tokamaker_recon_run ( type(c_ptr), intent(in), value tmaker_ptr,
logical(c_bool), intent(in), value vacuum,
type(tokamaker_recon_settings_type), intent(in), value settings,
integer(c_int), intent(out) error_flag )

Perform an equilibrium reconstruction using TokaMaker.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]vacuumReconstruct vacuum equilibrium (no plasma)?
[in]settingsReconstruction settings struct
[out]error_flagError flag (0 if no error)

◆ tokamaker_recon_setup()

subroutine tokamaker_recon_setup ( type(c_ptr), intent(in), value tmaker_ptr,
type(tokamaker_recon_settings_type), intent(in), value settings,
integer(c_int), intent(out) ncons,
integer(c_int), intent(out) error_flag )

Perform an equilibrium reconstruction using TokaMaker.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]settingsReconstruction settings struct
[out]nconsNumber of constraints
[out]error_flagError flag (0 if no error)

◆ tokamaker_require_equil()

logical function tokamaker_require_equil ( type(tokamaker_instance), intent(in) tmaker_obj,
character(kind=c_char), dimension(oft_error_slen), intent(out), optional error_str )

Require TokaMaker wrapper object to have TokaMaker equilibrium object allocated.

Parameters
[out]error_strError string (empty if no error)

◆ tokamaker_require_td()

logical function tokamaker_require_td ( type(tokamaker_instance), intent(in) tmaker_obj,
character(kind=c_char), dimension(oft_error_slen), intent(out), optional error_str )

Require TokaMaker wrapper object to have TokaMaker time-dependent solver object allocated.

Parameters
[out]error_strError string (empty if no error)

◆ tokamaker_sauter_fc()

subroutine tokamaker_sauter_fc ( type(c_ptr), intent(in), value tmaker_equil_ptr,
integer(c_int), intent(in), value npsi,
real(c_double), dimension(npsi), intent(in) psi_saut,
real(c_double), dimension(npsi), intent(out) fc,
real(c_double), dimension(npsi,3), intent(out) r_avgs,
real(c_double), dimension(npsi,2), intent(out) modb_avgs,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Evaluate Sauter trapped particle fraction and related quantities.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]npsiNumber of evaluation points
[in]psi_saut\( \psi \) values to compute trapped particle fraction and other fields
[out]fcTrapped particle fraction
[out]r_avgsFlux surface averaged radial coordinates \(<R>\), \(<1/R>\), \(<a>\)
[out]modb_avgsFlux surface averaged field strength \(<|B|>\), \(<|B|^2>\)
[out]error_strError string (empty if no error)

◆ tokamaker_save_eqdsk()

subroutine tokamaker_save_eqdsk ( type(c_ptr), intent(in), value tmaker_equil_ptr,
character(kind=c_char), dimension(oft_path_slen), intent(in) filename,
integer(c_int), intent(in), value nr,
integer(c_int), intent(in), value nz,
real(c_double), dimension(2), intent(in) rbounds,
real(c_double), dimension(2), intent(in) zbounds,
character(kind=c_char), dimension(40), intent(in) run_info,
real(c_double), intent(in), value psi_pad,
real(c_double), intent(in), value rcentr,
logical(c_bool), intent(in), value trunc_eq,
character(kind=c_char), dimension(oft_path_slen), intent(in) lim_filename,
real(c_double), intent(in), value lcfs_press,
integer(c_int), intent(in), value cocos,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Save current equilibrium in gEQDSK format.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]filenameFilename to save equilibrium to
[in]run_infoRun information
[in]nrNumber of radial grid points
[in]nzNumber of vertical grid points
[in]rboundsRadial grid bounds
[in]zboundsVertical grid bounds
[in]psi_padPadding in normalized flux at LCFS
[in]rcentrValue to use for Rcentr in gEQDSK file (negative to use equilibrium magnetic axis)
[in]trunc_eqTruncate equilibrium at lcfs_pad, if False \( q(\hat{\psi} > 1-pad) = q(1-pad) \)
[in]lim_filenameFile containing limiter contour to use instead of TokaMaker limiter
[in]lcfs_pressPlasma pressure on the LCFS (zero by default)
[in]cocosCOCOS version. (Only 2 or 7 supported. COCOS=7 is the default.)
[out]error_strError string (empty if no error)

◆ tokamaker_save_ifile()

subroutine tokamaker_save_ifile ( type(c_ptr), intent(in), value tmaker_equil_ptr,
character(kind=c_char), dimension(oft_path_slen), intent(in) filename,
integer(c_int), intent(in), value npsi,
integer(c_int), intent(in), value ntheta,
real(c_double), intent(in), value psi_pad,
real(c_double), intent(in), value lcfs_press,
logical(c_bool), intent(in), value pack_lcfs,
logical(c_bool), intent(in), value single_prec,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Save current equilibrium to iFile format.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]filenameFilename to save equilibrium to
[in]npsiNumber of radial sampling points
[in]nthetaNumber of poloidal sampling points
[in]psi_padPadding in normalized flux at LCFS
[in]lcfs_pressPlasma pressure on the LCFS (zero by default)
[in]pack_lcfsPack toward LCFS with quadraturic sampling?
[in]single_precSave single precision file? (default: double precision)
[out]error_strError string (empty if no error)

◆ tokamaker_save_mug()

subroutine tokamaker_save_mug ( type(c_ptr), intent(in), value tmaker_equil_ptr,
character(kind=c_char), dimension(oft_path_slen), intent(in) filename,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Save current equilibrium in MUG transfer format.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]filenameFilename to save equilibrium to
[out]error_strError string (empty if no error)

◆ tokamaker_save_tokamaker()

subroutine tokamaker_save_tokamaker ( type(c_ptr), intent(in), value tmaker_equil_ptr,
character(kind=c_char), dimension(oft_path_slen), intent(in) filename,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Save current equilibrium in native TokaMaker format (eg. for restarting).

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]filenameFilename to save equilibrium to
[out]error_strError string (empty if no error)

◆ tokamaker_set_coil_bounds()

subroutine tokamaker_set_coil_bounds ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value coil_bounds,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set hard bounds on coil currents for a TokaMaker instance.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]coil_boundsHard bounds for each coil's current
[out]error_strError information

◆ tokamaker_set_coil_current_dist()

subroutine tokamaker_set_coil_current_dist ( type(c_ptr), intent(in), value tmaker_ptr,
integer(c_int), intent(in), value icoil,
type(c_ptr), intent(in), value curr_dist,
type(c_ptr), intent(out) dist_pointer,
logical(c_bool), intent(in), value normalize,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Overwrites default coil flux contribution to non-uniform current distribution.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]icoilCoil index
[in]curr_distCurrent distribution for coil
[out]dist_pointerPointer to current distribution (for use in plotting)
[in]normalizeNormalize distribution to have unit current?
[out]error_strError string (empty if no error)

◆ tokamaker_set_coil_currents()

subroutine tokamaker_set_coil_currents ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value currents,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set coil currents for a TokaMaker instance.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]currentsCoil currents [A]
[out]error_strError information

◆ tokamaker_set_coil_regmat()

subroutine tokamaker_set_coil_regmat ( type(c_ptr), intent(in), value tmaker_ptr,
integer(c_int), intent(in), value nregularize,
type(c_ptr), intent(in), value coil_reg_mat,
type(c_ptr), intent(in), value coil_reg_targets,
type(c_ptr), intent(in), value coil_reg_weights,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Sets the regularization matrix for coil currents in a TokaMaker instance.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]nregularizeNumber of regularization terms
[in]coil_reg_matRegularization matrix for coil currents
[in]coil_reg_targetsTarget values for regularization
[in]coil_reg_weightsWeights for regularization terms
[out]error_strError information

◆ tokamaker_set_coil_vsc()

subroutine tokamaker_set_coil_vsc ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value coil_gains,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Define virtual VSC coil for a TokaMaker instance as a weighted sum of physical coils.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]coil_gainsCoil weights for virtual VSC coil
[out]error_strError string (empty if no error)

◆ tokamaker_set_dipole_a()

subroutine tokamaker_set_dipole_a ( type(c_ptr), intent(in), value tmaker_ptr,
real(c_double), intent(in), value dipole_a,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set parameters for dipole anisotropic pressure profile.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]dipole_aNew value for dipole_a
[out]error_strError string (empty if no error)

◆ tokamaker_set_flux()

subroutine tokamaker_set_flux ( type(c_ptr), intent(in), value tmaker_ptr,
real(c_double), dimension(2,ntargets), intent(in) locations,
real(c_double), dimension(ntargets), intent(in) targets,
real(c_double), dimension(ntargets), intent(in) weights,
integer(c_int), intent(in), value ntargets,
real(c_double), intent(in), value grad_wt_lim,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Sets the flux targets for a TokaMaker instance.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]ntargetsNumber of flux target points
[in]locationsFlux target locations
[in]targetsFlux target values
[in]weightsWeights for flux targets
[in]grad_wt_limLimit on gradient-based weighting (negative to disable)
[out]error_strError string (empty if no error)

◆ tokamaker_set_isoflux()

subroutine tokamaker_set_isoflux ( type(c_ptr), intent(in), value tmaker_ptr,
real(c_double), dimension(2,ntargets), intent(in) targets,
real(c_double), dimension(2,ntargets), intent(in) ref_points,
real(c_double), dimension(ntargets), intent(in) weights,
integer(c_int), intent(in), value ntargets,
real(c_double), intent(in), value grad_wt_lim,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Sets isoflux targets for a TokaMaker instance.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]ntargetsNumber of isoflux target points
[in]targetsIsoflux target locations
[in]ref_pointsReference points for isoflux targets
[in]weightsWeights for isoflux targets
[in]grad_wt_limLimit on gradient-based weighting (negative to disable)
[out]error_strError string (empty if no error)

◆ tokamaker_set_mirnov()

subroutine tokamaker_set_mirnov ( type(c_ptr), intent(in), value tmaker_ptr,
real(c_double), dimension(2,ntargets), intent(in) locations,
real(c_double), dimension(2,ntargets), intent(in) norms,
real(c_double), dimension(ntargets), intent(in) targets,
real(c_double), dimension(ntargets), intent(in) weights,
integer(c_int), intent(in), value ntargets,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Sets the mirnov targets for a TokaMaker instance.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]ntargetsNumber of Mirnov target points
[in]locationsMirnov target locations
[in]normsMirnov target normals
[in]targetsMirnov target values
[in]weightsWeights for Mirnov targets
[out]error_strError string (empty if no error)

◆ tokamaker_set_mirror_slosh()

subroutine tokamaker_set_mirror_slosh ( type(c_ptr), intent(in), value tmaker_ptr,
real(c_double), intent(in), value mirror_n,
real(c_double), intent(in), value mirror_bturn,
real(c_double), intent(in), value mirror_zthroat,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set parameters for mirror anisotropic pressure profile.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]mirror_nNew value for dipole_a
[in]mirror_bturnNew value for dipole_a
[in]mirror_zthroatNew value for dipole_a
[out]error_strError string (empty if no error)

◆ tokamaker_set_profile_dofs()

subroutine tokamaker_set_profile_dofs ( type(c_ptr), intent(in), value tmaker_equil_ptr,
integer(c_int), intent(in), value prof_type,
type(c_ptr), intent(in), value dofs,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set degrees of freedom for desired flux profile.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]prof_typeType of profile (1: F*F', 2: P')
[in]dofsArray of degrees of freedom
[out]error_strError string (empty if no error)

◆ tokamaker_set_psi()

subroutine tokamaker_set_psi ( type(c_ptr), intent(in), value tmaker_equil_ptr,
type(c_ptr), intent(in), value psi_vals,
logical(c_bool), intent(in), value update_bounds,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set \( \psi \) values in TokaMaker equilibrium object.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]psi_valsNew \( \psi \) values to set in TokaMaker equilibrium object
[in]update_boundsUpdate bounds by determining new limiting points
[out]error_strError string (empty if no error)

◆ tokamaker_set_psi_dt()

subroutine tokamaker_set_psi_dt ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value psi_vals,
type(c_ptr), intent(in), value icoils,
type(c_ptr), intent(in), value vcoils,
real(c_double), intent(in), value dt,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set flux/coil current at previous time and coil voltage for quasi-static solve.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]psi_vals\( \psi \) values at reference time (t - dt)
[in]icoilsCoil currents at reference time (t - dt)
[in]vcoilsCoil voltages over time step
[in]dtTime step size
[out]error_strError string (empty if no error)

◆ tokamaker_set_saddles()

subroutine tokamaker_set_saddles ( type(c_ptr), intent(in), value tmaker_ptr,
real(c_double), dimension(2,ntargets), intent(in) targets,
real(c_double), dimension(ntargets), intent(in) weights,
integer(c_int), intent(in), value ntargets,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Sets the saddle point targets for a TokaMaker instance.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]ntargetsNumber of saddle point target points
[in]targetsSaddle point target locations
[in]weightsWeights for saddle point targets
[out]error_strError information

◆ tokamaker_set_settings()

subroutine tokamaker_set_settings ( type(c_ptr), intent(in), value tmaker_ptr,
type(tokamaker_settings_type), intent(in), value settings,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Update TokaMaker settings.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]settingsSettings object
[out]error_strError string (empty if no error)

◆ tokamaker_set_targets()

subroutine tokamaker_set_targets ( type(c_ptr), intent(in), value tmaker_ptr,
real(c_double), intent(in), value ip_target,
real(c_double), intent(in), value ip_ratio_target,
real(c_double), intent(in), value pax_target,
real(c_double), intent(in), value estore_target,
real(c_double), intent(in), value dflux_target,
real(c_double), intent(in), value r0_target,
real(c_double), intent(in), value z0_target,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set global target values for equilibrium solve.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]ip_targetTarget plasma current [A]
[in]ip_ratio_targetRatio of net plasma current contribution from \(F F'\) compared to \( P' \)
[in]pax_targetTarget axis pressure [Pa]
[in]estore_targetTarget stored energy [J]
[in]dflux_targetTarget dflux [Wb]
[in]r0_targetTarget major radius for magnetic axis
[in]z0_targetTarget vertical position for magnetic axis
[out]error_strError string (empty if no error)

◆ tokamaker_set_vcoil()

subroutine tokamaker_set_vcoil ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value rcoils,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Set Vcoils by defining non-zero resistance of coils.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]rcoilsResistance of coils (Ohm)
[out]error_strError string (empty if no error)

◆ tokamaker_setup()

subroutine tokamaker_setup ( type(c_ptr), intent(in), value tmaker_ptr,
integer(kind=c_int), intent(in), value order,
logical(kind=c_bool), intent(in), value full_domain,
integer(kind=c_int), intent(out) ncoils,
type(c_ptr), intent(out) coil_lmat,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Complete setup of TokaMaker device/wrapper object and build FE representation.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]orderFE order for Lagrange elements
[in]full_domainPlasma covers full domain (eg. fixed-boundary solves)?
[out]ncoilsNumber of coils in model
[out]coil_lmatPointer to coil inductance matrix
[out]error_strError string (empty if no error)

◆ tokamaker_setup_regions()

subroutine tokamaker_setup_regions ( type(c_ptr), intent(in), value tmaker_ptr,
character(kind=c_char), dimension(oft_path_slen), intent(in) coil_file,
type(c_ptr), intent(in), value reg_eta,
type(c_ptr), intent(in), value contig_flag,
type(c_ptr), intent(in), value xpoint_mask,
type(c_ptr), intent(in), value coil_nturns,
integer(c_int), intent(in), value ncoils,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Setup TokaMaker region representations based on coil, conductor, and other information.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]coil_filePath to file containing coil information (for legacy region loading)
[in]reg_etaResistivity values for each region
[in]contig_flagToroidal contiguity/inner limiter flag for each region (1 if toroidally contiguous, 0 if not, -1 if inner limiter region)
[in]xpoint_maskRegion mask for X-point search (1 if region can contain X-points, 0 otherwise)
[in]coil_nturnsNumber of turns for each coil
[in]ncoilsNumber of coils
[out]error_strError string (empty if no error)

◆ tokamaker_setup_td()

subroutine tokamaker_setup_td ( type(c_ptr), intent(in), value tmaker_ptr,
real(c_double), intent(in), value dt,
real(c_double), intent(in), value lin_tol,
real(c_double), intent(in), value nl_tol,
logical(c_bool), intent(in), value pre_plasma,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Setup nonlinear time-dependent solver.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]dtTime step size
[in]lin_tolLinear solver tolerance
[in]nl_tolNonlinear solver tolerance
[in]pre_plasmaInclude plasma contributions in preconditioner?
[out]error_strError string (empty if no error)

◆ tokamaker_solve()

subroutine tokamaker_solve ( type(c_ptr), intent(in), value tmaker_ptr,
logical(c_bool), intent(in), value vacuum,
integer(c_int), intent(out) nl_its,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Perform nonlinear solve to find equilibrium solution for given profiles, targets, etc.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]vacuumPerform vacuum solve?
[out]nl_itsNumber of nonlinear iterations
[out]error_strError string (empty if no error)

◆ tokamaker_step_td()

subroutine tokamaker_step_td ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value curr_ptr,
type(c_ptr), intent(in), value volt_ptr,
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 time-dependent solver by one time step.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]curr_ptrCoil currents at end of step
[in]volt_ptrCoil voltages at end of step
[in,out]timeCurrent simulation time
[in,out]dtTime step size
[out]nl_itsNumber of nonlinear iterations performed
[out]lin_itsNumber of linear iterations performed
[out]nretryNumber of retries performed
[out]error_strError string (empty if no error)

◆ tokamaker_trace_surf()

subroutine tokamaker_trace_surf ( type(c_ptr), intent(in), value tmaker_equil_ptr,
real(c_double), intent(in), value psi_surf,
type(c_ptr), intent(out) points,
integer(c_int), intent(out) npoints,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Trace a flux surface at specified \( \psi \) value and return points defining the surface.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]psi_surfLocation in normalized flux coordinates to trace surface (eg. 0 for LCFS)
[out]pointsPoints defining surface
[out]npointsNumber of points in contour
[out]error_strError string (empty if no error)

◆ tokamaker_vac_solve()

subroutine tokamaker_vac_solve ( type(c_ptr), intent(in), value tmaker_ptr,
type(c_ptr), intent(in), value psi_in,
type(c_ptr), intent(in), value rhs_source,
character(kind=c_char), dimension(oft_error_slen), intent(out) error_str )

Perform linear solve to find vacuum solution for given BCs and current sources.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]psi_inInput: BCs for \( \psi \), Output: solution \( \psi \)
[in]rhs_sourceCurrent source term [A/m^2] (optional)
[out]error_strError string (empty if no error)