Lattice Orient Vector error

Thanks Steve. Your suggestion did help. However, I am facing strange problems when I am using too many irrational numbers inspite of defining them through the variable command. There are two examples here:

  1. x: 1 0 sqrt(3),
    y: -sqrt(6) 0 sqrt(2) and
    z: 0 -4sqrt(2) 0 --> ERROR: Lattice orient vectors are not orthogonal
    However, when I remove the common factor of sqrt(2) from y, i.e.
    x: 1 0 sqrt(3),
    y: -sqrt(3) 0 1 and
    z: 0 -4
    sqrt(2) 0 --> It works!!
  2. Why does this not work either?
    x: sqrt(2) 1 sqrt(3),
    y: -2*sqrt(3) sqrt(6) sqrt(2) and
    z: -sqrt(2) -4 2sqrt(3) --> ERROR: Lattice orient vectors are not orthogonal
    But they are orthogonal!

I think whenever any two terms of any axis has a common irrational factor, it gives an error even if they are orthogonal and right-handed. Could you please explain what is causing the problem? Thanks a lot for your help.

Kind regards,
Tanushree

Can you post the portion of your input
script that does not work as you expect
(just the lattice commands and variable
definitions). It's possible there is
a round-off issue with these values
and the error check on orthogonality
is too precise.

Steve

(1) This is the first example that didn’t work: x: 1 0 sqrt(3), y: -sqrt(6) 0 sqrt(2) and z: 0 -4*sqrt(2) 0

variable s equal sqrt(3)
variable t equal sqrt(2)
variable f equal -sqrt(6)
variable x equal -4*sqrt(2)

lattice fcc 3.615 orient x 1 0 $s orient y $f 0 $t orient z 0 $x 0

=> ERROR: Lattice orient vectors are not orthogonal

When I just remove the common factor of sqrt(2) from y, it worked: x: 1 0 sqrt(3), y: -sqrt(3) 0 1 and z: 0 -4*sqrt(2) 0

variable s equal sqrt(3)
variable t equal sqrt(2)
variable f equal -sqrt(6)
variable x equal -4*sqrt(2)

lattice fcc 3.615 orient x 1 0 $s orient y -$s 0 1 orient z 0 $x 0

=> Works!!

(2) This is the second problem that doesn’t work: x: sqrt(2) 1 sqrt(3), y: -2*sqrt(3) sqrt(6) sqrt(2) and z: -sqrt(2) -4 2sqrt(3)

variable s equal sqrt(3)
variable t equal sqrt(2)
variable f equal sqrt(6)
variable x equal -2*sqrt(3)

lattice fcc 3.615 orient x $t 1 $s orient y $x $f $t orient z -$t -4 -$x

=> ERROR: Lattice orient vectors are not orthogonal

Thanks,
Tanushree

My bad, I confused the basis vectors (a1,a2,a3) with
the orientation vectors (orient x ... , etc) in my
earlier email.

In LAMMPS the orientation vectors are integer
values, corresponding to crystal directions, like the [012]
or [111] direction. So the orient xyz arguments
should all be +/- integers. Thus there is no round-off
issue. See the doc page for more details

If you really want to orient your unit cell in a sqrt(3)
direction (I don't think you do), then you can do that
with a1,a2,a3.

Steve

Actually I need the sqrt(3) factors in my lattice because I am trying to create an hcp crystal and when we convert from the Hexagonal coordinate system to the Orthogonal one, there are irrational factors involved.

I need to rotate my hcp crystal such that I have three directions that are orthogonal to each other. I realize we can’t use orient for this task so, I am using lattice custom a1, a2 and a3. Now, my question is will the basis vectors be the same for hcp crystals irrespective of the definition of the new a1, a2 and a3 that I am defining? In fcc, it is much simpler because even if I rotate my crystal, I can simply use orient command (as the directions are integer values) and it takes care of the basis atoms by itself.

The hcp directions that I am interested in are pretty complicated. They are x: [1 0 -1 1], y: [8 0 -8 -9] and z: [-1 2 -1 0] in the hexagonal coordinate system which when converted to the orthogonal system becomes x: [3 sqrt(3) 4sqrt(2/3)], y: [sqrt(6) sqrt(2) -3] and z: [-3 3sqrt(3) 0].

So, the command I am using is:

variable x1 equal 3
variable x2 equal sqrt(3)
variable x3 equal 4sqrt(2/3)
variable y1 equal sqrt(6)
variable y2 equal sqrt(6)
variable y3 equal -3
variable z1 equal -3
variable z2 equal 3
sqrt(3)
variable z3 equal 0

lattice custom 3.184215 a1 {x1} {x2} {x3} a2 {y1} {y2} {y3} a3 {z1} {z2} ${z3} basis 0.0 0.0 0.0 basis 0.5 0.5 0 basis 0.5 0.83333333 0.5 basis 0 0.33333333 0.5

The code runs without any error but I think the crystal generated is incorrect. I think these values of the basis are for the normal [0 0 0 1] (hexagonal) i.e. <0 0 1> directions. Really appreciate all your help.

Warm regards,
Tanushree

I don't know. All of this is just geometry as far as LAMMPS is
concerned. You can describe an hcp lattice with an orthogonal
unit cell will 4 basis atoms as LAMMPS does. To convert
from some other representation, you just need to do
the math correctly.

I suggest you calculate some atom coords by hand in the
2 different basis sets you are using, i.e. (a,b,c) edge vectors versus
(a',b',c') vectors of your 2 unit cells, and verify you end
up with the same atom coords.

Steve