Add ability to send positions to CP2K via file
Introduces the ability to side-step issues in passing large atomic structures to CP2K through stdin for MPI applications.
Adds a set_pos_file
option that sends positions via file rather than stdin, which is a route others have used successfully and one I've confirmed fixes issues with ASE.
My PR to CP2K which supports the new route has been merged, but we'd need to test against the main branch until the next CP2K release occurs.
Checklist
-
I am familiar with ASE's contribution guidelines. -
Doc strings in code changed in this MR are up to date. -
Unit tests have been added for new or changed code. -
Issue is resolved via "closes #XXXX" if applicable. -
Add warning about using the "set_pos_file" for structures larger than a few dozen atoms -
Check the shell version so we can warn users if their CP2K is out of date.
Merge request reports
Activity
added 1 commit
- 615b8de0 - Do not delete file, that - somehow - leads to CP2K stalling
added 1 commit
- d212b801 - Added warnings about versions, original error
- Resolved by Andrew Rosen
I'll push a unit test soon, but it won't work. Shall I mark it an xfail so that it'll eventually pass when CP2K is updated?
mentioned in issue #939
mentioned in issue #1477
added 1 commit
- 4a108514 - Add unit test, instructions for after CP2K release
marked the checklist item Unit tests have been added for new or changed code. as completed
marked the checklist item Issue is resolved via "closes #XXXX" if applicable. as completed
298 305 if 'positions' in system_changes: 299 self._shell.send('SET_POS %d' % self._force_env_id) 300 self._shell.send('%d' % (3 * n_atoms)) 301 for pos in self.atoms.get_positions(): 302 self._shell.send('%.18e %.18e %.18e' % tuple(pos)) 303 self._shell.send('*END') 306 if self.parameters.set_pos_file: 307 # TODO: Update version number when released 308 if self._shell.version < 7: 309 raise ValueError('SET_POS_FILE requires > CP2K 2024.X') 310 pos: np.ndarray = self.atoms.get_positions() 311 fn = self.label + '.pos' 312 with open(fn, 'w') as fp: 313 print(3 * n_atoms, file=fp) 314 for pos in self.atoms.get_positions(): 315 print('%.18e %.18e %.18e' % tuple(pos), file=fp) Apologies for the delay, @WardLT. Just one small question below before I go ahead and merge.