Is extraction of dipole moments from real-time TDDFT a Python command?


Jump to page 1Prev 16
Forum Vet
Try the following

export PYTHONHOME=/Library/Frameworks/Python.framework/Versions/2.7

export PYTHONVERSION=2.7

Forum Vet
Thanks a lot. This time NWCHEM6.5 has been successfully built, but still there is error perhaps associated with the input file

                    NWChem Python program
---------------------

nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat
nw_rtparse.py -xdipole -py -tkick_y h2o_abs.nwo > y.dat
nw_rtparse.py -xdipole -pz -tkick_z h2o_abs.nwo > z.dat

fft1d -d50 -z -p50000 <x.dat | rotate_fft > xw.dat
fft1d -d50 -z -p50000 <y.dat | rotate_fft > yw.dat
fft1d -d50 -z -p50000 <z.dat | rotate_fft > zw.dat

nw_rtparse -xdipole -tkickx -px | fft1d > xw.dat
nw_rtparse -xdipole -tkicky -py | fft1d > yw.dat
nw_rtparse -xdipole -tkickz -pz | fft1d > zw.dat

paste xw.dat yw.dat zw.dat > sw.dat

gnuplot> plot "sw.dat" u ($1*27.2114) : ($1*abs($3+$7+$11))

------------------------------------------------------------------------
python failed 0
------------------------------------------------------------------------
------------------------------------------------------------------------
current input line :
157: task python
------------------------------------------------------------------------
------------------------------------------------------------------------
This type of error is most commonly associated with calculations not reaching convergence criteria
------------------------------------------------------------------------
For more information see the NWChem manual at http://nwchemgit.github.io/index.php/NWChem_Documentation

  The bash exhibits
File "nwchem.py", line 1
nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat
^
SyntaxError: invalid syntax
 File "nwchem.py-1", line 1
nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat
File "nwchem.py-2", line 1
nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat
^
SyntaxError: ^
SyntaxError: invalid syntax
invalid syntax
0:python failed:Received an Error in Communication
application called MPI_Abort(comm=0x84000004, -1) - process 0

For further details see manual section:                                                                                                                                                                                                                                                                

=======================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= PID 364 RUNNING AT
= EXIT CODE: 255
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES


The input after the real time TDDFT is

python
nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat
nw_rtparse.py -xdipole -py -tkick_y h2o_abs.nwo > y.dat
nw_rtparse.py -xdipole -pz -tkick_z h2o_abs.nwo > z.dat

fft1d -d50 -z -p50000 <x.dat | rotate_fft > xw.dat
fft1d -d50 -z -p50000 <y.dat | rotate_fft > yw.dat
fft1d -d50 -z -p50000 <z.dat | rotate_fft > zw.dat

nw_rtparse -xdipole -tkickx -px | fft1d > xw.dat
nw_rtparse -xdipole -tkicky -py | fft1d > yw.dat
nw_rtparse -xdipole -tkickz -pz | fft1d > zw.dat

paste xw.dat yw.dat zw.dat > sw.dat

gnuplot> plot "sw.dat" u ($1*27.2114) : ($1*abs($3+$7+$11))
end
task python

Clicked A Few Times
All those commands are to be run from the command line, not inside an nwchem input file python block.

fft1d is a MatLab or octave script and only needs the file name as an argument, i.e.,
 octave -q fft1d.m x.dat > xw.dat
...unless you have explicitly set your desktop environment to execute .m files using octave.

There is more information starting at page 159 in the user manual available at
http://nwchemgit.github.io/images/NWChem6.5_Documentation.pdf

-drh

Forum Vet
Thanks a lot for your explanation.

If commands nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat, nw_rtparse.py -xdipole -py -tkick_y h2o_abs.nwo > y.dat, and nw_rtparse.py -xdipole -pz -tkick_z h2o_abs.nwo > z.dat are typed in the bash, the following error message appears although the directory of contrib/parsers is entered:
nw_rtparse.py: command not found

Clicked A Few Times
Quote:Xiongyan21 May 17th 5:13 am
If commands ... are typed in the bash, the following error message appears although the directory of contrib/parsers is entered:
nw_rtparse.py: command not found

If you are already in $NWCHEM_TOP/contrib/parsers, the command becomes:

 ./nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat

Executable files in your current working directory need to be specified with a leading ./,
otherwise the system will only search in the PATH directories.

-drh

Forum Vet
Thanks a lot for your explanation.
The permission of " ./nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat " is denied
in the bash although the directory of contrib/parsers is entered.

Clicked A Few Times
Quote:Xiongyan21 May 17th 7:11 pm
Thanks a lot for your explanation.
The permission of " ./nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat " is denied
in the bash although the directory of contrib/parsers is entered.
This issue is beyond the scope of NWChem.

You must study how to set Linux file permissions or flags, and the different ways of invoking python scripts.

-drh

Forum Vet
Does it mean that the commands cannot be carried out on MAC OS X?

Gets Around
No, it means that the Python file is not marked executable.

Try

python nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat


instead.

Forum Vet
Thanks very much for your guide.

This time the error message becomes

Traceback (most recent call last):
 File "nw_rtparse.py", line 381, in <module>
main()
File "nw_rtparse.py", line 322, in main
raise Exception ('Failed to read in data from file: '+'"'+fname1+'"')
Exception: Failed to read in data from file: "h2o_abs.nwo"
bash-3.2# python nw_rtparse.py -xdipole -px -tkick_x h2o.nwo > x.dat
Traceback (most recent call last):
 File "nw_rtparse.py", line 381, in <module>
main()
File "nw_rtparse.py", line 322, in main
raise Exception ('Failed to read in data from file: '+'"'+fname1+'"')
Exception: Failed to read in data from file: "h2o.nwo"

In fact, my input file is called h2o.nw and h2o_abs.nw is not allowed because of the "_".
The resulting files in nwchem target are water.db, water.movecs, and h2o.log , because the input is based on the file water.nw in QA, and its name is changed.
Furthermore, it seems that there is no file with the extension of nwo produced.
Actually I wish to understand the meaning of ...h2o_abs.nwo >x.dat.

Forum Regular
python nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo > x.dat

"-xdipole" tells the script that you want to extract the dipole moment from the output file
"-px" tells the script that you want to extract the x-component of the dipole moment
"-tkick_x" tells the script that you have set the tag option of the RT-TDDFT input block to kick_x
"h2o_abs.nwo" is the name of your output file
">" is standard Linux for redirecting the output from the script to a file
"x.dat" is the file that you are telling the computer to use for the redirect above

if you used the command

python nw_rtparse.py -xdipole -px -tkick_x h2o_abs.nwo

the output would just print to the screen

You need to modify the options and the name of the output to fit what you actually want/have. So if you based your calculation on the water absorption spectrum example in the QA directory and did not change the tag option from what is in that file and the output file from your calculation is called h2o.log then you would need to execute the command

python nw_rtparse.py -xdipole -px -tkickx h2o.log > x.dat

in order to put the x-component of the dipole into the file x.dat. For the y-component you would do

python nw_rtparse.py -xdipole -py -tkicky h2o.log > y.dat

to put the y-component in the file y.dat, and likewise for the z-component.
As mentioned in another comment above, it would benefit you greatly to do a little reading on basic Linux commands as there are many that can make life much easier when processing the data from your calculations. Mac OS X is a Linux based operating system so almost all Linux commands will work in your terminal.

Best,
Sean

Forum Vet
Thanks very much for your detailed explanation.
Something seems more complicated, because the error also appears in the bash

python nw_rtparse.py -xdipole -px -tkickx h2o.log > x.dat
Traceback (most recent call last):
 File "nw_rtparse.py", line 381, in <module>
main()
File "nw_rtparse.py", line 322, in main
raise Exception ('Failed to read in data from file: '+'"'+fname1+'"')
Exception: Failed to read in data from file: "h2o.log".

The x.dat contains the following
NWChem Real-time TDDFT output parser
  1. ======================================

  2. Runtime options
  3. ---------------
  4. compare = False
  5. target = dipole
  6. tolerance = 1e-05
  7. delim =
  8. polarization = x
  9. header = True
  10. zero = False
  11. tag = kickx
  12. geom = system
  13. spin = closedshell

  14. File 1
  15. ------
  16. Filename: "h2o.log"
Is it complete and correct?

Forum Regular
The script is most likely unable to find any RT-TDDFT output in your file. Have you verified that your calculation successfully produced the RT-TDDFT output? What is the output from the command

grep 'kickx' h2o.log

Forum Vet
Thanks a lot.

grep 'kickx' h2o.log
...
kickx 199.80000 ### Propagation finished ###

"python nw_rtparse.py -xdipole -px -tkickx h2o.log > x.dat" works.
I will try further.

...
  1. File 1
  2. ------
  3. Filename: "h2o.log"
  4. Number of data points: 999
  5. Time range: [0.0: 199.6]

  6. -----------------------------------------
  7. Time [au] dipole [au]
  8. -----------------------------------------

0.0000000000e+00     2.3000096268e-16
...

Forum Vet
Thank you all very much for all your time, considerations and helps for me to put the data from an Nwchem output into a file necessary for further calculations, and I am trying to download and install Octave; nevertheless, for OS X 10.10 Yosemite only Octave server VM installer can be available, and the easiest is the employment of Binary installer for OS X 10.9.1, waiting for a test of whether it is feasible on MAC OS X 10.10.3.


Forum >> NWChem's corner >> Running NWChem
Jump to page 1Prev 16