Support of different algebraic systems

The base system does not assume any commutation rules amongst the generators of the algebra, ie free algebra or tensor algebra is assumed. However, by subclassing the Drudge class, domain specific knowledge about the algebraic system in the problem can be given. Inside drudge, we have some algebraic systems that is already built in.

Abstract Wick alegbra

class drudge.WickDrudge(*args, wick_parallel=0, **kwargs)[source]

Drudge for Wick-style algebras.

A Wick-style algebra is an algebraic system where the commutator between any generators of the algebra is a simple scalar value. This drudge will attempt to put the vectors into normal order based on the given comparator and contractor by Wick theorem.

Normally, subclasses need to override the properties phase, contractor, and comparator with domain-specific knowledge.

__init__(*args, wick_parallel=0, **kwargs)[source]

Initialize the Wick drudge.

This level just have one option to handle, the parallelism option.

wick_parallel

Get the Wick parallelism level.

contractor

Get the contractor for the algebraic system.

The contractor is going to be called with two vectors to return the value of their contraction.

phase

Get the phase for the commutation rule.

The phase should be a constant defining the phase of the commutation rule.

comparator

Get the comparator for the canonicalized vectors.

The normal ordering operation will be performed according to this comparator. It will be called with two canonicalized vectors for a boolean value. True should be returned if the first given vector is less than the second vector. The two vectors will be attempted to be transposed when False is returned.

normal_order(terms: pyspark.rdd.RDD, **kwargs)[source]

Normal order the terms according to generalized Wick theorem.

The actual expansion is based on the information given in the subclasses by the abstract properties.

Concrete Wick algebras

Fermion-boson CCR/CAR algebra

class drudge.FockDrudge(*args, exch=-1, **kwargs)[source]

Drudge for doing fermion/boson operator algebra on Fock spaces.

This is the general base class for drudges working on fermion/boson operator algebras. Here general methods are defined for working on these algebraic systems, but no problem specific information, like ranges or operator base, is defined. Generally, operators for Fock space problems has either CR or AN as the first index to give their creation or annihilation character.

To customize the details of the commutation rules, properties op_parser and ancr_contractor can be overridden.

__init__(*args, exch=-1, **kwargs)[source]

Initialize the drudge.

Parameters:exch ({1, -1}) – The exchange symmetry for the Fock space. Constants FERMI and BOSE can be used.
contractor

Get the contractor for the algebra.

The operations are read here on-the-fly so that possibly customized behaviour from the subclasses can be read.

phase

Get the phase for the commutation rules.

comparator

Get the comparator for the normal ordering operation.

vec_colour

Get the vector colour evaluator.

OP_PARSER

alias of Callable

op_parser

Get the parser for field operators.

The result should be a callable taking an vector and return a triple of operator base, operator character, and the actual indices to the operator. This can be helpful for cases where the interpretation of the operators needs to be tweeked.

ANCR_CONTRACTOR

alias of Callable

ancr_contractor

Get the contractor for annihilation and creation operators.

In this drudge, the contraction between creation/creation, annihilation/annihilation, and creation/annihilation operators are fixed. By this property, a callable for contracting annihilation operators with a creation operator can be given. It will be called with the base and indices (excluding the character) of the annihilation operators and the base and indices of the creation operator. A simple SymPy expression is expected in the result.

By default, the result will be a simple delta.

eval_vev(tensor: drudge.drudge.Tensor, contractor)[source]

Evaluate vacuum expectation value.

The contractor needs to be given as a callable accepting two operators. And this function is also set as a tensor method by the same name.

eval_phys_vev(tensor: drudge.drudge.Tensor)[source]

Evaluate expectation value with respect to the physical vacuum.

Here the contractor from normal-ordering will be used. And this function is also set as a tensor method by the same name.

normal_order(terms: pyspark.rdd.RDD, **kwargs)[source]

Normal order the field operators.

Here the normal-ordering operation of general Wick drudge will be invoked twice to ensure full simplification.

static dagger(tensor: drudge.drudge.Tensor, real=False)[source]

Get the Hermitian adjoint of the given operator.

This method is also set to be a tensor method with the same name.

Parameters:
  • tensor – The operator to take the Hermitian adjoint for.
  • real – If the amplitude is assumed to be real. Note that this need not be set if the amplitude is concrete real numbers.
set_n_body_base(base: sympy.tensor.indexed.IndexedBase, n_body: int)[source]

Set an indexed base as an n-body interaction.

The symmetry of an n-body interaction has full permutation symmetry among the corresponding slots in the first and second half.

When the body count if less than two, no symmetry is added. And the added symmetry is for the given valence only.

set_dbbar_base(base: sympy.tensor.indexed.IndexedBase, n_body: int, n_body2=None)[source]

Set an indexed base as a double-bar interaction.

A double barred interaction has full permutation symmetry among its first half of slots and its second half individually. For fermion field, the permutation is assumed to be anti-commutative.

The size of the second half can be given by another optional argument, or it is assumed to have the same size as the first half. It can also be zero, which gives one chunk of symmetric slots only.

drudge.CR

The label for creation operators.

drudge.AN

The label for annihilation operators.

drudge.FERMI

The label for fermion exchange symmetry.

drudge.BOSE

The label for boson exchange symmetry.

Clifford algebra

class drudge.CliffordDrudge(ctx, inner: typing.Callable[[drudge.term.Vec, drudge.term.Vec], sympy.core.expr.Expr] = <function inner_by_delta>, **kwargs)[source]

Drudge for Clifford algebras.

A Clifford algebra over a inner product space \(V\) is an algebraic system with

\[uv + vu = 2 \langle u, v \rangle\]

for all \(u, v \in V\).

This drudge should work for any Clifford algebra with given inner product function.

Inner

alias of Callable

__init__(ctx, inner: typing.Callable[[drudge.term.Vec, drudge.term.Vec], sympy.core.expr.Expr] = <function inner_by_delta>, **kwargs)[source]

Initialize the drudge.

Parameters:
  • ctx – The context for Spark.
  • inner – The callable to compute the inner product of two vectors. By default, the inner product of vectors of the same base and the same number of indices will be computed to be the delta, or ValueError will be raised.
  • kwargs – All other keyword arguments will be forwarded to the base class WickDrudge.
phase

The phase for Clifford algebra, negative unity.

comparator

Comparator for Clifford algebra.

Here we just compare vectors by the default sort key for vectors.

contractor

Contractor for Clifford algebra.

The inner product function will be invoked.

normal_order(terms: pyspark.rdd.RDD, **kwargs)[source]

Put vectors in Clifford algebra in normal-order.

After the normal-ordering by Wick expansion, adjacent equal vectors will be collapsed by rules of Clifford algebra.

Abstract quadratic algebra

class drudge.GenQuadDrudge(ctx, full_balance=False, **kwargs)[source]

Drudge for general quadratic algebra.

This abstract base class encompasses a wide range of algebraic systems. By a quadratic algebra, we mean any algebraic system with commutation rules

\[a b = \phi b a + \kappa\]

for any two elements \(a\) and \(b\) in the algebra with \(\phi\) a scalar and \(\kappa\) any element in the algebra. This includes all Lie algebra systems by fixing \(\phi\) to plus unity. Other algebra systems with other \(\phi\) can also be treated as long as it is a scalar.

For the special case of \(\phi = \pm 1\) and \(\kappa\) being a scalar, WickDrudge should be used, which utilizes the special structure and has much better performance.

__init__(ctx, full_balance=False, **kwargs)[source]

Initialize the drudge.

full_balance

If full load-balancing is to be performed during normal-ordering.

Swapper

alias of Callable

swapper

The function to be called with two operators to commute.

It is going to be called with two vectors. When they are already in desired order, a None should be returned. Or the phase of the commutation should be returned as a SymPy expression, along with the commutator, which can be anything that can be interpreted as terms.

It is named as swapper is avoid any confusion about the established meaning of the word commutator in mathematics.

normal_order(terms: pyspark.rdd.RDD, **kwargs)[source]

Normal order the terms in the RDD.

Concrete quadratic algebras

class drudge.SU2LatticeDrudge(ctx, cartan=Vec('J^z', ()), raise_=Vec('J^+', ()), lower=Vec('J^-', ()), root=1, norm=2, **kwargs)[source]

Drudge for a lattice of SU(2) algebras.

This drudge has the commutation rules for SU(2) algebras in Cartan-Weyl form (Ladder operators). Here both the shift and Cartan operators can have additional lattice indices. Operators on different lattice sites always commute.

The the normal-ordering operation would try to put raising operators before the Cartan operators, which come before the lowering operators.

__init__(ctx, cartan=Vec('J^z', ()), raise_=Vec('J^+', ()), lower=Vec('J^-', ()), root=1, norm=2, **kwargs)[source]

Initialize the drudge.

Parameters:
  • ctx – The Spark context for the drudge.
  • cartan – The basis operator for the Cartan subalgebra (\(J^z\) operator for spin problem). It is registered in the name archive by the first letter in its label followed by an underscore.
  • raise – The raising operator. It is also also registered in the name archive by the first letter in its label followed by _p.
  • lower – The lowering operator, registered by the first letter followed by _m.
  • root – The coefficient for the commutator between the Cartan and shift operators.
  • norm – The coefficient for the commutator between the raising and lowering operators.
  • kwargs – All other keyword arguments are given to the base class GenQuadDrudge.
swapper

The swapper for the spin algebra.