![]() |
The Open FUSION Toolkit 26.6
An open-source framework for fusion and plasma science and engineering
|
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. | |
| __init__ | ( | self, | |
| tMaker_obj, | |||
| in_filename = 'fit.in', | |||
| out_filename = 'fit.out' ) |
Create equilibrium reconstruction object.
| tMaker_obj | TokaMaker object used for computing G-S equilibria |
| in_filename | Filename to use for reconstruction input |
| out_filename | Filename to use for reconstruction outputs |
| __del__ | ( | self | ) |
Destroy reconstruction object.
| add_flux_loop | ( | self, | |
| loc, | |||
| val, | |||
| err ) |
Add full poloidal flux loop constraint.
| loc | Location of flux loop in R-Z plane [2] |
| val | Value of flux loop constraint |
| err | Error in constraint |
| add_Mirnov | ( | self, | |
| loc, | |||
| norm, | |||
| val, | |||
| err ) |
Add Mirnov sensor constraint.
| loc | Location of Mirnov in R-Z plane [2] |
| norm | Unit normal in R-Z plane [2] |
| val | Value of Mirnov constraint |
| err | Error in constraint |
| add_pressure | ( | self, | |
| loc, | |||
| val, | |||
| err ) |
Add plasma pressure constraint.
| loc | Location of measurement in R-Z plane [2] |
| val | Value of pressure constraint |
| err | Error in constraint |
| add_saddle | ( | self, | |
| p1, | |||
| p2, | |||
| width, | |||
| val, | |||
| err ) |
Add saddle loop constraint.
| p1 | Location of first toroidal saddle leg in R-Z plane [2] |
| p2 | Location of second toroidal saddle leg in R-Z plane [2] |
| width | Toroidal extent in radians |
| val | Value of saddle loop constraint |
| err | Error in 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.
| vacuum | Perform vacuum reconstruction |
| save_to_file | Save error matrix to file specified in settings.outfile |
|
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.
| cofs | DoF vector |
| recon_obj | TokaMaker.reconstruction.reconstruction object to be used |
| in_jac | Flag indicating whether this function is being called from a Jacobian calculation to make print statements during finite differencing |
|
static |
Compute Jacobian matrix corresponding by differencing opt_error for given DoF vector cofs and reconstruction object recon_obj.
| cofs | DoF vector |
| recon_obj | TokaMaker.reconstruction.reconstruction object to be used |
| in_jac | Ignored flag just to match signature with opt_error |
| 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.
| fig | Matplotlib figure to plot on |
| ax | Matplotlib axis to plot on |
| plot_flux_loops | Whether to plot flux loop constraints |
| plot_mirnovs | Whether to plot Mirnov sensor constraints |
| plot_saddles | Whether to plot saddle loop constraints |
| plot_pressure | Whether to plot plasma pressure constraints |
| mirnov_scale | Scaling factor for Mirnov sensor quiver plot (default 1.0, smaller values increase arrow size) |
| base_zorder | Base z-order for plotting constraints (default 0.0, higher values will plot on top of lower values) |
| 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.
| ax | Matplotlib axis to plot on |
| error_mat | Error matrix, if None eval_error will be called |
| error_file | File containing error data |
| coil_ax | Matplotlib axis to plot coil current constraints on |
| chi_ax | Matplotlib axis to plot chi-squared values on |
| 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.
| vacuum | Perform vacuum reconstruction |
| linearized_fit | Use linearized solve for suitable terms |
| maxits | Maximum number of iterations |
| eps | Epsilong factor for finite difference derivative calculations |
| ftol | Stopping condition: termination occurs when both the actual and predicted relative reductions in the sum of squares are at most ftol |
| xtol | Stopping condition: termination occurs when the relative error between two consecutive iterates is at most xtol |
| gtol | Stopping condition: termination occurs when the cosine of the angle between fvec and any column of the jacobian is at most gtol in absolute value |
| reset_constraints | ( | self | ) |
Remove all current constraints.
| set_coil_currents | ( | self, | |
| targets, | |||
| errs ) |
Set coil current constraints.
| targets | Dictionary of coil current targets |
| errs | Dictionary of coil current constraint errors |
| set_DFlux | ( | self, | |
| DFlux, | |||
| err ) |
Set diamagnetic flux constraint.
| DFlux | Value of diamagnetic flux constraint |
| err | Error in constraint |
| set_Ip | ( | self, | |
| Ip, | |||
| err ) |
Set plasma current constraint.
| Ip | Value of plasma current constraint |
| err | Error in 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.
This function should be called after setting up constraints with setup_constraints and before calling optimization routines.
| fail_factor | Factor to multiply initial error by for failed solves |
| pp_target_weight | Weight for global P' targets when treated as soft constraints and fit_Pscale is True |
| opoint_target_weight | Weight for R0 and Z0 targets when treated as soft constraints and fitR0 or fitZ0 is True |
| write_fit_in | ( | self | ) |
Create reconstruction input file for specified constraints.
|
protected |
Coil current constraints.
|
protected |
Diamagnetic flux constraint.
|
protected |
|
protected |
|
protected |
|
protected |
Flux loop constraints.
|
protected |
Plasma current constraint.
|
protected |
Mirnov sensor constraints.
|
protected |
Number of constraints in underlying Fortran object.
|
protected |
Plasma pressure constraints.
|
protected |
Saddle loop constraints.
|
protected |
Grad-Shafranov object for reconstruction.
| 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.