Extracting Atomic Forces from XYZ Trajectories in CP2K

101 views
Skip to first unread message

riccardo piombo

unread,
Oct 9, 2023, 11:54:14 AM10/9/23
to cp2k

Dear CP2K Community,

We have encountered a challenge while working with MD trajectories in XYZ format. Specifically, we have trajectories containing atomic positions and velocities for each frame, but unfortunately, we do not have the corresponding atomic forces.

In theory, it is possible to calculate atomic forces based on atomic positions and velocities. However, we are unsure about the specific algorithm and where it can be found within the CP2K codebase.

We are reaching out to the community to inquire if anyone can provide guidance on:

  1. 1. Locating the algorithm or module responsible for calculating atomic forces within CP2K.
  2. 2. Assessing the feasibility of extracting atomic forces from our XYZ trajectories in a reasonably short amount of time.

Any assistance or insights on this matter would be greatly appreciated. We understand that this may be a non-trivial task, but we are hopeful that the CP2K community's expertise can help us navigate this challenge.

Thank you in advance for your support and expertise.

Best regards Riccardo Piombo

Victor Volkov

unread,
Oct 9, 2023, 12:04:13 PM10/9/23
to cp...@googlegroups.com
Hello Riccardo:

I did not have problems to print atomic forces while working with xyz and velocities.
I used the following instructing in the MOTION section under PRINT

&MOTION
  &PRINT
   
  &FORCES ON
      &EACH
        MD 1
      &END EACH
      FILENAME =force.xyz
    &END FORCES

  &END PRINT
&END MOTION

Hope this would help.
Victor



--
You received this message because you are subscribed to the Google Groups "cp2k" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cp2k+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cp2k/311dfc7b-f7ec-4d45-a7c4-32e9203b8ee1n%40googlegroups.com.

riccardo piombo

unread,
Oct 9, 2023, 1:11:20 PM10/9/23
to cp...@googlegroups.com
Dear Victor,

The problem is the following:
We already have our MD trajectories but we (unfortunately) made a mistake and we didn't ask cp2k to print the Atomic forces in the way you explained. Since the trajectories are very long (hundreds of picoseconds and for several huge supercells) and now we don't have any computational time available, I'm wondering to compute the Atomic forces from scratch by coding a program able to do that.
To that aim,  I Need to know the integration algorithm implemented. Since cp2k is so huge I'm looking for some guidance. 

Thanks for your reply.
Best regards,

Riccardo Piombo 

You received this message because you are subscribed to a topic in the Google Groups "cp2k" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cp2k/4cQuy8fJHQo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cp2k+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cp2k/CAK%2B-SSgNN2ZnRQRo8EMqB8v1zLuUyUVTd4AZCEoOZg1jVw4Fhw%40mail.gmail.com.

Jürg Hutter

unread,
Oct 10, 2023, 2:58:07 AM10/10/23
to cp...@googlegroups.com
Hi

all integrators in CP2K are based on the Velocity Verlet algorithm.
The different routines can be found in the src/motion directory.

If your trajectory was generated for a NVE ensemble without any
constraints, you can easily extract the forces from inverting the
Velocity Verlet algorithm.
If you were using any type of thermostat or any geometrical constraints
it will be very difficult or impossible. At least I don't see a straightforward
way.
Depending on you final goal, recalculating the forces at a subset of your
trajectory will be your only option.

regards
JH

________________________________________
From: cp...@googlegroups.com <cp...@googlegroups.com> on behalf of riccardo piombo <riccard...@gmail.com>
Sent: Monday, October 9, 2023 5:54 PM
To: cp2k
Subject: [CP2K:19326] Extracting Atomic Forces from XYZ Trajectories in CP2K

Dear CP2K Community,

We have encountered a challenge while working with MD trajectories in XYZ format. Specifically, we have trajectories containing atomic positions and velocities for each frame, but unfortunately, we do not have the corresponding atomic forces.

In theory, it is possible to calculate atomic forces based on atomic positions and velocities. However, we are unsure about the specific algorithm and where it can be found within the CP2K codebase.

We are reaching out to the community to inquire if anyone can provide guidance on:

1. 1. Locating the algorithm or module responsible for calculating atomic forces within CP2K.
2. 2. Assessing the feasibility of extracting atomic forces from our XYZ trajectories in a reasonably short amount of time.

Any assistance or insights on this matter would be greatly appreciated. We understand that this may be a non-trivial task, but we are hopeful that the CP2K community's expertise can help us navigate this challenge.

Thank you in advance for your support and expertise.

Best regards Riccardo Piombo

--
You received this message because you are subscribed to the Google Groups "cp2k" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cp2k+uns...@googlegroups.com<mailto:cp2k+uns...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/cp2k/311dfc7b-f7ec-4d45-a7c4-32e9203b8ee1n%40googlegroups.com<https://groups.google.com/d/msgid/cp2k/311dfc7b-f7ec-4d45-a7c4-32e9203b8ee1n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Simone Ritarossi

unread,
Oct 10, 2023, 4:17:17 AM10/10/23
to cp...@googlegroups.com
Hi users,
I have the same problem and I used Langevin (second-generation Car-Parrinello). In this case?

Simone Ritarossi 

To unsubscribe from this group and stop receiving emails from it, send an email to cp2k+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cp2k/ZR0P278MB0759B06368A3D5E374E749D39FCDA%40ZR0P278MB0759.CHEP278.PROD.OUTLOOK.COM.

riccardo piombo

unread,
Oct 10, 2023, 4:37:48 AM10/10/23
to cp2k
Hi Prof. Hutter,
my simulations are also based on the Langevin ensamble. 
do we have to give up on calculating atomic forces from the xyz trajectory?

Kind regards,
Riccardo Piombo

riccardo piombo

unread,
Oct 10, 2023, 5:19:58 AM10/10/23
to cp2k
In particular, the goal is to obtain a file like an extended xyz one and try training a machine learing potential.

Best regards,
Riccardo Piombo

Jürg Hutter

unread,
Oct 10, 2023, 6:01:42 AM10/10/23
to cp...@googlegroups.com
Hi

in this case you want forces from uncorrelated configurations. Depending on your system and the ML algorithm you probably need about 1000 learning points.
I would run a REFTRAJ run with about 1000 points along your full trajectory
and recalculate the forces (NO Langevin!).
You will have the additional benefit, that your forces are more accurate
then in the original run.

regards
JH

________________________________________
From: cp...@googlegroups.com <cp...@googlegroups.com> on behalf of riccardo piombo <riccard...@gmail.com>
Sent: Tuesday, October 10, 2023 11:19 AM
To: cp2k
Subject: Re: [CP2K:19337] Extracting Atomic Forces from XYZ Trajectories in CP2K
To view this discussion on the web visit https://groups.google.com/d/msgid/cp2k/c2cef1eb-eb15-4b04-adf2-7b365f2ea301n%40googlegroups.com<https://groups.google.com/d/msgid/cp2k/c2cef1eb-eb15-4b04-adf2-7b365f2ea301n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Jürg Hutter

unread,
Oct 10, 2023, 6:02:47 AM10/10/23
to cp...@googlegroups.com
No, there are random contributions to the propagation that you will not be
able to retrace.
JH

________________________________________
From: cp...@googlegroups.com <cp...@googlegroups.com> on behalf of riccardo piombo <riccard...@gmail.com>
Sent: Tuesday, October 10, 2023 10:37 AM
To: cp2k
Subject: Re: [CP2K:19335] Extracting Atomic Forces from XYZ Trajectories in CP2K
To view this discussion on the web visit https://groups.google.com/d/msgid/cp2k/b9230076-a40b-4e74-8b91-4d90d9ae180dn%40googlegroups.com<https://groups.google.com/d/msgid/cp2k/b9230076-a40b-4e74-8b91-4d90d9ae180dn%40googlegroups.com?utm_medium=email&utm_source=footer>.

riccardo piombo

unread,
Oct 10, 2023, 7:58:24 AM10/10/23
to cp2k
So should we lose all hope in computing the atomic forces in the way I had imagined?

Best regards,
Riccardo Piombo

Reply all
Reply to author
Forward
0 new messages