This file is indexed.

/usr/share/python-ase/doc/ase/lattice.rst is in python-ase-doc 3.12.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
.. _general-crystal-section:

General crystal structures and surfaces
=======================================

.. module:: ase.lattice

Modules for creating crystal structures are found in the module
:mod:`ase.lattice`.  Most Bravais lattices are implemented, as
are a few important lattices with a basis.  The modules can create
lattices with any orientation (see below).  These modules can be used
to create surfaces with any crystal structure and any orientation by
later adding a vacuum layer with :func:`ase.build.add_vacuum`.


Example
-------

To set up a slab of FCC copper with the [1,-1,0] direction along the
x-axis, [1,1,-2] along the y-axis and [1,1,1] along the z-axis, use::

  from ase.lattice.cubic import FaceCenteredCubic
  atoms = FaceCenteredCubic(directions=[[1,-1,0], [1,1,-2], [1,1,1]],
                            size=(2,2,3), symbol='Cu', pbc=(1,1,0))

The minimal unit cell is repeated 2*2*3 times.  The lattice constant
is taken from the database of lattice constants in :mod:`ase.data` module.
There are periodic boundary conditions along the *x* and *y* axis, but
free boundary conditions along the *z* axis. Since the three directions
are perpendicular, a (111) surface is created.

To set up a slab of BCC copper with [100] along the first axis, [010]
along the second axis, and [111] along the third axis use::

  from ase.lattice.cubic import BodyCenteredCubic
  atoms = BodyCenteredCubic(directions=[[1,0,0], [0,1,0], [1,1,1]],
                            size=(2,2,3), symbol='Cu', pbc=(1,1,0),
                            latticeconstant=4.0)

Since BCC is not the natural crystal structure for Cu, a lattice
constant has to be specified.  Note that since the repeat directions
of the unit cell are not orthogonal, the Miller indices of the
surfaces will *not* be the same as the Miller indices of the axes.
The indices of the surfaces in this example will be (1,0,-1), (0,1,-1)
and (0,0,1).


Available crystal lattices
--------------------------

The following modules are currently available (the * mark lattices
with a basis):

* ``lattice.cubic``

  - ``SimpleCubic`` 
  - ``FaceCenteredCubic``
  - ``BodyCenteredCubic``
  - ``Diamond`` (*)

* ``lattice.tetragonal``

  - ``SimpleTetragonal``
  - ``CenteredTetragonal``

* ``lattice.orthorhombic``

  - ``SimpleOrthorhombic``
  - ``BaseCenteredOrthorhombic``
  - ``FaceCenteredOrthorhombic``
  - ``BodyCenteredOrthorhombic``

* ``lattice.monoclinic``

  - ``SimpleMonoclinic``
  - ``BaseCenteredMonoclinic``

* ``lattice.triclinic``

  - ``Triclinic``

* ``lattice.hexagonal``

  - ``Hexagonal``
  - ``HexagonalClosedPacked`` (*)
  - ``Graphite`` (*)

* The rhombohedral (or trigonal) lattices are not implemented.  They
  will be implemented when the need arises (and if somebody can tell
  us the precise definition of the 4-number Miller indices - we only
  know that they are "almost the same as in hexagonal lattices").

* ``lattice.compounds``

  Lattices with more than one element.  These are mainly intended as
  examples allowing you to define new such lattices.  Currently, the
  following are defined

  - ``B1`` = ``NaCl`` = ``Rocksalt``
  - ``B2`` = ``CsCl``
  - ``B3`` = ``ZnS`` = ``Zincblende``
  - ``L1_2`` = ``AuCu3``
  - ``L1_0`` = ``AuCu``


Usage
-----

The lattice objects are called with a number of arguments specifying
e.g. the size and orientation of the lattice.  All arguments should be
given as named arguments.  At a minimum the ``symbol`` argument must
be specified.


``symbol``
  The element, specified by the atomic number (an integer) or by the
  atomic symbol (i.e. 'Au').  For compounds, a tuple or list of
  elements should be given.  This argument is mandatory.

``directions`` and/or ``miller``: 
  Specifies the orientation of the
  lattice as the Miller indices of the three basis vectors of the
  supercell (``directions=...``) and/or as the Miller indices of the
  three surfaces (``miller=...``).  Normally, one will specify either
  three directions or three surfaces, but any combination that is both
  complete and consistent is allowed, e.g. two directions and two
  surface miller indices (this example is slightly redundant, and
  consistency will be checked).  If only some directions/miller
  indices are specified, the remaining should be given as ``None``.
  If you intend to generate a specific surface, and prefer to specify
  the miller indices of the unit cell basis (``directions=...``), it
  is a good idea to give the desired Miller index of the surface as
  well to allow the module to test for consistency.  Example:

  >>> atoms = BodyCenteredCubic(directions=[[1,-1,0],[1,1,-1],[0,0,1]],
  ...                           miller=[None, None, [1,1,2]], ...)

  If neither ``directions`` nor ``miller`` are specified, the default
  is ``directions=[[1,0,0], [0,1,0], [0,0,1]]``.

``size``:
  A tuple of three numbers, defining how many times the fundamental
  repeat unit is repeated. Default: (1,1,1).  Be aware that if
  high-index directions are specified, the fundamental repeat unit may
  be large.

``latticeconstant``:
  The lattice constant.  If no lattice constant is
  specified, one is extracted from ASE.ChemicalElements provided that
  the element actually has the crystal structure you are creating.
  Depending on the crystal structure, there will be more than one
  lattice constant, and they are specified by giving a dictionary or a
  tuple (a scalar for cubic lattices).  Distances are given in
  Angstrom, angles in degrees. 

  =============  ===================  ========================================
  Structure      Lattice constants    Dictionary-keys
  =============  ===================  ========================================
  Cubic          a                    'a'
  Tetragonal     (a, c)               'a', 'c' or 'c/a'
  Orthorhombic   (a, b, c)            'a', 'b' or 'b/a', 'c' or 'c/a'
  Triclinic      (a, b, c, `\alpha`,  'a', 'b' or 'b/a', 'c' or
                 `\beta`, `\gamma`)   'c/a', 'alpha', 'beta', 'gamma'
  Monoclinic     (a, b, c, alpha)     'a', 'b' or 'b/a', 'c' or 'c/a', 'alpha'
  Hexagonal      (a, c)               'a', 'c' or 'c/a'
  =============  ===================  ========================================
  
  Example:

  >>> atoms = Monoclinic( ... , latticeconstant={'a': 3.06, 
  ...     'b/a': 0.95, 'c/a': 1.07, 'alpha': 74})


``debug``:
  Controls the amount of information printed.  0: no info is printed.
  1 (the default): The indices of surfaces and unit cell vectors are
  printed.  2: Debugging info is printed.


Defining new lattices
---------------------

Often, there is a need for new lattices - either because an element
crystallizes in a lattice that is not a simple Bravais lattice, or
because you need to work with a compound or an ordered alloy.

All the lattice generating objects are instances of a class, you
generate new lattices by deriving a new class and instantiating it.
This is best explained by an example.  The diamond lattice is two
interlacing FCC lattices, so it can be seen as a face-centered cubic
lattice with a two-atom basis.  The Diamond object could be defined like
this::

  from ase.lattice.cubic import FaceCenteredCubicFactory
  class DiamondFactory(FaceCenteredCubicFactory):
      """A factory for creating diamond lattices."""
      xtal_name = 'diamond'
      bravais_basis = [[0, 0, 0], [0.25, 0.25, 0.25]]
    
  Diamond = DiamondFactory()


Lattices with more than one element
```````````````````````````````````

Lattices with more than one element is made in the same way.  A new
attribute, ``element_basis``, is added, giving which atoms in the
basis are which element.  If there are four atoms in the basis, and
element_basis is (0,0,1,0), then the first, second and fourth atoms
are one element, and the third is the other element.  As an example,
the AuCu3 structure (also known as `\mathrm{L}1_2`) is defined as::

  # The L1_2 structure is "based on FCC", but is really simple cubic
  # with a basis.
  class AuCu3Factory(SimpleCubicFactory):
      "A factory for creating AuCu3 (L1_2) lattices."
      bravais_basis = [[0, 0, 0], [0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]]
      element_basis = (0, 1, 1, 1)

  AuCu3 = L1_2 = AuCu3Factory()

Sometimes, more than one crystal structure can be used to define the
crystal structure, for example the Rocksalt structure is two
interpenetrating FCC lattices, one with one kind of atoms and one with
another.  It would be tempting to define it as

::

  class NaClFactory(FaceCenteredCubicFactory):
      "A factory for creating NaCl (B1, Rocksalt) lattices."

      bravais_basis = [[0, 0, 0], [0.5, 0.5, 0.5]]
      element_basis = (0, 1)


  B1 = NaCl = Rocksalt = NaClFactory()

but if this is used to define a finite system, one surface would be
covered with one type of atoms, and the opposite surface with the
other.  To maintain the stochiometry of the surfaces, it is better to
use the simple cubic lattice with a larger basis::

  # To prevent a layer of element one on one side, and a layer of
  # element two on the other side, NaCl is based on SimpleCubic instead
  # of on FaceCenteredCubic
  class NaClFactory(SimpleCubicFactory):
      "A factory for creating NaCl (B1, Rocksalt) lattices."

      bravais_basis = [[0, 0, 0], [0, 0, 0.5], [0, 0.5, 0], [0, 0.5, 0.5],
                       [0.5, 0, 0], [0.5, 0, 0.5], [0.5, 0.5, 0],
                       [0.5, 0.5, 0.5]]
      element_basis = (0, 1, 1, 0, 1, 0, 0, 1)


  B1 = NaCl = Rocksalt = NaClFactory()

More examples can be found in the file :git:`ase/lattice/compounds.py`.