Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of an atomic forces parser #144

Open
sshepherd637 opened this issue Jul 16, 2021 · 6 comments
Open

Addition of an atomic forces parser #144

sshepherd637 opened this issue Jul 16, 2021 · 6 comments

Comments

@sshepherd637
Copy link

sshepherd637 commented Jul 16, 2021

I have been using this AiiDA plugin for a while as it's basically a necessity for the amount of similar calculations I run, to that end because I need the atomic forces of the calculation output and retrievable, I have created an additional parsing function to parse any atomic forces output by the calculation if the run type is 'ENERGY/FORCE'. It then saves those forces to an ArrayData node called atomic_forces.

It's formatted quite simply, so if anyone can think of anything else required within the rough example I've given here (note the titles are not included within the actual array, but shown here to help explain):

Atom Number Atom Kind X component Y component Z component
1 1 0.005 0.005. 0.005

and so on, etc etc...

The output units within the array are the units specified within the output file.

Just something I've been using for a bit now, and after cleaning it up slightly, think it might be useful to have here as a tracked array of the forces.

Edit: I can't quite seem the get the table formatting to work with markdown, but I'm sure you get the idea

@yakutovicha
Copy link
Contributor

Hi @sshepherd637

Edit: I can't quite seem the get the table formatting to work with markdown, but I'm sure you get the idea

No problem, I just fixed it. It was enough to delete the spaces in front of the first 1.

I believe the Cp2kToolsParser, that has been introduced recently (#133), might be able to do that. @dev-zero could you please confirm?

In case it is not, a PR would be welcome (we can discuss the implementation details here). In case it is - I can just release a new version of the plugin.

@dev-zero
Copy link
Contributor

@yakutovicha yes, the https://github.com/cp2k/cp2k-output-tools used by the Cp2kToolsParser can parse forces as of v0.4.0.
@sshepherd637 after installing the cp2k-output-tools you can use cp2kparse -f highlight calc.out to show which parts of the output are being recognized/parsed (bold is matched), suggestions for improvement or PRs are welcome.

@dev-zero
Copy link
Contributor

and what you get is this (following the somewhat verbose nested-dict approach):

  "forces": {
    "atomic": {
      "per_atom": [
        {
          "atom": 1,
          "element": "Si",
          "kind": 1,
          "x": 0.0,
          "y": 0.0,
          "z": 0.0
        },
        {
          "atom": 2,
          "element": "Si",
          "kind": 1,
          "x": 0.0,
          "y": 1e-08,
          "z": 1e-08
        },
        {
          "atom": 3,
          "element": "Si",
          "kind": 1,
          "x": 1e-08,
          "y": 1e-08,
          "z": 0.0
        },
        {
          "atom": 4,
          "element": "Si",
          "kind": 1,
          "x": 1e-08,
          "y": 0.0,
          "z": 1e-08
        },
        {
          "atom": 5,
          "element": "Si",
          "kind": 1,
          "x": -1e-08,
          "y": -1e-08,
          "z": -1e-08
        },
        {
          "atom": 6,
          "element": "Si",
          "kind": 1,
          "x": -1e-08,
          "y": -1e-08,
          "z": -1e-08
        },
        {
          "atom": 7,
          "element": "Si",
          "kind": 1,
          "x": -1e-08,
          "y": -1e-08,
          "z": -1e-08
        },
        {
          "atom": 8,
          "element": "Si",
          "kind": 1,
          "x": -1e-08,
          "y": -1e-08,
          "z": -1e-08
        }
      ],
      "sum": {
        "norm": 0.0,
        "x": -0.0,
        "y": -0.0,
        "z": -0.0
      },
      "unit": "a.u."
    }
  },

@sshepherd637
Copy link
Author

Yeah, that works quite well!

I guess with that output working it becomes more a matter of whether you all (@yakutovicha @dev-zero) deem it useful to have an ArrayData node to represent the atomic forces as an output of the CP2K calculation?

I personally do, it's slightly more included within the aiida-cp2k package (in that it doesn't need the cp2k-output-tools package) and automatically retrieves the forces, rather than require additional work getting the calc.out file of the calculation.

@dev-zero
Copy link
Contributor

@sshepherd637 the cp2k-output-tools package is pulled in by aiida-cp2k already. Storing the retrieved data as an ArrayData node in addition to the nested dict is of course an option.

@sshepherd637
Copy link
Author

@dev-zero
Okay, in that case I'll leave it up to you whether it would be useful. In terms of code, I have written two functions, one for parsing and the other to create and format the data node. Let me know what you think! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants