Skip to content

Type error when subscripting cell array

o = Structure ((atoms: ((symbols: 'O'), (x: 0.) [angstrom], (y: 0.) [angstrom],
               (z: 0.) [angstrom])), (cell: [[12., 0., 0.], [0., 12., 0.], [0., 0., 12.]] [angstrom]))

We want to take the x component of the first cell vector of the first configuration.

This code, which is the most intuitive,

cell = o.cell[0]
print(cell[0][0])

yields

Type error: vre-language/examples/cell_index_error.vm:7:7 --> cell[0][0] <--
Invalid use of index in type Quantity

This is a (less intuitive) work-around:

cells = o.cell:array
cell = cells[0]
print(cell[0][0])
Edited by Ivan Kondov