1
1
from argparse import ArgumentParser
2
+
3
+ from utils .animation import save_trajectory
2
4
from utils .args import parse_args , str2bool
3
5
from systems import System
4
6
import matplotlib .pyplot as plt
@@ -203,11 +205,14 @@ def main():
203
205
x_0 += args .base_sigma * eps
204
206
205
207
x_t_det = setup .sample_paths (state_q , x_0 , args .dt , args .T , args .BS , None )
208
+ # In case we have a second order integration scheme, we remove the velocity for plotting
209
+ x_t_det_no_vel = x_t_det [:, :, :system .A .shape [0 ]]
206
210
207
- if system .plot :
208
- # In case we have a second order integration scheme, we remove the velocity for plotting
209
- x_t_det_no_vel = x_t_det [:, :, : system . A . shape [ 0 ]]
211
+ if system .mdtraj_topology :
212
+ save_trajectory ( system . mdtraj_topology , x_t_det_no_vel [ 0 ]. reshape ( 1 , - 1 , 3 ), f' { args . save_dir } /det_0.pdb' )
213
+ save_trajectory ( system . mdtraj_topology , x_t_det_no_vel [ - 1 ]. reshape ( 1 , - 1 , 3 ), f' { args . save_dir } /det_-1.pdb' )
210
214
215
+ if system .plot :
211
216
plot_energy (system , [x_t_det_no_vel [0 ], x_t_det_no_vel [- 1 ]], args .log_plots )
212
217
show_or_save_fig (args .save_dir , 'path_energy_deterministic' , args .extension )
213
218
@@ -216,10 +221,13 @@ def main():
216
221
217
222
key , path_key = jax .random .split (key )
218
223
x_t_stoch = setup .sample_paths (state_q , x_0 , args .dt , args .T , args .BS , path_key )
224
+ x_t_stoch_no_vel = x_t_stoch [:, :, :system .A .shape [0 ]]
219
225
220
- if system .plot :
221
- x_t_stoch_no_vel = x_t_stoch [:, :, :system .A .shape [0 ]]
226
+ if system .mdtraj_topology :
227
+ save_trajectory (system .mdtraj_topology , x_t_stoch_no_vel [0 ].reshape (1 , - 1 , 3 ), f'{ args .save_dir } /stoch_0.pdb' )
228
+ save_trajectory (system .mdtraj_topology , x_t_stoch_no_vel [- 1 ].reshape (1 , - 1 , 3 ), f'{ args .save_dir } /stoch_-1.pdb' )
222
229
230
+ if system .plot :
223
231
plot_energy (system , [x_t_stoch_no_vel [0 ], x_t_stoch_no_vel [- 1 ]], args .log_plots )
224
232
show_or_save_fig (args .save_dir , 'path_energy_stochastic' , args .extension )
225
233
0 commit comments