Skip to content
Snippets Groups Projects

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

Edited by Logan Ward

Merge request reports

Pipeline #1270953339 passed

Pipeline passed for 4a108514 on WardLT:cp2k-set-pos-file

Test coverage 74.83% from 1 job

Merged by Andrew RosenAndrew Rosen May 1, 2024 (May 1, 2024 5:15am UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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.

    • Author Contributor

      No, I don't have a reason beyond "habit." Would write be more performant? Print flushing the write buffer does seem unnecessary

      I can change that. Won't be for a few days, until I'm back working off the computer which has the newest cp2k

    • Mostly, I was just genuinely curious. It really shouldn't make much of a practical difference here. I haven't actually seen someone do this before in the wild! No need to revisit this MR. I'll merge. :thumbsup:

    • Please register or sign in to reply
  • merged

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading