Skip to content

Commit ebf6b56

Browse files
committed
Add VolumeMaintainingOutlet interface
1 parent 49e66cd commit ebf6b56

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

src/Domain.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,14 @@ end
15031503
dydt[d.indexes[3]] -= inter.Vout(t)
15041504
end
15051505
end
1506+
for inter in interfaces
1507+
if isa(inter,VolumeMaintainingOutlet) && d == inter.domain #VolumeMaintainingOutlet has to be evaluated after dVdt has been modified by everything else
1508+
@inbounds dVdt = dydt[d.indexes[3]]
1509+
@inbounds flow = P*dVdt/(R*T)
1510+
@views @inbounds dydt[d.indexes[1]:d.indexes[2]] .-= flow * ns/N
1511+
@inbounds dydt[d.indexes[3]] -= dVdt
1512+
end
1513+
end
15061514
end
15071515

15081516
@inline function calcdomainderivatives!(d::ConstantVDomain{W,Y},dydt::K,interfaces::Z12;t::Z10,T::Z4,P::Z9,Us::Z,Hs::Z11,V::Z2,C::Z3,ns::Z5,N::Z6,Cvave::Z7) where {Z12,Z11,Z10,Z9,W<:IdealGas,Z7,K,Y<:Integer,Z6,Z,Z2,Z3,Z4,Z5}
@@ -1586,6 +1594,14 @@ end
15861594
dydt[d.indexes[4]] -= inter.Vout(t)
15871595
end
15881596
end
1597+
for inter in interfaces
1598+
if isa(inter,VolumeMaintainingOutlet) && d == inter.domain #VolumeMaintainingOutlet has to be evaluated after dVdt has been modified by everything else
1599+
@inbounds dVdt = dydt[d.indexes[4]]
1600+
@inbounds flow = P*dVdt/(R*T)
1601+
@views @inbounds dydt[d.indexes[1]:d.indexes[2]] .-= flow * ns/N
1602+
@inbounds dydt[d.indexes[4]] -= dVdt
1603+
end
1604+
end
15891605
end
15901606

15911607
@inline function calcdomainderivatives!(d::ParametrizedTPDomain{W,Y},dydt::K,interfaces::Z12;t::Z10,T::Z4,P::Z9,Us::Z,Hs::Z11,V::Z2,C::Z3,ns::Z5,N::Z6,Cvave::Z7) where {Z11,Z10,Z9,W<:IdealGas,Z7,K,Y<:Integer,Z6,Z,Z2,Z3,Z4,Z5,Z12}
@@ -1619,6 +1635,14 @@ end
16191635
dydt[d.indexes[3]] -= inter.Vout(t)
16201636
end
16211637
end
1638+
for inter in interfaces
1639+
if isa(inter,VolumeMaintainingOutlet) && d == inter.domain #VolumeMaintainingOutlet has to be evaluated after dVdt has been modified by everything else
1640+
@inbounds dVdt = dydt[d.indexes[3]]
1641+
@inbounds flow = P*dVdt/(R*T)
1642+
@views @inbounds dydt[d.indexes[1]:d.indexes[2]] .-= flow * ns/N
1643+
@inbounds dydt[d.indexes[3]] -= dVdt
1644+
end
1645+
end
16221646
end
16231647

16241648
@inline function calcdomainderivatives!(d::ParametrizedVDomain{W,Y},dydt::K,interfaces::Z12;t::Z10,T::Z4,P::Z9,Us::Z,Hs::Z11,V::Z2,C::Z3,ns::Z5,N::Z6,Cvave::Z7) where {Z11,Z10,Z9,W<:IdealGas,Z7,K,Y<:Integer,Z6,Z,Z2,Z3,Z4,Z5,Z12}
@@ -1705,6 +1729,14 @@ end
17051729
dydt[d.indexes[4]] -= inter.Vout(t)
17061730
end
17071731
end
1732+
for inter in interfaces
1733+
if isa(inter,VolumeMaintainingOutlet) && d == inter.domain #VolumeMaintainingOutlet has to be evaluated after dVdt has been modified by everything else
1734+
@inbounds dVdt = dydt[d.indexes[4]]
1735+
@inbounds flow = P*dVdt/(R*T)
1736+
@views @inbounds dydt[d.indexes[1]:d.indexes[2]] .-= flow * ns/N
1737+
@inbounds dydt[d.indexes[4]] -= dVdt
1738+
end
1739+
end
17081740
end
17091741
export calcdomainderivatives!
17101742

src/Interface.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,17 @@ struct VolumetricFlowRateOutlet{V,F1<:Function} <: AbstractBoundaryInterface
304304
end
305305
export VolumetricFlowRateOutlet
306306

307+
"""
308+
VolumeMaintainingOutlet is designed for gas phase domain such that the flow rate of this outlet will adjust to maintain the volume of the
309+
domain to be constant. This is particularly useful to simulate any vapor-liquid phase system where the gas phase outlet
310+
is determined by the amount of evaporation.
311+
"""
312+
struct VolumeMaintainingOutlet{V} <: AbstractBoundaryInterface
313+
domain::V
314+
end
315+
316+
export VolumeMaintainingOutlet
317+
307318
struct VaporLiquidMassTransferInternalInterfaceConstantT{D1,D2,B} <: AbstractInternalInterface
308319
domaingas::D1
309320
domainliq::D2

0 commit comments

Comments
 (0)