Skip to content

ConstantReservoirDiffusion Interface #269

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions src/Domain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,8 @@ export calcthermo
cond = kLAs .* inter.molefractions .* inter.P ./ kHs * V

dydt[d.indexes[1]:d.indexes[2]] .-= (evap .- cond)
elseif isa(inter, ConstantReservoirDiffusion) && d == inter.domain
dydt[d.indexes[1]:d.indexes[2]] = inter.A .* d.diffusivity .* (inter.c .- ns./V) / inter.layer_thickness
elseif isa(inter, VolumetricFlowRateInlet) && d == inter.domain
dydt[d.indexes[1]:d.indexes[2]] .+= inter.Vin(t) * inter.cs
elseif isa(inter, VolumetricFlowRateOutlet) && d == inter.domain
Expand Down Expand Up @@ -3084,6 +3086,12 @@ end
@simd for i in domain.indexes[1]:domain.indexes[2]
@inbounds @fastmath jac[i, i] -= inter.Vout(t) / V
end
elseif isa(inter, ConstantReservoirDiffusion) && domain == inter.domain
# dn/dt .+= inter.A .* domain.diffusivity .* (inter.c .- ns./V) / inter.layer_thickness
# d/dni(dni/dt) .-= (inter.A .* d.diffusivity / (V * inter.layer_thickness)
@simd for i in domain.indexes[1]:domain.indexes[2]
@inbounds @fastmath jac[i, i] -= inter.A * domain.diffusivity / (V * inter.layer_thickness)
end
end
end

Expand Down
18 changes: 15 additions & 3 deletions src/Interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,23 @@ struct Outlet{V,FF<:Function} <: AbstractBoundaryInterface
end
export Outlet

struct ConstantReservoirDiffusion{S,V<:AbstractArray,U<:Real}
domain::S
c::V
A::U
layer_thickness::U
end

function ConstantReservoirDiffusion(domain::V, conddict::Dict{X1,X}, A::B, layer_thickness::B) where {V,X1,X,B<:Real}
cs = makespcsvector(domain.phase, conddict)
return ConstantReservoirDiffusion(domain,cs,A,layer_thickness)
end

"""
kLAkHCondensationEvaporationWithReservoir adds evaporation and condensation to
(1) a liquid phase domain with a constant composition vapor resevoir, where number of moles, P, and T need to be specified, or
(2) a gas phase domain with a constant composition liquid resevoir, where number of moles, V, and T need to be specified.
kLA and kH are used to model cond/evap.
kLA and kH are used to model cond/evap.
kLA is liquid volumetric mass transfer coefficient with unit 1/s , and kH is Henry's law constant defined as gas phase partial pressure of solute over liquid phase concentration of solute.
"""

Expand Down Expand Up @@ -363,7 +375,7 @@ end
export VolumetricFlowRateInlet

"""
VolumeMaintainingOutlet is designed for gas phase domain such that the flow rate of this outlet will adjust to maintain the volume of the
VolumeMaintainingOutlet is designed for gas phase domain such that the flow rate of this outlet will adjust to maintain the volume of the
domain to be constant. This is particularly useful to simulate any vapor-liquid phase system where the gas phase outlet
is determined by the amount of evaporation.
"""
Expand Down Expand Up @@ -538,4 +550,4 @@ function evaluate(ri::FragmentBasedReactiveFilmGrowthInterfaceConstantT, dydt, V
end
end

export evaluate
export evaluate
Loading