2.5. Turbine farms

class opentidalfarm.farm.Farm(domain, turbine=None, site_ids=None, function_space=None, n_time_steps=None)[source]

Bases: BaseFarm

Extends BaseFarm. Creates a farm from a mesh and subdomain ids.

Following parameters are available:

Variables:
  • domain – A Domain object describing the domain.

  • turbine – A Turbine object describing the domain.

  • site_ids – A list of integers describing the subdomain identifiers of the farm(s)

  • function_space – A dolfin.FunctionSpace that specifies in which function space the turbine friction is in.

class opentidalfarm.farm.RectangularFarm(domain, site_x_start, site_x_end, site_y_start, site_y_end, turbine=None, site_ids=None, order=2, n_time_steps=None)[source]

Bases: Farm

Extends Farm. Defines a rectangular Farm.

This class holds the turbines within a rectangular site.

add_lhs_turbine_layout(number_turbines, x_start=None, x_end=None, y_start=None, y_end=None)[source]

Adds to the farm a turbine layout based upon a latin hypercube sampling of the turbine area.

Parameters:
  • turbine (Turbine object.) – Defines the type of turbine to add to the farm.

  • number_turbines (int) – The number of turbines to be placed.

  • x_start (float) – The minimum x-coordinate of the site.

  • x_end (float) – The maximum x-coordinate of the site.

  • y_start (float) – The minimum y-coordinate of the site.

  • y_end (float) – The maximum y-coordinate of the site.

Raises:

ValueError

add_regular_turbine_layout(num_x, num_y, x_start=None, x_end=None, y_start=None, y_end=None)[source]

Adds a rectangular turbine layout to the farm.

A rectangular turbine layout with turbines evenly spread out in each direction across the given rectangular site.

Parameters:
  • turbine (Turbine object.) – Defines the type of turbine to add to the farm.

  • num_x (int) – The number of turbines placed in the x-direction.

  • num_y (int) – The number of turbines placed in the y-direction.

  • x_start (float) – The minimum x-coordinate of the site.

  • x_end (float) – The maximum x-coordinate of the site.

  • y_start (float) – The minimum y-coordinate of the site.

  • y_end (float) – The maximum y-coordinate of the site.

Raises:

ValueError

add_staggered_turbine_layout(num_x, num_y, x_start=None, x_end=None, y_start=None, y_end=None)[source]

Adds a rectangular, staggered turbine layout to the farm.

A rectangular turbine layout with turbines evenly spread out in each direction across the given rectangular site.

Parameters:
  • turbine (Turbine object.) – Defines the type of turbine to add to the farm.

  • num_x (int) – The number of turbines placed in the x-direction.

  • num_y (int) – The number of turbines placed in the y-direction (will be one less on every second row).

  • x_start (float) – The minimum x-coordinate of the site.

  • x_end (float) – The maximum x-coordinate of the site.

  • y_start (float) – The minimum y-coordinate of the site.

  • y_end (float) – The maximum y-coordinate of the site.

Raises:

ValueError

site_boundary_constraints()[source]

Returns the site boundary constraints for a rectangular site.

These constraints ensure that the turbine positions remain within the turbine site during optimisation.

Raises:

ValueError

Returns:

Tuple of lists of length equal to the twice the number of turbines. Each list contains dolfin_adjoint.Constant objects of the upper and lower bound coordinates.

property site_x_end

The maximum x-coordinate of the site.

Getter:

Returns the maximum x-coordinate of the site.

Type:

float

property site_x_start

The minimum x-coordinate of the site.

Getter:

Returns the minimum x-coordinate of the site.

Type:

float

property site_y_end

The maximum y-coordinate of the site.

Getter:

Returns the maximum y-coordinate of the site.

Type:

float

property site_y_start

The minimum y-coordinate of the site.

Getter:

Returns the minimum y-coordinate of the site.

Type:

float

2.5.1. Create a rectangular farm

class opentidalfarm.farm.rectangular_farm.RectangularFarm(domain, site_x_start, site_x_end, site_y_start, site_y_end, turbine=None, site_ids=None, order=2, n_time_steps=None)[source]

Extends Farm. Defines a rectangular Farm.

This class holds the turbines within a rectangular site.

add_lhs_turbine_layout(number_turbines, x_start=None, x_end=None, y_start=None, y_end=None)[source]

Adds to the farm a turbine layout based upon a latin hypercube sampling of the turbine area.

Parameters:
  • turbine (Turbine object.) – Defines the type of turbine to add to the farm.

  • number_turbines (int) – The number of turbines to be placed.

  • x_start (float) – The minimum x-coordinate of the site.

  • x_end (float) – The maximum x-coordinate of the site.

  • y_start (float) – The minimum y-coordinate of the site.

  • y_end (float) – The maximum y-coordinate of the site.

Raises:

ValueError

add_regular_turbine_layout(num_x, num_y, x_start=None, x_end=None, y_start=None, y_end=None)[source]

Adds a rectangular turbine layout to the farm.

A rectangular turbine layout with turbines evenly spread out in each direction across the given rectangular site.

Parameters:
  • turbine (Turbine object.) – Defines the type of turbine to add to the farm.

  • num_x (int) – The number of turbines placed in the x-direction.

  • num_y (int) – The number of turbines placed in the y-direction.

  • x_start (float) – The minimum x-coordinate of the site.

  • x_end (float) – The maximum x-coordinate of the site.

  • y_start (float) – The minimum y-coordinate of the site.

  • y_end (float) – The maximum y-coordinate of the site.

Raises:

ValueError

add_staggered_turbine_layout(num_x, num_y, x_start=None, x_end=None, y_start=None, y_end=None)[source]

Adds a rectangular, staggered turbine layout to the farm.

A rectangular turbine layout with turbines evenly spread out in each direction across the given rectangular site.

Parameters:
  • turbine (Turbine object.) – Defines the type of turbine to add to the farm.

  • num_x (int) – The number of turbines placed in the x-direction.

  • num_y (int) – The number of turbines placed in the y-direction (will be one less on every second row).

  • x_start (float) – The minimum x-coordinate of the site.

  • x_end (float) – The maximum x-coordinate of the site.

  • y_start (float) – The minimum y-coordinate of the site.

  • y_end (float) – The maximum y-coordinate of the site.

Raises:

ValueError

site_boundary_constraints()[source]

Returns the site boundary constraints for a rectangular site.

These constraints ensure that the turbine positions remain within the turbine site during optimisation.

Raises:

ValueError

Returns:

Tuple of lists of length equal to the twice the number of turbines. Each list contains dolfin_adjoint.Constant objects of the upper and lower bound coordinates.

property site_x_end

The maximum x-coordinate of the site.

Getter:

Returns the maximum x-coordinate of the site.

Type:

float

property site_x_start

The minimum x-coordinate of the site.

Getter:

Returns the minimum x-coordinate of the site.

Type:

float

property site_y_end

The maximum y-coordinate of the site.

Getter:

Returns the maximum y-coordinate of the site.

Type:

float

property site_y_start

The minimum y-coordinate of the site.

Getter:

Returns the minimum y-coordinate of the site.

Type:

float

2.5.2. Create a base farm

class opentidalfarm.farm.base_farm.BaseFarm(domain=None, turbine=None, site_ids=None, n_time_steps=None)[source]

A base Farm class from which other Farm classes should be derived.

add_turbine(coordinates)[source]

Add a turbine to the farm at the given coordinates.

Creates a new turbine of the same specification as the prototype turbine and places it at coordinates.

Parameters:

coordinates (list()) – The x-y coordinates where the turbine should be placed.

property control_array

A serialized representation of the farm based on the controls.

Returns:

A serialized representation of the farm based on the controls.

Return type:

numpy.ndarray

property control_array_global

A serialized representation of the farm based on the controls.

In contrast to the control_array property, this property returns the global array of all CPUs. In serial, control_array and control_array_global are equivalent.

Returns:

A serialized representation of the farm based on the controls.

Return type:

numpy.ndarray

minimum_distance_constraints(large=False)[source]

Returns an instance of MinimumDistanceConstraints.

Parameters:

large (bool) – Use a minimum distance implementation that is suitable for large farms (i.e. many turbines). Default: False

Returns:

An instance of dolfin_adjoint.InequalityConstraint that enforces a minimum distance between turbines.

Return type:

MinimumDistanceConstraints (if large=False) or MinimumDistanceConstraintsLargeArray (if large=True)

property number_of_turbines

The number of turbines in the farm.

Returns:

The number of turbines in the farm.

Return type:

int

set_turbine_positions(positions)[source]

Sets the turbine position and an equal friction parameter.

Parameters:

positions (list) – List of tuples containint x-y coordinates of turbines to be added.

site_boundary_constraints()[source]

Raises NotImplementedError if called.

property turbine_frictions

The friction coefficients of turbines within the farm. :returns: The friction coefficients of turbines within the farm. :rtype: list()

property turbine_positions

The positions of turbines within the farm. :returns: The positions of turbines within the farm. :rtype: list()