@@ -29,7 +29,7 @@ function surface_distance_condition(
29
29
) # Height of the molecule in the surface normal direction
30
30
31
31
# 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 )]
33
33
34
34
# Ignore substrate above molecule in case PBC wrapping puts one above the diatomic
35
35
highest_z = max (substrate_heights[substrate_heights.≤ molecule_position]. .. )
60
60
61
61
Evaluate true if the diatomic bond length is below `threshold`.
62
62
"""
63
- function close_approach_condition (x:: AbstractArray , indices:: Vector{Int} , simulation:: AbstractSimulation ; threshold = 1.5 u " Å" )
64
- if Structure. pbc_distance (x, indices... , simulation) ≤ threshold
63
+ function close_approach_condition (x:: AbstractArray , indices:: Vector{Int} , simulation:: AbstractSimulation ; threshold = austrip ( 1.5 u " Å" ) )
64
+ if austrip ( Structure. pbc_distance (x, indices... , simulation) ) ≤ threshold
65
65
return true
66
66
else
67
67
return false
@@ -83,7 +83,7 @@ If the second condition is never reached (can happen for particularly quick deso
83
83
diatomic bond length is above the given value and saves from that point onwards.
84
84
"""
85
85
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.5 u " Å" ))
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))
87
87
88
88
if isa (desorbed_frame, Nothing)
89
89
@debug " No desorption event found."
@@ -108,7 +108,7 @@ function get_desorption_frame(trajectory::AbstractVector, diatomic_indices::Vect
108
108
end
109
109
end
110
110
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 " Å" )
112
112
# First determine where the reaction occurred on the surface.
113
113
desorption_frame = get_desorption_frame (trajectory, indices, simulation; surface_distance_threshold= surface_distance_threshold, surface_normal= surface_normal)
114
114
if isa (desorption_frame, Nothing)
0 commit comments