Avogadro is handling of coordinates ok?

Hi,

I encounter unexpected behaviour of Avogadro when working on an
extension plugin. I observe an inconsistency in how Avogadro
handles atomic coordinates depending on the origin of the data.
This is what I do in my plugin:

================================

  1. "Download step: I copy the atomic positions from Avogadro to the plugin.
    (By first creating an instance OpenBabel::OBMol from an
    Avogadro::Molecule, and then using the access functions of
    OpenBabel::OBMol and OpenBabel::OBAtom.)

  2. In the plugin, I modify the coordinates of the atoms (MD, minimisation)

  3. Upload step:
    I copy back the -modified- coordinates of the molecule into Avogadro.
    (By using the Avogadro::Molecule access function setAtomPos:

       avMol->setAtomPos( i, vec3d );
    

    where i runs over all atoms, and vec3d is an instance of
    Eigen::Vector3d containing the modified coordinates of atom i.
    When the coordinates are copied over, I do a avmol->update().
    =================================

TO check if things are working as expected I output the atomic
coordinates in the plugin to the screen, where I compare them to the
coordinates as displayed in the build->Cartesian Editor. It turns out
that the download step always copies the coordinates correctly from the
Avogadro host to the plugin. The upload step, howver, fails in certain
situations.

Here is my problem: depending on how I have created the molecule (in
Avogadro, the procudure above succeeds or fails.

  • When I have obtained the molecule in Avogadro by loading it from a
    file (in my case, a Sybyl mol2 file) there is no problem.
    the coordinates in the plugin are always identical to the ones in
    Avogadro via the above mechanism.

  • When I create a molecule interactively, the above procedure shows in
    the upload step large differences.
    There is a subtlety here which may point to the a clue:

    If I create ethane (C2H6) by first making CH4 and the augmenting to
    form C2H6, the upload step goes wrong.
    However, If I create C2H6 in one go by pressing the mouse down, drag
    the mouse and then release the mouse, the upload step is ok again.

Is there someone who can explain me what cold be going on here? Is there
a difference (in Avogadro) between a molecule that is created
interactively and one that is loaded from file?

Kind Regards,
Bertwim

On Tue, Jan 26, 2010 at 5:45 AM, B.W.H. van Beest bwvb@xs4all.nl wrote:

Hi,

I encounter unexpected behaviour of Avogadro when working on an
extension plugin. I observe an inconsistency in how Avogadro
handles atomic coordinates depending on the origin of the data.
This is what I do in my plugin:

What is Avogadro doing that is wrong? Is it moving the wrong atoms to
correct coordinates, eg A should be at (0,0,0) and B at (1,1,1), but A
is a (1,1,1) and B is at (0,0,0)? Or is it moving A to (10,2,37) and B
to (-12,14,-6)? WIthout knowing what Avo is doing wrong it is hard to
say what’s happening.

Dave

Yes, I realise it is hard to imagine

Molecule read from file: Correct behaviour.

  1. Atom A (x,y,z) is copied to extension, where is has the same
    coordinates (x,y,z)
  2. In the extension, atom A changes its position, e.g. due to a MD time
    step or minimisation: (x,y,z) → (x’, y’, z’)
  3. Atom coordinates are copied back to Avogadro: The same (x’,y’z’)
    are now seen in the cartesian editor.

Molecule built interactively: Wrong behaviour:
(e.g. C10H22 is “clicked together”, by clicking on the canvas to and
connecting the fragments. Avogadro automatically adds the hydrogens.)

  1. As above: coordinates are copied ok.
  2. As above, (x,y,z) → (x’, y’, z’) in the extension.
  3. Atom coordinates are copied back from extension to Avogadro.
    However, I now see
    different cooordinates, say (x", y", z") in the cartesion editor.
    There is no swapping of atoms, just different coordinates.

NOTE: on further inspection it seems that the atoms in the fragment
that is created first are ok! The others are different.
(some a few percent, others are way-off.
Perhaps this last NOTE offers a clou?

Regards,
Bertwim

David Lonie wrote:

On Tue, Jan 26, 2010 at 5:45 AM, B.W.H. van Beest bwvb@xs4all.nl wrote:

Hi,

I encounter unexpected behaviour of Avogadro when working on an
extension plugin. I observe an inconsistency in how Avogadro
handles atomic coordinates depending on the origin of the data.
This is what I do in my plugin:

What is Avogadro doing that is wrong? Is it moving the wrong atoms to
correct coordinates, eg A should be at (0,0,0) and B at (1,1,1), but A
is a (1,1,1) and B is at (0,0,0)? Or is it moving A to (10,2,37) and B
to (-12,14,-6)? WIthout knowing what Avo is doing wrong it is hard to
say what’s happening.

Dave