Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jumps calculation: switched joined prerequisites to independent prerequisites #247

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/gemdat/jumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def _generic_transitions_to_jumps(transitions: Transitions,
fromevent = None
candidate_jump = None

# Only take jumps which hit the inner radius
for _, event in events.iterrows():
# If we are jumping, but we go to the next atom index, reset
if fromevent is not None:
Expand All @@ -57,6 +56,7 @@ def _generic_transitions_to_jumps(transitions: Transitions,
'stop time'] >= minimal_residence:
jumps.append(candidate_jump)
candidate_jump = None
fromevent = None
elif candidate_jump['destination site'] != event[
'destination site']:
candidate_jump = None
Expand All @@ -66,18 +66,28 @@ def _generic_transitions_to_jumps(transitions: Transitions,
if event['start site'] != event['destination site']:
fromevent = event

# Check if we have a candidate jump to the inner site
# (only residence time still has to be checked)
if fromevent is not None:
# if we jump back, remove fromevent
if fromevent['start site'] == event['destination site']:
fromevent = None
candidate_jump = None
continue
if event['destination inner site'] == -1:

# Check if jump to the inner site, add it to the jumps immediately
if event['destination inner site'] != -1:
event['start site'] = fromevent['start site']
event['start time'] = fromevent['start time']
fromevent = None
candidate_jump = None
jumps.append(event)
continue
event['start site'] = fromevent['start site']
event['start time'] = fromevent['start time']
fromevent = None
candidate_jump = event

# If we enter another site, create a candidate jump
if candidate_jump is None:
if event['destination site'] != -1:
event['start site'] = fromevent['start site']
event['start time'] = fromevent['start time']
candidate_jump = event

# Also add a last candidate jump (if there is one
if candidate_jump is not None:
Expand Down
12 changes: 7 additions & 5 deletions tests/integration/jumps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ def test_site_inner_fraction(self, vasp_traj, vasp_sites, structure):
structure=structure,
floating_specie='Li',
site_inner_fraction=0.5)
jumps = Jumps(transitions=transitions, sites=vasp_sites)
jumps = Jumps(transitions=transitions,
sites=vasp_sites,
minimal_residence=100)

assert len(jumps.data) == 256
assert len(jumps.data) == 267
assert np.all(jumps.data[::100].to_numpy() == np.array([[
0, 94, 0, 282, 303
], [16, 64, 42, 2106, 2179], [35, 77, 15, 2559, 2603]]))
], [15, 74, 8, 1271, 1286], [34, 49, 33, 3141, 3296]]))

def test_minimal_residency(self, vasp_traj, vasp_sites, structure):
transitions = Transitions.from_trajectory(trajectory=vasp_traj,
Expand All @@ -31,7 +33,7 @@ def test_minimal_residency(self, vasp_traj, vasp_sites, structure):
sites=vasp_sites,
minimal_residence=3)

assert len(jumps.data) == 457
assert len(jumps.data) == 462
assert np.all(jumps.data[::200].to_numpy() == np.array([[
0, 94, 0, 282, 284
], [18, 54, 24, 3336, 3368], [41, 67, 41, 2886, 2893]]))
], [18, 54, 24, 2937, 3015], [41, 41, 67, 849, 851]]))