Skip to content

Commit

Permalink
Merge pull request byuflowlab#62 from BTV25/hackathon
Browse files Browse the repository at this point in the history
Hackathon updates
  • Loading branch information
andrewning authored Jun 14, 2024
2 parents f548be6 + b2c7d14 commit d876e97
Show file tree
Hide file tree
Showing 21 changed files with 1,109 additions and 1,202 deletions.
20 changes: 6 additions & 14 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,27 @@ version = "0.1.0"

[deps]
CCBlade = "e1828068-15df-11e9-03e4-ef195ea46fa4"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
FLOWMath = "6cb5d3fb-0fe8-4cc2-bd89-9fe0b19a99d3"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Geodesy = "0ef565a4-170c-5f04-8de2-149903a85f3d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
TestSetExtensions = "98d24dd4-01ad-11ea-1b02-c9a08f80db04"
XLSX = "fdbf4ff8-1666-58a4-91e7-1b58723a45e0"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[compat]
CSV = "0.10"
CCBlade = "0.2"
DelimitedFiles = "1"
FLOWMath = "0.3"
TestSetExtensions = "3"
Geodesy = "1"
YAML = "0.4"
DataFrames = "1"
SpecialFunctions = "0,2"
FiniteDiff = "2"
XLSX = "0.10"
DelimitedFiles = "1"
CCBlade = "0.2"
PyPlot = "2"
ForwardDiff = "0.10"
Geodesy = "1"
SpecialFunctions = "0,2"
TestSetExtensions = "3"
YAML = "0.4"
julia = "1"

[extras]
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@

### Install FLOWFarm

```julia
```
julia
(v1.x) pkg> dev https://github.com/byuflowlab/FLOWFarm.jl.git
```

## Testing

To test FLOWFarm, run the following from the top directory:

```julia
```
julia
julia
]
activate .
Expand Down
9 changes: 5 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
- Smooth/continous model implementations
- Runs on a single core, across multiple cores (threaded), or on multiple machines (distributed).
- Designed so that new model implementations can be included by adding a single method
- Allows for Wake Expansion Continuation (WEC) as described [here](http://flowlab.groups.et.byu.net/preprints/Thomas2021.pdf)
- Allows for Wake Expansion Continuation (WEC) as described here

## Installation

### Install FLOWFarm

```julia
```
julia
(v1.x) pkg> dev https://github.com/byuflowlab/FLOWFarm.jl.git
```

## Testing

To test FLOWFarm, run the following from the top directory:

```julia
```
julia
julia
]
activate .
Expand Down
18 changes: 4 additions & 14 deletions src/FLOWFarm.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
module FLOWFarm
using ForwardDiff: Iterators
using Geodesy: bound_thetad
using Geodesy; const gd = Geodesy
using ForwardDiff
using LinearAlgebra

# using CCBlade
using PyPlot; const plt = PyPlot
using FLOWMath: linear,trapz,Akima,ksmax,abs_smooth
# using Statistics
using FLOWMath
using Distributed
using YAML
using XLSX
using DataFrames
using CSV
using SpecialFunctions
using Geodesy; const gd = Geodesy
using YAML

include("io.jl")
include("utilities.jl")
include("turbines.jl")
include("windfarms.jl")
include("wind_resources.jl")
include("wind_shear_models.jl")
Expand All @@ -31,8 +21,8 @@ include("general_models.jl")
include("power_models.jl")
include("user_functions.jl")
include("optimization_functions.jl")
include("fatigue_model.jl")
include("tip.jl")
include("cost_models.jl")
include("plotting.jl")
include("fatigue_model.jl")
end # module
14 changes: 7 additions & 7 deletions src/cost_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Container for parameters related to the Levelized Cost of Energy model (NREL 201
- `FCR::Float`: Fixed Charge Rate
- `OpEx::Float`: Operational Expenditures
"""
struct Levelized{TF} <: AbstractCostModel
TCC::TF
BOS::TF
FC::TF
FCR::TF
OpEx::TF
struct Levelized{T1,T2,T3,T4,T5} <: AbstractCostModel
TCC::T1
BOS::T2
FC::T3
FCR::T4
OpEx::T5
end
Levelized() = Levelized(776.0, 326.0, 120.0, .0655, 43.0) # Default values taken from NREL 2019 Cost of Wind Energy

Expand All @@ -37,7 +37,7 @@ Calculates the LCOE using the same numbers as NREL's FLORIS Model
"""

function cost_of_energy(rotor_diameter, hub_height, rated_power, AEP, Cost::Levelized)

nturbines = length(rotor_diameter)
# Taken from 2019 Cost of Wind Energy Review
TCC = Cost.TCC
Expand Down
35 changes: 15 additions & 20 deletions src/fatigue_model.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using FLOWFarm
using CCBlade

const ff=FLOWFarm


"""
multiple_components_op(U, V, W, Omega, r, precone, yaw, tilt, azimuth, rho, mu=1.81206e-05, asound=1.0)
Expand Down Expand Up @@ -480,16 +475,16 @@ function get_single_damage(model_set,problem_description,turbine_ID,state_ID,nCy
oms = zeros(nCycles*naz)

turbine_inflow_velcities = zeros(nturbines) .+ ws
temp_resource = ff.DiscretizedWindResource([3*pi/2], [ws], [1.0], measurementheight, air_density,ambient_tis, wind_shear_model)
temp_pd = ff.WindFarmProblemDescription(windfarm, temp_resource, [windfarmstate])
ff.turbine_velocities_one_direction!(points_x, points_y, model_set, temp_pd)
temp_resource = DiscretizedWindResource([3*pi/2], [ws], [1.0], measurementheight, air_density,ambient_tis, wind_shear_model)
temp_pd = WindFarmProblemDescription(windfarm, temp_resource, [windfarmstate])
turbine_velocities_one_direction!(points_x, points_y, model_set, temp_pd)

wfs_temp = temp_pd.wind_farm_states[1]
for i = 1:nCycles*naz
az = az_arr[(i+1)%naz+1]

"""need to figure this out"""
x_locs, y_locs, z_locs = ff.find_xyz_simple(turbine_x[turbine_ID],turbine_y[turbine_ID],turbine_z[turbine_ID].+hub_height,r,yaw,az)
x_locs, y_locs, z_locs = find_xyz_simple(turbine_x[turbine_ID],turbine_y[turbine_ID],turbine_z[turbine_ID].+hub_height,r,yaw,az)

TI_arr = zeros(length(r))
for k = 1:length(r)
Expand Down Expand Up @@ -518,7 +513,7 @@ function get_single_damage(model_set,problem_description,turbine_ID,state_ID,nCy
U = U + turb_samples[i]*TI_inst.*U
op = distributed_velocity_op.(U, Omega, r, precone, yaw, tilt, az, rho)
out = CCBlade.solve.(Ref(rotor), sections, op)
flap[i],edge[i] = ff.get_moments(out,Rhub,Rtip,r,az,precone,tilt)
flap[i],edge[i] = get_moments(out,Rhub,Rtip,r,az,precone,tilt)
oms[i] = Omega


Expand Down Expand Up @@ -582,7 +577,7 @@ function get_single_state_damage(model_set,problem_description,state_ID,nCycles,
nturbines = length(turbine_x)
damage = zeros(nturbines)
for k = 1:nturbines
damage[k] = ff.get_single_damage(model_set,problem_description,k,state_ID,nCycles,az_arr,
damage[k] = get_single_damage(model_set,problem_description,k,state_ID,nCycles,az_arr,
turb_samples,points_x,points_y,omega_func,pitch_func,turbulence_func,r,rotor,sections,Rhub,Rtip,precone,tilt,rho,
Nlocs=Nlocs,fos=fos)
end
Expand All @@ -607,11 +602,11 @@ function get_total_farm_damage(model_set,problem_description,nCycles,az_arr,
for k = 1:ndirections

problem_description.wind_farm_states[k].turbine_x[:],problem_description.wind_farm_states[k].turbine_y[:] =
ff.rotate_to_wind_direction(wind_farm.turbine_x, wind_farm.turbine_y, wind_resource.wind_directions[k])
rotate_to_wind_direction(wind_farm.turbine_x, wind_farm.turbine_y, wind_resource.wind_directions[k])

problem_description.wind_farm_states[k].sorted_turbine_index[:] = sortperm(problem_description.wind_farm_states[k].turbine_x)

state_damage = ff.get_single_state_damage(model_set,problem_description,k,nCycles,az_arr,
state_damage = get_single_state_damage(model_set,problem_description,k,nCycles,az_arr,
turb_samples,points_x,points_y,omega_func,pitch_func,turbulence_func,r,rotor,sections,Rhub,Rtip,precone,tilt,rho,
Nlocs=Nlocs,fos=fos)
damage = damage + state_damage.*frequencies[k]
Expand All @@ -622,9 +617,9 @@ end



struct NpTp{T}
Np::T
Tp::T
struct NpTp{T1,T2}
Np::T1
Tp::T2
end


Expand All @@ -648,9 +643,9 @@ function get_single_damage_surr(turbine_x,turbine_y,turbine_z,rotor_diameter,hub
edge = zeros(nCycles*naz)
oms = zeros(nCycles*naz)

temp_resource = ff.DiscretizedWindResource([3*pi/2], [ws], [1.0], measurementheight, air_density, ambient_tis, wind_shear_model)
temp_resource = DiscretizedWindResource([3*pi/2], [ws], [1.0], measurementheight, air_density, ambient_tis, wind_shear_model)

turbine_velocities, turbine_ct, turbine_local_ti = ff.turbine_velocities_one_direction(turbine_x, turbine_y, turbine_z, rotor_diameter, hub_height, turbine_yaw,
turbine_velocities, turbine_ct, turbine_local_ti = turbine_velocities_one_direction(turbine_x, turbine_y, turbine_z, rotor_diameter, hub_height, turbine_yaw,
turbine_ai, sorted_turbine_index, ct_model, rotor_sample_points_y, rotor_sample_points_z, wind_resource,
model_set; wind_farm_state_id=state_ID)

Expand All @@ -659,7 +654,7 @@ function get_single_damage_surr(turbine_x,turbine_y,turbine_z,rotor_diameter,hub
az = az_arr[(i+1)%naz+1]

"""need to figure this out"""
x_locs, y_locs, z_locs = ff.find_xyz_simple(turbine_x[turbine_ID],turbine_y[turbine_ID],turbine_z[turbine_ID].+hub_height[turbine_ID],r,turbine_yaw[turbine_ID],az)
x_locs, y_locs, z_locs = find_xyz_simple(turbine_x[turbine_ID],turbine_y[turbine_ID],turbine_z[turbine_ID].+hub_height[turbine_ID],r,turbine_yaw[turbine_ID],az)

TI_arr = zeros(length(r))
for k = 1:length(r)
Expand Down Expand Up @@ -699,7 +694,7 @@ function get_single_damage_surr(turbine_x,turbine_y,turbine_z,rotor_diameter,hub
out = NpTp(np,tp)
# println("spline: ", out.Np[1], " ", out.Tp[1])
# println("___________________________")
flap[i],edge[i] = ff.get_moments(out,Rhub,Rtip,r,az,precone,tilt)
flap[i],edge[i] = get_moments(out,Rhub,Rtip,r,az,precone,tilt)
oms[i] = Omega
println("loop time: ", time()-time1)
end
Expand Down
Loading

0 comments on commit d876e97

Please sign in to comment.