opBasis¶
This submodule allows the user to input the desired Model
specifying the
desired transformations and transformation-behaviour of the future operator
basis. Part of a Model
are also declarations of any custom implementations
of Block
. Finally, classes of operators can be defined as string-valued so
called templates, which are then parsed into ansätze for the desired operator
basis. While proposing ansätze via templates can be performed manually, via
getTemplates
one may get a complete set of templates without the danger of
overlooking any. After imposing the specified transformation-behaviour through
a call to overcompleteBasis
this yields a yet overcomplete basis.
- class Model(pyName: str, blocks: list[str], transf: dict[str, str], spurion: list[str], flavourSets: dict[str, list[str]], pyModule: object)¶
Bases:
object
Represents a theory with optional flavour contant and a given set of transformations that keep the action invariant. Any composite field may transform non-trivially as selected by the transformation behaviour accompanying each transformation.
CAUTION: Not intended for direct use. The user should go through the static method
read
orparse
instead.- _checkBlockConsistency()¶
Checks that any indices provided for all custom Block implementations match our expectations and the naming of class attributes follows our conventions. For more details what those are, see
Block
.- Raises:
AssertionError – If types do not match our expectations.
- apply()¶
Replaces the currently used Model.
Enforces the appropriate sorting convention within a
Bilinear
. Since it depends on the current Model it has to be called at any time the Model is being changed. Loads the Python module corresponding to this Model thus making customBlock
and transformations accessible.
- static parse(content: str)¶
Parses model from string.
Parses the description of a model, i.e., the underlying theory to be considered from the string content. Checks for consistency of chosen custom Block names.
- Parameters:
content (str) – String to parse the Model from.
- Returns:
Python representation of the chosen theory.
- Return type:
- Raises:
AssertionError – If some basic formatting is wrong or more than one Transf section is given.
ValueError – If a custom name coincides with internal naming or is being used more than once.
NotImplementedError – If an unknown option is encountered.
- static read(fname: str)¶
Load model from file.
Reads the description of a model, i.e., the underlying theory to be considered from a file with name fname and hands it over to
Model.parse
.
- toReference()¶
Turns model description into a string discarding any defined templates. May be used to store alongside any found operator bases to keep track of the model being used at the time, i.e., for reproducibility.
- _checkProtected(name: str, type_: str, protected: list[str])¶
Checks if a custom name has been used prior or is protected. The latter is by convention true for any names starting with an underscore or are names reserved for default implementations of
Block
. If no problems are found the name is added to the list of used names.- Parameters:
- Raises:
ValueError – If
name
is already being used or otherwise protected.
- _parsePart(template: str, model: Model) Iterator[Trace | Bilinear] ¶
Parse string representation of Trace or Bilinear.
Parses the given expression into either
Trace
orBilinear
with all possible variants. If the expression does not match any of the expected patterns an error is raised.- Parameters:
- Returns:
Iterator over all possible variants matching the parsed template, e.g., different indices.
- Return type:
- Raises:
ValueError – If the given template does not match any regular expression, something is wrong with the formatting.
- overcompleteBasis(template: str, model: Model) list[LinearComb] ¶
Find all ansätze compatible with the desired transformation properties.
Produces all possibilities of spacetime indices, gamma structures etc. in accordance with the given template template. The appropriate basis is then worked out using all symmetries listed in model and applying vetoing from Spurion symmetry checks.
- Parameters:
- Returns:
All (unique) expressions surviving the transformation requirements and all Spurion symmetry checks.
- Return type:
- parseAnsatz(template: str, model: Model) Iterator[LinearComb] ¶
Turn template into all possible ansätze.
Translates the given template into all variants matching that form. In turn those variants form all the possible ansätze used to build a basis of operators with appropriate transformation properties.
- Parameters:
- Returns:
Iterator over all possible variants matching the parsed template, e.g., different indices.
- Return type:
Iterator[LinearComb]
- Raises:
ValueError – Indicates that the used template is badly formatted, e.g., due to missing custom Block definitions.
- symmetrise(ansatz: LinearComb, model: Model) LinearComb ¶
Iteratively enforce transformation properties on a given ansatz.
Takes an initial ansatz, i.e., a linear combination (or more commonly a monomial) and performs the specified transformations. If the ansatz transforms already properly, nothing happens. Otherwise the new contribution is stored.
Eventually all contributions are added up to enforce compliance with the specified transformations. If the result does not vanish, it is compatible.
- Parameters:
ansatz (LinearComb) – Python representation of the (partially) symmetrised ansatz.
model (Model) – Descriptor of the currently assumed theory including the desired transformation properties.
- Returns:
Further symmetrised variant of the initial ansatz.
- Return type:
- Raises:
ValueError – If enforcing the desired transformation properties fails within MAX_ITER iterations.