I am running into an issue I do not understand. I have some code in which I pass a number of parameters as a struct. It works for some of the functions, but not for another function. I think I need another set of eyes to see where I am going wrong.
All the code in the MWE below seems to work except the last line errors.
using FlexUnits: QuantFieldVector, DimsMod
using Revise
g = 9.81u"m/s^2"
nrr_theoretical(dia, W) = @. 2*W.dnl_start*(sin(acos((W.dd+W.g)/(W.dd+dia)))) - π/4*(dia^2 - W.dc^2)*W.ρ*g
nrr_min(dia, W) = max.(nrr_theoretical(dia, W), W.rrl_min)
dnl_min(dia, W) = @. (π/4*(dia^2 - W.dc^2)*W.ρ*g + nrr_min(dia, W))/(2*sin(acos((W.dd+W.g)/(W.dd+dia))))
mutable struct Foo{T} <: QuantFieldVector{7,T}
dd::Quantity{T, D"m"}
g::Quantity{T, D"m"}
dc::Quantity{T, D"m"}
ds::Quantity{T, D"m"}
rrl_min::Quantity{T, D"N/m"}
dnl_start::Quantity{T, D"N/m"}
ρ::Quantity{T, D"kg/m^3"}
end
W = Foo(24u"in", 28u"mm", 100u"mm", 1.3u"m", 4u"lbf/in",12u"lbf/in", 835u"kg/m^3")
diatransition = 0.8u"m"
W.dnl_start
nrr_theoretical(400u"mm", W)
nrr_min(400u"mm", W)
dnl_min(400u"mm", W)
ERROR: FieldError: type Float64 has no field `dnl_start`; Float64 has no fields at all.
Stacktrace:
[1] getproperty
@ .\Base_compiler.jl:57 [inlined]
[2] nrr_theoretical(dia::Quantity{Float64, StaticDims{m}}, W::Float64)
@ Main .\REPL[77]:1
[3] nrr_min(dia::Quantity{Float64, StaticDims{m}}, W::Float64)
@ Main .\REPL[76]:1