Skip to content

Commit

Permalink
exp integrator tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
aarontrowbridge committed Nov 10, 2024
1 parent a41a7ac commit 68b4059
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/integrators/exponential_integrators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ end
∂Ũ⃗ₜ₊₁ℰ = sparse(I, ℰ.dim, ℰ.dim)
∂Ũ⃗ₜℰ = -expĜₜ

∂aₜℰ = -ForwardDiff.jacobian(
a -> expv(Δtₜ, Id .G(a), Ũ⃗ₜ),
∂aₜℰ = ForwardDiff.jacobian(
a -> -expv(Δtₜ, Id .G(a), Ũ⃗ₜ),
aₜ
)

if.freetime
∂Δtₜℰ = -(Id Gₜ) * expĜₜ * Ũ⃗ₜ
∂Δtₜℰ = -(Id Gₜ) * (expĜₜ * Ũ⃗ₜ)
return ∂Ũ⃗ₜℰ, ∂Ũ⃗ₜ₊₁ℰ, ∂aₜℰ, ∂Δtₜℰ
else
return ∂Ũ⃗ₜℰ, ∂Ũ⃗ₜ₊₁ℰ, ∂aₜℰ
Expand Down Expand Up @@ -290,18 +290,18 @@ end
# compute the generator
Gₜ =.G(aₜ)

expGₜ = exp_eigen(Δtₜ * Gₜ)
expGₜ = sparse(exp_eigen(Δtₜ * Gₜ))

∂ψ̃ₜ₊₁ℰ = sparse(I, ℰ.dim, ℰ.dim)
∂ψ̃ₜℰ = -expGₜ

∂aₜℰ = -ForwardDiff.jacobian(
a -> expv(Δtₜ, ℰ.G(a), ψ̃ₜ),
∂aₜℰ = ForwardDiff.jacobian(
a -> -expv(Δtₜ, ℰ.G(a), ψ̃ₜ),
aₜ
)

if.freetime
∂Δtₜℰ = -Gₜ * expGₜ * ψ̃ₜ
∂Δtₜℰ = -Gₜ * (expGₜ * ψ̃ₜ)
return ∂ψ̃ₜℰ, ∂ψ̃ₜ₊₁ℰ, ∂aₜℰ, ∂Δtₜℰ
else
return ∂ψ̃ₜℰ, ∂ψ̃ₜ₊₁ℰ, ∂aₜℰ
Expand Down Expand Up @@ -433,6 +433,14 @@ end
end
end

function get_comps(P::DensityOperatorExponentialIntegrator, traj::NamedTrajectory)
if P.freetime
return P.density_operator_components, P.drive_components, traj.components[traj.timestep]
else
return P.density_operator_components, P.drive_components
end
end

# ******************************************************************************* #

@testitem "testing UnitaryExponentialIntegrator" begin
Expand Down

0 comments on commit 68b4059

Please sign in to comment.