byuflowlab / ccblade.jl Goto Github PK
View Code? Open in Web Editor NEWBlade Element Momentum Method for Propellers and Turbines
License: Other
Blade Element Momentum Method for Propellers and Turbines
License: Other
Here is the error in CCBlade, it happens when you set Vinf (~line 124) smaller than .01. It traces back to the fzero call on ~line 483. It's not a big deal since we're not yet doing design where Vinf needs to cross zero. (Hope this a good place to record issues like this)
LoadError: BoundsError
while loading /Users/kmoore/Dropbox/CodeRepos/CCblade_Updated/src/example.jl, in expression starting on line 132
in indexed_next(::Float64, ::Int64, ::Bool) at tuple.jl:35
in (::#R#30)(::Float64) at ccblade.jl:456
in update_state(::Roots.Bisection, ::Roots.DerivativeFree, ::Roots.UnivariateZeroState{Float64,Float64}, ::Roots.UnivariateZeroOptions{Float64}) at bracketing.jl:119
in find_zero(::Roots.Bisection, ::Roots.DerivativeFree, ::Roots.UnivariateZeroState{Float64,Float64}, ::Roots.UnivariateZeroOptions{Float64}) at find_zero.jl:320
in #find_zero#12(::Int64, ::Bool, ::Array{Any,1}, ::Function, ::Function, ::Array{Float64,1}, ::Roots.Bisection) at bracketing.jl:69
in #fzero#67(::Array{Any,1}, ::Function, ::Function, ::Float64, ::Float64) at Roots.jl:110
in fzero(::Function, ::Float64, ::Float64) at Roots.jl:105
in distributedLoads(::Rotor, ::Inflow, ::Bool) at ccblade.jl:483
in include_string(::String, ::String) at loading.jl:441
in include_string(::String, ::String) at sys.dylib:?
in include_string(::Module, ::String, ::String) at eval.jl:32
in (::Atom.##59#62{String,String})() at eval.jl:73
in withpath(::Atom.##59#62{String,String}, ::String) at utils.jl:30
in withpath(::Function, ::String) at eval.jl:38
in macro expansion at eval.jl:71 [inlined]
in (::Atom.##58#61{Dict{String,Any}})() at task.jl:60
I am trying to use CCBlade.jl for optimization of a (remote controlled) helicopter's rotor. A rotor blade usually has a rectangular shape with a constant theta over the complete blade. When solving such a blade, the function solve() presents two warnings, one at the root and one at the tip of the blade. I have added section.r to the warn statement in line 721. With a blade starting at r=0.1m and a tip radius of 0.9m I get the follwing output:
┌ Warning: ("no solution found for this section at station ", 0.1)
└ @ CCBlade /home/holger/.julia/packages/CCBlade/pJbY9/src/CCBlade.jl:721
┌ Warning: ("no solution found for this section at station ", 0.9)
└ @ CCBlade /home/holger/.julia/packages/CCBlade/pJbY9/src/CCBlade.jl:721
What is causing these warnings?Is it safe to ignore them?
The calculated torque and thrust of the rotor (and the resulting power) seems to be in a reasonable magnitude, so I guess there is nothing too bad happening here.
This code still doesn't run. There are some obvious errors, like if I run it gives me a syntax error pointing to line 643: "Error evaluating ccblade.jl LoadError: syntax: use "^" instead of "**""
here is the line
q = 0.5*rho*W**2
which should be
q = 0.5*rho*W^2
Hi there,
In a number of the OpenMDAO examples I get an error that af_from_files can't be imported on the julia side, e.g. when I run run_openmdao_ccblade.py, I get:
WARNING: replacing module _PyJuliaHelper.
Traceback (most recent call last):
File "/root/pyjulia/src/julia/pseudo_python_cli.py", line 308, in main
python(**vars(ns))
File "/root/pyjulia/src/julia/pseudo_python_cli.py", line 59, in python
scope = runpy.run_path(script, run_name="__main__")
File "/root/miniconda3/lib/python3.8/runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "/root/miniconda3/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/root/miniconda3/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "run_openmdao_ccblade.py", line 8, in <module>
from ccblade.ccblade_jl import CCBladeGroup
File "/root/CCBlade.jl/openmdao/python/ccblade/ccblade_jl.py", line 7, in <module>
from julia.CCBlade import af_from_files
File "/root/pyjulia/src/julia/core.py", line 260, in load_module
raise ImportError("{} not found".format(juliapath))
ImportError: CCBlade.af_from_files not found
I'll poke around and see if I can fix it. Was this a name change to AlphaAF?
Hi
Trying to model a T-motor quad-rotor blade, I have encountered problems when the wind is blowing through the back of the blade.
The problem is that the thrust goes to negative values suddenly after the wind direction is changed through the top to the bottom of rotor disk(which is not happening in reality).
Even with negligible wind speed, the results show meaningless fluctuations (I could not set the wind speed to zero due to numerical issues).
I have attached the rotor geometry and the results.
Thanks in advance
geometryAndOutputs.zip
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
There is no need to redefine constants like pi. Those already exist in Julia
I am just wondering, but are there any plans to add Davoudi's [1] "hybrid BEM" to CCBlade in the future?
[1] B. Davoudi, “A Hybrid Blade Element Momentum Model for Flight Simulation of Rotary Wing Unmanned Aerial Vehicles,” AIAA Paper, 2019.
You've made type declarations fortran style (which makes sense b/c it was translated from Fortran), but isn't the typical syntax in Julia.
instead of func(x)
x::Float64
you should use func(x::Float64)
When I try to create eg a vector of Section
structs with nightly builds of Julia, like this:
(jl_DjwQyJ) pkg> using CCBlade
ERROR: `using` is not a recognized command. Type ? for help with available commands
julia> using CCBlade
julia> radii = range(0.1, 1.0; length=10)
0.1:0.1:1.0
julia> chord = similar(radii)
10-element Vector{Float64}:
6.9368548214818e-310
6.9369127073666e-310
6.93690470785607e-310
6.93685482148497e-310
6.9369056525649e-310
6.93685482148813e-310
6.9368548214913e-310
6.93691005160844e-310
6.9369127073666e-310
6.9369057171642e-310
julia> theta = similar(radii)
10-element Vector{Float64}:
5.4e-323
5.0e-324
5.0e-323
4.4e-323
4.0e-323
3.5e-323
2.5e-323
3.0e-323
2.0e-323
1.5e-323
julia> sections = Section.(radii, chord, theta, alpha->(1.0, 1.0))
ERROR: type Section has no field ref
Stacktrace:
[1] _broadcast_getindex_evalf
@ ./broadcast.jl:677 [inlined]
[2] _broadcast_getindex
@ ./broadcast.jl:650 [inlined]
[3] getindex
@ ./broadcast.jl:604 [inlined]
[4] copy
@ ./broadcast.jl:910 [inlined]
[5] materialize
@ ./broadcast.jl:871 [inlined]
[6] getproperty(obj::Vector{Section{Float64, var"#7#8"}}, sym::Symbol)
@ CCBlade ~/.julia/packages/CCBlade/5jTbo/src/CCBlade.jl:91
[7] dataids(A::Vector{Section{Float64, var"#7#8"}})
@ Base ./abstractarray.jl:1555
[8] mightalias
@ Base ./abstractarray.jl:1530 [inlined]
[9] unalias
@ Base ./abstractarray.jl:1495 [inlined]
[10] broadcast_unalias
@ Base.Broadcast ./broadcast.jl:945 [inlined]
[11] preprocess
@ Base.Broadcast ./broadcast.jl:952 [inlined]
[12] preprocess_args (repeats 2 times)
@ Base.Broadcast ./broadcast.jl:954 [inlined]
[13] preprocess
@ Base.Broadcast ./broadcast.jl:951 [inlined]
[14] copyto!
@ Base.Broadcast ./broadcast.jl:968 [inlined]
[15] copyto!
@ Base.Broadcast ./broadcast.jl:924 [inlined]
[16] copy
@ Base.Broadcast ./broadcast.jl:896 [inlined]
[17] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Type{Section}, Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Vector{Float64}, Vector{Float64}, Base.RefValue{var"#7#8"}}})
@ Base.Broadcast ./broadcast.jl:871
[18] top-level scope
@ REPL[8]:1
julia> versioninfo()
Julia Version 1.11.0-DEV.1187
Commit ca0a266e4f6 (2024-01-03 13:34 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
WORD_SIZE: 64
LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)
Environment:
JULIA_PKG_SERVER = us-east.pkg.julialang.org
(jl_DjwQyJ) pkg> st
Status `/tmp/jl_DjwQyJ/Project.toml`
[e1828068] CCBlade v0.2.5
(jl_DjwQyJ) pkg>
I get an error that appears to be related to the convenience functions used to access individual fields of a Vector{<:Section}
:
Line 90 in 50ba0be
If I remove that function, then the error goes away:
shell> nvr ./dev/CCBlade/src/CCBlade.jl # Remove Base.getproperty(obj::AbstractVector{<:Section}, sym::Symbol)
julia> using CCBlade
Precompiling CCBlade
1 dependency successfully precompiled in 3 seconds. 59 already precompiled.
julia> radii = range(0.1, 1.0; length=10)
0.1:0.1:1.0
julia> chord = similar(radii)
10-element Vector{Float64}:
6.9321471006254e-310
6.9321549093946e-310
6.93215490939933e-310
6.93215490940407e-310
6.9321471855873e-310
6.93214830413057e-310
6.93215490940723e-310
6.9321549094104e-310
6.93215490941356e-310
6.9321549094167e-310
julia> theta = similar(radii)
10-element Vector{Float64}:
0.0
1.390671161567e-309
0.0
0.0
1.390671161567e-309
0.0
0.0
1.265e-321
0.0
0.0
julia> sections = Section.(radii, chord, theta, alpha->(1.0, 1.0))
10-element Vector{Section{Float64, var"#7#8"}}:
Section{Float64, var"#7#8"}(0.1, 6.9321471006254e-310, 0.0, var"#7#8"())
Section{Float64, var"#7#8"}(0.2, 6.9321549093946e-310, 1.390671161567e-309, var"#7#8"())
Section{Float64, var"#7#8"}(0.3, 6.93215490939933e-310, 0.0, var"#7#8"())
Section{Float64, var"#7#8"}(0.4, 6.93215490940407e-310, 0.0, var"#7#8"())
Section{Float64, var"#7#8"}(0.5, 6.9321471855873e-310, 1.390671161567e-309, var"#7#8"())
Section{Float64, var"#7#8"}(0.6, 6.93214830413057e-310, 0.0, var"#7#8"())
Section{Float64, var"#7#8"}(0.7, 6.93215490940723e-310, 0.0, var"#7#8"())
Section{Float64, var"#7#8"}(0.8, 6.9321549094104e-310, 1.265e-321, var"#7#8"())
Section{Float64, var"#7#8"}(0.9, 6.93215490941356e-310, 0.0, var"#7#8"())
Section{Float64, var"#7#8"}(1.0, 6.9321549094167e-310, 0.0, var"#7#8"())
julia> versioninfo()
Julia Version 1.11.0-DEV.1187
Commit ca0a266e4f6 (2024-01-03 13:34 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 12 × Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
WORD_SIZE: 64
LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)
Environment:
JULIA_PKG_SERVER = us-east.pkg.julialang.org
julia>
I know CCBlade doesn't use Julia nightly builds for testing, but I recently ran into this and thought I'd bring it up. The error doesn't occur with any of the stable Julia builds—I checked 1.9.4 and 1.10.0 today.
Dear all,
I found the 419th line has a bug:
419: AlphaReMachAF(alpha, Re, Mach, cl, cd) = AlphaMachAF(alpha, Re, Mach, cl, cd, "CCBlade generated airfoil")
It looks to be corrected like this:
AlphaReMachAF(alpha, Re, Mach, cl, cd) = AlphaReMachAF(alpha, Re, Mach, cl, cd, "CCBlade generated airfoil")
I found the 425th and 426th lines have bugs:
423: info, Re1, Mach1, alpha, cl1, cd1 = parsefile(filenames[1, 1], radians) # assumes common alpha and info across files
424: nalpha = length(alpha)
425: nRe = length(Re1)
426: nMach = length(Mach1)
They look to be corrected like these:
423: info, _, _, alpha, cl1, cd1 = parsefile(filenames[1, 1], radians) # assumes common alpha and info across files
424: nalpha = length(alpha)
425: nRe, nMach = size(filenames)
Sincerely
When running optimizations with CCBlade.jl, sometimes the optimizer will figure out a way to manipulate the design such that the DuSeligEggers
rotation correction will reduce the drag coefficient to < 0
. As a workaround, I've been using a tweaked version of the correction:
using CCBlade: CCBlade
"""
DuSeligEggersNonNegDeltaCD(a, b, d, m, alpha0)
DuSeligEggersNonNegDeltaCD(a=1.0, b=1.0, d=1.0, m=2*pi, alpha0=0.0) # uses defaults
DuSelig correction for lift an Eggers correction for drag.
**Arguments**
- `a, b, d::Float64`: parameters in Du-Selig paper. Normally just 1.0 for each.
- `m::Float64`: lift curve slope. Defaults to 2 pi for zero argument version.
- `alpha0::Float64`: zero-lift angle of attack. Defaults to 0 for zero argument version.
"""
struct DuSeligEggersNonNegDeltaCD{TF} <: CCBlade.RotationCorrection
a::TF
b::TF
d::TF
m::TF
alpha0::TF
end
DuSeligEggersNonNegDeltaCD() = DuSeligEggersNonNegDeltaCD(1.0, 1.0, 1.0, 2*pi, 0.0)
function CCBlade.rotation_correction(du::DuSeligEggersNonNegDeltaCD, cl, cd, cr, rR, tsr, alpha, phi=alpha, alpha_max_corr=30*pi/180)
# Du-Selig correction for lift
Lambda = tsr / sqrt(1 + tsr^2)
expon = du.d / (Lambda * rR)
fcl = 1.0/du.m*(1.6*cr/0.1267*(du.a-cr^expon)/(du.b+cr^expon)-1)
# linear lift line
cl_linear = du.m*(alpha - du.alpha0)
# adjustment for max correction
amax = atan(1/0.12) - 5*pi/180 # account for singularity in Eggers (not pi/2)
if abs(alpha) >= amax
adj = 0.0
elseif abs(alpha) > alpha_max_corr
adj = ((amax-abs(alpha))/(amax-alpha_max_corr))^2
else
adj = 1.0
end
# increment in cl
deltacl = adj*fcl*(cl_linear - cl)
cl += deltacl
# Eggers correction for drag
deltacd = deltacl * (sin(phi) - 0.12*cos(phi))/(cos(phi) + 0.12*sin(phi)) # note that we can actually use phi instead of alpha as is done in airfoilprep.py b/c this is done at each iteration
if deltacd > 0
cd += deltacd
end
return cl, cd
end
In the code above, the correction is only applied if it actually increases the drag coefficient. But I'm not familiar with the physics and wonder if that's the "right" thing to do (though it definitely prevents the negative drag coefficients I and others see occasionally).
I tried installing CCBlade on fresh Julia 1.6 installations on both Windows and Linux, however running add CCBlade
fails to successfully install.
julia> import Pkg; Pkg.precompile()
Precompiling project...
✗ ImplicitAD
✗ CCBlade
0 dependencies successfully precompiled in 19 seconds (30 already precompiled)
ERROR: The following 1 direct dependency failed to precompile:
CCBlade [e1828068-15df-11e9-03e4-ef195ea46fa4]
Failed to precompile CCBlade [e1828068-15df-11e9-03e4-ef195ea46fa4] to C:\Users\WillHewson.julia\compiled\v1.6\CCBlade\jl_FF55.tmp.
ERROR: LoadError: UndefVarError: TrackedArray not defined
Stacktrace:
[1] top-level scope
@ C:\Users\WillHewson.julia\packages\ReverseDiff\7pHoq\src\macros.jl:334
[2] include
@ .\Base.jl:384 [inlined]
[3] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base .\loading.jl:1235
[4] top-level scope
@ none:1
[5] eval
@ .\boot.jl:360 [inlined]
[6] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[7] top-level scope
@ none:1
in expression starting at C:\Users\WillHewson.julia\packages\ImplicitAD\0cPWZ\src\ImplicitAD.jl:1
ERROR: LoadError: Failed to precompile ImplicitAD [e7cbb90b-9b31-4eb2-a8c8-45099c074ee1] to C:\Users\WillHewson.julia\compiled\v1.6\ImplicitAD\jl_8B.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IOContext{Base.PipeEndpoint}, internal_stdout::IOContext{IOStream}, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] include
@ .\Base.jl:384 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1235
[9] top-level scope
@ none:1
[10] eval
@ .\boot.jl:360 [inlined]
[11] eval(x::Expr)
@ Base.MainInclude .\client.jl:446
[12] top-level scope
@ none:1
in expression starting at C:\Users\WillHewson.julia\packages\CCBlade\sFMxf\src\CCBlade.jl:14
Stacktrace:
[1] pkgerror(msg::String)
@ Pkg.Types C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Types.jl:55
[2] precompile(ctx::Pkg.Types.Context; internal_call::Bool, strict::Bool, warn_loaded::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:1265
[3] precompile
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:921 [inlined]
[4] #precompile#196
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:919 [inlined]
[5] precompile()
@ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:919
[6] top-level scope
@ REPL[3]:1
Hi @andrewning,
I just read your paper.
Good job and thank you so much! I was having issues with convergence myself, and it didn't occur to me to go further and reformulate as a one dimensional equation problem. Great move.
I see you have implemented your solution in Julia, which is out of my scope for the moment. I need the code to run in Python, so I will keep you posted how my implementation of your paper goes.
Cheers,
Enrique
All of the content in bem.jl is now in ccblade.jl so you should delete bem.jl
Currently Omega needs to be the same type as Vinf.
I run into the error UndefVarError: u not defined
raised by residualVx0()
. Apparently there is no definition of u
when falling in the if case os*k2 < 0
.
Hi. I am a Python user who is trying to use CCBlade in OpenMDAO framework. Thanks for openmdao/python code in this repo, I could do simple optimization code.
However, I have some questions. First, I was trying to use example codes in CCBlade.jl/openmdao/python/examples/ folder, most codes require 'ViternaAirfoil' function of openbemt. I think it seems to include Reynolds number correction. How can I use this example codes except openbemt codes?
Second, if I use 'af_from_files' function in utils.py, should I use interpolated and corrected airfoil data? This function seems to have no any corrections about Re and Mach.
I'm not sure if it will be delivered well due to my poor English.
Have a nice day!
Julia isn't like Fortran where you return outputs and inputs in the function call and distinguish then with a declaration. Instead in Julia you can return a tuple.
So instead of:
# out
fzero, a, ap :: Float64
You should have at the end of the function
return fzero, a, ap
The code (especially the tests and the airfoil data) contain a lot of references to a Python package called "openbemt". After an hour of googling, I was unable to find any information about that package. The name suggests, that this package might be open source as well. If so, could you please provide a link or another reference where to obtain it? Maybe this reference could be part of the README.md?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.