Skip to content

Commit e1a445d

Browse files
committed
add calcthermo functions for ConstantTADomain
1 parent 8957617 commit e1a445d

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

src/Domain.jl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,73 @@ end
13641364
end
13651365
export calcthermo
13661366

1367+
@inline function calcthermo(d::ConstantTADomain{W,Y},y::J,t::Q,p::Q2=DiffEqBase.NullParameters()) where {Q2<:DiffEqBase.NullParameters,W<:IdealSurface,Y<:Integer,J<:AbstractArray,Q<:Real}
1368+
if t != d.t[1]
1369+
d.t[1] = t
1370+
d.jacuptodate[1] = false
1371+
end
1372+
ns = y[d.indexes[1]:d.indexes[2]]
1373+
N = sum(ns)
1374+
cs = ns./d.A
1375+
C = N/d.A
1376+
P = 0.0
1377+
return ns,cs,d.T,P,d.A,C,N,d.mu,d.kfs,d.krevs,Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),0.0
1378+
end
1379+
1380+
@inline function calcthermo(d::ConstantTADomain{W,Y},y::J,t::Q,p::Q2=DiffEqBase.NullParameters()) where {Q2<:Array{Float64,1},W<:IdealSurface,Y<:Integer,J<:Array{Float64,1},Q<:Real}
1381+
if t != d.t[1]
1382+
d.t[1] = t
1383+
d.jacuptodate[1] = false
1384+
end
1385+
ns = y[d.indexes[1]:d.indexes[2]]
1386+
N = sum(ns)
1387+
cs = ns./d.A
1388+
C = N/d.A
1389+
P = 0.0
1390+
@views nothermochg = d.Gs == p[1:length(d.phase.species)]
1391+
if nothermochg
1392+
return ns,cs,d.T,P,d.A,C,N,d.mu,p[length(d.phase.species)+1:length(d.phase.species)+length(d.phase.reactions)],d.krevs,Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),0.0
1393+
else
1394+
d.kfs = p[length(d.phase.species)+1:length(d.phase.species)+length(d.phase.reactions)]
1395+
d.Gs = p[1:length(d.phase.species)]
1396+
d.krevs = getkfkrevs(;phase=d.phase,T=d.T,P=P,C=C,N=N,ns=ns,Gs=d.Gs,diffs=d.diffusivity,V=d.V,kfs=d.kfs)[2]
1397+
return ns,cs,d.T,P,d.A,C,N,d.mu,d.kfs,d.krevs,Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),0.0
1398+
end
1399+
end
1400+
1401+
@inline function calcthermo(d::ConstantTADomain{W,Y},y::Array{W2,1},t::Q,p::Q2=DiffEqBase.NullParameters()) where {W2<:ForwardDiff.Dual,Q2,W<:IdealSurface,Y<:Integer,J<:AbstractArray,Q<:Real} #autodiff y
1402+
if t != d.t[1]
1403+
d.t[1] = t
1404+
d.jacuptodate[1] = false
1405+
end
1406+
ns = y[d.indexes[1]:d.indexes[2]]
1407+
N = sum(ns)
1408+
cs = ns./d.A
1409+
C = N/d.A
1410+
P = 0.0
1411+
Gs = p[1:length(d.phase.species)]
1412+
kfs = convert(typeof(y),p[length(d.phase.species)+1:length(d.phase.species)+length(d.phase.reactions)])
1413+
krevs = convert(typeof(y),getkfkrevs(;phase=d.phase,T=d.T,P=P,C=C,N=N,ns=ns,Gs=Gs,diffs=d.diffusivity,V=d.V,kfs=kfs)[2])
1414+
return ns,cs,d.T,P,d.V,C,N,d.mu,kfs,krevs,Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),0.0
1415+
end
1416+
1417+
@inline function calcthermo(d::ConstantTADomain{W,Y},y::J,t::Q,p::Q2=DiffEqBase.NullParameters()) where {Q2,W<:IdealSurface,Y<:Integer,J<:AbstractArray,Q<:Real} #autodiff p
1418+
if t != d.t[1]
1419+
d.t[1] = t
1420+
d.jacuptodate[1] = false
1421+
end
1422+
ns = y[d.indexes[1]:d.indexes[2]]
1423+
N = sum(ns)
1424+
cs = ns./d.A
1425+
C = N/d.A
1426+
P = 0.0
1427+
Gs = p[1:length(d.phase.species)]
1428+
kfs = p[length(d.phase.species)+1:length(d.phase.species)+length(d.phase.reactions)]
1429+
krevs = getkfkrevs(;phase=d.phase,T=d.T,P=P,C=C,N=N,ns=ns,Gs=Gs,diffs=d.diffusivity,V=d.V,kfs=kfs)[2]
1430+
return ns,cs,d.T,P,d.A,C,N,d.mu,kfs,krevs,Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),Array{Float64,1}(),0.0
1431+
end
1432+
export calcthermo
1433+
13671434
@inline function calcdomainderivatives!(d::Q,dydt::Z7,interfaces::Z12;t::Z10,T::Z4,P::Z9,Us::Array{Z,1},Hs::Array{Z11,1},V::Z2,C::Z3,ns::Z5,N::Z6,Cvave::Z8) where {Q<:AbstractDomain,Z12,Z11,Z10,Z9,Z8<:Real,Z7,W<:IdealGas,Y<:Integer,Z6,Z,Z2,Z3,Z4,Z5}
13681435
for ind in d.constantspeciesinds #make dydt zero for constant species
13691436
@inbounds dydt[ind] = 0.0

0 commit comments

Comments
 (0)