Skip to content

Commit

Permalink
Three functions of windfield translated
Browse files Browse the repository at this point in the history
  • Loading branch information
ufechner7 committed May 7, 2022
1 parent 2f4f04a commit 302ac38
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ authors = ["Uwe Fechner <[email protected]> and contributors"]
version = "0.1.0"

[deps]
HypergeometricFunctions = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
KiteUtils = "90980105-b163-44e5-ba9f-8b1c83bb0533"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
TestEnv = "1e6cf692-eddd-4d53-88a5-2d735e33781b"

[compat]
julia = "1.6, 1.7, 1.8"
KiteUtils = "^0.3.4"
Parameters = "^0.12"
TestEnv = "1"
HypergeometricFunctions = "0.3"
julia = "1.6, 1.7, 1.8"

[extras]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Expand Down
3 changes: 2 additions & 1 deletion src/AtmosphericModels.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module AtmosphericModels

using KiteUtils, Parameters
using KiteUtils, Parameters, HypergeometricFunctions

export AtmosphericModel, ProfileLaw, EXP, LOG, EXPLOG, FAST_EXP, FAST_LOG, FAST_EXPLOG
export clear, calc_rho, calc_wind_factor
Expand Down Expand Up @@ -92,5 +92,6 @@ function calc_wind_factor(s::AM, height, ::Type{Val{6}})
evalpoly(1/height, (1.0, 1735.2333827029918, 279373.0012683715))
end

include("windfield.jl")

end
33 changes: 17 additions & 16 deletions src/windfield.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
This module provides methods to create a turbulent wind field and to read
the actual wind velocity vector as function of the 3d position
Expand All @@ -14,23 +13,25 @@ The code is based on the following papers:
Engineering Mechanics 13(4), pp. 269-282.
"""

# def pfq(z):
# return np.real(hyp2f1(1./3., 17./6., 4./3., z))
function pfq(z)
_₂F₁(1. /3 , 17. /6, 4. /3, z)
end

# def calcSigma1(v_wind_gnd):
# # TODO: What is the meaning of this value ???
# v_height = calcWindHeight(v_wind_gnd, HUB_HEIGHT)
# sigma1 = I_REF * (0.75 * v_height + 5.6)
# return sigma1
function calc_sigma1(am, v_wind_gnd)
v_height = v_wind_gnd * calc_wind_factor(am, am.set.avg_height, Val{Int(EXP)})
am.set.i_ref * (0.75 * v_height + 5.6)
end

# def nextpow2(i):
# """
# Find 2^n that is equal to or greater than i.
# """
# n = 1
# while n < i:
# n *= 2
# return n
"""
Find 2^n that is equal to or greater than i.
"""
function nextpow2(i)
n = 1
while n < i
n *= 2
end
n
end

# def calcFullName(v_wind_gnd, basename='windfield_4050_500', rel_sigma = 1.0):
# path = HOME+'/00PythonSoftware/KiteSim/Environment/'
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ end
clear(am)
end

@testset "windfield" begin
@test AtmosphericModels.pfq(0.1) 1.079576584249971
@test AtmosphericModels.calc_sigma1(am, 10.0) 2.181983002542761
@test AtmosphericModels.nextpow2(10) == 16
end

0 comments on commit 302ac38

Please sign in to comment.