Thanks very much for your prompt assistance, Noel and Geoffrey!

This has solved my problem.

Take care,
Stephen


________________________________
From: Geoffrey Hutchison <[email protected]>
Sent: Tuesday, February 4, 2020 12:55 PM
To: Shiring, Stephen B <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [Open Babel] Python: Getting atomic forces after a FF optimization

I’m writing a Python script to screen a bunch of molecules, and for part of 
that I would like to read in and optimize a geometry using OpenBabel’s 
ForceField methods subjected to a couple constraints. I would like to obtain 
the resulting forces for each atom from the optimization to use as an initial 
cut off.

You definitely want to use Open Babel 3.0, e.g.

        success = ff.Setup(mol.OBMol)
        if not success:
            ff = pybel._forcefields["uff"]
            success = ff.Setup(mol.OBMol)
            if not success:
                sys.exit("Cannot set up forcefield")

        ff.ConjugateGradients(100, 1.0e-3)

        ff.GetCoordinates(mol.OBMol)
        gradients = ff.GetGradientPtr()
        print(type(gradients))

        for atom in mol.atoms:
            grad = ff.GetGradient(atom.OBAtom)
            print(grad.GetX(), grad.GetY(), grad.GetZ())

Hope that helps,
-Geoff
_______________________________________________
OpenBabel-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to