Skip to content

Commit

Permalink
moved additional parameters to the config file
Browse files Browse the repository at this point in the history
  • Loading branch information
azimonti committed Aug 12, 2024
1 parent 67a8088 commit 9e50650
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
10 changes: 10 additions & 0 deletions mod_config_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@
plot_phase=True, # plot real an imaginary or phase
increase_precision=True, # use Runge-Kutta or Euler
rk_method='DOP853', # RK method 'RK23', 'RK45', or 'DOP853'
high_res=True, # enable high resolution simulation
plot=True, # enable plotting
compute=True, # enable computations
animate=True, # enable animations
load_data=False, # load data from a file
save_data=False, # save data to a file
data_folder='data/simul', # folder for data files
animation_format='mp4', # format for animations
total_duration=6, # total duration of the simulation
fps=30, # frames per second for the animation
verbose=False
)

Expand Down
25 changes: 14 additions & 11 deletions schrodinger_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,18 +488,20 @@ def plot_update(self, cur_step: int):
def make_plot(outfile: str):
global cfg, p
params = {
'high_res': True,
# fixed parameters
'ggplot': False,
'dark_background': False,
'do_plot': True,
'do_compute': True,
'do_animation': True,
'load_data': False,
'save_data': False,
'data_folder': 'data/simul',
'animation_format': 'mp4',
'total_duration': 6,
'fps': 30
# configuarable parameters
'high_res': cfg.high_res,
'do_plot': cfg.plot,
'do_compute': cfg.compute,
'do_animation': cfg.animate,
'load_data': cfg.load_data,
'save_data': cfg.save_data,
'data_folder': cfg.data_folder,
'animation_format': cfg.animation_format,
'total_duration': cfg.total_duration,
'fps': cfg.fps
}
# init data so a plot can be done without computing
x = np.arange(-p.x_max, p.x_max, p.dx)
Expand All @@ -522,7 +524,8 @@ def make_plot(outfile: str):
with open(simul_dir + '/config.pkl', 'rb') as file:
cfg = pickle.load(file)
p = pickle.load(file)
if params['do_compute']:
# Do not compute if load
else:
t, psi = compute(
x, t, psi, v, params['total_duration'] * params['fps'])
# serialize data
Expand Down

0 comments on commit 9e50650

Please sign in to comment.