bluemira.equilibria.find_legs ============================= .. py:module:: bluemira.equilibria.find_legs .. autoapi-nested-parse:: Class and Methods for separatrix legs. Classes ------- .. autoapisummary:: bluemira.equilibria.find_legs.NumNull bluemira.equilibria.find_legs.SortSplit bluemira.equilibria.find_legs.LegFlux bluemira.equilibria.find_legs.CalcMethod Functions --------- .. autoapisummary:: bluemira.equilibria.find_legs.get_legs_length_and_angle bluemira.equilibria.find_legs.get_single_null_legs bluemira.equilibria.find_legs.get_legs_double_null_xsplit bluemira.equilibria.find_legs.get_legs_double_null_zsplit bluemira.equilibria.find_legs.get_leg_list bluemira.equilibria.find_legs._extract_offsets bluemira.equilibria.find_legs.add_pair_to_dict bluemira.equilibria.find_legs._extract_leg bluemira.equilibria.find_legs._extract_leg_using_index_value bluemira.equilibria.find_legs.calculate_connection_length Module Contents --------------- .. py:class:: NumNull(*args, **kwds) Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: bluemira.equilibria.find_legs.NumNull :parts: 1 :private-bases: Class for use with LegFlux. .. py:attribute:: DN Double Null .. py:attribute:: SN Single Null .. py:class:: SortSplit(*args, **kwds) Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: bluemira.equilibria.find_legs.SortSplit :parts: 1 :private-bases: Class for use with LegFlux. .. py:attribute:: X Split the flux in x-direction .. py:attribute:: Z Split the flux in z-direction .. py:class:: LegFlux(eq: bluemira.equilibria.equilibrium.Equilibrium, psi_n_tol: float = 1e-06, delta_start: float = 0.01, rtol: float = 0.001) Class for those pesky separatrix legs. :param eq: Input Equilibrium :param psi_n_tol: The normalised psi tolerance to use :param delta_start: Search range value for finding LCFS. Will search for the transition from a "closed" to "open" flux surface for normalised flux values between 1 - delta_start and 1 + delta_start. :param rtol: Relative tolerance used for finding configuration of separatrix split for double null .. py:attribute:: eq .. py:attribute:: o_point .. py:attribute:: x_points .. py:attribute:: rtol :value: 0.001 .. py:attribute:: x_range_lcfs .. py:attribute:: delta .. py:attribute:: delta_offsets .. py:attribute:: dx_offsets :value: None .. py:method:: which_legs() Determine how to find and sort legs. For a double null this function: - sorts the x-points by lower then upper - keeps the separatrix list sorted by longest then shortest :returns: * *n_null* -- Weather it is single (SN) or double null (DN) Configuration * *sort_split* -- How the separatrix has been split. Z - split into Upper and Lower X - split into Inner and Outer .. py:method:: get_leg_offsets(leg_dict) Expands the leg list if user requires offset flux surfaces. .. py:method:: get_legs(n_layers: int = 1, dx_off: float = 0.0, delta: float | None = None, delta_offsets: float | None = None) Get separatrix legs. :param n_layers: Number of flux surfaces to extract for each leg :param dx_off: Total span in radial space of the flux surfaces to extract :param delta: intersection point x value +- delta is used to find starting point of leg flux see '_extract_leg'. :param delta_offsets: intersection point x value +- delta_offsets is used to find starting point of offsets leg flux see '_extract_offsets'. :returns: Dictionary of separatrix legs (lists of coordinates), with keys: - lower_inner - lower_outer - upper_inner - upper_outer :rtype: leg_dict :raises EquilibriaError: if a strange number of legs would be found for an X-point: .. rubric:: Notes Will return two legs in the case of a single null (an upper or lower pair). Will return four legs in the case of a double null. We can't rely on the X-point being contained within the two legs, due to interpolation and local minimum finding tolerances. .. py:function:: get_legs_length_and_angle(eq: bluemira.equilibria.equilibrium.Equilibrium, leg_dict: dict[str, numpy.typing.NDArray[numpy.float64] | None], plasma_facing_boundary: bluemira.equilibria.equilibrium.Grid | bluemira.geometry.coordinates.Coordinates | None = None) Calculates the length of all the divertor legs in a dictionary. :returns: * leg length dictionary for a given leg * the angle dictionary for a given leg .. py:function:: get_single_null_legs(separatrix, delta, o_point, x_points, imin=None) :returns: The legs from a single null separatrix as a dictionary. .. py:function:: get_legs_double_null_xsplit(separatrix, delta, x_points, o_point) :returns: The legs from a double null separatrix, split in x-direction, as a dictionary. .. py:function:: get_legs_double_null_zsplit(separatrix, delta, x_points, o_point, x_range_lcfs) :returns: The legs from a double null separatrix, split in z-direction, as a dictionary. .. py:function:: get_leg_list(leg_pair, delta, o_p, x_p=None, imin=None) Extracts leg/s from given flux line and return as sorted list. Legs are sorted by inner then outer. :returns: the legs sort by in and out :raises BluemiraError: if x_p and imin are both None .. py:function:: _extract_offsets(eq, ref_leg, direction, o_p, dx_offsets, delta_offsets) -> list :returns: Flux surfaces offset from separatrix leg .. py:function:: add_pair_to_dict(sorted_legs, x_p, o_p) Convert a upper or lower pair of sorted legs into a dictionary. .. py:function:: _extract_leg(flux_line: bluemira.geometry.coordinates.Coordinates, x_cut: float, z_cut: float, delta_x: float, o_point_z: float) Extract legs from a flux surface using a chosen intersection point. :param flux_line: Coordinates of a flux surface :param x_cut: a point on the horizontal line (radial_line) that intersects the flux surface, below beyond which the flux surface becomes the legs :param z_cut: a point on the horizontal line (radial_line) that intersects the flux surface, below beyond which the flux surface becomes the legs :param delta_x: the width of the radial_line (used for cutting) :param o_point_z: the approximate height of the o-point (center of the plasma). Used to determine whether the leg being processed in a loop is a top or button of a double-null divertor tokamak. :returns: A list of the flux legs .. py:function:: _extract_leg_using_index_value(flux_line: bluemira.geometry.coordinates.Coordinates, i_cut: float) Extract legs from a flux surface using an intersection point chosen by index value. :returns: The flux legs .. py:class:: CalcMethod(*args, **kwds) Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: bluemira.equilibria.find_legs.CalcMethod :parts: 1 :private-bases: Class for use with calculate_connection_length function. User can choose how the connection length is calculated .. py:attribute:: FIELD_LINE_TRACER .. py:attribute:: FLUX_SURFACE_GEOMETRY .. py:function:: calculate_connection_length(eq: bluemira.equilibria.equilibrium.Equilibrium, div_target_start_point: bluemira.geometry.coordinates.Coordinates | None = None, first_wall: bluemira.geometry.coordinates.Coordinates | None = None, div_norm_psi: float | None = None, forward: bool = True, psi_n_tol: float = 1e-06, delta_start: float = 0.01, rtol: float = 0.1, n_turns_max: int = 50, n_points: int = 1000, calculation_method: str = 'flux_surface_geometry') Calculate the parallel connection length from a starting point to a flux-intercepting surface using either flux surface geometry or a field line tracer. User can choose an xz point or a normalised psi value to select a flux surface of interest - please NOTE, an input div_norm_psi will override an input div_target_start_point if both are entered. If no starting point is selected then use the separatrix at the Outboard Midplane. :returns: The connection length :raises BluemiraError: If an invalid option calculation_method is selected. If an invalid div_norm_psi value is entered. If no target is provided for FLT calculation_method - this is because the flux interception point found is not accurate enough to be used on a separatrix automatically found by bluemira (n.b., the FLT can not distinguish between open and closed flux).