Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2f727a0
include electronchange in reaction reconstruction in phase
mjohnson541 Feb 4, 2024
bf881fc
add Marcus kinetics type and allow dGrxn dependence of kinetics
mjohnson541 Feb 4, 2024
28f79ad
handle dGrxn and d dependence of reactions in interfaces and phase ca…
mjohnson541 Feb 4, 2024
e12c096
fix getKc call in ReactiveInternalInterface
mjohnson541 Sep 23, 2024
5ebd05b
adapt Domains to dGrxn and d dependence of forward rate coefficient c…
mjohnson541 Feb 4, 2024
a624f50
add a Marcus reaction to the ORR.rms mechanism for testing
mjohnson541 Feb 4, 2024
6aaac6c
Added reference potential to Arrheniusq
ssun30 May 28, 2024
5611ec6
Fixed interfaces not setting phi correctly
ssun30 Aug 6, 2024
43aab6f
Parser uses RMG if RDKit fails to get structure
ssun30 Aug 6, 2024
13c840a
add phi and d to newer domains
mjohnson541 Sep 23, 2024
50ed351
phase electron change fixes
mjohnson541 Sep 25, 2024
f4f4590
missing domain tweaks for phi/d
mjohnson541 Sep 25, 2024
d613624
fix FragmentBasedReactiveFilmGrowthInterfaceConstantT interface
mjohnson541 Sep 25, 2024
66c591d
Added default values for wr/wp for Marcus Kinetics
ssun30 Oct 9, 2024
9cd3508
Changed variable naming in TestReactors
ssun30 Nov 7, 2024
115f580
Fixed typos
mjohnson541 Sep 25, 2024
f94e0d3
loosen solver tolerances for some tests
ssun30 Nov 8, 2024
1fc9604
TEMP: added checks to restrict barrier height
ssun30 Jan 5, 2025
a814423
add ConstantReservoirDiffusion interface
mjohnson541 Mar 27, 2025
762e418
add ConstantReservoirDiffusion to derivative calculation
mjohnson541 Mar 27, 2025
b1e3352
add ConstantReservoirDiffusion to Jacobian calculation
mjohnson541 Mar 27, 2025
db65cab
Commented out checks that disallow negative barriers
ssun30 Jul 24, 2025
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
61 changes: 46 additions & 15 deletions src/Calculators/Rate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export AbstractFalloffRate
Ea::Q
unc::P = EmptyRateUncertainty()
end
@inline (arr::Arrhenius)(;T::Q,P::N=0.0,C::S=0.0,phi=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath arr.A*T^arr.n*exp(-arr.Ea/(R*T))
@inline (arr::Arrhenius)(T::Q;P::N=0.0,C::S=0.0,phi=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath arr.A*T^arr.n*exp(-arr.Ea/(R*T))
@inline (arr::Arrhenius)(;T::Q,P::N=0.0,C::S=0.0,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath arr.A*T^arr.n*exp(-arr.Ea/(R*T))
@inline (arr::Arrhenius)(T::Q;P::N=0.0,C::S=0.0,phi=0.0,d=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath arr.A*T^arr.n*exp(-arr.Ea/(R*T))
export Arrhenius

@with_kw struct StickingCoefficient{N<:Real,K<:Real,Q<:Real,P<:AbstractRateUncertainty} <: AbstractRate
Expand All @@ -23,29 +23,60 @@ export Arrhenius
Ea::Q
unc::P = EmptyRateUncertainty()
end
@inline (arr::StickingCoefficient)(;T::Q,P::N=0.0,C::S=0.0,phi=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath min(arr.A*T^arr.n*exp(-arr.Ea/(R*T)),1.0)
@inline (arr::StickingCoefficient)(T::Q;P::N=0.0,C::S=0.0,phi=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath min(arr.A*T^arr.n*exp(-arr.Ea/(R*T)),1.0)
@inline (arr::StickingCoefficient)(;T::Q,P::N=0.0,C::S=0.0,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath min(arr.A*T^arr.n*exp(-arr.Ea/(R*T)),1.0)
@inline (arr::StickingCoefficient)(T::Q;P::N=0.0,C::S=0.0,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath min(arr.A*T^arr.n*exp(-arr.Ea/(R*T)),1.0)
export StickingCoefficient

@with_kw struct Arrheniusq{N<:Real,K<:Real,Q<:Real,P<:AbstractRateUncertainty,B} <: AbstractRate
@with_kw struct Arrheniusq{N<:Real,K<:Real,Q<:Real,R<:Real,P<:AbstractRateUncertainty,B} <: AbstractRate
A::N
n::K
Ea::Q
q::B = 0.0
V0::R = 0.0
unc::P = EmptyRateUncertainty()
end
@inline (arr::Arrheniusq)(;T::Q,P::N=0.0,C::S=0.0,phi=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath arr.A*T^arr.n*exp((-arr.Ea-arr.q*F*phi)/(R*T))
@inline (arr::Arrheniusq)(T::Q;P::N=0.0,C::S=0.0,phi=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath arr.A*T^arr.n*exp((-arr.Ea-arr.q*F*phi)/(R*T))
@inline (arr::Arrheniusq)(;T::Q, P::N=0.0, C::S=0.0, phi=0.0, dGrxn=0.0, d=0.0) where {Q<:Real, N<:Real, S<:Real} = begin
barrier = arr.Ea+arr.q*F*(phi-arr.V0)
# corrected_barrier = max(0, dGrxn, barrier)
corrected_barrier = barrier
@fastmath arr.A*T^arr.n*exp(-corrected_barrier/(R*T))
end
@inline (arr::Arrheniusq)(T::Q; P::N=0.0, C::S=0.0, phi=0.0, dGrxn=0.0, d=0.0) where {Q<:Real, N<:Real, S<:Real} = begin
barrier = arr.Ea+arr.q*F*(phi-arr.V0)
# corrected_barrier = max(0, dGrxn, barrier)
corrected_barrier = barrier
@fastmath arr.A*T^arr.n*exp(-corrected_barrier/(R*T))
end
export Arrheniusq

@with_kw struct Marcus{N<:Real,K<:Real,Q,P<:AbstractRateUncertainty,B} <: AbstractRate
A::N
n::K
lmbd_i_coefs::Q
lmbd_o::K
wr::K = 0.0
wp::K = 0.0
beta::B
unc::P = EmptyRateUncertainty()
end
@inline function (arr::Marcus)(;T::Q,P::N=0.0,C::S=0.0,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,N<:Real,S<:Real}
@fastmath lmbd = arr.lmbd_o + evalpoly(T,arr.lmbd_i_coefs)
@fastmath arr.A*T^arr.n*exp(-lmbd/4.0*(1.0+dGrxn/lmbd)^2/(R*T)-arr.beta*d)
end
@inline function (arr::Marcus)(T::Q;P::N=0.0,C::S=0.0,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,N<:Real,S<:Real}
@fastmath lmbd = arr.lmbd_o + evalpoly(T,arr.lmbd_i_coefs)
@fastmath return arr.A*T^arr.n*exp(-lmbd/4.0*(1.0+dGrxn/lmbd)^2/(R*T)-arr.beta*d)
end
export Marcus

@with_kw struct PdepArrhenius{T<:Real,Q<:AbstractRateUncertainty,Z<:AbstractRate} <: AbstractRate
Ps::Array{T,1}
arrs::Array{Z,1}
unc::Q = EmptyRateUncertainty()
end
PdepArrhenius(Ps::Array{Q,1},arrs::Array{Z,1}) where {Q<:Real,Z<:AbstractRate} = PdepArrhenius(sort(Ps),arrs)

@inline function (parr::PdepArrhenius)(;T::Q=nothing,P::V=nothing,C::S=0.0,phi=0.0) where {Q<:Real,V<:Real,S<:Real}
@inline function (parr::PdepArrhenius)(;T::Q=nothing,P::V=nothing,C::S=0.0,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,V<:Real,S<:Real}
inds = getBoundingIndsSorted(P,parr.Ps)::Tuple{Int64,Int64}

if inds[2] == -1
Expand All @@ -65,7 +96,7 @@ export PdepArrhenius
unc::Q = EmptyRateUncertainty()
end

@inline function (marr::MultiArrhenius)(;T::Q,P::R=0.0,C::S=0.0,phi=0.0) where {Q<:Real,R<:Real,S<:Real}
@inline function (marr::MultiArrhenius)(;T::Q,P::R=0.0,C::S=0.0,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,R<:Real,S<:Real}
out = 0.0
for arr in marr.arrs
@fastmath out += arr(T)
Expand All @@ -79,7 +110,7 @@ export MultiArrhenius
unc::Q = EmptyRateUncertainty()
end

@inline function (parr::MultiPdepArrhenius)(;T::Q,P::R=0.0,C::S=0.0,phi=0.0) where {Q<:Real,R<:Real,S<:Real}
@inline function (parr::MultiPdepArrhenius)(;T::Q,P::R=0.0,C::S=0.0,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,R<:Real,S<:Real}
out = 0.0
for pdar in parr.parrs
@fastmath out += pdar(T=T,P=P)
Expand All @@ -95,7 +126,7 @@ export MultiPdepArrhenius
unc::Q = EmptyRateUncertainty()
end

(tbarr::ThirdBody)(;T::Q=nothing,P::R=0.0,C::S=nothing,phi=0.0) where {Q<:Real,R<:Real,S<:Real} = C*(tbarr.arr(T))
(tbarr::ThirdBody)(;T::Q=nothing,P::R=0.0,C::S=nothing,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,R<:Real,S<:Real} = C*(tbarr.arr(T))
export ThirdBody

@with_kw struct Lindemann{N<:Integer,K<:AbstractFloat,Q<:AbstractRateUncertainty} <: AbstractFalloffRate
Expand All @@ -106,7 +137,7 @@ export ThirdBody
unc::Q = EmptyRateUncertainty()
end

@inline function (lnd::Lindemann)(;T::Q=nothing,P::R=0.0,C::S=nothing,phi=0.0) where {Q<:Real,R<:Real,S<:Real}
@inline function (lnd::Lindemann)(;T::Q=nothing,P::R=0.0,C::S=nothing,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,R<:Real,S<:Real}
k0 = lnd.arrlow(T=T)
kinf = lnd.arrhigh(T=T)
@fastmath Pr = k0*C/kinf
Expand All @@ -126,7 +157,7 @@ export Lindemann
unc::R = EmptyRateUncertainty()
end

@inline function (tr::Troe)(;T::Q,P::R=0.0,C::S=nothing,phi=0.0) where {Q<:Real,R<:Real,S<:Real}
@inline function (tr::Troe)(;T::Q,P::R=0.0,C::S=nothing,phi=0.0,dGrxn=0.0,d=0.0) where {Q<:Real,R<:Real,S<:Real}
k0 = tr.arrlow(T=T)
kinf = tr.arrhigh(T=T)
@fastmath Pr = k0*C/kinf
Expand Down Expand Up @@ -195,7 +226,7 @@ export getredtemp
end
export getredpress

@inline function (ch::Chebyshev)(;T::N,P::Q=0.0,C::B=0.0,phi=0.0) where {N<:Real,B<:Real,Q<:Real}
@inline function (ch::Chebyshev)(;T::N,P::Q=0.0,C::B=0.0,phi=0.0,dGrxn=0.0,d=0.0) where {N<:Real,B<:Real,Q<:Real}
k = 0.0
Tred = getredtemp(ch,T)
Pred = getredpress(ch,P)
Expand Down Expand Up @@ -228,7 +259,7 @@ export getkineticstype

@inline extracttypename(typ::Symbol) = string(typ)
@inline extracttypename(typ) = string(typ.name)

@inline function _calcdkdCeff(tbarr::ThirdBody,T::Float64,Ceff::Float64)
return @fastmath tbarr.arr(T)
end
Expand Down
8 changes: 4 additions & 4 deletions src/Calculators/Ratevec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Arrheniusvec(arrs::T) where {T<:AbstractArray}
end
return Arrheniusvec(A=A,n=n,Ea=Ea)
end
@inline (arr::Arrheniusvec)(;T::Q,P::N=0.0,C::S=0.0,phi=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath @inbounds arr.A.*exp.(arr.n.*log(T).-arr.Ea.*(1.0/(R*T)))
@inline (arr::Arrheniusvec)(;T::Q,P::N=0.0,C::S=0.0,phi=0.0,dGrxns=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath @inbounds arr.A.*exp.(arr.n.*log(T).-arr.Ea.*(1.0/(R*T)))
@inline (arr::Arrheniusvec)(T::Q;P::N=0.0,C::S=0.0,phi=0.0) where {Q<:Real,N<:Real,S<:Real} = @fastmath @inbounds arr.A.*exp.(arr.n.*log(T).-arr.Ea.*(1.0/(R*T)))
export Arrheniusvec

Expand Down Expand Up @@ -86,7 +86,7 @@ export getredtemp
end
export getredpress

@inline function (ch::Chebyshevvec)(;T::N,P::Q=0.0,C::B=0.0,phi=0.0) where {N<:Real,B<:Real,Q<:Real}
@inline function (ch::Chebyshevvec)(;T::N,P::Q=0.0,C::B=0.0,phi=0.0,dGrxns=0.0) where {N<:Real,B<:Real,Q<:Real}
k = zeros(N,size(ch.coefs)[1])
Tred = getredtemp(ch,T)
Pred = getredpress(ch,P)
Expand Down Expand Up @@ -170,7 +170,7 @@ function Troevec(troes::T) where {T<:AbstractArray}
end
export Troevec

@inline function (tr::Troevec)(;T::Q=nothing,P::R=0.0,C::S=nothing,phi=0.0) where {Q<:Real,R<:Real,S<:Real}
@inline function (tr::Troevec)(;T::Q=nothing,P::R=0.0,C::S=nothing,phi=0.0,dGrxns=0.0) where {Q<:Real,R<:Real,S<:Real}
k0 = tr.arrlow(T=T)
kinf = tr.arrhigh(T=T)
@fastmath Pr = k0.*C./kinf
Expand Down Expand Up @@ -201,7 +201,7 @@ function PdepArrheniusvec(pdeparrs::T) where {T<:AbstractArray}
end
export PdepArrheniusvec

@inline function (parr::PdepArrheniusvec)(;T::Q=nothing,P::V=nothing,C::S=0.0,phi=0.0) where {Q<:Real,V<:Real,S<:Real}
@inline function (parr::PdepArrheniusvec)(;T::Q=nothing,P::V=nothing,C::S=0.0,phi=0.0,dGrxns=0.0) where {Q<:Real,V<:Real,S<:Real}
inds = getBoundingIndsSorted(P,parr.Ps)::Tuple{Int64,Int64}
if inds[2] == -1
return @inbounds parr.arrvecs[inds[1]](T=T)
Expand Down
Loading
Loading