Skip to content

Commit 7195855

Browse files
committed
switch to ReverseDiffVJP(false) for VJP calculations
ReverseDiffVJP(true) assumed there was no programmatic branching in the function This is true for most simulations when the rate coefficients are constant, but the assumption breaks down when the rate coefficients aren't constant Originally ReverseDiffVJP(false) gave NaNs when run and TrackerVJP() would crash (as it does currently) and so ReverseDiffVJP(true) was set as the default This should resolve issues with inconsistency between forward sensitivities and adjoint sensitivities
1 parent 94b834a commit 7195855

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Simulation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ By default uses the InterpolatingAdjoint algorithm with vector Jacobian products
138138
this assumes no changes in code branching during simulation, if that were to become no longer true, the Tracker
139139
based alternative algorithm is slower, but avoids this concern.
140140
"""
141-
function getadjointsensitivities(bsol::Q,target::String,solver::W;sensalg::W2=InterpolatingAdjoint(autojacvec=ReverseDiffVJP(true)),abstol::Float64=1e-6,reltol::Float64=1e-3,kwargs...) where {Q,W,W2}
141+
function getadjointsensitivities(bsol::Q,target::String,solver::W;sensalg::W2=InterpolatingAdjoint(autojacvec=ReverseDiffVJP(false)),abstol::Float64=1e-6,reltol::Float64=1e-3,kwargs...) where {Q,W,W2}
142142
@assert target in bsol.names || target in ["T","V","P"]
143143
if target in ["T","V","P"]
144144
ind = getthermovariableindex(bsol.domain,target)

0 commit comments

Comments
 (0)