4
$\begingroup$

As a basic example, I want to build a defect MgO unit cell within ASE. From VASP the input is simple:

Mg4O8
1.00
5.40  0.00  0.00
0.00  5.40  0.00
0.00  0.00  5.40

4 8
Direct
0.10  0.10  0.10
0.50  0.50  0.00
0.50  0.00  0.50
0.00  0.50  0.50
0.25  0.25  0.25
0.25  0.25  0.75
0.25  0.75  0.25
0.25  0.75  0.75
0.75  0.75  0.75
0.75  0.75  0.25
0.75  0.25  0.75
0.75  0.25  0.25 

Looking into the ASE code, I have come across the ase.build.bulk function.

ase.build.bulk(name, crystalstructure=None, a=None, b=None, c=None, *, alpha=None, covera=None, u=None, orthorhombic=False, cubic=False, basis=None)

However, I have to specify the crystal structure, and I have no control over ionic positions.

Is there another way I can create an ASE cell object by providing the unit cell dimensions and the exact coordinates?

$\endgroup$

1 Answer 1

5
$\begingroup$

In ASE, this can be done in a rather straightforward way. You just need to build an ase.Atoms object. For your structure, you can use the following code:

from ase import Atoms

atoms = Atoms(symbols='Mg4O8',
              scaled_positions=[[0.10, 0.10, 0.10],
                                [0.50, 0.50, 0.00],
                                [0.50, 0.00, 0.50],
                                [0.00, 0.50, 0.50],
                                [0.25, 0.25, 0.25],
                                [0.25, 0.25, 0.75],
                                [0.25, 0.75, 0.25],
                                [0.25, 0.75, 0.75],
                                [0.75, 0.75, 0.75],
                                [0.75, 0.75, 0.25],
                                [0.75, 0.25, 0.75],
                                [0.75, 0.25, 0.25]],
              cell=[[5.40, 0.00, 0.00],
                    [0.00, 5.40, 0.00],
                    [0.00, 0.00, 5.40]],
              pbc=True)

Note that if you have Cartesian coordinates instead of fractional coordinates, use positions=[...] instead of scaled_positions=[...]. The coordinates should be written in the same order as your symbols.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .