nifty7.minimization.energy module#

class Energy(position)[source]#

Bases: object

Provides the functional used by minimization schemes.

The Energy object is an implementation of a scalar function including its gradient and metric at some position.

Parameters:

position (Field) – The input parameter of the scalar function.

Notes

An instance of the Energy class is defined at a certain location. If one is interested in the value, gradient or metric of the abstract energy functional one has to ‘jump’ to the new position using the at method. This method returns a new energy instance residing at the new position. By this approach, intermediate results from computing e.g. the gradient can safely be reused for e.g. the value or the metric.

Memorizing the evaluations of some quantities minimizes the computational effort for multiple calls.

apply_metric(x)[source]#
Parameters:

x (Field or MultiField) – Argument for the metric operator

Returns:

Output of the metric operator

Return type:

Field or MultiField

at(position)[source]#

Returns a new Energy object, initialized at position.

Parameters:

position (Field) – Location in parameter space for the new Energy object.

Returns:

Energy object at new position.

Return type:

Energy

property gradient#

The gradient at given position.

Type:

Field

property gradient_norm#

L2-norm of the gradient at given position.

Type:

float

longest_step(direction)[source]#

Returns the longest allowed step size along direction

Parameters:

direction (Field) – the search direction

Returns:

the longest allowed step when starting from self.position along direction. If None, the step size is not limited.

Return type:

float or None

property metric#

implicitly defined metric. A positive semi-definite operator or function describing the metric of the potential at the given position.

Type:

LinearOperator

property position#

selected location in parameter space.

The Field location in parameter space where value, gradient and metric are evaluated.

Type:

Field

property value#

value of the functional.

The value of the energy functional at given position.

Type:

float