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

Detailed Description

TokaMaker equilibrium reconstruction class.

Public Member Functions

 __del__ (self)
 Destroy reconstruction object.
 __init__ (self, tMaker_obj, in_filename='fit.in', out_filename='fit.out')
 Create equilibrium reconstruction object.
 add_flux_loop (self, loc, val, err)
 Add full poloidal flux loop constraint.
 add_Mirnov (self, loc, norm, val, err)
 Add Mirnov sensor constraint.
 add_pressure (self, loc, val, err)
 Add plasma pressure constraint.
 add_saddle (self, p1, p2, width, val, err)
 Add saddle loop constraint.
 destroy_constraints (self)
 Destroy constraints in TokaMaker.
 eval_error (self, vacuum=False, save_to_file=False)
 Evaluate error in current equilibrium for specified constraints without performing reconstruction.
 opt_get_dofs (self)
 Get DoF vector for general optimization routines using opt_error and opt_error_jacobian.
 plot_constraints (self, fig, ax, plot_flux_loops=True, plot_mirnovs=True, plot_saddles=True, plot_pressure=True, mirnov_scale=1.0, base_zorder=0)
 Plot constraint locations in R-Z plane for current constraints.
 plot_error (self, ax, error_mat=None, error_file=None, coil_ax=None, chi_ax=None)
 Plot constraint values and reconstructed signals for current equilibrium from reconstruction output file.
 read_fit_in (self)
 Read constraints from existing input file.
 reconstruct (self, vacuum=False, linearized_fit=False, maxits=100, eps=1.E-3, ftol=1.E-3, xtol=1.E-3, gtol=1.E-3)
 Reconstruct G-S equation with specified fitting constraints, profiles, etc.
 reset_constraints (self)
 Remove all current constraints.
 set_coil_currents (self, targets, errs)
 Set coil current constraints.
 set_DFlux (self, DFlux, err)
 Set diamagnetic flux constraint.
 set_Ip (self, Ip, err)
 Set plasma current constraint.
 setup_constraints (self)
 Set up constraints in TokaMaker for current equilibrium without performing reconstruction.
 setup_get_opt (self, fail_factor=1.E2, pp_target_weight=1.E5, opoint_target_weight=1.E2)
 Setup object for use with general optimization routines, such as scipy.optimize.minimize, which will call opt_error and, optionally, opt_error_jacobian with appropriate arguments.
 write_fit_in (self)
 Create reconstruction input file for specified constraints.

Static Public Member Functions

 opt_error (cofs, recon_obj, in_jac)
 Compute weighted constraint error for given DoF vector cofs and reconstruction object recon_obj.
 opt_error_jacobian (cofs, recon_obj, in_jac)
 Compute Jacobian matrix corresponding by differencing opt_error for given DoF vector cofs and reconstruction object recon_obj.

Public Attributes

 con_file = in_filename
 Name of constraint file (input for reconstruction).
 out_file = out_filename
 Name of reconstruction output file.
 settings = tokamaker_recon_settings()
 Reconstruction specific settings object.

Protected Attributes

list _coil_current_cons = []
 Coil current constraints.
 _Dflux_con = None
 Diamagnetic flux constraint.
 _EQ_center = self._tMaker_obj.copy_eq()
int _err_min = 1.E99
 _fail_error = error0*fail_factor
list _flux_loops = []
 Flux loop constraints.
 _Ip_con = None
 Plasma current constraint.
list _mirnovs = []
 Mirnov sensor constraints.
int _ncons = 0
 Number of constraints in underlying Fortran object.
list _pressure_cons = []
 Plasma pressure constraints.
list _saddles = []
 Saddle loop constraints.
 _tMaker_obj = tMaker_obj
 Grad-Shafranov object for reconstruction.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
tMaker_obj,
in_filename = 'fit.in',
out_filename = 'fit.out' )

Create equilibrium reconstruction object.

Parameters
tMaker_objTokaMaker object used for computing G-S equilibria
in_filenameFilename to use for reconstruction input
out_filenameFilename to use for reconstruction outputs

◆ __del__()

__del__ ( self)

Destroy reconstruction object.

Member Function Documentation

◆ add_flux_loop()

add_flux_loop ( self,
loc,
val,
err )

Add full poloidal flux loop constraint.

Parameters
locLocation of flux loop in R-Z plane [2]
valValue of flux loop constraint
errError in constraint

◆ add_Mirnov()

add_Mirnov ( self,
loc,
norm,
val,
err )

Add Mirnov sensor constraint.

Parameters
locLocation of Mirnov in R-Z plane [2]
normUnit normal in R-Z plane [2]
valValue of Mirnov constraint
errError in constraint

◆ add_pressure()

add_pressure ( self,
loc,
val,
err )

Add plasma pressure constraint.

Parameters
locLocation of measurement in R-Z plane [2]
valValue of pressure constraint
errError in constraint

◆ add_saddle()

add_saddle ( self,
p1,
p2,
width,
val,
err )

Add saddle loop constraint.

Parameters
p1Location of first toroidal saddle leg in R-Z plane [2]
p2Location of second toroidal saddle leg in R-Z plane [2]
widthToroidal extent in radians
valValue of saddle loop constraint
errError in constraint

◆ destroy_constraints()

destroy_constraints ( self)

Destroy constraints in TokaMaker.

◆ eval_error()

eval_error ( self,
vacuum = False,
save_to_file = False )

Evaluate error in current equilibrium for specified constraints without performing reconstruction.

Parameters
vacuumPerform vacuum reconstruction
save_to_fileSave error matrix to file specified in settings.outfile
Returns
Error matrix if save_to_file=False, otherwise None (error matrix will be saved to file)

◆ opt_error()

opt_error ( cofs,
recon_obj,
in_jac )
static

Compute weighted constraint error for given DoF vector cofs and reconstruction object recon_obj.

This function is designed to be called by general optimization routines, such as scipy.optimize.minimize.

Parameters
cofsDoF vector
recon_objTokaMaker.reconstruction.reconstruction object to be used
in_jacFlag indicating whether this function is being called from a Jacobian calculation to make print statements during finite differencing
Returns
Weighted error vector for current DoFs

◆ opt_error_jacobian()

opt_error_jacobian ( cofs,
recon_obj,
in_jac )
static

Compute Jacobian matrix corresponding by differencing opt_error for given DoF vector cofs and reconstruction object recon_obj.

Parameters
cofsDoF vector
recon_objTokaMaker.reconstruction.reconstruction object to be used
in_jacIgnored flag just to match signature with opt_error
Returns
Jacobian matrix for current DoFs

◆ opt_get_dofs()

opt_get_dofs ( self)

Get DoF vector for general optimization routines using opt_error and opt_error_jacobian.

Returns
DoF vector

◆ plot_constraints()

plot_constraints ( self,
fig,
ax,
plot_flux_loops = True,
plot_mirnovs = True,
plot_saddles = True,
plot_pressure = True,
mirnov_scale = 1.0,
base_zorder = 0 )

Plot constraint locations in R-Z plane for current constraints.

Parameters
figMatplotlib figure to plot on
axMatplotlib axis to plot on
plot_flux_loopsWhether to plot flux loop constraints
plot_mirnovsWhether to plot Mirnov sensor constraints
plot_saddlesWhether to plot saddle loop constraints
plot_pressureWhether to plot plasma pressure constraints
mirnov_scaleScaling factor for Mirnov sensor quiver plot (default 1.0, smaller values increase arrow size)
base_zorderBase z-order for plotting constraints (default 0.0, higher values will plot on top of lower values)

◆ plot_error()

plot_error ( self,
ax,
error_mat = None,
error_file = None,
coil_ax = None,
chi_ax = None )

Plot constraint values and reconstructed signals for current equilibrium from reconstruction output file.

Parameters
axMatplotlib axis to plot on
error_matError matrix, if None eval_error will be called
error_fileFile containing error data
coil_axMatplotlib axis to plot coil current constraints on
chi_axMatplotlib axis to plot chi-squared values on

◆ read_fit_in()

read_fit_in ( self)

Read constraints from existing input file.

◆ reconstruct()

reconstruct ( self,
vacuum = False,
linearized_fit = False,
maxits = 100,
eps = 1.E-3,
ftol = 1.E-3,
xtol = 1.E-3,
gtol = 1.E-3 )

Reconstruct G-S equation with specified fitting constraints, profiles, etc.

Parameters
vacuumPerform vacuum reconstruction
linearized_fitUse linearized solve for suitable terms
maxitsMaximum number of iterations
epsEpsilong factor for finite difference derivative calculations
ftolStopping condition: termination occurs when both the actual and predicted relative reductions in the sum of squares are at most ftol
xtolStopping condition: termination occurs when the relative error between two consecutive iterates is at most xtol
gtolStopping condition: termination occurs when the cosine of the angle between fvec and any column of the jacobian is at most gtol in absolute value
Returns
Error flag

◆ reset_constraints()

reset_constraints ( self)

Remove all current constraints.

◆ set_coil_currents()

set_coil_currents ( self,
targets,
errs )

Set coil current constraints.

Parameters
targetsDictionary of coil current targets
errsDictionary of coil current constraint errors

◆ set_DFlux()

set_DFlux ( self,
DFlux,
err )

Set diamagnetic flux constraint.

Parameters
DFluxValue of diamagnetic flux constraint
errError in constraint

◆ set_Ip()

set_Ip ( self,
Ip,
err )

Set plasma current constraint.

Parameters
IpValue of plasma current constraint
errError in constraint

◆ setup_constraints()

setup_constraints ( self)

Set up constraints in TokaMaker for current equilibrium without performing reconstruction.

Returns
Error flag

◆ setup_get_opt()

setup_get_opt ( self,
fail_factor = 1.E2,
pp_target_weight = 1.E5,
opoint_target_weight = 1.E2 )

Setup object for use with general optimization routines, such as scipy.optimize.minimize, which will call opt_error and, optionally, opt_error_jacobian with appropriate arguments.

This function should be called after setting up constraints with setup_constraints and before calling optimization routines.

Parameters
fail_factorFactor to multiply initial error by for failed solves
pp_target_weightWeight for global P' targets when treated as soft constraints and fit_Pscale is True
opoint_target_weightWeight for R0 and Z0 targets when treated as soft constraints and fitR0 or fitZ0 is True
Returns
Initial DoF vector for optimization, error vector for initial DoFs

◆ write_fit_in()

write_fit_in ( self)

Create reconstruction input file for specified constraints.

Member Data Documentation

◆ _coil_current_cons

_coil_current_cons = []
protected

Coil current constraints.

◆ _Dflux_con

_Dflux_con = None
protected

Diamagnetic flux constraint.

◆ _EQ_center

_EQ_center = self._tMaker_obj.copy_eq()
protected

◆ _err_min

int _err_min = 1.E99
protected

◆ _fail_error

_fail_error = error0*fail_factor
protected

◆ _flux_loops

_flux_loops = []
protected

Flux loop constraints.

◆ _Ip_con

_Ip_con = None
protected

Plasma current constraint.

◆ _mirnovs

_mirnovs = []
protected

Mirnov sensor constraints.

◆ _ncons

int _ncons = 0
protected

Number of constraints in underlying Fortran object.

◆ _pressure_cons

_pressure_cons = []
protected

Plasma pressure constraints.

◆ _saddles

_saddles = []
protected

Saddle loop constraints.

◆ _tMaker_obj

_tMaker_obj = tMaker_obj
protected

Grad-Shafranov object for reconstruction.

◆ con_file

con_file = in_filename

Name of constraint file (input for reconstruction).

◆ out_file

out_file = out_filename

Name of reconstruction output file.

◆ settings

Reconstruction specific settings object.


The documentation for this class was generated from the following file: