Skip to content

Commit 1faa018

Browse files
committed
🐛 Missing unit conversion in close_approach_condition
1 parent b430786 commit 1faa018

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Analysis/diatomic.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function surface_distance_condition(
2929
) # Height of the molecule in the surface normal direction
3030

3131
# Get the height of all substrate atoms in surface normal direction.
32-
substrate_heights = [surface_normal_height(get_positions(x)[:, substrate_atom_id], surface_normal) for substrate_atom_id in symdiff(1:length(simulation.atoms.masses), indices)]
32+
substrate_heights = [surface_normal_height(get_positions(x)[:, substrate_atom_id]) for substrate_atom_id in symdiff(1:length(simulation.atoms.masses), indices, surface_normal)]
3333

3434
# Ignore substrate above molecule in case PBC wrapping puts one above the diatomic
3535
highest_z = max(substrate_heights[substrate_heights.≤molecule_position]...)
@@ -60,8 +60,8 @@ end
6060
6161
Evaluate true if the diatomic bond length is below `threshold`.
6262
"""
63-
function close_approach_condition(x::AbstractArray, indices::Vector{Int}, simulation::AbstractSimulation; threshold = 1.5u"Å")
64-
if Structure.pbc_distance(x, indices..., simulation) threshold
63+
function close_approach_condition(x::AbstractArray, indices::Vector{Int}, simulation::AbstractSimulation; threshold = austrip(1.5u"Å"))
64+
if austrip(Structure.pbc_distance(x, indices..., simulation)) threshold
6565
return true
6666
else
6767
return false
@@ -83,7 +83,7 @@ If the second condition is never reached (can happen for particularly quick deso
8383
diatomic bond length is above the given value and saves from that point onwards.
8484
"""
8585
function get_desorption_frame(trajectory::AbstractVector, diatomic_indices::Vector{Int}, simulation::AbstractSimulation; surface_normal::Vector=[0, 0, 1], surface_distance_threshold=austrip(5.0 * u"Å"), fallback_distance_threshold = austrip(1.5u"Å"))
86-
desorbed_frame = findfirst([surface_distance_condition(frame, diatomic_indices, simulation; surface_distance_threshold=surface_distance_threshold) for frame in trajectory])
86+
desorbed_frame = findfirst(surface_distance_condition.(trajectory, Ref(diatomic_indices), Ref(simulation); surface_distance_threshold=surface_distance_threshold))
8787

8888
if isa(desorbed_frame, Nothing)
8989
@debug "No desorption event found."
@@ -108,7 +108,7 @@ function get_desorption_frame(trajectory::AbstractVector, diatomic_indices::Vect
108108
end
109109
end
110110

111-
function get_desorption_angle(trajectory::AbstractVector, indices::Vector{Int}, simulation::AbstractSimulation; surface_normal=[0, 0, 1], surface_distance_threshold=austrip(5.0 * u"Å"))
111+
function get_desorption_angle(trajectory::AbstractVector, indices::Vector{Int}, simulation::AbstractSimulation; surface_normal=[0, 0, 1], surface_distance_threshold=5.0 * u"Å")
112112
# First determine where the reaction occurred on the surface.
113113
desorption_frame = get_desorption_frame(trajectory, indices, simulation; surface_distance_threshold=surface_distance_threshold, surface_normal=surface_normal)
114114
if isa(desorption_frame, Nothing)

0 commit comments

Comments
 (0)