Skip to content

Commit 7518576

Browse files
Separate flux to flux_sun, flux_scat, and flux_rad
1 parent 5c68af0 commit 7518576

4 files changed

Lines changed: 42 additions & 35 deletions

File tree

src/TPM.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,9 @@ broadcast_thermo_params!(thermo_params::ThermoParams, shape::ShapeModel) = broad
156156
- `shape` : Shape model
157157
- `thermo_params` : Thermophysical parameters
158158
159-
- `flux` : Flux on each face. Matrix of size (Number of faces, 3). Three components are:
160-
- `flux[:, 1]` : F_sun, flux of direct sunlight
161-
- `flux[:, 2]` : F_scat, flux of scattered light
162-
- `flux[:, 3]` : F_rad, flux of thermal emission from surrounding surface
159+
- `flux_sun` : Flux of direct sunlight on each face [W/m²]
160+
- `flux_scat` : Flux of scattered light on each face [W/m²]
161+
- `flux_rad` : Flux of thermal emission from surrounding surface on each face [W/m²]
163162
- `temperature` : Temperature matrix `(n_depth, n_face)` according to the number of depth cells `n_depth` and the number of faces `n_face`.
164163
165164
- `face_forces` : Thermal force on each face
@@ -179,7 +178,9 @@ struct SingleAsteroidThermoPhysicalModel{P<:AbstractThermoParams, S<:HeatConduct
179178
shape ::ShapeModel
180179
thermo_params ::P
181180

182-
flux ::Matrix{Float64} # (n_face, 3)
181+
flux_sun ::Vector{Float64} # Flux of direct sunlight
182+
flux_scat ::Vector{Float64} # Flux of scattered light
183+
flux_rad ::Vector{Float64} # Flux of thermal emission from surrounding surface
183184
temperature ::Matrix{Float64} # (n_depth, n_face)
184185

185186
face_forces ::Vector{SVector{3, Float64}}
@@ -217,14 +218,16 @@ function SingleAsteroidThermoPhysicalModel(shape, thermo_params; SELF_SHADOWING,
217218
n_depth = thermo_params.n_depth
218219
n_face = length(shape.faces)
219220

220-
flux = zeros(n_face, 3)
221+
flux_sun = zeros(n_face)
222+
flux_scat = zeros(n_face)
223+
flux_rad = zeros(n_face)
221224
temperature = zeros(n_depth, n_face)
222225

223226
face_forces = zeros(SVector{3, Float64}, n_face)
224227
force = zero(MVector{3, Float64})
225228
torque = zero(MVector{3, Float64})
226229

227-
SingleAsteroidThermoPhysicalModel(shape, thermo_params, flux, temperature, face_forces, force, torque, SELF_SHADOWING, SELF_HEATING, SOLVER, BC_UPPER, BC_LOWER)
230+
SingleAsteroidThermoPhysicalModel(shape, thermo_params, flux_sun, flux_scat, flux_rad, temperature, face_forces, force, torque, SELF_SHADOWING, SELF_HEATING, SOLVER, BC_UPPER, BC_LOWER)
228231
end
229232

230233

src/energy_flux.jl

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ function energy_in(stpm::SingleAsteroidTPM)
2929
for i in eachindex(stpm.shape.faces)
3030
R_vis = stpm.thermo_params.reflectance_vis[i]
3131
R_ir = stpm.thermo_params.reflectance_ir[i]
32-
F_sun = stpm.flux[i, 1]
33-
F_scat = stpm.flux[i, 2]
34-
F_rad = stpm.flux[i, 3]
32+
F_sun = stpm.flux_sun[i]
33+
F_scat = stpm.flux_scat[i]
34+
F_rad = stpm.flux_rad[i]
3535
a = stpm.shape.face_areas[i]
3636

3737
E_in += flux_total(R_vis, R_ir, F_sun, F_scat, F_rad) * a
@@ -82,18 +82,18 @@ function update_flux_sun!(stpm::SingleAsteroidTPM, r̂☉::StaticVector{3}, F☉
8282
for i in eachindex(stpm.shape.faces)
8383
if isilluminated(stpm.shape, r̂☉, i)
8484
= stpm.shape.face_normals[i]
85-
stpm.flux[i, 1] = F☉ * (n̂ r̂☉)
85+
stpm.flux_sun[i] = F☉ * (n̂ r̂☉)
8686
else
87-
stpm.flux[i, 1] = 0
87+
stpm.flux_sun[i] = 0
8888
end
8989
end
9090
else
9191
for i in eachindex(stpm.shape.faces)
9292
= stpm.shape.face_normals[i]
9393
if r̂☉ > 0
94-
stpm.flux[i, 1] = F☉ * (n̂ r̂☉)
94+
stpm.flux_sun[i] = F☉ * (n̂ r̂☉)
9595
else
96-
stpm.flux[i, 1] = 0
96+
stpm.flux_sun[i] = 0
9797
end
9898
end
9999
end
@@ -147,13 +147,13 @@ function update_flux_scat_single!(stpm::SingleAsteroidTPM)
147147
stpm.SELF_HEATING == false && return
148148

149149
for i_face in eachindex(stpm.shape.faces)
150-
stpm.flux[i_face, 2] = 0.
150+
stpm.flux_scat[i_face] = 0.
151151
for visiblefacet in stpm.shape.visiblefacets[i_face]
152152
j = visiblefacet.id
153153
fᵢⱼ = visiblefacet.f
154154
R_vis = stpm.thermo_params.reflectance_vis[j]
155155

156-
stpm.flux[i_face, 2] += fᵢⱼ * R_vis * stpm.flux[j, 1]
156+
stpm.flux_scat[i_face] += fᵢⱼ * R_vis * stpm.flux_sun[j]
157157
end
158158
end
159159
end
@@ -200,15 +200,15 @@ function update_flux_rad_single!(stpm::SingleAsteroidTPM)
200200
stpm.SELF_HEATING == false && return
201201

202202
for i in eachindex(stpm.shape.faces)
203-
stpm.flux[i, 3] = 0.
203+
stpm.flux_rad[i] = 0.
204204
for visiblefacet in stpm.shape.visiblefacets[i]
205205
j = visiblefacet.id
206206
fᵢⱼ = visiblefacet.f
207207
ε = stpm.thermo_params.emissivity[j]
208208
R_ir = stpm.thermo_params.reflectance_ir[j]
209209
Tⱼ = stpm.temperature[begin, j]
210210

211-
stpm.flux[i, 3] += ε * σ_SB * (1 - R_ir) * fᵢⱼ * Tⱼ^4
211+
stpm.flux_rad[i] += ε * σ_SB * (1 - R_ir) * fᵢⱼ * Tⱼ^4
212212
end
213213
end
214214
end
@@ -271,7 +271,7 @@ function mutual_shadowing!(btpm::BinaryAsteroidTPM, r☉, rₛ, R₂₁)
271271

272272
## if △A₁B₁C₁ is NOT facing the sun
273273
if r̂☉ n̂₁ < 0
274-
btpm.pri.flux[i, 1] = 0
274+
btpm.pri.flux_sun[i] = 0
275275
continue
276276
end
277277

@@ -282,7 +282,7 @@ function mutual_shadowing!(btpm::BinaryAsteroidTPM, r☉, rₛ, R₂₁)
282282

283283
## In the secondary shadow
284284
if θ₁ < θ_r₂
285-
btpm.pri.flux[i, 1] = 0
285+
btpm.pri.flux_sun[i] = 0
286286
continue
287287
## Out of the secondary shadow
288288
elseif θ₁ > θ_R₂
@@ -305,7 +305,7 @@ function mutual_shadowing!(btpm::BinaryAsteroidTPM, r☉, rₛ, R₂₁)
305305
## if △A₁B₁C₁ and △A₂B₂C₂ are facing each other
306306
if d₁₂ n̂₁ > 0 && d₁₂ n̂₂ < 0
307307
if raycast(A₂, B₂, C₂, r̂☉, G₁)
308-
btpm.pri.flux[i, 1] = 0
308+
btpm.pri.flux_sun[i] = 0
309309
break
310310
end
311311
end
@@ -331,7 +331,7 @@ function mutual_shadowing!(btpm::BinaryAsteroidTPM, r☉, rₛ, R₂₁)
331331

332332
## if △A₂B₂C₂ is NOT facing the sun
333333
if r̂☉ n̂₂ < 0
334-
btpm.sec.flux[j, 1] = 0
334+
btpm.sec.flux_sun[j] = 0
335335
continue
336336
end
337337

@@ -342,7 +342,7 @@ function mutual_shadowing!(btpm::BinaryAsteroidTPM, r☉, rₛ, R₂₁)
342342

343343
## In the primary shadow
344344
if θ₂ < θ_r₁
345-
btpm.sec.flux[j, 1] = 0
345+
btpm.sec.flux_sun[j] = 0
346346
continue
347347
## Out of the primary shadow
348348
elseif θ₂ > θ_R₁
@@ -358,7 +358,7 @@ function mutual_shadowing!(btpm::BinaryAsteroidTPM, r☉, rₛ, R₂₁)
358358
## if △A₁B₁C₁ and △A₂B₂C₂ are facing each other
359359
if d₁₂ n̂₁ > 0 && d₁₂ n̂₂ < 0
360360
if raycast(A₁, B₁, C₁, r̂☉, G₂)
361-
btpm.sec.flux[j, 1] = 0
361+
btpm.sec.flux_sun[j] = 0
362362
break
363363
end
364364
end
@@ -368,7 +368,7 @@ function mutual_shadowing!(btpm::BinaryAsteroidTPM, r☉, rₛ, R₂₁)
368368

369369
#### Total eclipse of the secondary ####
370370
elseif π - θ₋ θ < π
371-
btpm.sec.flux[:, 1] .= 0
371+
btpm.sec.flux_sun .= 0
372372
end
373373
end
374374

@@ -429,12 +429,12 @@ function mutual_heating!(btpm::BinaryAsteroidTPM, rₛ, R₂₁)
429429
R_ir₂ = thermo_params2.reflectance_ir[j]
430430

431431
## Mutual heating by scattered light
432-
btpm.pri.flux[i, 2] += f₁₂ * R_vis₂ * btpm.sec.flux[j, 1]
433-
btpm.sec.flux[j, 2] += f₂₁ * R_vis₁ * btpm.pri.flux[i, 1]
432+
btpm.pri.flux_scat[i] += f₁₂ * R_vis₂ * btpm.sec.flux_sun[j]
433+
btpm.sec.flux_scat[j] += f₂₁ * R_vis₁ * btpm.pri.flux_sun[i]
434434

435435
## Mutual heating by thermal radiation
436-
btpm.pri.flux[i, 3] += ε₂ * σ_SB * (1 - R_ir₂) * f₁₂ * T₂^4
437-
btpm.sec.flux[j, 3] += ε₁ * σ_SB * (1 - R_ir₁) * f₂₁ * T₁^4
436+
btpm.pri.flux_rad[i] += ε₂ * σ_SB * (1 - R_ir₂) * f₁₂ * T₂^4
437+
btpm.sec.flux_rad[j] += ε₁ * σ_SB * (1 - R_ir₁) * f₂₁ * T₁^4
438438
end
439439
end
440440
end

src/heat_conduction.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ function forward_euler!(stpm::SingleAsteroidTPM, Δt)
7272
ε = stpm.thermo_params.emissivity[i_face]
7373
εσ = ε * σ_SB
7474

75-
F_sun, F_scat, F_rad = stpm.flux[i_face, :]
75+
F_sun = stpm.flux_sun[i_face]
76+
F_scat = stpm.flux_scat[i_face]
77+
F_rad = stpm.flux_rad[i_face]
7678
F_total = flux_total(R_vis, R_ir, F_sun, F_scat, F_rad)
7779

7880
stpm.temperature[begin, i_face] = (F_total / εσ)^(1/4)
@@ -250,8 +252,10 @@ function update_upper_temperature!(stpm::SingleAsteroidTPM, i::Integer)
250252
ε = stpm.thermo_params.emissivity[i]
251253
Δz = stpm.thermo_params.Δz
252254

253-
F_sun, F_scat, F_rad = stpm.flux[i, :]
254-
F_total = flux_total(R_vis, R_ir, F_sun, F_scat, F_rad)
255+
F_sun = stpm.flux_sun[i]
256+
F_scat = stpm.flux_scat[i]
257+
F_rad = stpm.flux_rad[i]
258+
F_total = flux_total(R_vis, R_ir, F_sun, F_scat, F_rad)
255259
update_surface_temperature!(stpm.SOLVER.T, F_total, P, l, Γ, ε, Δz)
256260
#### Insulation boundary condition ####
257261
elseif stpm.BC_UPPER isa InsulationBoundaryCondition

src/non_grav.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ function update_thermal_force!(stpm::SingleAsteroidTPM)
2222
n̂ᵢ = stpm.shape.face_normals[i]
2323
aᵢ = stpm.shape.face_areas[i]
2424

25-
F_sun = stpm.flux[i, 1]
26-
F_scat = stpm.flux[i, 2]
27-
F_rad = stpm.flux[i, 3]
25+
F_sun = stpm.flux_sun[i]
26+
F_scat = stpm.flux_scat[i]
27+
F_rad = stpm.flux_rad[i]
2828
Tᵢ = stpm.temperature[begin, i]
2929

3030
## Total emittance from face i , Eᵢ [W/m²].

0 commit comments

Comments
 (0)