Error: Python input parse with "spring bond" constraint


Click here for full thread
Clicked A Few Times
More information
I've been searching around for a way to make the rtdb stay in a valid state after changing the spring constraint.

Adding a constraint in normal NWChem input leaves the rtdb in a valid state. Additionally, adding a constraint on the same two atoms later (whether in Python or in normal NWChem input) doesn't remove the constraint then re-add it, instead it just overwrites the constraint that's already there. So my solution was to add the constraint once before the python block using normal NWChem input, then in the Python block only to modify the existing constraint. This does not work though.

echo
title "Relax Carbon Chain"                                                                                             

permanent_dir ./perm
scratch_dir ./scratch

start carbon-chain-force

geometry units angstrom noautoz
    load carbon-chain-relaxed.xyz
end

basis
    * library 6-31g**
end

dft
    iterations 100
    xc b3lyp
    direct                                                                                                             
end

task dft optimize

constraints
    spring bond 1 12 0.00000642 184.78
end

python
    if (ga_nodeid() == 0):
        print "@@Marker1\n"

    task_optimize('dft')
    if (ga_nodeid() == 0):
        print "@@Marker2\n"

    input_parse('constraints; spring bond 1 12 0.00000642 369.57; end\n')
    if (ga_nodeid() == 0):
        print "@@Marker3\n"

    task_optimize('dft')
    if (ga_nodeid() == 0):
        print "@@Marker4\n"
end
task python


All four markers are reached, and the calculation ends successfully.

However, the new spring r0 is never actually applied. Looking through the output, it reads in the constraint information after Marker2 is reached, and looks like it's applying it. But in the optimization right after that, when it goes to add the spring energy to the DFT energy, it is still using the old spring (with r0 of 184.78). So it seems that input passed through "input_parse" is not treated the same as input passed in through the NWChem file. Changing the spring constant instead of the spring rest-length also doesn't seem to take.

For now I am relying on using a BASH script to unravel all the Python logic (looping over different spring lengths) to the NWChem input before running NWChem. But I would like to use the Python interface to dynamically change the initial spring length as it goes (in search of getting close to a list of specific forces). Also using the Python interface I can output the exact data I need as I go to a file, instead of processing the NWChem output afterward.