qsymm.hamiltonian_generator module

qsymm.hamiltonian_generator.bloch_family(hopping_vectors, symmetries, norbs, onsites=True, momenta=[k_x, k_y, k_z], symmetrize=True, prettify=True, num_digits=10, bloch_model=False)[source]

Generate a family of symmetric Bloch-Hamiltonians.

Parameters:
  • hopping_vectors (list of tuples (a, b, vec)) – a and b are identifiers for the different sites (e.g. strings) of the unit cell, vec is the real space hopping vector. Vec may contain contain integers, sympy symbols, or floating point numbers.

  • symmetries (list of PointGroupElement or ContinuousGroupGenerator) – Generators of the symmetry group. ContinuousGroupGenerators can only have onsite action as a lattice system cannot have continuous rotation invariance. It is assumed that the block structure of the unitary action is consistent with norbs, as returned by symmetry_from_permutation.

  • norbs (OrderedDict : {site : norbs_site} or tuple of tuples ((site, norbs_site), )) – sites are ordered in the order specified, with blocks of size norbs_site corresponding to each site.

  • onsites (bool, default True) – Whether to include on-site terms consistent with the symmetry.

  • momenta (iterable of strings or Sympy symbols) – Names of momentum variables, default ['k_x', 'k_y', 'k_z'] or corresponding sympy symbols.

  • symmetrize (bool, default True) – Whether to use the symmetrization strategy. This does not require a full set of hoppings to start, all symmetry related hoppings are generated. Otherwise the constraining strategy is used, this does not generate any new hoppings beyond the ones specified and constrains coefficients to enforce symmetry.

  • prettify (bool) – Whether to prettify the result. This step may be numerically unstable.

  • num_digits (int, default 10) – Number of significant digits kept when prettifying.

  • bloch_model (bool, default False) – Determines the return format of this function. If set to False, returns a list of Model objects. If True, returns a list of BlochModel objects. BlochModel objects are more suitable than Model objects if the hopping vectors include floating point numbers.

Returns:

  • family (list of Model or BlochModel objects) – A list of Model or BlochModel objects representing the family that satisfies the symmetries specified. Each object satisfies all the symmetries by construction.

  • Notes

  • ——

  • There is no need to specify the translation vectors, all necessary information

  • is encoded in the symmetries and hopping vectors.

  • In the generic case the Bloch-Hamiltonian produced is not Brillouin-zone periodic,

  • instead it acquires a unitary transformation W_G = delta_{ab} exp(i G (r_a - r_b))

  • where G is a reciprocal lattice vector, a and b are sites and r_a is the

  • real space position of site a. If the lattice is primitive (there is only one

  • site per unit cell), the hopping vectors are also translation vectors and the

  • resulting Hamiltonian is BZ periodic.

  • If symmetrize=True, all onsite unitary symmetries need to be explicitely

  • specified as ContinuousGroupGenerators. Onsite PointGroupSymmetries (ones

  • with R=identity) are ignored.

  • If floating point numbers are used in the argument hopping_vectors, it is

  • recommended to have this function return BlochModel objects instead of Model

  • objects, by setting the bloch_model flag to True.

qsymm.hamiltonian_generator.check_symmetry(family, symmetries, num_digits=None)[source]

Check that a family satisfies symmetries. A symmetry is satisfied if all members of the family satisfy it.

If the input family was rounded before hand, it is necessary to use specify the number of significant digits using num_digits, otherwise this check might fail.

Parameters:
  • family (iterable of Model or BlochModel objects representing) – a family.

  • symmetries (iterable representing the symmetries to check.) – If the family is a Hamiltonian family, symmetries is an iterable of PointGroupElement objects representing the symmetries to check.

  • num_digits (integer) – In the case that the input family has been rounded, num_digits should be the number of significant digits to which the family was rounded.

Raises:

ValueError – If the family does not satisfy the symmetry.

qsymm.hamiltonian_generator.constrain_family(symmetries, family, sparse_linalg=False)[source]

Apply symmetry constraints to a family.

Parameters:
  • symmetries (iterable of PointGroupElement objects, representing the symmetries) – that are used to constrain the Hamiltonian family.

  • family (iterable of Model or BlochModel objects, representing the Hamiltonian) – family to which the symmetry constraints are applied.

  • sparse_linalg (bool) – Whether to use sparse linear algebra. Using sparse solver can result in performance increase for large, highly constrained families, but not as well tested as the default dense version.

Returns:

family – family with the symmetry constraints applied.

Return type:

iterable of Model or BlochModel objects, that represents the

qsymm.hamiltonian_generator.continuum_hamiltonian(symmetries, dim, total_power, all_powers=None, momenta=[k_x, k_y, k_z], sparse_linalg=False, prettify=False, num_digits=10)[source]

Generate a family of continuum Hamiltonians that satisfy symmetry constraints.

Parameters:
  • symmetries (iterable of PointGroupElement objects.) – An iterable of PointGroupElement objects, each describing a symmetry that the family should possess.

  • dim (integer) – The number of spatial dimensions along which the Hamiltonian family is translationally invariant. Only the first dim entries in all_powers and momenta are used.

  • total_power (integer or list of integers) – Allowed total powers of the momentum variables in the continuum Hamiltonian. If an integer is given, all powers below it are included as well.

  • all_powers (list of integer or list of list of integers) – Allowed powers of the momentum variables in the continuum Hamiltonian listed for each spatial direction. If an integer is given, all powers below it are included as well. If a list of integers is given, only these powers are used.

  • momenta (iterable of strings or Sympy symbols) – Names of momentum variables, default ['k_x', 'k_y', 'k_z'] or corresponding sympy symbols.

  • sparse_linalg (bool) – Whether to use sparse linear algebra. Using sparse solver can result in performance increase for large, highly constrained families, but not as well tested as the default dense version.

  • prettify (boolean, default False) – Whether to make the basis pretty by rounding and basis change. For details see docstring of make_basis_pretty. May be numerically unstable.

  • num_digits (integer, default 10) – Number of significant digits to which the basis is rounded using prettify. This argument is ignored if prettify = False.

Returns:

family – A list of Model objects representing the family that satisfies the symmetries specified. Each Model object satisfies all the symmetries by construction.

Return type:

list

qsymm.hamiltonian_generator.continuum_pairing(symmetries, dim, total_power, all_powers=None, momenta=[k_x, k_y, k_z], phases=None, ph_square=1, sparse_linalg=False, prettify=False, num_digits=10)[source]

Generate a family of continuum superconducting pairing functions that satisfy symmetry constraints.

The specified symmetry operators should act on the normal state Hamiltonian, not in particle-hole space.

Parameters:
  • symmetries (iterable of PointGroupElement objects.) – An iterable of PointGroupElement objects, each describing a symmetry that the family should possess.

  • dim (integer) – The number of spatial dimensions along which the Hamiltonian family is translationally invariant. Only the first dim entries in all_powers and momenta are used.

  • total_power (integer or list of integers) – Allowed total powers of the momentum variables in the continuum Hamiltonian. If an integer is given, all powers below it are included as well.

  • all_powers (list of integer or list of list of integers) – Allowed powers of the momentum variables in the continuum Hamiltonian listed for each spatial direction. If an integer is given, all powers below it are included as well. If a list of integers is given, only these powers are used.

  • momenta (list of int or list of Sympy objects) – Indices of momenta from [‘k_x’, ‘k_y’, ‘k_z’] or a list of names for the momentum variables. Default is [‘k_x’, ‘k_y’, ‘k_z’].

  • phases (iterable of numbers) – Phase factors to multiply the hole block of the symmetry operators in particle-hole space. By default, all phase factors are 1.

  • ph_square (integer, either 1 or -1.) – Specifies whether the particle-hole operator squares to +1 or -1.

  • sparse_linalg (bool) – Whether to use sparse linear algebra. Using sparse solver can result in performance increase for large, highly constrained families, but not as well tested as the default dense version.

  • prettify (boolean, default False) – Whether to make the basis pretty by rounding and basis change. For details see docstring of make_basis_pretty. May be numerically unstable.

  • num_digits (integer, default 10) – Number of significant digits to which the basis is rounded using prettify. This argument is ignored if prettify = False.

Returns:

family – A list of Model objects representing the family that satisfies the symmetries specified. Each Model object satisfies all the symmetries by construction.

Return type:

list

qsymm.hamiltonian_generator.continuum_variables(dim, total_power, all_powers=None, momenta=[k_x, k_y, k_z])[source]

Make a list of all linearly independent combinations of momentum variables with given total power.

Parameters:
  • dim (integer) – The number of spatial dimensions along which the Hamiltonian family is translationally invariant. Only the first dim entries in all_powers and momenta are used.

  • total_power (integer) – Allowed total power of the momentum variables in the continuum Hamiltonian.

  • all_powers (list of integer or list of list of integers) – Allowed powers of the momentum variables in the continuum Hamiltonian listed for each spatial direction. If an integer is given, all powers below it are included as well. If a list of integers is given, only these powers are used.

  • momenta (list of int or list of Sympy objects) – Indices of momenta from [‘k_x’, ‘k_y’, ‘k_z’] or a list of names for the momentum variables. Default is [‘k_x’, ‘k_y’, ‘k_z’].

Return type:

A list of Sympy objects, representing the momentum variables that enter the Hamiltonian.

qsymm.hamiltonian_generator.display_family(family, summed=False, coeffs=None, nsimplify=True)[source]

Display a Hamiltonian family in a Jupyter notebook

If this function is used from a Jupyter notebook then it uses the notebook’s rich LaTeX display features. If used from a console or script, then this function just uses print().

Parameters:
  • family (iterable of Model or BlochModel objects) – List of terms in a Hamiltonian family.

  • summed (boolean) – Whether to display the Hamiltonian family by individual member (False), or as a sum over all members with expansion coefficients (True).

  • coeffs (list of sympy objects, optional) – Coefficients used when combining terms in the family if summed is True.

  • nsimplify (boolean) – Whether to use sympy.nsimplify on the output or not, which attempts to replace floating point numbers with simpler expressions, e.g. fractions.

qsymm.hamiltonian_generator.hamiltonian_from_family(family, coeffs=None, nsimplify=True, tosympy=True)[source]

Form a Hamiltonian from a Hamiltonian family by taking a linear combination of its elements.

Parameters:
  • family (iterable of Model or BlochModel objects) – List of terms in the Hamiltonian family.

  • coeffs (list of sympy objects, optional) – Coefficients used to form the linear combination of terms in the family. Element n of coeffs multiplies member n of family. The default choice of the coefficients is c_n.

  • nsimplify (bool) – Whether to use sympy.nsimplify on the output or not, which attempts to replace floating point numbers with simpler expressions, e.g. fractions.

  • tosympy (bool) – Whether to convert the Hamiltonian to a sympy expression. If False, a Model or BlochModel object is returned instead, depending on the type of the Hamiltonian family.

Returns:

ham – The Hamiltonian, i.e. the linear combination of entries in family.

Return type:

sympy.Matrix or Model/BlochModel object.

qsymm.hamiltonian_generator.make_basis_pretty(family, num_digits=2)[source]

Attempt to make a family more legible by reducing the number of nonzero entries in the matrix coefficients.

Parameters:
  • family (iterable of Model or BlochModel objects representing) – a family.

  • num_digits (positive integer) – Number of significant digits that matrix coefficients are rounded to.

  • matrix (This attempts to make the family more legible by prettifying a) –

:param : :param which is done by bringing it to reduced row-echelon form. This: :param procedure may be numerically unstable: :param so this function should be used: :param with caution.:

qsymm.hamiltonian_generator.remove_duplicates(family, tol=1e-08)[source]

Remove linearly dependent terms in Hamiltonian family using SVD.

Parameters:
  • family (iterable of Model or BlochModel objects representing) – a family.

  • tol (float) – tolerance used in SVD when finding the span.

Returns:

rfamily – the family with only linearly independent terms.

Return type:

list of Model or BlochModel objects representing

qsymm.hamiltonian_generator.round_family(family, num_digits=3)[source]

Round the matrix coefficients of a family to specified significant digits.

Parameters:
  • family (iterable of Model objects that represents) – a family.

  • num_digits (integer) – Number if significant digits to which the matrix coefficients are rounded.

Returns:

  • A list of Model objects representing the family, with

  • the matrix coefficients rounded to num_digits significant digits.

qsymm.hamiltonian_generator.subtract_family(family1, family2, tol=1e-08, prettify=False)[source]

Remove the linear span of family2 from the span of family1 using SVD. family2 must be a span of terms that are either inside the span of family1 or orthogonal to it. This guarantees that projecting out family2 from family1 results in a subfamily of family1.

Parameters:
  • family1 (iterable of Model or BlochModel objects) – Hamiltonian families.

  • family2 (iterable of Model or BlochModel objects) – Hamiltonian families.

  • tol (float) – tolerance used in SVD when finding the span.

Returns:

rfamily – family1 with the span of family2 removed.

Return type:

list of Model or BlochModel objects representing

qsymm.hamiltonian_generator.symmetrize_monomial(monomial, symmetries)[source]

Symmetrize monomial by averaging over all symmetry images under symmetries.

Parameters:
  • monomial (Model or BlochModel object) – Hamiltonian term to be symmetrized

  • symmetries (iterable of PointGroupElement objects) – Symmetries to use for symmetrization. symmetries must form a closed group.

Returns:

Symmetrized term.

Return type:

Model or BlochModel object