Skip to content

Commit

Permalink
added display of current time while computing
Browse files Browse the repository at this point in the history
  • Loading branch information
azimonti committed Aug 26, 2024
1 parent 0a41004 commit 713d067
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion mod_config_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
plot_anim=False, # plot animation
load_data=False, # load data from a file
save_data=True, # save data to a file
data_folder='data/simul', # folder for data files
data_folder='data/simul', # folder for data files
output_file='schrodinger_2d.png', # output file name
animation_format='mp4', # animation format (mp4 or gif)
verbose=True
)
Expand Down
10 changes: 6 additions & 4 deletions schrodinger_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,15 @@ def compute(self):
if perc // 10 > self.perc // 10:
self.perc = perc
elapsed_time = time.time() - self.start_time
current_time = time.strftime("%H:%M:%S", time.localtime())
if elapsed_time >= 3600:
formatted_time = time.strftime(
"%H:%M:%S", time.gmtime(elapsed_time))
else:
formatted_time = time.strftime(
"%M:%S", time.gmtime(elapsed_time))
print(f"completed {int(perc)}% of the computation, "
f"elapsed {formatted_time}")
print(f"completed {int(perc)}% of the animation, "
f"elapsed {formatted_time} [{current_time}]")

def __init_plot(self):
plot_psi = self.psi_plot[0]
Expand Down Expand Up @@ -390,14 +391,15 @@ def __animate_frame(self, frame, is_animation=True):
if perc // 10 > self.perc // 10:
self.perc = perc
elapsed_time = time.time() - self.start_time
current_time = time.strftime("%H:%M:%S", time.localtime())
if elapsed_time >= 3600:
formatted_time = time.strftime(
"%H:%M:%S", time.gmtime(elapsed_time))
else:
formatted_time = time.strftime(
"%M:%S", time.gmtime(elapsed_time))
print(f"completed {int(perc)}% of the animation, "
f"elapsed {formatted_time}")
f"elapsed {formatted_time} [{current_time}]")

return self.img,

Expand Down Expand Up @@ -527,7 +529,7 @@ def main():
tmp_dir = os.path.join(script_dir, 'tmp')
if not os.path.exists(tmp_dir):
os.makedirs(tmp_dir)
ofile = tmp_dir + "/schrodinger_2d.png"
ofile = tmp_dir + "/" + cfg.output_file
make_plot(ofile)


Expand Down

0 comments on commit 713d067

Please sign in to comment.