Avogadro & Crystal Cells

Dear Carsten,

Last night, I slipped in some initial crystal unit cell support. If
an OBUnitCell is present, Avogadro will now render a 2x2x2 crystal.
Obviously, in the near future, we should add a way to specify the
unit cell and number of cells in each of the a, b, and c directions.

Please let me know what you think. I know crystals were on the
Kalzium 4 TODO.

I’m including two files (ZnO and Si) that OB will recognize, as well
as an indication of selecting one atom in the 2 atom Si unit cell.

Cheers,
-Geoff

Hey Geoff,

nice work; i only see a few things to improve:

  • the select-tool doesn’t allow to select a rectangular region
  • the navigate-tool is fooled because when you click on an atom,
    it always considers it to belong to the same molecule even if one clicks on
    another molecule in the crystal. Also, when one clicks on an empty area,
    movement should be done with respect to the center of the crystal, not of
    this particular molecule.
  • more generally, GLWidget::center() and GLWidget::radius() should return the
    approximate center and radius of the crystal, not of one molecule. Camera
    needs that in order to place the camera adequately. That will also
    automatically fix the behavior of the navigate tool when the click is on an
    empty area.

Cheers,
Benoit

On Wednesday 02 May 2007 06:12:33 Geoffrey Hutchison wrote:

Dear Carsten,

Last night, I slipped in some initial crystal unit cell support. If
an OBUnitCell is present, Avogadro will now render a 2x2x2 crystal.
Obviously, in the near future, we should add a way to specify the
unit cell and number of cells in each of the a, b, and c directions.

Please let me know what you think. I know crystals were on the
Kalzium 4 TODO.

I’m including two files (ZnO and Si) that OB will recognize, as well
as an indication of selecting one atom in the 2 atom Si unit cell.

Cheers,
-Geoff

Am Mittwoch, 2. Mai 2007 07:50:35 schrieb Benoît Jacob:

  • the navigate-tool is fooled because when you click on an atom,
    it always considers it to belong to the same molecule even if one clicks on
    another molecule in the crystal. Also, when one clicks on an empty area,
    movement should be done with respect to the center of the crystal, not of
    this particular molecule.
  • more generally, GLWidget::center() and GLWidget::radius() should return
    the approximate center and radius of the crystal, not of one molecule.
    Camera needs that in order to place the camera adequately. That will also
    automatically fix the behavior of the navigate tool when the click is on an
    empty area.

Well, SiO2 for example isn’t a molecule or consists of a million SiO2
molecules. It is a crystalstructure and the bonds Avo is drawing are not like
the regular bonds you know from H2O or Ethanol.
The atoms are not even atoms, they are ions (“charged atoms”).

So I guess we need to reword those thing when Avo is now able to draw crystal
structures…

Carsten

Am Mittwoch, 2. Mai 2007 06:12:33 schrieben Sie:

Dear Carsten,

Last night, I slipped in some initial crystal unit cell support. If
an OBUnitCell is present, Avogadro will now render a 2x2x2 crystal.
Obviously, in the near future, we should add a way to specify the
unit cell and number of cells in each of the a, b, and c directions.

As soon as I can set the translation of the three vectors this would already
be usable in school.
I’d love to see the axes beein drawn. This would look like:

http://www.homepages.ucl.ac.uk/~ucfbanf/morenosite_crystal.jpg

or even better:
http://www.muskingum.edu/~ericlaw/pd_courses/geol301/Crystallography/crystalSystems/system_images/xtalAxis.jpg

Please let me know what you think. I know crystals were on the
Kalzium 4 TODO.

In case you want me to owe you a beer or two, this is teachers dream:

I’m including two files (ZnO and Si) that OB will recognize, as well
as an indication of selecting one atom in the 2 atom Si unit cell.

The funny thing is that Avo isn’t displaying the .fract-file in the
FileOpen-Diallog… ./avogadro file.fract works, though…

Carsten

I should mention that the crystal cell work was done as a test. Can I
add a feature like that without changing the engine class. Yes.
That’s a good sign that the engine API is in good shape.

The other test would be doing some sort of stereo projection (e.g.,
red-green stereo). Offsets (like the crystal cell) are clearly
possible, although the color change is hard.

So perhaps it’s better if the engines have a color object which can
be set and retrieved by the engine. This would also make it possible
to subclass color for other properties (e.g., color by atom type).

On May 2, 2007, at 6:14 AM, Carsten Niehaus wrote:

As soon as I can set the translation of the three vectors this
would already
be usable in school. I’d love to see the axes beein drawn. This
would look like:

Neither should be too hard. It’s just adding an extension. I’ll write
one and Kalzium can adopt it, since you won’t use extensions, right?

I definitely intend to draw axes – also for general x/y/z and a
“regular” molecule. I’ll add that this afternoon if I have time.

In case you want me to owe you a beer or two, this is teachers dream:
http://library.tedankara.k12.tr/chemistry/vol2/allotropy/h76.jpg

Perhaps not for the first release.

The funny thing is that Avo isn’t displaying the .fract-file in the
FileOpen-Diallog… ./avogadro file.fract works, though…

Works for me on Mac.

Am Mittwoch, 2. Mai 2007 07:50:35 schrieb Benoît Jacob:

  • the navigate-tool is fooled because when you click on an atom,
    it always considers it to belong to the same molecule

No, I consider this good behavior. If I click on an atom, it selects
the identical atom in every unit cell. That’s nice for teaching – it
illustrates translational symmetry. The selected atoms really are
the same atom in the same molecule. Later, it’s easy enough to add a
“make a supercell” extension which actually creates new atoms and bonds.

I think it’s what most people expect with crystal software. Do you
agree Carsten?

  • more generally, GLWidget::center() and GLWidget::radius() should
    return
    the approximate center and radius of the crystal, not of one molecule.
    Camera needs that in order to place the camera adequately. That
    will also
    automatically fix the behavior of the navigate tool when the click
    is on an
    empty area.

Fair enough. As mentioned above, I wanted to see if it’s possible to
add features like crystal cells without modifying the engine.

  • the select-tool doesn’t allow to select a rectangular region

Weird. Any thoughts Donald?

Thanks,
-Geoff

On Wed, 2 May 2007, Geoffrey Hutchison wrote:

  • the navigate-tool is fooled because when you click on an atom,
    it always considers it to belong to the same molecule

No, I consider this good behavior. If I click on an atom, it selects
the identical atom in every unit cell. That’s nice for teaching

Hmm. I understand what you’re saying, but here it’s not just identifying
atoms in different molecules in the crystal, it’s actually giving a
particular molecule in the crystal a special role : all rotation/zooming
will be done with respect to (the atoms in) this molecule.

There is also a deeper problem:

Imagine this molecule : A–B

And now this cell, consisting of 2 times this molecule : A–B--A–B

Now I want to zoom to the second A to see how it is surrounded by the B’s.
But the zoom gets it wrong, and zooms to the first A (the
leftmost one). The resulting viewpoint is very different as this A is not
surrounded by B’s, so I can’t observe what I wanted to!

the same atom in the same molecule. Later, it’s easy enough to add a
"make a supercell" extension which actually creates new atoms and bonds.

OK, that would indeed solve that problem.

  • the select-tool doesn’t allow to select a rectangular region

Weird. Any thoughts Donald?

Actually I can explain this one a bit more: when you select a rectangular
region containing twice the same atom but in different cells, this atom’s
selection status gets toggled twice, hence it doesn’t change. More
generally this happens when the selection box contains the same atom an
even number of times.

Cheers,
Benoit

On May 2, 2007, at 9:14 AM, Benoit Jacob wrote:

Hmm. I understand what you’re saying, but here it’s not just
identifying atoms in different molecules in the crystal, it’s
actually giving a particular molecule in the crystal a special
role : all rotation/zooming will be done with respect to (the atoms
in) this molecule.

Right, but isn’t that because the center and radius aren’t set
correctly?

Actually I can explain this one a bit more: when you select a
rectangular region containing twice the same atom but in different
cells, this atom’s selection status gets toggled twice, hence it
doesn’t change. More generally this happens when the selection box
contains the same atom an even number of times.

Aha. Great, that’s obvious now – the rectangle goes through all the
hits, so it sees the same atom multiple times. Just need to add some
unit cell logic then.

Thanks!
-Geoff

On Wed, 2 May 2007, Geoffrey Hutchison wrote:

On May 2, 2007, at 9:14 AM, Benoit Jacob wrote:

Hmm. I understand what you’re saying, but here it’s not just identifying
atoms in different molecules in the crystal, it’s actually giving a
particular molecule in the crystal a special role : all rotation/zooming
will be done with respect to (the atoms in) this molecule.

Right, but isn’t that because the center and radius aren’t set correctly?

The navigate tool has two different behaviors, according to whether an
atom is clicked or not.

In case no atom is clicked, indeed, this is only a matter of setting
correctly the center (IIRC the radius doesn’t matter here, is only used by
the Camera).

But in case an atom is clicked, we are interested in the position of this
atom. Zoom will be done toward this atom, rotation will be done around it.
I think that this is very convenient because it allows to very quickly and
precisely get whatever viewpoint one may wish.

Even the left-button action (lateral translation) uses the data of the
atom position in a nontrivial way : it makes sure that this particular
atom follows exactly the mouse, which is nontrivial because in 3D
different atoms move at different speeds on screen (depending on how far
they are).

This all might sound like nitpicking but I think it helps both comfort and
efficiency.

Cheers,
Benoit

Am Mittwoch, 2. Mai 2007 14:53:01 schrieb Geoffrey Hutchison:

  • the navigate-tool is fooled because when you click on an atom,
    it always considers it to belong to the same molecule

No, I consider this good behavior. If I click on an atom, it selects
the identical atom in every unit cell. That’s nice for teaching – it
illustrates translational symmetry. The selected atoms really are
the same atom in the same molecule. Later, it’s easy enough to add a
"make a supercell" extension which actually creates new atoms and bonds.

I think it’s what most people expect with crystal software. Do you
agree Carsten?

At least I do. But of course it is nice to be able to do both:

  • select an atom so that only that atom is selected / highlighted
  • select all atoms at the same position (for example all atoms at {0,1,0} in
    all cells)

Carsten