Skip to content

build_tokamak_system.m

Basic Information

  USAGE: tok_system= build_tokamak_system(build_inputs)

  PURPOSE: Generic script to build tokamak axisymmetric system from
    pre-calculated objects. Includes R,Z,Ip response in system.

  INPUTS: (in build_inputs structure)
   tokamak = name of tokamak system to construct (required)
   vacuum_objs = structure containing device model objects (required)
   cccirc = connection vector for CC's
   netlist = network connection description (Only one of cccirc or netlist can
             be input.  If neither is input, default connections are used.)
   efit_gfile = equilibrium gfile to read (not required if ichooseq=0)
   ichooseq= equilibrium file type:
       0 = vacuum model (no equilibrium data required)
    1 = efit_gfile
    2 = corsica generated flat files
    3 = saved corsica equilibrium
    4 = TokSys equilibrium data structure
   corsica_inputs = name of directory containing corsica input (flat) files
            (required only if ichooseq=2)
   corsica_savefile = name of saved corsica equilibrium
            (required only if ichooseq=3)
   equil_data = name of TokSys format equilibrium data structure
            (required only if ichooseq=4)
   irzresp_dynamic, irzresp_output = flags determining plasma contribution to
          dynamic (state) and output equations (default = 3 for both):
        0 = motionless plasma
     1 = rigid R motion
     2 = rigid Z
     3 = both R and Z rigid motions
     4 = nonrigid plasma response based on vst in corsica
     5 = gspert, (perturbed grad-shafronv equation plasma response)

  OPTIONAL INPUTS:
   vvgroup = vacuum vessel grouping vector: length = all vessel elements
        set element value = k to belong to group k, 0 to not include
        (default= [1:total # elements])
   vvcirc  = circuit connection vector for vac. vessel(default=all independent)
   iplcirc = flag to select inclusion of plasma circuit in state space(1)
        or not(0) (optional, default = 1 if ichooseq>0)
   Rp       = (optional) user override of computed plasma resistance
   Rext     = extra circuit resistance to add to each coil and vessel element
           can be either length=#coils or #coils + #vessel (default=0)
   Lext     = extra circuit inductance to add to each coil/vessel
           can be either length=#coils or #coils + #vessel (default=0)
   replace_Rext= if 1, instead of adding Rext, replace the computed coil/vessel
                     resistance with Rext (default=0)
   cc_file = file containing coil currents (optional, usually given by efit)
   idx_efit_to_tok = optional map of efit indices to toksys indices, s.t. if
       I=currents in efit order, then I(idx_efit_to_tok)=currents in toksys order
   scldzdis = To increase gamma when irzresp_dynamic=irzresp_output=4,
            make scldzdis<1.0. (optional, default=1)
   tok_geo_plot_fn = one of 'generic', 'plot_east_geo', 'plot_kstar_geo', etc.
        (optional, default = '' or 'none' => no plots)
   Te_res = plasma electron temp for plasma resistance calc [eV]
              (optional, default = 4000eV)
   li_res = plasma internal inductance for resistance calculation
               (optional,default = 0.5)
   Zeff_res = Zeff for resistance calc (optional, default = 1.5)
   scale_R_scpf = scale factor to multiply resistance of superconducting
           PF coils, scalar or vector of length = number of coils
                     (optional, default = 1 applied to ALL coils)
   netlist_currents = array of strings defining branches for which to output
                      currents (optional, default = no current outputs,
                      not used if cccirc used for circuit connectivity)
   netlist_voltages = n x 2 matrix, each row containing node numbers [N1 N2],
                      with voltage output defined as V(N1)-V(N2)
                      (optional, default = no voltage outputs,
                       not used if cccirc used for circuit connectivity)
   gspert_options = options for gspert calculation (only used if irzresp values=5)
   iwait = (optional) flag: 1=wait when error messages, 0(default)=no wait
   verbose  = level of screen output. Allowed values are:
         0 = no messages or uncritical warnings (default)
         1 = display warnings
         2 = display warnings and other messages

  OUTPUTS:
     tok_system = structure containing model of tokamak system

  RESTRICTIONS:
        Must have specified objects files in specified path.
    Dimensions of equilibrium objects much match electromagnetic system
    dimensions (eg grid rg,zg must match crj dimensions).

  METHOD:
       Loads and defines objects needed for control analysis/design.
    cccirc uses Corsica connection vector convention: vector of indices
    identifying which circuit each coil belongs to ("index" is negative to
    denote antiseries...). So eg [1 2 3 1 -2 -3] means coil 1 is series'd
    with coil 4, coil 2 is antiseries'd with coil 5, coil 3 is antiseriesd
    with coil 6, and there are 3 total circuits in the final connected
    system.

Dependencies