gvec.core.compute#
GVEC Postprocessing - Compute Functions
- gvec.core.compute.Evaluations(rho: Literal['int'] | int | float | DataArray | ndarray | Sequence | None = 'int', theta: Literal['int'] | int | float | DataArray | ndarray | Sequence | None = 'int', zeta: Literal['int'] | int | float | DataArray | ndarray | Sequence | None = 'int', state: State | None = None, nfp: int | None = None)#
- gvec.core.compute.EvaluationsBoozer(rho: Literal['int'] | int | float | DataArray | ndarray | Sequence, theta_B: int | float | DataArray | ndarray | Sequence, zeta_B: int | float | DataArray | ndarray | Sequence, state: State, **boozer_kwargs)#
Create an Evaluations dataset with a grid in Boozer coordinates.
This factory function generates a mesh in logical coordinates (rho, theta, zeta) based on a grid in Boozer coordinates. The grid has dimensions (“rad”, “pol”, “tor”), corresponding to the radial, poloidal, and toroidal directions.
If a 2D or 3D array for theta_B or zeta_B is passed, the corresponding coordinate for the poloidal/toroidal dimension needs to be set manually afterwards (e.g. ev[“alpha”] = (“pol”, values) and ev = ev.set_coords(“alpha”).set_xindex(“alpha”)).
- Parameters:
rho ("int" | int | float | 1D array (DataArray, ndarray, list)) – The specification of the radial, radius-like coordinate. “int” will use the integration points from the state object.
theta_B (int | float | 1D, 2D or 3D array (DataArray, ndarray, list)) – The specification of the poloidal, angle-like Boozer coordinate. 1D assumes dimension “pol”, 2D assumes (“pol”, “tor”), 3D assumes (“rad”, “pol”, “tor”).
zeta_B (int | float | 1D, 2D or 3D array (DataArray, ndarray, list)) – The specification of the toroidal, angle-like Boozer coordinate. 1D assumes dimension “tor”, 2D assumes (“pol”, “tor”), 3D assumes (“rad”, “pol”, “tor”).
state (State) – The gvec.State object to create the grid for. Used to perform the Boozer transform.
boozer_kwargs (dict) – Additional keyword arguments to pass to the get_boozer method of the state object. These can be used to specify the Boozer transform parameters, such as the maximum mode numbers via ‘MNfactor’.
- gvec.core.compute.compute(ev: ~xarray.core.dataset.Dataset, *quantities: str, state: ~gvec.core.state.State | None = None, registry: ~collections.abc.Mapping = {'B': <function B>, 'B_contra_t': <function B>, 'B_contra_t_B': <function B_contra_t_B>, 'B_contra_z': <function B>, 'B_contra_z_B': <function B_contra_z_B>, 'B_theta_avg': <function B_theta_avg>, 'B_zeta_avg': <function B_zeta_avg>, 'F': <function F>, 'F_r_avg': <function F_r_avg>, 'I_pol': <function I_pol>, 'I_tor': <function I_tor>, 'J': <function J>, 'J_contra_r': <function J>, 'J_contra_t': <function J>, 'J_contra_z': <function J>, 'Jac': <function Jac>, 'Jac_B': <function Jac_B>, 'Jac_P': <function Jac_P>, 'Jac_h': <function Jac_h>, 'Jac_l': <function Jac>, 'LA': <function _base.<locals>.base>, 'N_FP': <function N_FP>, 'Phi': <function _profile.<locals>.profile>, 'Phi_edge': <function Phi_edge>, 'V': <function V>, 'W_MHD': <function W_MHD>, 'X1': <function _base.<locals>.base>, 'X2': <function _base.<locals>.base>, 'chi': <function _profile.<locals>.profile>, 'dB_contra_t_dr': <function dB>, 'dB_contra_t_dt': <function dB>, 'dB_contra_t_dz': <function dB>, 'dB_contra_z_dr': <function dB>, 'dB_contra_z_dt': <function dB>, 'dB_contra_z_dz': <function dB>, 'dJac_dr': <function Jac_derivs>, 'dJac_dt': <function Jac_derivs>, 'dJac_dz': <function Jac_derivs>, 'dJac_h_dr': <function Jac_h_derivs>, 'dJac_h_dt': <function Jac_h_derivs>, 'dJac_h_dz': <function Jac_h_derivs>, 'dJac_l_dr': <function Jac_derivs>, 'dJac_l_dt': <function Jac_derivs>, 'dJac_l_dz': <function Jac_derivs>, 'dLA_dr': <function _base.<locals>.base>, 'dLA_drr': <function _base.<locals>.base>, 'dLA_drt': <function _base.<locals>.base>, 'dLA_drz': <function _base.<locals>.base>, 'dLA_dt': <function _base.<locals>.base>, 'dLA_dtt': <function _base.<locals>.base>, 'dLA_dtz': <function _base.<locals>.base>, 'dLA_dz': <function _base.<locals>.base>, 'dLA_dzz': <function _base.<locals>.base>, 'dNU_B_dt': <function dNU_B_dt>, 'dNU_B_dz': <function dNU_B_dz>, 'dPhi_dr': <function _profile.<locals>.profile>, 'dPhi_drr': <function _profile.<locals>.profile>, 'dV_dPhi_n': <function dV_dPhi_n>, 'dV_dPhi_n2': <function dV_dPhi_n2>, 'dX1_dr': <function _base.<locals>.base>, 'dX1_drr': <function _base.<locals>.base>, 'dX1_drt': <function _base.<locals>.base>, 'dX1_drz': <function _base.<locals>.base>, 'dX1_dt': <function _base.<locals>.base>, 'dX1_dtt': <function _base.<locals>.base>, 'dX1_dtz': <function _base.<locals>.base>, 'dX1_dz': <function _base.<locals>.base>, 'dX1_dzz': <function _base.<locals>.base>, 'dX2_dr': <function _base.<locals>.base>, 'dX2_drr': <function _base.<locals>.base>, 'dX2_drt': <function _base.<locals>.base>, 'dX2_drz': <function _base.<locals>.base>, 'dX2_dt': <function _base.<locals>.base>, 'dX2_dtt': <function _base.<locals>.base>, 'dX2_dtz': <function _base.<locals>.base>, 'dX2_dz': <function _base.<locals>.base>, 'dX2_dzz': <function _base.<locals>.base>, 'dchi_dr': <function _profile.<locals>.profile>, 'dchi_drr': <function _profile.<locals>.profile>, 'dg_rr_dr': <function metric>, 'dg_rr_dt': <function metric>, 'dg_rr_dz': <function metric>, 'dg_rt_dr': <function metric>, 'dg_rt_dt': <function metric>, 'dg_rt_dz': <function metric>, 'dg_rz_dr': <function metric>, 'dg_rz_dt': <function metric>, 'dg_rz_dz': <function metric>, 'dg_tt_dr': <function metric>, 'dg_tt_dt': <function metric>, 'dg_tt_dz': <function metric>, 'dg_tz_dr': <function metric>, 'dg_tz_dt': <function metric>, 'dg_tz_dz': <function metric>, 'dg_zz_dr': <function metric>, 'dg_zz_dt': <function metric>, 'dg_zz_dz': <function metric>, 'diota_dr': <function _profile.<locals>.profile>, 'diota_drr': <function _profile.<locals>.profile>, 'dp_dr': <function _profile.<locals>.profile>, 'dp_drr': <function _profile.<locals>.profile>, 'e_q1': <function hmap>, 'e_q2': <function hmap>, 'e_q3': <function hmap>, 'e_rho': <function e_rho>, 'e_theta': <function e_theta>, 'e_theta_B': <function e_theta_B>, 'e_zeta': <function e_zeta>, 'e_zeta_B': <function e_zeta_B>, 'g_rr': <function g_rr>, 'g_rt': <function g_rt>, 'g_rz': <function g_rz>, 'g_tt': <function g_tt>, 'g_tz': <function g_tz>, 'g_zz': <function g_zz>, 'gamma': <function gamma>, 'grad_rho': <function grad_rho>, 'grad_theta': <function grad_theta>, 'grad_theta_P': <function grad_theta_P>, 'grad_zeta': <function grad_zeta>, 'iota': <function _profile.<locals>.profile>, 'iota_0': <function iota_0>, 'iota_avg': <function iota_avg>, 'iota_curr': <function iota_curr>, 'iota_curr_0': <function iota_curr_0>, 'major_radius': <function minor_major_radius>, 'minor_radius': <function minor_major_radius>, 'mod_B': <function _modulus.<locals>.mod_v>, 'mod_F': <function _modulus.<locals>.mod_v>, 'mod_J': <function _modulus.<locals>.mod_v>, 'mod_e_rho': <function _modulus.<locals>.mod_v>, 'mod_e_theta': <function _modulus.<locals>.mod_v>, 'mod_e_zeta': <function _modulus.<locals>.mod_v>, 'mod_grad_rho': <function _modulus.<locals>.mod_v>, 'mod_grad_theta': <function _modulus.<locals>.mod_v>, 'mod_grad_zeta': <function _modulus.<locals>.mod_v>, 'mu0': <function mu0>, 'p': <function _profile.<locals>.profile>, 'pos': <function hmap>, 'shear': <function shear>, 'theta_P': <function theta_P>, 'xyz': <function xyz>}) Dataset#
Compute the target equilibrium quantity and add it to the given evaluation dataset.
This method will compute required parameters recursively and add them to the dataset.
- Parameters:
ev (xr.Dataset) – The evaluation dataset with the target coordinates (rho, theta, zeta) and possibly some precomputed quantities.
quantities (str) – One or more names of the quantities to compute. See table_of_quantities for a list of available quantities.
state (State, optional) – A gvec.State object that is used to compute the quantities. Not necessary if the desired quantities only depend on already computed quantities.
registry (Mapping, optional) – The registry of computable quantites to use.
- gvec.core.compute.ev2ft(ev, quiet=False)#
- gvec.core.compute.evaluate(state: State, *quantities: str, rho: Literal['int'] | int | float | DataArray | ndarray | Sequence | None = 'int', theta: Literal['int'] | int | float | DataArray | ndarray | Sequence | None = 'int', zeta: Literal['int'] | int | float | DataArray | ndarray | Sequence | None = 'int')#
- gvec.core.compute.evaluate_sfl(state: State, *quantities: str, rho: int | float | DataArray | ndarray | Sequence | Literal['int'], theta: int | float | DataArray | ndarray | Sequence, zeta: int | float | DataArray | ndarray | Sequence, sfl: Literal['boozer'], **boozer_kwargs)#
- gvec.core.compute.fluxsurface_integral(quantity: DataArray)#
Compute the flux surface integral of the given quantity.
- gvec.core.compute.ft_autoremove(ft: Dataset, drop=False, **tol_kwargs)#
autoremove variables which are always close to zero (e.g. due to stellarator symmetry)
- gvec.core.compute.radial_integral(quantity: DataArray)#
Compute the radial integral/average of the given quantity.
- gvec.core.compute.table_of_quantities(markdown: bool = False, registry: ~collections.abc.Mapping = {'B': <function B>, 'B_contra_t': <function B>, 'B_contra_t_B': <function B_contra_t_B>, 'B_contra_z': <function B>, 'B_contra_z_B': <function B_contra_z_B>, 'B_theta_avg': <function B_theta_avg>, 'B_zeta_avg': <function B_zeta_avg>, 'F': <function F>, 'F_r_avg': <function F_r_avg>, 'I_pol': <function I_pol>, 'I_tor': <function I_tor>, 'J': <function J>, 'J_contra_r': <function J>, 'J_contra_t': <function J>, 'J_contra_z': <function J>, 'Jac': <function Jac>, 'Jac_B': <function Jac_B>, 'Jac_P': <function Jac_P>, 'Jac_h': <function Jac_h>, 'Jac_l': <function Jac>, 'LA': <function _base.<locals>.base>, 'N_FP': <function N_FP>, 'Phi': <function _profile.<locals>.profile>, 'Phi_edge': <function Phi_edge>, 'V': <function V>, 'W_MHD': <function W_MHD>, 'X1': <function _base.<locals>.base>, 'X2': <function _base.<locals>.base>, 'chi': <function _profile.<locals>.profile>, 'dB_contra_t_dr': <function dB>, 'dB_contra_t_dt': <function dB>, 'dB_contra_t_dz': <function dB>, 'dB_contra_z_dr': <function dB>, 'dB_contra_z_dt': <function dB>, 'dB_contra_z_dz': <function dB>, 'dJac_dr': <function Jac_derivs>, 'dJac_dt': <function Jac_derivs>, 'dJac_dz': <function Jac_derivs>, 'dJac_h_dr': <function Jac_h_derivs>, 'dJac_h_dt': <function Jac_h_derivs>, 'dJac_h_dz': <function Jac_h_derivs>, 'dJac_l_dr': <function Jac_derivs>, 'dJac_l_dt': <function Jac_derivs>, 'dJac_l_dz': <function Jac_derivs>, 'dLA_dr': <function _base.<locals>.base>, 'dLA_drr': <function _base.<locals>.base>, 'dLA_drt': <function _base.<locals>.base>, 'dLA_drz': <function _base.<locals>.base>, 'dLA_dt': <function _base.<locals>.base>, 'dLA_dtt': <function _base.<locals>.base>, 'dLA_dtz': <function _base.<locals>.base>, 'dLA_dz': <function _base.<locals>.base>, 'dLA_dzz': <function _base.<locals>.base>, 'dNU_B_dt': <function dNU_B_dt>, 'dNU_B_dz': <function dNU_B_dz>, 'dPhi_dr': <function _profile.<locals>.profile>, 'dPhi_drr': <function _profile.<locals>.profile>, 'dV_dPhi_n': <function dV_dPhi_n>, 'dV_dPhi_n2': <function dV_dPhi_n2>, 'dX1_dr': <function _base.<locals>.base>, 'dX1_drr': <function _base.<locals>.base>, 'dX1_drt': <function _base.<locals>.base>, 'dX1_drz': <function _base.<locals>.base>, 'dX1_dt': <function _base.<locals>.base>, 'dX1_dtt': <function _base.<locals>.base>, 'dX1_dtz': <function _base.<locals>.base>, 'dX1_dz': <function _base.<locals>.base>, 'dX1_dzz': <function _base.<locals>.base>, 'dX2_dr': <function _base.<locals>.base>, 'dX2_drr': <function _base.<locals>.base>, 'dX2_drt': <function _base.<locals>.base>, 'dX2_drz': <function _base.<locals>.base>, 'dX2_dt': <function _base.<locals>.base>, 'dX2_dtt': <function _base.<locals>.base>, 'dX2_dtz': <function _base.<locals>.base>, 'dX2_dz': <function _base.<locals>.base>, 'dX2_dzz': <function _base.<locals>.base>, 'dchi_dr': <function _profile.<locals>.profile>, 'dchi_drr': <function _profile.<locals>.profile>, 'dg_rr_dr': <function metric>, 'dg_rr_dt': <function metric>, 'dg_rr_dz': <function metric>, 'dg_rt_dr': <function metric>, 'dg_rt_dt': <function metric>, 'dg_rt_dz': <function metric>, 'dg_rz_dr': <function metric>, 'dg_rz_dt': <function metric>, 'dg_rz_dz': <function metric>, 'dg_tt_dr': <function metric>, 'dg_tt_dt': <function metric>, 'dg_tt_dz': <function metric>, 'dg_tz_dr': <function metric>, 'dg_tz_dt': <function metric>, 'dg_tz_dz': <function metric>, 'dg_zz_dr': <function metric>, 'dg_zz_dt': <function metric>, 'dg_zz_dz': <function metric>, 'diota_dr': <function _profile.<locals>.profile>, 'diota_drr': <function _profile.<locals>.profile>, 'dp_dr': <function _profile.<locals>.profile>, 'dp_drr': <function _profile.<locals>.profile>, 'e_q1': <function hmap>, 'e_q2': <function hmap>, 'e_q3': <function hmap>, 'e_rho': <function e_rho>, 'e_theta': <function e_theta>, 'e_theta_B': <function e_theta_B>, 'e_zeta': <function e_zeta>, 'e_zeta_B': <function e_zeta_B>, 'g_rr': <function g_rr>, 'g_rt': <function g_rt>, 'g_rz': <function g_rz>, 'g_tt': <function g_tt>, 'g_tz': <function g_tz>, 'g_zz': <function g_zz>, 'gamma': <function gamma>, 'grad_rho': <function grad_rho>, 'grad_theta': <function grad_theta>, 'grad_theta_P': <function grad_theta_P>, 'grad_zeta': <function grad_zeta>, 'iota': <function _profile.<locals>.profile>, 'iota_0': <function iota_0>, 'iota_avg': <function iota_avg>, 'iota_curr': <function iota_curr>, 'iota_curr_0': <function iota_curr_0>, 'major_radius': <function minor_major_radius>, 'minor_radius': <function minor_major_radius>, 'mod_B': <function _modulus.<locals>.mod_v>, 'mod_F': <function _modulus.<locals>.mod_v>, 'mod_J': <function _modulus.<locals>.mod_v>, 'mod_e_rho': <function _modulus.<locals>.mod_v>, 'mod_e_theta': <function _modulus.<locals>.mod_v>, 'mod_e_zeta': <function _modulus.<locals>.mod_v>, 'mod_grad_rho': <function _modulus.<locals>.mod_v>, 'mod_grad_theta': <function _modulus.<locals>.mod_v>, 'mod_grad_zeta': <function _modulus.<locals>.mod_v>, 'mu0': <function mu0>, 'p': <function _profile.<locals>.profile>, 'pos': <function hmap>, 'shear': <function shear>, 'theta_P': <function theta_P>, 'xyz': <function xyz>})#
Generate a table of computable quantities.
- Parameters:
markdown (optional) – If True, return the table as a Ipython.Markdown object. Otherwise, return the table as a string.
- Returns:
The table of quantities. If markdown is True, the table is returned as an instance of IPython.display.Markdown. Otherwise, the table is returned as a string.
- Return type:
str or IPython.display.Markdown
Notes
This method generates a table of quantities based on the attributes of the registered quantities. The table includes the label, long name, and symbol of each quantity.