Problem with nw spectrum.py


Clicked A Few Times
Hello:

I used acetone for a simple test of tddft. When I attempt to obtain a spectrum using the python script, nw_spectrum.py as:

python ./nw_spectrum.py -b0.3 -p5000 -wnm <acetone.log >spectrum.dat

it gives the following error:

Traceback (most recent call last):
 File "./nw_spectrum.py", line 664, in <module>
main()
File "./nw_spectrum.py", line 627, in main
roots = parse_input_tddft (opts)
File "./nw_spectrum.py", line 322, in parse_input_tddft
raise Exception ("Failed to find oscillator strength after looking {0} lines.".format(ioscline))
Exception: Failed to find oscillator strength after looking 10 lines.

I have included the acetone input file below. Would you be willing to run this file and attempt to produce the spectrum wirh
 ./nw_spectrum.py  ?

Thanks so much for helping me with this. I am probably overlooking something very simple.

Kind regards,

Angelo


START acetone
TITLE "B3LYP/6-31G* Acetone"
geometry
zmatrix
c
o 1 r1
x 2 1.0 1 90.0
c 1 r2 2 a1 3 0.0
c 1 r2 2 a1 3 180.0
h 4 r3 1 a2 2 0.0
h 4 r3 1 a2 2 120.0
h 4 r3 1 a2 2 240.0
h 5 r3 1 a2 2 0.0
h 5 r3 1 a2 2 120.0
h 5 r3 1 a2 2 240.0
variables
r1 1.23
r2 1.40
r3 1.10
a1 120.0
a2 109.471
end
end
BASIS
* library 6-31G*
END
DFT
XC B3LYP
END
TDDFT
RPA
NROOTS 20
END
TASK TDDFT ENERGY

Gets Around
It's hard to dig in to this script because reading from stdin blocks normal command line debugger use, but it appears that the script reads all roots that are present correctly and then incorrectly keeps looking for more roots. I haven't figured out exactly why that happens, but in the mean time just add a "break" statement after line 321.

e.g. old code:
...
            while True:
                ioscline = ioscline + 1
                if ioscline >= max_osc_search:
                    raise Exception ("Failed to find oscillator strength after looking {0} lines.".format(ioscline))
...


and new code:
...
            while True:
                ioscline = ioscline + 1
                if ioscline >= max_osc_search:
                    break
                    raise Exception ("Failed to find oscillator strength after looking {0} lines.".format(ioscline))
...


This is just a hack, not a proper fix, but it appears to let the script terminate normally. The resulting plotted data looks ok at first glance.

Clicked A Few Times
It worked!

Thanks so much for looking into this.

Warm regards,

Angelo

Gets Around
Updated script
I have reworked nw_spectrum.py to enable file-based I/O and to provide a better fix for the problem reported in this thread. The problem turns out to be that the script expects only singlet states in the TDDFT output, but by default both singlet and triplet states appear, even though all the triplet data may be "Spin forbidden". I modified the parser to ignore triplet states. It would be fairly easy to make the parser configurable to handle triplet or singlet states, but I didn't do that because I don't know if anything else would need to change for triplets. I would be happy to see this version included in the NWChem distribution if the developers wish.

http://www.sciencemadness.org/cc/nw_spectrum.py


Forum >> NWChem's corner >> General Topics