model
model#
import tensorwaves.model
Evaluatable physics models for amplitude analysis.
The model module takes care of lambdifying mathematical expressions to
computational backends. Currently, mathematical expressions are implemented
as sympy expressions only.
- class LambdifiedFunction(model: Model, backend: Union[str, tuple, dict] = 'numpy')[source]#
Bases:
tensorwaves.interfaces.FunctionImplements
Functionbased on aModelusing {meth}`~.Model.lambdify`.
- class SympyModel(expression: Expr, parameters: Dict[Symbol, Union[float, complex]], max_complexity: Optional[int] = None)[source]#
Bases:
tensorwaves.interfaces.ModelFull definition of an arbitrary model based on
sympy.Note that input for particle physics amplitude models are based on four momenta. However, for reasons of convenience, some models may define and use a distinct set of kinematic variables (e.g. in the helicity formalism: angles \(\theta\) and \(\phi\)). In this case, a
DataTransformerinstance (adapter) is needed to transform four momentum information into the custom set of kinematic variables.- Args: expressionA sympy expression that contains the complete
information of the model based on some inputs. The inputs are defined via the
free_symbolsattribute of thesympy.Expr. parameters: Defines which inputs of the model are parameters. The keys represent the parameter set, while the values represent their default values. Consequently the variables of the model are defined as the intersection of the total input set with the parameter set.
- property parameters: Dict[str, Union[complex, float]]#
Get mapping of parameters to suggested initial values.
- get_backend_modules(backend: Union[str, tuple, dict]) Union[str, tuple, dict][source]#
Preprocess the backend argument passed to
lambdify.Note in
lambdifythe backend is specified via themodulesargument.
- optimized_lambdify(args: Sequence[Symbol], expression: Expr, modules: Optional[Union[str, tuple, dict]] = None, *, min_complexity: int = 0, max_complexity: int, **kwargs: Any) Callable[source]#
Speed up
lambdifywithsplit_expression.See also
- split_expression(expression: Expr, max_complexity: int, min_complexity: int = 0) Tuple[Expr, Dict[Symbol, Expr]][source]#
Split an expression into a ‘top expression’ and several sub-expressions.
Replace nodes in the expression tree of a
sympy.Exprthat lie within a certain complexity range (seecount_ops()) with symbols and keep a mapping of each to these symbols to the sub-expressions that they replaced.See also