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

Carrier history #49

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions morphct/mobility_kmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ def run_single_kmc(
carrier_list is returned. Otherwise it is assumed this function is being
as part of a multiprocessing run and nothing is returned.
"""

if seed is not None:
np.random.seed(seed)

Expand All @@ -414,6 +415,8 @@ def run_single_kmc(
else:
filename = None



v_print(f"Found {len(jobs):d} jobs to run", verbose, filename=filename)

try:
Expand All @@ -433,6 +436,7 @@ def run_single_kmc(
carrier_list = []
box = snap.configuration.box[:3]
for i_job, [carrier_no, lifetime, ctype] in enumerate(jobs):
hopsites = []
v_print(f"starting job {i_job}", verbose, filename=filename)
t1 = time.perf_counter()
# Find a random position to start the carrier in
Expand All @@ -458,13 +462,28 @@ def run_single_kmc(
continue_sim = True
while continue_sim:
continue_sim = i_carrier.calculate_hop(chromo_list, verbose=verbose)
hopsites.append(i_carrier.current_chromo.center)
# Now the carrier has finished hopping, let's calculate its vitals
i_carrier.update_displacement()

t2 = time.perf_counter()
elapsed_time = float(t2) - float(t1)
time_str = hf.time_units(elapsed_time)

hopdirectory = os.path.join(kmc_directory, "carrier_pathfiles")

if not os.path.exists(hopdirectory):
os.makedirs(hopdirectory)

hoppathfile = os.path.join(hopdirectory, f"{i_carrier.id}.npy")

if os.path.exists(hoppathfile):
os.remove(hoppathfile)

if i_carrier.id in range(0,5,1):
hopsites = np.array(hopsites)
np.save(hoppathfile, hopsites)

v_print(
f"\t{i_carrier.c_type} hopped {i_carrier.n_hops} times over "
+ f"{i_carrier.current_time:.2e} seconds "
Expand Down