Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing models of ducted fan propulsion #104

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
284 changes: 284 additions & 0 deletions src/engine/ducted_fan/ductedfancalc.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
"""
ductedfancalc!(pari, parg, para, pare, ip, icall, initeng)

Calls function ductedfansize! or ductedfanoper! for one operating point.

!!! details "🔃 Inputs and Outputs"
**Input:**
- `pari`, `parg`, `para`, `pare`: aircraft data storage arrays
- `ip::Int64`: mission point
- `icall`: 0 call on-design sizing routine ductedfansize!
1 call off-design analysis routine ductedfanoper!, specified fan power
2 call off-design analysis routine ductedfanoper!, specified thrust

- `initeng`: 0 initialize variables for iteration in ductedfanoper!
1 use current variables as initial guesses in ductedfanoper!
"""
function ductedfancalc!(pari, parg, para, pare, ip,

Check warning on line 17 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L17

Added line #L17 was not covered by tests
icall, initeng)

iBLIc = pari[iiBLIc]

Check warning on line 20 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L20

Added line #L20 was not covered by tests

neng = parg[igneng]
S = parg[igS]

Check warning on line 23 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L22-L23

Added lines #L22 - L23 were not covered by tests

Fsp = pare[ieFsp]
pif = pare[iepif]
pid = pare[iepid]
pifn = pare[iepifn]

Check warning on line 28 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L25-L28

Added lines #L25 - L28 were not covered by tests

epolf = pare[ieepolf]

Check warning on line 30 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L30

Added line #L30 was not covered by tests

pifK = pare[iepifK]
epfK = pare[ieepfK]
M2 = pare[ieM2]
M0 = pare[ieM0]
Tt0 = pare[ieTt0]
ht0 = pare[ieht0]
pt0 = pare[iept0]
cpt0 = pare[iecpt0]
Rt0 = pare[ieRt0]
p0 = pare[iep0]
a0 = pare[iea0]
rho0 = pare[ierho0]
mu0 = pare[iemu0]
T0 = pare[ieT0]
u0 = pare[ieu0]

Check warning on line 46 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L32-L46

Added lines #L32 - L46 were not covered by tests

#Heat exchanger variables
Δh_radiator = pare[ieRadiatorDeltah]
Δp_radiator = pare[ieRadiatorDeltap]

Check warning on line 50 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L49-L50

Added lines #L49 - L50 were not covered by tests

#- - - - - - - - - - - - - - - - - - - - - - -
#---- set BL ingestion parameters
if (M0 == 0.0)

Check warning on line 54 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L54

Added line #L54 was not covered by tests
#----- no ingestion for static case
Phiinl = 0.0
Kinl = 0.0

Check warning on line 57 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L56-L57

Added lines #L56 - L57 were not covered by tests

else
#----- assume engine is at TE of fuselage
DAfsurf = para[iaDAfsurf]
KAfTE = para[iaKAfTE]
fBLIf = parg[igfBLIf]

Check warning on line 63 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L61-L63

Added lines #L61 - L63 were not covered by tests

#----- assume 85% of wing dissipation is on surface
fDwake = 0.15
CDAwing = para[iaCDwing] * S
DAwsurf = CDAwing * (1.0 - fDwake)
KAwTE = DAwsurf

Check warning on line 69 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L66-L69

Added lines #L66 - L69 were not covered by tests

fBLIw = parg[igfBLIw]

Check warning on line 71 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L71

Added line #L71 was not covered by tests

#----- set ingested PKinl-PVinl = Phiinl for one engine
Phiinl = 0.5 * rho0 * u0^3 * (DAfsurf * fBLIf + DAwsurf * fBLIw) / neng
Kinl = 0.5 * rho0 * u0^3 * (KAfTE * fBLIf + KAwTE * fBLIw) / neng

Check warning on line 75 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L74-L75

Added lines #L74 - L75 were not covered by tests
end
#- - - - - - - - - - - - - - - - - - - - - - -

# #--------------------------------------------------------------------------
if (icall == 0)

Check warning on line 80 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L80

Added line #L80 was not covered by tests
#----- engine sizing case

Fe = pare[ieFe] #ducted fan sized for a given thrust

Check warning on line 83 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L83

Added line #L83 was not covered by tests

TSEC, Fsp, Pfan, mfan,

Check warning on line 85 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L85

Added line #L85 was not covered by tests
Tt0, ht0, pt0, cpt0, Rt0,
Tt18, ht18, pt18, cpt18, Rt18,
Tt2, ht2, pt2, cpt2, Rt2,
Tt21, ht21, pt21, cpt21, Rt21,
Tt7, ht7, pt7, cpt7, Rt7,
u0,
T2, u2, p2, cp2, R2, A2,
T7, u7, p7, cp7, R7, A7,
T8, u8, p8, cp8, R8, A8,
epf,
etaf, Lconv = ductedfansize!(gee, M0, T0, p0, a0, M2,
Fe, Phiinl, Kinl, iBLIc,
pif,
pid, pifn,
epolf,
pifK, epfK,
Δh_radiator, Δp_radiator
)

mbf = mfan * sqrt(Tt2 / Tref) / (pt2 / pref)
M7 = u7 / sqrt(T7 * R7 * cp7 / (cp7 - R7))

Check warning on line 106 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L105-L106

Added lines #L105 - L106 were not covered by tests

pifD = pif
mbfD = mbf

Check warning on line 109 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L108-L109

Added lines #L108 - L109 were not covered by tests

Nf = 1.0 #Arbitrarily set to 1 as only ratios matter
Nbf = Nf / sqrt(Tt2 / Tref)
NbfD = Nbf

Check warning on line 113 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L111-L113

Added lines #L111 - L113 were not covered by tests

#----- store design-point parameters
pare[ieA2] = A2
pare[ieA7] = A7

Check warning on line 117 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L116-L117

Added lines #L116 - L117 were not covered by tests

pare[iembfD] = mbfD
pare[iepifD] = pifD
pare[ieNbfD] = Nbf

Check warning on line 121 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L119-L121

Added lines #L119 - L121 were not covered by tests

else
#----- fixed parameters
A2 = pare[ieA2]
A7 = pare[ieA7]

Check warning on line 126 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L125-L126

Added lines #L125 - L126 were not covered by tests

mbfD = pare[iembfD]
pifD = pare[iepifD]
NbfD = pare[ieNbfD]
Δh_radiator = pare[ieRadiatorDeltah]
Δp_radiator = pare[ieRadiatorDeltap]

Check warning on line 132 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L128-L132

Added lines #L128 - L132 were not covered by tests

if (initeng == 0)

Check warning on line 134 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L134

Added line #L134 was not covered by tests
#------ force TFOPER to initialize these state variables
mbf = 0.0
pif = 0.0
M2 = 1.0

Check warning on line 138 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L136-L138

Added lines #L136 - L138 were not covered by tests
else
#------ use existing state variables as initial guesses
mbf = pare[iembf]
pif = pare[iepif]
M2 = pare[ieM2]

Check warning on line 143 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L141-L143

Added lines #L141 - L143 were not covered by tests
end
if (icall == 1) #Power is specified, thrust will be computed
Feng = 0.0
Peng = pare[iePfanmax]
iPspec = true

Check warning on line 148 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L145-L148

Added lines #L145 - L148 were not covered by tests

TSEC, Fsp, Feng, Pfan, mfan,

Check warning on line 150 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L150

Added line #L150 was not covered by tests
pif, mbf, Nbf,
Tt0, ht0, pt0, cpt0, Rt0,
Tt18, ht18, pt18, cpt18, Rt18,
Tt2, ht2, pt2, cpt2, Rt2,
Tt21, ht21, pt21, cpt21, Rt21,
Tt7, ht7, pt7, cpt7, Rt7,
u0, T2, u2, p2, cp2, R2, M2,
T7, u7, p7, cp7, R7, M7,
T8, u8, p8, cp8, R8, M8, A8,
epf, etaf = ductedfanoper!(M0, T0, p0, a0, Tref, pref,
Phiinl, Kinl, iBLIc,
pid, pifn,
pifD,
mbfD, NbfD,
A2, A7,
epolf,
pifK, epfK,
Feng, Peng,
M2, pif, mbf,
Δh_radiator, Δp_radiator,
iPspec)
elseif (icall == 2) #Thrust is specified, power to be computed
Feng = pare[ieFe]
Peng = 0.0
iPspec = false

Check warning on line 175 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L172-L175

Added lines #L172 - L175 were not covered by tests

TSEC, Fsp, Feng, Pfan, mfan,

Check warning on line 177 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L177

Added line #L177 was not covered by tests
pif, mbf, Nbf,
Tt0, ht0, pt0, cpt0, Rt0,
Tt18, ht18, pt18, cpt18, Rt18,
Tt2, ht2, pt2, cpt2, Rt2,
Tt21, ht21, pt21, cpt21, Rt21,
Tt7, ht7, pt7, cpt7, Rt7,
u0, T2, u2, p2, cp2, R2, M2,
T7, u7, p7, cp7, R7, M7,
T8, u8, p8, cp8, R8, M8, A8,
epf, etaf = ductedfanoper!(M0, T0, p0, a0, Tref, pref,
Phiinl, Kinl, iBLIc,
pid, pifn,
pifD,
mbfD, NbfD,
A2, A7,
epolf,
pifK, epfK,
Feng, Peng,
M2, pif, mbf,
Δh_radiator, Δp_radiator,
iPspec)
end
end
HTRf = parg[igHTRf]
dfan = sqrt(4.0 * A2 / (pi * (1.0 - HTRf^2)))
parg[igdfan] = dfan

Check warning on line 203 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L201-L203

Added lines #L201 - L203 were not covered by tests

pare[iePfan] = Pfan
pare[ieTSEC] = TSEC
pare[ieTSFC] = TSEC / 120e6 #TODO change when fuel is not burnt
pare[ieFsp] = Fsp
pare[iemfan] = mfan
pare[iePhiinl] = Phiinl
pare[ieKinl] = Kinl

Check warning on line 211 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L205-L211

Added lines #L205 - L211 were not covered by tests

pare[iembf] = mbf
pare[iepif] = pif
pare[ieNbf] = Nbf
pare[ieNf] = Nbf * sqrt(Tt2 / Tref)

Check warning on line 216 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L213-L216

Added lines #L213 - L216 were not covered by tests

pare[ieTt0] = Tt0
pare[ieht0] = ht0
pare[iept0] = pt0
pare[iecpt0] = cpt0
pare[ieRt0] = Rt0

Check warning on line 222 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L218-L222

Added lines #L218 - L222 were not covered by tests

pare[ieTt18] = Tt18
pare[ieht18] = ht18
pare[iept18] = pt18
pare[iecpt18] = cpt18
pare[ieRt18] = Rt18

Check warning on line 228 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L224-L228

Added lines #L224 - L228 were not covered by tests

pare[ieTt2] = Tt2
pare[ieht2] = ht2
pare[iept2] = pt2
pare[iecpt2] = cpt2
pare[ieRt2] = Rt2

Check warning on line 234 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L230-L234

Added lines #L230 - L234 were not covered by tests

pare[ieTt21] = Tt21
pare[ieht21] = ht21
pare[iept21] = pt21
pare[iecpt21] = cpt21
pare[ieRt21] = Rt21

Check warning on line 240 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L236-L240

Added lines #L236 - L240 were not covered by tests

pare[ieTt7] = Tt7
pare[ieht7] = ht7
pare[iept7] = pt7
pare[iecpt7] = cpt7
pare[ieRt7] = Rt7

Check warning on line 246 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L242-L246

Added lines #L242 - L246 were not covered by tests

pare[ieu0] = u0

Check warning on line 248 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L248

Added line #L248 was not covered by tests

pare[iep2] = p2
pare[ieT2] = T2
pare[ieR2] = R2
pare[iecp2] = cp2
pare[ieu2] = u2

Check warning on line 254 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L250-L254

Added lines #L250 - L254 were not covered by tests

pare[iep7] = p7
pare[ieT7] = T7
pare[ieR7] = R7
pare[iecp7] = cp7
pare[ieu7] = u7

Check warning on line 260 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L256-L260

Added lines #L256 - L260 were not covered by tests

pare[iep8] = p8
pare[ieT8] = T8
pare[ieR8] = R8
pare[iecp8] = cp8
pare[ieu8] = u8

Check warning on line 266 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L262-L266

Added lines #L262 - L266 were not covered by tests

pare[ieA8] = A8

Check warning on line 268 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L268

Added line #L268 was not covered by tests

pare[ieepf] = epf

Check warning on line 270 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L270

Added line #L270 was not covered by tests

pare[ieetaf] = etaf

Check warning on line 272 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L272

Added line #L272 was not covered by tests

if (icall == 1)
pare[ieFe] = Feng

Check warning on line 275 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L274-L275

Added lines #L274 - L275 were not covered by tests
end

if (M7 <= 0.999999)
ichoke7 = 0

Check warning on line 279 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L278-L279

Added lines #L278 - L279 were not covered by tests
else
ichoke7 = 1

Check warning on line 281 in src/engine/ducted_fan/ductedfancalc.jl

View check run for this annotation

Codecov / codecov/patch

src/engine/ducted_fan/ductedfancalc.jl#L281

Added line #L281 was not covered by tests
end

end
Loading
Loading