contrib/python: scan input() -- relationship between reported and actual geometries?


Gets Around
The situation:
Running e.g.
scratch_dir /scratch
Title "meoh_pes"
Start  meoh_pes
echo
charge 0
geometry autosym units angstrom
 C     0.0351714     0.00548884     0.0351714
 H     -0.617781     -0.634073     0.667983
 H     0.667983     -0.634073     -0.617781
 H     -0.605139     0.646470     -0.605139
 O     0.839603     0.818768     0.839603
 H     1.38912     0.201564     1.38912
end
ecce_print ecce.out
basis "ao basis" cartesian print
  H library "3-21G"
  O library "3-21G"
  C library "3-21G"
END
dft
  mult 1
  direct
  XC b3lyp
  grid fine
  iterations 99
  mulliken
end
driver
  default
end
python
from nwgeom import *
geom = ''' 
    geometry adjust
        zcoord
            bond 1 5 %f cccc constant
        end
    end 
'''
results=scan_input(geom,[1.398],[3.398],19,'dft',task_optimize)


for i in range(0,len(results)):
    print results[i][0][0],results[i][1]
end

task python

works fine and generates a series of energies for the relaxed PES scan. However, the printed results (via python) are of the form
Scanning NWChem input - results from step  1
 
(-115.07289919583619, [-0.0013504849478134656, 0.018005190622919345, 0.0, 5.579142471789922e-06, -7.262063278778985e-07, 1.369338144779908e-05, 5.579142471789922e-06, -7.262063278778985e-07, -1.369338144779908e-05, -1.8163470062615428e-05, -2.4371896595737352e-06, 0.0, 0.0013598078343054765, -0.018000708280353828, 0.0, -2.3177013348807396e-06, -5.92740248682444e-07, 0.0])
 
Scanning NWChem input - step 2 of 19 

If I clean it up the coordinates look like this:
C	-0.0013504849478134656	 0.018005190622919345	 0.0
H	5.579142471789922e-06	 -7.262063278778985e-07	 1.369338144779908e-05
H	5.579142471789922e-06	 -7.262063278778985e-07	 -1.369338144779908e-05
H	-1.8163470062615428e-05	 -2.4371896595737352e-06	 0.0
O	0.0013598078343054765	 -0.018000708280353828	 0.0
H	-2.3177013348807396e-06	 -5.92740248682444e-07	 0.0


whereas the coordinates are given (in Å) by nwchem as
  No.       Tag          Charge          X              Y              Z
 ---- ---------------- ---------- -------------- -------------- --------------
    1 C                    6.0000    -0.00618375     0.68819272     0.00000000
    2 H                    1.0000    -0.51476781     1.07380349     0.89423057
    3 H                    1.0000    -0.51476781     1.07380349    -0.89423057
    4 H                    1.0000     1.02323844     1.04933621     0.00000000
    5 O                    8.0000     0.10645828    -0.80556622     0.00000000
    6 H                    1.0000    -0.82908766    -1.14932968     0.00000000


The question:
How do I use the coordinates given by the python output? Due to the single-line format they are very easy to extract using sed and gawk, but I can't figure out how to turn them into proper cartesian coordinates with reasonable units. Just to clarify -- I can extract the coordinates as given by scan_input and I can turn them into properly formatted xyz files, but there's something fishy about the magnitudes.

While there are similarities (e.g. look at the z column) the coordinates aren't related by simple scaling. I also looked at the distances between the coordinates, e.g. in the python output the C(1)-H(2) and the O(5)-C(1) distances are
sqrt((-0.0013504849478134656-5.579142471789922e-06)^2+(0.018005190622919345+7.262063278778985e-07)^2+(0-1.369338144779908e-05)^2)=0.018057
sqrt((0.0013598078343054765+0.0013504849478134656)^2+(-0.018000708280353828-0.018005190622919345)^2+(0-0)^2)=0.036108

while in the nwchem coordinates the distances are
sqrt((-0.00618375+0.51476781)^2+(0.68819272-1.07380349)^2+(0-0.89423057)^2)=1.0986
sqrt((0.10645828+0.00618375)^2+(-0.80556622-0.68819272)^2+(0-0)^2)=1.4980


1.0986/0.018057=60.841
1.4980/0.036108=41.487

The python output doesn't seem to be the change in coordinates either.

Am I missing something obvious here? Everything looks fine in ecce and the geometries are correctly given there, but it would be nice to be able to extract it from the nwchem output.

Forum Vet
Gradients
The 18 printed numbers do not correspond to the coordinates but to the gradients, instead.
Python is printing as results the output of task, that is energy plus gradients.
If you want the DFT code to output geometries used at every energy calculation, you can add the
print geometry keyword to the DFT input section, e.g.


dft
 print geometry
end

Gets Around
Thanks, Edo, for the prompt reply.

Yes, I feel a bit stupid since I now see that the values are the same as the ones reported in the "DFT ENERGY GRADIENTS" section.

However, the dft;print geometry;end statement doesn't quite do what I was looking for -- the geometry is printed by default anyway, and adding the print geometry statement only causes it to be printed more often, whereas I was hoping for an easily grep-able final geometry statement for each optimized structure. Looks like the easiest approach will be to write a parser in python instead.

Anyway, thanks for the prompt response!

Edit:
The python parser is here: http://verahill.blogspot.com.au/2013/08/506-extracting-optimized-structures.html

(and see here for the PES scan: http://verahill.blogspot.com.au/2013/08/503-relaxed-pes-scanning-in-nwchem.html)


Forum >> NWChem's corner >> Running NWChem