Skip to content

Commit

Permalink
update Farm and multi dim turb to work with library paths
Browse files Browse the repository at this point in the history
  • Loading branch information
RHammond2 committed Nov 15, 2023
1 parent 85f8eae commit 7e7f821
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
12 changes: 8 additions & 4 deletions floris/simulation/farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,14 @@ def construct_turbine_correct_cp_ct_for_tilt(self):
def construct_turbine_map(self):
multi_key = "multi_dimensional_cp_ct"
if multi_key in self.turbine_definitions[0] and self.turbine_definitions[0][multi_key]:
# TODO: Need to load this with the turbine library location
self.turbine_map = [
TurbineMultiDimensional.from_dict(turb) for turb in self.turbine_definitions
]
self.turbine_map = []
for turb in self.turbine_definitions:
try:
_turb = {**turb, **{"turbine_library_path": self.interal_turbine_library}}
self.turbine_map.append(TurbineMultiDimensional.from_dict(_turb))
except FileNotFoundError:
_turb = {**turb, **{"turbine_library_path": self.turbine_library_path}}
self.turbine_map.append(TurbineMultiDimensional.from_dict(_turb))
else:
self.turbine_map = [Turbine.from_dict(turb) for turb in self.turbine_definitions]

Expand Down
11 changes: 10 additions & 1 deletion floris/simulation/turbine_multi_dim.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

import copy
from collections.abc import Iterable
from pathlib import Path

import attrs
import numpy as np
import pandas as pd
from attrs import define, field
Expand Down Expand Up @@ -423,9 +425,12 @@ class TurbineMultiDimensional(Turbine):
the rotor radius.
Defaults to 0.5.
"""

power_thrust_data_file: str = field(default=None)
multi_dimensional_cp_ct: bool = field(default=False)
turbine_library_path: Path = field(
default=Path(".").resolve(),
validator=attrs.validators.instance_of(Path)
)

# rloc: float = float_attrib() # TODO: goes here or on the Grid?
# use_points_on_perimeter: bool = bool_attrib()
Expand All @@ -447,6 +452,10 @@ class TurbineMultiDimensional(Turbine):
# self.use_points_on_perimeter = False

def __attrs_post_init__(self) -> None:
# Solidify the data file path and name
self.power_thrust_data_file = (
self.turbine_library_path / self.power_thrust_data_file
).resolve()

# Read in the multi-dimensional data supplied by the user.
df = pd.read_csv(self.power_thrust_data_file)
Expand Down

0 comments on commit 7e7f821

Please sign in to comment.