The Open FUSION Toolkit 1.0.0-6f445ef
An open-source framework for fusion and plasma science and engineering
Loading...
Searching...
No Matches
Data Types | Functions/Subroutines
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
 Needs docs. More...
 
type  tokamaker_recon_settings_type
 Needs docs. More...
 
type  tokamaker_settings_type
 Needs docs. More...
 

Functions/Subroutines

subroutine tokamaker_alloc (tmaker_ptr, mesh_ptr, error_str)
 Needs docs.
 
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_f::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)
 Needs docs.
 
subroutine tokamaker_destroy (tmaker_ptr, error_str)
 Needs docs.
 
subroutine tokamaker_eig_td (tmaker_ptr, omega, neigs, eigs, eig_vecs, include_bounds, eta_plasma, pm, error_str)
 Needs docs.
 
subroutine tokamaker_eig_wall (tmaker_ptr, neigs, eigs, eig_vecs, pm, error_str)
 Needs docs.
 
logical function tokamaker_equil_ccast (tmaker_equil_cptr, tmaker_equil_obj, error_str)
 Evaluate Green's function for axisymmetric toroidal current loop.
 
subroutine tokamaker_equil_copy (tmaker_ptr, old_equil_ptr, new_equil_ptr, error_str)
 Needs docs.
 
subroutine tokamaker_equil_destroy (tmaker_equil_ptr, error_str)
 Needs docs.
 
subroutine tokamaker_equil_set (tmaker_ptr, new_equil_ptr, error_str)
 Needs docs.
 
subroutine tokamaker_eval_green (n, r, z, rc, zc, vals)
 Needs docs.
 
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)
 Needs docs.
 
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)
 Needs docs.
 
subroutine tokamaker_get_limiter (tmaker_ptr, np, r_loc, nloops, loop_ptr, error_str)
 Needs docs.
 
subroutine tokamaker_get_mesh (tmaker_ptr, np, r_loc, nc, lc_loc, reg_loc, error_str)
 Needs docs.
 
subroutine tokamaker_get_plasma_lmat (tmaker_equil_ptr, lmat, error_str)
 Get mutual inductance matrix for coils and plasma.
 
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)
 Needs docs.
 
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)
 Needs docs.
 
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_recon_run (tmaker_ptr, vacuum, settings, error_flag)
 Needs docs.
 
logical function tokamaker_require_equil (tmaker_obj, error_str)
 Needs docs.
 
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)
 Needs docs.
 
subroutine tokamaker_save_ifile (tmaker_equil_ptr, filename, npsi, ntheta, psi_pad, lcfs_press, pack_lcfs, single_prec, error_str)
 Needs docs.
 
subroutine tokamaker_save_mug (tmaker_equil_ptr, filename, error_str)
 Needs docs.
 
subroutine tokamaker_set_coil_bounds (tmaker_ptr, coil_bounds, error_str)
 Needs docs.
 
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)
 Needs docs.
 
subroutine tokamaker_set_coil_regmat (tmaker_ptr, nregularize, coil_reg_mat, coil_reg_targets, coil_reg_weights, error_str)
 Needs docs.
 
subroutine tokamaker_set_coil_vsc (tmaker_ptr, coil_gains, error_str)
 Needs docs.
 
subroutine tokamaker_set_dipole_a (tmaker_ptr, dipole_a, error_str)
 Needs docs.
 
subroutine tokamaker_set_flux (tmaker_ptr, locations, targets, weights, ntargets, grad_wt_lim, error_str)
 Needs docs.
 
subroutine tokamaker_set_isoflux (tmaker_ptr, targets, ref_points, weights, ntargets, grad_wt_lim, error_str)
 Needs docs.
 
subroutine tokamaker_set_mirror_slosh (tmaker_ptr, mirror_n, mirror_bturn, mirror_zthroat, error_str)
 Needs docs.
 
subroutine tokamaker_set_psi (tmaker_equil_ptr, psi_vals, update_bounds, error_str)
 Needs docs.
 
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)
 Needs docs.
 
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, r0_target, v0_target, error_str)
 Needs docs.
 
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)
 Needs docs.
 
subroutine tokamaker_setup_regions (tmaker_ptr, coil_file, reg_eta, contig_flag, xpoint_mask, coil_nturns, ncoils, error_str)
 Needs docs.
 
subroutine tokamaker_setup_td (tmaker_ptr, dt, lin_tol, nl_tol, pre_plasma, error_str)
 Needs docs.
 
subroutine tokamaker_solve (tmaker_ptr, vacuum, error_str)
 Needs docs.
 
subroutine tokamaker_step_td (tmaker_ptr, curr_ptr, volt_ptr, time, dt, nl_its, lin_its, nretry, error_str)
 Needs docs.
 
subroutine tokamaker_trace_surf (tmaker_equil_ptr, psi_surf, points, npoints, error_str)
 Needs docs.
 
subroutine tokamaker_vac_solve (tmaker_ptr, psi_in, rhs_source, error_str)
 Needs docs.
 

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 
)

Needs docs.

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_f::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 
)

Needs docs.

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 
)

Needs docs.

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_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 
)

Needs docs.

Parameters
[in]tmaker_ptrPointer to TokaMaker 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 
)

Needs docs.

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 
)

Evaluate Green's function for axisymmetric toroidal current loop.

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 
)

Needs docs.

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 
)

Needs docs.

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 
)

Needs docs.

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 
)

Needs docs.

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 
)

Needs docs.

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 
)

Needs docs.

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 
)

Needs docs.

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 
)

Needs docs.

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_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 
)

Needs docs.

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 
)

Needs docs.

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_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)  settings,
integer(c_int), intent(out)  error_flag 
)

Needs docs.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]vacuumNeeds docs
[in]settingsNeeds docs
[out]error_flagNeeds docs

◆ 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 
)

Needs docs.

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 
)

Needs docs.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]filenameNeeds docs
[in]run_infoNeeds docs
[in]nrNeeds docs
[in]nzNeeds docs
[in]rboundsNeeds docs
[in]zboundsNeeds docs
[in]psi_padNeeds docs
[in]rcentrNeeds docs
[in]trunc_eqNeeds docs
[in]lim_filenameNeeds docs
[in]lcfs_pressNeeds docs
[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 
)

Needs docs.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]filenameNeeds docs
[in]npsiNeeds docs
[in]nthetaNeeds docs
[in]psi_padNeeds docs
[in]lcfs_pressNeeds docs
[in]pack_lcfsNeeds docs
[in]single_precNeeds docs
[out]error_strNeeds docs

◆ 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 
)

Needs docs.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]filenameNeeds docs
[out]error_strNeeds docs

◆ 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 
)

Needs docs.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]coil_boundsNeeds docs
[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
[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 
)

Needs docs.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]currentsNeeds docs
[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 
)

Needs docs.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]nregularizeNeeds docs
[in]coil_reg_matNeeds docs
[in]coil_reg_targetsNeeds docs
[in]coil_reg_weightsNeeds docs
[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 
)

Needs docs.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]coil_gainsNeeds docs
[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 
)

Needs docs.

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 
)

Needs docs.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]ntargetsNeeds docs
[in]locationsNeeds docs
[in]targetsNeeds docs
[in]weightsNeeds docs
[in]grad_wt_limNeeds docs
[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 
)

Needs docs.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]ntargetsNeeds docs
[in]targetsNeeds docs
[in]ref_pointsNeeds docs
[in]weightsNeeds docs
[in]grad_wt_limNeeds docs
[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 
)

Needs docs.

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_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 
)

Needs docs.

Parameters
[in]tmaker_equil_ptrTokaMaker equilibrium instance
[in]psi_valsNeeds docs
[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 
)

Needs docs.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]ntargetsNeeds docs
[in]targetsNeeds docs
[in]weightsNeeds docs
[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)  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  r0_target,
real(c_double), intent(in), value  v0_target,
character(kind=c_char), dimension(oft_error_slen), intent(out)  error_str 
)

Needs docs.

Parameters
[in]tmaker_ptrTokaMaker instance
[in]ip_targetNeeds docs
[in]ip_ratio_targetNeeds docs
[in]pax_targetNeeds docs
[in]estore_targetNeeds docs
[in]r0_targetNeeds docs
[in]v0_targetNeeds docs
[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 
)

Needs docs.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]orderFE order for Lagrange elements
[in]full_domainNeeds docs
[out]ncoilsNeeds docs
[out]coil_lmatNeeds docs
[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 
)

Needs docs.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]coil_fileNeeds docs
[in]reg_etaNeeds docs
[in]contig_flagNeeds docs
[in]xpoint_maskNeeds docs
[in]coil_nturnsNeeds docs
[in]ncoilsNeeds docs
[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 
)

Needs docs.

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,
character(kind=c_char), dimension(oft_error_slen), intent(out)  error_str 
)

Needs docs.

Parameters
[in]tmaker_ptrPointer to TokaMaker object
[in]vacuumPerform vacuum solve?
[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 
)

Needs docs.

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 
)

Needs docs.

Parameters
[in]tmaker_equil_ptrPointer to TokaMaker equilibrium object
[in]psi_surfNeeds docs
[out]pointsNeeds docs
[out]npointsNeeds docs
[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 
)

Needs docs.

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)