Skip to content

Commit

Permalink
add back right density eval for compositional
Browse files Browse the repository at this point in the history
  • Loading branch information
moyner committed Jun 17, 2023
1 parent c3ba141 commit a85619d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/flux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,26 @@ end
end

@inline function darcy_phase_kgrad_potential(face, phase, state, model, flux_type, tpfa::TPFA, upw, common = flux_primitives(face, state, model, flux_type, upw, tpfa))
ρ = state.PhaseMassDensities
pc, ref_index = capillary_pressure(model, state)
∇p, T_f, gΔz = common
l = tpfa.left
r = tpfa.right

Δpc = capillary_gradient(pc, l, r, phase, ref_index)
@inbounds ρ_c = ρ[phase, l]
@inbounds ρ_i = ρ[phase, r]
ρ_avg = 0.5*(ρ_i + ρ_c)
ρ_avg = face_average_density(model, state, tpfa, phase)
q = -T_f*(∇p + Δpc + gΔz*ρ_avg)
return q
end

function face_average_density(model, state, tpfa, phase)
ρ = state.PhaseMassDensities
l = tpfa.left
r = tpfa.right
@inbounds ρ_c = ρ[phase, l]
@inbounds ρ_i = ρ[phase, r]
return 0.5*(ρ_i + ρ_c)
end

@inline function gradient(X, tpfa::TPFA)
return @inbounds X[tpfa.right] - X[tpfa.left]
end
Expand Down
12 changes: 12 additions & 0 deletions src/multicomponent/flux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,15 @@ end
end
return q
end

function face_average_density(model::CompositionalModel, state, tpfa, phase)
ρ = state.PhaseMassDensities
s = state.Saturations
l = tpfa.left
r = tpfa.right
@inbounds s_l = s[phase, l]
@inbounds s_r = s[phase, r]
@inbounds ρ_l = ρ[phase, l]
@inbounds ρ_r = ρ[phase, r]
return (s_l*ρ_r + s_r*ρ_l)/max(s_l + s_r, 1e-8)
end

0 comments on commit a85619d

Please sign in to comment.