spectre.utils

Module Contents

spectre.utils.find_res_infaces(q, qres)

Ex use: ‘surfaces=find_res_infaces(1/o.input.physics.iota[1:], 2.0)’

spectre.utils.get_xinit_specwrap(test)
class spectre.utils.Timer
spectre.utils.create_runfile(name, ext, run)
spectre.utils.periodic_integrator_thzt(f, t, z)

Integrates strictly periodic f where t, z are grids with 0, d, 2d, …, 2pi-d

spectre.utils.get_fsa_wrapper(f, test)
spectre.utils.get_freal_fsa(test)
spectre.utils.get_freal_fsa_metric(test)
spectre.utils.check_fsa_vols(test)
spectre.utils.get_xmn(x, test, m, n, lvol=None)
spectre.utils.reshape_fjac(fjac, nt, nz)
spectre.utils.reshape_modes_fjac(fjac, im_, in_, mpol, ntor, nvol, nt, nz)
spectre.utils.get_fmn_force_mask(test)
spectre.utils.remove_file(fname)
spectre.utils.infaces_unflatten(x, test, add_psifactor=False)
spectre.utils.infaces_flatten(r, z, test, add_psifactor=False)
spectre.utils.unpack_interfaces(xin, test)
spectre.utils.pack_interfaces(r_even, r_odd, z_even, z_odd, test)
spectre.utils.get_vec_pot_flat(test)

Get vector potential from the current solution. Found using test.wrapper_funcs_mod.get_vec_pot

Args:

test (SPECTRE): Wrapper object

Returns:

ndarray[float]: At cosine coefficients, shape (sum(lrad+1), mn) ndarray[float]: Az cosine coefficients, shape (sum(lrad+1), mn) ndarray[float]: At sine coefficients, shape (sum(lrad+1), mn) ndarray[float]: Az sine coefficients, shape (sum(lrad+1), mn)

spectre.utils.get_vec_pot(test)

Get vector potential from the current solution. Found using test.wrapper_funcs_mod.get_vec_pot

Args:

test (SPECTRE): Wrapper object

Returns:

List[ndarray[float]]: At cosine coefficients, list of arrays with shape (lrad, mn) List[ndarray[float]]: Az cosine coefficients, list of arrays with shape (lrad, mn) List[ndarray[float]]: At sine coefficients, list of arrays with shape (lrad, mn) List[ndarray[float]]: Az sine coefficients, list of arrays with shape (lrad, mn)

spectre.utils.update_bnorm(test, first_free_bound, print_info=False)

Update B.n on computational boundary from plasma using virtual-casing principle

first_free_bound: Sets which surface current is used for the virtual-casing

True: the surface current on the inner face of plasma boundary False: the surface current on the outer face of the plasma boundary

(requires a solution of vacuum field which in turn requires B.n from plasma)

spectre.utils.filter_stellsym_pts(arr, nt, nz)

Takes an array on the full (nt, nz) grid and returns only the unique stellarator-symmetric components. Conserves the sum of squared arr (up to a constant factor), e.g. sum(arr**2) == 2 * sum(filter_stellsym_pts(arr**2,…)).

spectre.utils.save_errors_to_h5(filename_h5, fsa_err, beltrami_errors_avg, beltrami_errors_max, f_errs_rms, f_errs_max)