Importing Structures
If you have DFT data that are stored in different place/format than the CLEASE database (databases, trajectory files, xyz files, etc.), CLEASE offers the possibility of importing those structures. The only thing that needs to be provided is the initial (e.g. non-relaxed structure where all atoms are on ideal sites) and the total energy associated with it. Note that the total energy can be one of the relaxed structure. To show how this feature can be used we generate an example dataset using ASE's EMT calculator and store them in a trajectory file.
1from ase.calculators.emt import EMT
2from ase.build import bulk
3from ase.io.trajectory import TrajectoryWriter
4writer_initial = TrajectoryWriter("initial.traj")
5writer_final = TrajectoryWriter("final.traj")
6for i in range(10):
7atoms = bulk("Au", a=4.05)*(3, 3, 3)
8writer_initial.write(atoms)
9calc = EMT()
10atoms.calc = calc
11en = atoms.get_potential_energy()
12writer_final.write(atoms)Next, we want to import these data into CLEASE. First, we create the settings
1from clease.structgen import NewStructures
2from clease.settings import CEBulk, Concentration
3settings = CEBulk(
4Concentration(basis_elements=[['Au', 'Cu']]),
5crystalstructure='fcc', a=4.05, db_name="imported.db")
6new_struct = NewStructures(settings)Next, we load our structures
1from ase.io.trajectory import TrajectoryReader
2reader_init = TrajectoryReader("initial.traj")
3reader_final = TrajectoryReader("final.traj")
4for i in range(len(reader_init)):
5initial = reader_init[i]
6final = reader_final[i]
7ini_id = new_struct.insert_structure(init_struct=initial, final_struct=final)Note that it is important that the final structure has energy. In case you have stored the structures in a way that the energy is not added to the structures when it is loaded, add the energy to the final structure via a SinglePointCalculator. Furthermore, if you only have the initial structure (and not the final), you can perfectly fine just replace the final structure with a copy of the initial.