Skip to content

Commit

Permalink
added mmerging of trajectories
Browse files Browse the repository at this point in the history
  • Loading branch information
cpignedoli committed Feb 14, 2024
1 parent 9d85230 commit ab08517
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion aiida_nanotech_empa/workflows/cp2k/reftraj_md_workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,26 @@ def merge_batches_output(self):
# merged_traj = []
# for i_batch in range(self.ctx.n_batches):
# merged_traj.extend(self.ctx[f"reftraj_batch_{i_batch}"].outputs.trajectory)
positions=[self.ctx.first_structure.outputs.output_trajectory.get_array('positions')]
cells=[self.ctx.first_structure.outputs.output_trajectory.get_array('cells')]
forces=[self.ctx.first_structure.outputs.output_trajectory.get_array('forces')]
for batch in self.ctx.batches:
key = f"reftraj_batch_{batch[0]}_to_{batch[-1]}"
if not getattr(
self.ctx, key).is_finished_ok:
self.report(f"Batch {key} failed")
return self.exit_codes.ERROR_TERMINATION

positions.append(getattr(self.ctx, key).outputs.output_trajectory.get_array('positions'))
cells.append(getattr(self.ctx, key).outputs.output_trajectory.get_array('cells'))
forces.append(getattr(self.ctx, key).outputs.output_trajectory.get_array('forces'))

positions=np.concatenate(positions)
cells=np.concatenate(cells)
forces=np.concatenate(forces)
symbols = self.ctx.first_structure.outputs.output_trajectory.symbols
output_trajectory = TrajectoryData()
output_trajectory.set_trajectory(symbols, positions, cells=cells)
self.out('output_trajectory', self.inputs.trajectory)
self.report("done")
return engine.ExitCode(0)

0 comments on commit ab08517

Please sign in to comment.