@@ -597,6 +597,76 @@ function ParametrizedTConstantVDomain(;phase::IdealDiluteSolution,initialconds::
597597end
598598export ParametrizedTConstantVDomain
599599
600+ @with_kw struct ConstantTADomain{N<: AbstractPhase ,S<: Integer ,W<: Real , W2<: Real , I<: Integer , Q<: AbstractArray } <: AbstractConstantKDomain
601+ phase:: N
602+ indexes:: Q # assumed to be in ascending order
603+ constantspeciesinds:: Array{S,1}
604+ T:: W
605+ A:: W
606+ kfs:: Array{W,1}
607+ krevs:: Array{W,1}
608+ efficiencyinds:: Array{I,1}
609+ Gs:: Array{W,1}
610+ rxnarray:: Array{UInt16,2}
611+ mu:: W = 0.0
612+ diffusivity:: Array{W,1} = Array {Float64,1} ()
613+ jacobian:: Array{W,2} = Array {Float64,2} (undef,(0 ,0 ))
614+ sensitivity:: Bool = false
615+ jacuptodate:: MArray{Tuple{1},Bool,1,1} = MVector (false )
616+ t:: MArray{Tuple{1},W2,1,1} = MVector (0.0 )
617+ p:: Array{W,1}
618+ end
619+ function ConstantTADomain (;phase:: E2 ,initialconds:: Dict{X,X2} ,constantspecies:: Array{X3,1} = Array {String,1} (),
620+ sparse:: Bool = false ,sensitivity:: Bool = false ,stationary:: Bool = false ) where {E<: Real ,E2<: AbstractPhase ,W<: Real ,X,X2,X3}
621+ # set conditions and initialconditions
622+ T = 0.0
623+ A = 0.0
624+ y0 = zeros (length (phase. species))
625+ spnames = [x. name for x in phase. species]
626+ for (key,val) in initialconds
627+ if key == " T"
628+ T = val
629+ elseif key == " A"
630+ A = val
631+ else
632+ ind = findfirst (isequal (key),spnames)
633+ @assert typeof (ind)<: Integer " $key not found in species list: $spnames "
634+ y0[ind] = val
635+ end
636+ end
637+
638+ @assert A != 0.0
639+ @assert T != 0.0
640+ ns = y0
641+ N = sum (ns)
642+
643+ if length (constantspecies) > 0
644+ spcnames = getfield .(phase. species,:name )
645+ constspcinds = [findfirst (isequal (k),spcnames) for k in constantspecies]
646+ else
647+ constspcinds = Array {Int64,1} ()
648+ end
649+ efficiencyinds = [rxn. index for rxn in phase. reactions if typeof (rxn. kinetics)<: AbstractFalloffRate && length (rxn. kinetics. efficiencies) > 0 ]
650+ Gs = calcgibbs (phase,T)
651+ if :solvent in fieldnames (typeof (phase)) && typeof (phase. solvent) != EmptySolvent
652+ mu = phase. solvent. mu (T)
653+ else
654+ mu = 0.0
655+ end
656+ C = phase. sitedensity
657+ kfs,krevs = getkfkrevs (phase= phase,T= T,P= 0.0 ,C= C,N= N,ns= ns,Gs= Gs,diffs= [],V= A)
658+ p = vcat (Gs,kfs)
659+ if sparse
660+ jacobian= spzeros (typeof (T),length (phase. species),length (phase. species))
661+ else
662+ jacobian= zeros (typeof (T),length (phase. species),length (phase. species))
663+ end
664+ rxnarray = getreactionindices (phase)
665+ return ConstantTADomain (phase,MVector (phase. species[1 ]. index,phase. species[end ]. index),constspcinds,
666+ T,A,kfs,krevs,efficiencyinds,Gs,rxnarray,mu,jacobian,sensitivity,MVector (false ),MVector (0.0 ),stationary), y0, p
667+ end
668+ export ConstantTADomain
669+
600670@inline function calcthermo (d:: ConstantTPDomain{W,Y} ,y:: J ,t:: Q ,p:: W3 = DiffEqBase. NullParameters ()) where {W3<: DiffEqBase.NullParameters ,W<: IdealGas ,Y<: Integer ,J<: Array{Float64,1} ,Q} # no parameter input
601671 if t != d. t[1 ]
602672 d. t[1 ] = t
0 commit comments