# 2.6. Functionals¶

Initialises the various functionals. All functionals should overload the Prototype, as this allows them to be combined (added, subtracted and scaled). Functionals are grouped by type; Power / Cost / Environment etc.

## 2.6.1. Power Functionals¶

class opentidalfarm.functionals.power_functionals.PowerFunctional(problem, cut_in_speed=None, cut_out_speed=None, eps=1e-10)[source]

Implements a power functional of the form:

$J(u, m) = \int \rho c_t ||sq(u)||^{1.5}~ dx,$

where $$c_t$$ is the friction due to the turbines, and $$sq(u)$$ is the squared velocity that takes into account the cut-in/out behaviour of the turbines, i.e.

$\begin{split}sq(u) = \begin{cases} eps \|u\|^2 & \text{if } \|u\| < {cut\_in\_speed} \\ (cut\_out\_speed)^2 & \text{if } \|u\| > {cut\_out\_speed} \\ \|u\|^2 & \text{else.} \end{cases}\end{split}$
Parameters:
• problem (Instance of the problem class.) – The problem for which the functional is being computed.

• cut_in_speed (float) – The turbine’s cut in speed (Default: None).

• cut_out_speed (float) – The turbine’s cut out speed (Default: None).

• eps – The turbine’s cut in speed slope (Default: 1e-10).

Jt(state, turbine_field)[source]

Computes the power output of the farm.

Parameters:
• state (dolfin.Function) – Current solution state

• turbine_field (dolfin.Function) – Turbine friction field

Jt_individual(state, i)[source]

Computes the power output of the i’th turbine.

Parameters:
• state (dolfin.Function) – Current solution state

• i (Integer) – refers to the i’th turbine

force(state, turbine_field)[source]

Computes the force field over turbine field

Parameters:
• state (dolfin.Function) – Current solution state.

• turbine_field (dolfin.Function) – Turbine friction field

force_individual(state, i)[source]

Computes the total force on the i’th turbine

Parameters:
• state (dolfin.Function) – Current solution state

• i (Integer) – refers to the i’th turbine

power(state, turbine_field)[source]

Computes the power field over the domain.

Parameters:
• state (dolfin.Function) – Current solution state.

• turbine_field (dolfin.Function) – Turbine friction field

## 2.6.2. Cost Functionals¶

class opentidalfarm.functionals.cost_functionals.CostFunctional(problem)[source]

Implements a cost functional of the form:

$J(u, m) = \int c_t~ dx,$

where $$c_t$$ is the friction due to the turbines.

Parameters:

problem (Instance of the problem class.) – The problem for which the functional is being computed.

Jt(state, turbine_field)[source]

Computes the cost of the farm.

Parameters:
• state (dolfin.Function) – Current solution state

• turbine_field (dolfin.Function) – Turbine friction field

Jt_individual(state, i)[source]

Computes the cost of the i’th turbine.

Parameters:
• state (dolfin.Function) – Current solution state

• i (Integer) – turbine index

## 2.6.3. Prototype Functional¶

Functional objects are overloads of the prototype functional. This allows functionals to be combined and scaled. The initialisation and ‘Jt’ methods should be overloaded.