SAMB figure#

Utility for SAMB figures (QtDraw), keeping polar and axial parts distinct.

At each center (the origin for an atomic SAMB, the sites or bond centers of the cluster otherwise), the harmonics of the atomic SAMB are multiplied by the cluster weights and summed, separately for each type X = Q, G, T, M of the atomic SAMB:

f_X(r) = sum_{terms with atomic type X} c * Y_cluster[i] * O_atomic(r).

A cluster SAMB is drawn as a combined SAMB whose atomic SAMB is Q0 (O_atomic = 1), except an antisymmetric (T, M) bond cluster, which is drawn as arrows along the bonds (the flow given by Im(Y), like a bond current). The harmonics of Q_l and G_l (T_l and M_l) are the same polynomial, so that each type is drawn in its own way:

Q (polar, time-even): lobes abs(f) colored by sign (BrBG, teal + / brown -). T (polar, time-odd): lobes abs(f) colored by sign (coolwarm, red + / blue -). G (axial, time-even): translucent lobes with axial-vector arrows inside (forestgreen). M (axial, time-odd): translucent lobes with axial-vector arrows inside (dodgerblue).

An axial multipole of rank l is drawn as the axial-vector field A(r) = r_hat f(r_hat): an arrow along r_hat inside each lobe, outward for f > 0 and inward for f < 0, which transforms as an axial vector (like a spin). The contraction of r_hat O_lm with an axial vector has the parity (-1)^(l+1) of G_l. For a constant f (G_0), the arrows are put in the six directions +-x, +-y, +-z (a hedgehog). For an antisymmetric (T/M) bond cluster, Im(Y) refers to the bond direction: the object at the bond center is (atomic part) x T, the T being the flow along the bond, shown by a red arrow along the bond direction (tail to head) with the sign in the lobes. When the atomic part is Q0 (a constant), the sign and the magnitude go to the arrow and no lobe is drawn, as for a cluster SAMB. Magnitudes are normalized by the max. abs(f) of all centers and types.

center_polynomials(mm, terms, site_bond)[source]#

Polynomials f_X at the centers of a site or bond cluster.

Parameters:
  • mm (MaterialModel) – model.

  • terms (list) – [(coeff, O_atomic (sympy), atomic type X, cluster key, cluster comp.)].

  • site_bond (str) – site or bond.

Returns:

  • (ndarray) – centers (fractional).

  • (ndarray or None) – bond vectors (fractional).

  • (dict) – X -> [polynomial at each center].

  • (ndarray) – bool, direction of the bond is shown ?

combined_site_bond(mm, usamb)[source]#

Site or bond of a combined SAMB.

Parameters:
Returns:

  • (str) – site or bond, see “wyckoff”.

draw_bond_flow(qtdraw, mm, site_bond, ckey, comp, name='samb')[source]#

Draw an antisymmetric (T, M) bond cluster SAMB as arrows along the bonds.

The weight Im(Y) refers to the bond direction (tail to head): each bond has an arrow along +vector for Im(Y) > 0 and along -vector for Im(Y) < 0 (the flow, like a bond current), with the length proportional to abs(Im(Y)). Each arrow is a T (an imaginary hopping), drawn in one color; the type of the cluster (T or M) is that of the whole pattern, e.g. circulating flows for an M-type cluster.

Parameters:
  • qtdraw (PyVistaWidget) – QtDraw widget.

  • mm (MaterialModel) – model.

  • site_bond (list) – bonds of the cluster.

  • ckey (tuple) – cluster SAMB key.

  • comp (int) – component.

  • name (str, optional) – group name.

draw_center(qtdraw, position, poly, scale=1.0, size=0.5, A=None, axial_opacity=0.3, polar_opacity_mixed=0.55, arrow_width=None, axial_style='arrow', name='samb')[source]#

Draw polynomials of the four types at one center.

Parameters:
  • qtdraw (PyVistaWidget) – QtDraw widget.

  • position (array-like) – center (fractional).

  • poly (dict) – X -> polynomial (sympy or str), X = Q, G, T, M.

  • scale (float, optional) – normalization (max. abs(f) of all centers).

  • size (float, optional) – lobe length for abs(f) = scale.

  • A (ndarray, optional) – unit-cell vectors as columns (cartesian = A @ fractional), for the arrows.

  • axial_opacity (float, optional) – opacity of the axial lobes.

  • polar_opacity_mixed (float, optional) – opacity of the polar lobes when axial parts exist at the same center.

  • arrow_width (float, optional) – width of the arrows (default: 0.06 * size).

  • axial_style (str, optional) – “arrow” (axial vector inside each lobe) or “ring” (rotation ring at each lobe tip).

  • name (str, optional) – group name.

draw_samb_figure(qtdraw, mm, tag, size=None, axial_style='arrow')[source]#

Draw an atomic (x), cluster (y) or combined (z) SAMB.

Parameters:
  • qtdraw (PyVistaWidget) – QtDraw widget.

  • mm (MaterialModel) – model.

  • tag (str) – SAMB tag, “x1”, “y2”, “z3”, …

  • size (float, optional) – lobe length for the max. abs(f) (cluster and combined SAMB), default: samb_figure_size(mm).

  • axial_style (str, optional) – “arrow” or “ring”.

draw_structure(qtdraw, mm, site_bond=())[source]#

Set the crystal and draw the sites (and the bonds of the SAMB).

Parameters:
  • qtdraw (PyVistaWidget) – QtDraw widget.

  • mm (MaterialModel) – model.

  • site_bond (list, optional) – sites or bonds of the SAMB (bonds are drawn in white).

harmonic_expression(group, key, comp)[source]#

Polynomial of an atomic SAMB key (X, l, Gamma, n, p, s, k, “q”) and component (T -> Q, M -> G).

Parameters:
  • group (Group) – group.

  • key (tuple) – atomic SAMB key.

  • comp (int) – component.

Returns:

  • (sympy) – polynomial in x, y, z.

lobe_directions(expr, threshold=0.35, min_angle=55.0, values=None)[source]#

Directions of the lobe tips of abs(f) (local maxima on the unit sphere).

Parameters:
  • expr (sympy or str) – polynomial in x, y, z.

  • threshold (float, optional) – keep maxima with abs(f) >= threshold * max. abs(f).

  • min_angle (float, optional) – minimum angle between two tips [deg].

  • values (ndarray, optional) – values of expr on the sphere points (computed if None).

Returns:

  • (list) – [(direction ndarray, f value)].

max_abs(expr)[source]#

Max. of abs(f) on the unit sphere.

Parameters:

expr (sympy or str) – polynomial in x, y, z.

Returns:

  • (float) – max. abs(f).

samb_figure_size(mm)[source]#

Lobe length for the max. abs(f) of cluster and combined SAMBs: SAMB_FIGURE_SIZE_RATIO times the shortest bond of the model (0.1 times the shortest cell length without bonds).

Parameters:

mm (MaterialModel) – model.

Returns:

  • (float) – lobe length.

samb_figure_type(tag)[source]#

Kind of a SAMB tag.

Parameters:

tag (str) – “x1”, “y2”, “z3”, …

Returns:

  • (str) – “atomic”, “cluster” or “combined”.

save_samb_png(qtdraw, filename, view=None, window_size=(900, 900))[source]#

Save PNG of the objects of a QtDraw widget, rendered off screen with a white background.

Parameters:
  • qtdraw (PyVistaWidget) – QtDraw widget.

  • filename (str) – PNG file name.

  • view (list, optional) – view indices [a1,a2,a3] (QtDraw default if None).

  • window_size (tuple, optional) – image size.

select_samb_figure(mm, samb_figure)[source]#

SAMBs to draw.

Parameters:
  • mm (MaterialModel) – model.

  • samb_figure (bool or list) – True for all the atomic SAMBs, and the cluster and combined SAMBs of the sites and of the bonds with neighbor < qtdraw/max_neighbor, or list of tags, e.g. [“x1”, “y2”, “z3”].

Returns:

  • (list) – tags.