floris_design #7

Merged
maxim merged 4 commits from floris_design into main 2024-11-24 14:13:10 +04:00
3 changed files with 15 additions and 3 deletions
Showing only changes of commit 7cdbd65432 - Show all commits

View File

@ -65,7 +65,8 @@ class FlorisULSTU(FlorisModel):
for experiment_count in range(experiment_counts): for experiment_count in range(experiment_counts):
self.reset_operation() self.reset_operation()
self.set(wind_speeds=[wind_speeds[0]], wind_directions=[wind_dirs[0]], turbulence_intensities=[0.05]) self.set(wind_speeds=[wind_speeds[experiment_count]], wind_directions=[wind_dirs[experiment_count]],
turbulence_intensities=[0.05])
ax = axarr[experiment_count] ax = axarr[experiment_count]
horizontal_plane = self.calculate_horizontal_plane(height=90.0) horizontal_plane = self.calculate_horizontal_plane(height=90.0)
visualize_cut_plane( visualize_cut_plane(

View File

@ -12,6 +12,7 @@ class SWeatherInfo(BaseModel):
class SFlorisInputParams(BaseModel): class SFlorisInputParams(BaseModel):
layout_x: list[float] = Field(Query([])) layout_x: list[float] = Field(Query([]))
layout_y: list[float] = Field(Query([])) layout_y: list[float] = Field(Query([]))
yaw_angle: list[float] = Field(Query([]))
date_start: date date_start: date
date_end: date date_end: date

View File

@ -8,6 +8,7 @@ from fastapi.responses import FileResponse
from data.repository import WeatherRepository from data.repository import WeatherRepository
from data.schemas import SFlorisInputParams, SFlorisOutputData, SWeatherInfo from data.schemas import SFlorisInputParams, SFlorisOutputData, SWeatherInfo
import numpy as np
sys.path.append(str(Path(__file__).parent.parent.parent)) sys.path.append(str(Path(__file__).parent.parent.parent))
@ -27,12 +28,13 @@ router = APIRouter(
async def get_windmill_data( async def get_windmill_data(
data: Annotated[SFlorisInputParams, Depends()] data: Annotated[SFlorisInputParams, Depends()]
): ):
if len(data.layout_x) != len(data.layout_y): if len(data.layout_x) != len(data.layout_y) and len(data.layout_x) != len(data.yaw_angle):
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST, status_code=HTTPStatus.BAD_REQUEST,
detail="Length of layout x and y must be the same", detail="Length of layout x and y and yaw_angle must be the same",
) )
fmodel = FlorisULSTU() fmodel = FlorisULSTU()
client = OpenMeteoClient() client = OpenMeteoClient()
@ -49,6 +51,14 @@ async def get_windmill_data(
turbulence_intensities=[0.1] * len(wind_directions) turbulence_intensities=[0.1] * len(wind_directions)
) )
yaw_angles = np.zeros((len(wind_directions), len(data.layout_x)))
for i in range(len(data.layout_x)):
yaw_angles[:, i] = data.yaw_angle[i]
fmodel.set(
yaw_angles=yaw_angles,
)
fmodel.run() fmodel.run()
res = fmodel.get_turbine_powers().tolist() res = fmodel.get_turbine_powers().tolist()