Extracting Final Optimized Geometry from NWChem Output

33 views
Skip to first unread message

Hadeel Moustafa

unread,
Mar 26, 2024, 12:50:22 AMMar 26
to NWChem Forum

Hi everyone

I'm writing to ask for advice on how to get the NWChem output file's final optimised geometry in XYZ format.

Right now, NWChem version 7.2.0 is what I'm using.

I've attempted to use the driver XYZ directive in the input file, however, it records every step in between during optimization. I've also tried using the grep and awk tools to post-process the output file, but I either can't discover the pertinent keywords or get redundant data.

Would you kindly advise on the best way to extract only the final optimized geometry for NWChem version 7.2.0 in XYZ format?

This is how I've done it 

start

title “H2O”

geometry units angstrom

  O 0  0  0

  H 0  1.430 1.107

  H 0 -1.430 1.107

end

basis

  * library sto-3g except O

  O library 6-31g

end

driver

  xyz  # This will capture the initial geometry

end

dft

  xc b3lyp

end

task dft optimize

driver  # This will capture the final geometry after optimization

  xyz output="water_optimized.xyz"

end


and I also tried sth like


grep -A 3 "Final geometry" water.out | tail -3 > water_optimized.xyz

Best regards

Hadeel

Edoardo Aprà

unread,
Mar 26, 2024, 2:29:11 PMMar 26
to NWChem Forum
$ docker run --shm-size 256m -u `id -u` --rm -v `pwd`:/data ghcr.io/nwchemgit/nwchem-dev /data/gxyz.nw

$ ls -lrt gxyz-*xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-000.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-001.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-002.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-003.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-004.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-005.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-006.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-007.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-008.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-009.xyz
-rw-r--r-- 1 edo root 209 Mar 26 11:28 gxyz-010.xyz

$ cat gxyz-010.xyz
     3
 geometry
 O                     0.00000000     0.00000000     0.12352733
 H                    -0.80772323     0.00000000     0.71313634
 H                     0.80772323     0.00000000     0.71313634

Hadeel Moustafa

unread,
Mar 27, 2024, 9:57:02 AMMar 27
to NWChem Forum

I am aware that using the command "ls -lrt *xyz" allows me to obtain the necessary file list. However, I am seeking a more efficient solution wherein a script or similar tool can automatically generate the final xyz file


Imagine that I have 10 folders for those folder I want to

Identify the file named "final_optimized_structure.xyz" within each folder automatically to be able to use it for the next step 

Edoardo Aprà

unread,
Mar 27, 2024, 4:10:10 PMMar 27
to NWChem Forum
I think I am still struggling to understand what is discussed here.
Anyhow, a simple bash command (outside of NWChem) gets you the final geometry output

$ cat $(ls -rt g*xyz | tail -1)

Edoardo Aprà

unread,
Mar 27, 2024, 4:11:55 PMMar 27
to NWChem Forum
Instead, if you want simply NWChem to reuse the last geometry, the restart option is what you want to use
Reply all
Reply to author
Forward
0 new messages