Skip to content

Commit ce7f911

Browse files
authored
Moving general surface hopping functions to SurfaceHoppingMethods.jl (#357)
* changed location of get_hopping_eigenvalues() changed the location of the definition of the get_hopping_eigenvalues() function to SurfaceHoppingMethods.jl so this general surface hopping function is defined in a more appropriate location * fixing mistake in previous commit Previous commit copied over the wrong function from SurfaceHoppingMethods\rpsh.jl * added RingPolymerSimulation as dependency in SurfaceHoppingMethods.jl * Moved general surface hopping functions to SurfaceHoppingMethods.jl (#356) Moved two generally applicable surface hopping functions get_hopping_nonadiabatic_coupling() and get_hopping_velocity() to SurfaceHoppingMethods.jl and moved their duplicate RingPolymer definitions to the same file to bring these definitions more in line with the duplicate function definition philosophy in the rest of NQCD * Imported get_centroid() to SurfaceHoppingMethods Added get_centroid() to SurfaceHoppingMethods.jl so that get_hopping_velocity() is able to work as expected.
1 parent 06745a6 commit ce7f911

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

src/DynamicsMethods/SurfaceHoppingMethods/SurfaceHoppingMethods.jl

+17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ using ComponentArrays: ComponentVector
1111
using DiffEqBase: DiffEqBase
1212
using LinearAlgebra: LinearAlgebra, lmul!
1313
using OrdinaryDiffEq: OrdinaryDiffEq
14+
using RingPolymerArrays: get_centroid
1415

1516
using NQCDynamics:
1617
NQCDynamics,
@@ -93,6 +94,22 @@ function DynamicsUtils.get_hopping_eigenvalues(sim::RingPolymerSimulation, r::Ab
9394
return Calculators.get_centroid_eigen(sim.calculator, r).values
9495
end
9596

97+
function DynamicsUtils.get_hopping_nonadiabatic_coupling(sim::Simulation, r::AbstractMatrix)
98+
return Calculators.get_nonadiabatic_coupling(sim.calculator, r)
99+
end
100+
101+
function DynamicsUtils.get_hopping_nonadiabatic_coupling(sim::RingPolymerSimulation, r::AbstractArray{T,3}) where {T}
102+
return Calculators.get_centroid_nonadiabatic_coupling(sim.calculator, r)
103+
end
104+
105+
function DynamicsUtils.get_hopping_velocity(::Simulation, v::AbstractMatrix)
106+
return v
107+
end
108+
109+
function DynamicsUtils.get_hopping_velocity(::RingPolymerSimulation, v::AbstractArray{T,3}) where {T}
110+
return get_centroid(v)
111+
end
112+
96113
include("decoherence_corrections.jl")
97114
include("surface_hopping.jl")
98115
include("fssh.jl")

src/DynamicsMethods/SurfaceHoppingMethods/fssh.jl

-8
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ function evaluate_hopping_probability!(sim::AbstractSimulation{<:FSSH}, u, dt)
7575
fewest_switches_probability!(sim.method.hopping_probability, v, σ, s, d, dt)
7676
end
7777

78-
function DynamicsUtils.get_hopping_nonadiabatic_coupling(sim::Simulation, r::AbstractMatrix)
79-
return Calculators.get_nonadiabatic_coupling(sim.calculator, r)
80-
end
81-
82-
function DynamicsUtils.get_hopping_velocity(::Simulation, v::AbstractMatrix)
83-
return v
84-
end
85-
8678
function fewest_switches_probability!(probability, v, σ, s, d, dt)
8779
probability .= 0 # Set all entries to 0
8880
for m in axes(σ, 1)

src/DynamicsMethods/SurfaceHoppingMethods/rpsh.jl

-8
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ function DynamicsMethods.motion!(du, u, sim::RingPolymerSimulation{<:SurfaceHopp
2727
DynamicsUtils.set_quantum_derivative!(dσ, u, sim)
2828
end
2929

30-
function DynamicsUtils.get_hopping_nonadiabatic_coupling(sim::RingPolymerSimulation, r::AbstractArray{T,3}) where {T}
31-
return Calculators.get_centroid_nonadiabatic_coupling(sim.calculator, r)
32-
end
33-
34-
function DynamicsUtils.get_hopping_velocity(::RingPolymerSimulation, v::AbstractArray{T,3}) where {T}
35-
return get_centroid(v)
36-
end
37-
3830
function perform_rescaling!(
3931
sim::RingPolymerSimulation{<:SurfaceHopping}, velocity, γ, d
4032
)

0 commit comments

Comments
 (0)