How to convert a CIF file to Exciting's input.xml rapidly?

Greetings!
I am a researcher aiming to use Exciting to calculate second harmonic generation based on my experimental crystal data. However, my unit cell contains hundreds of atoms, making it difficult to write input files for Exciting manually. Are there any pre-processing codes to convert the cif format to input.xml format rapidly? I would appreciate it if anyone could offer help!
Best wishes!

Hi Ming-Yu,

Yes, you can using python.

Use Pymatgen or ASE to convert CIF to an ASE Atoms object.
Then use excitingtools to generate the exciting input.

excitingtools is included with exciting in: tools/exciting_tools (we currently recommend this over the pypi version).

As an example:

import ase
from pymatgen.io.cif import CifParser
from excitingtools import ExcitingGroundStateInput, ExcitingStructure, ExcitingInputXML

def cif_to_ase_atoms(file: str) -> ase.atoms.Atoms:
    """Convert CIF to ASE Atoms.

    ASE's read_cif() is an alternative but pymatgen always handles
    CIFs from the materials project with no problems
    :param file:
    :return:
    """
    structure = CifParser(file).get_structures()[0]
    atoms = ase.atoms.Atoms(numbers=structure.atomic_numbers,
                            cell=structure.lattice.matrix,
                            scaled_positions=structure.frac_coords,
                            pbc=True)
    return atoms

    title = 'add_me'
    atoms = cif_to_ase_atoms('file.cif')
    ground_state_options = {'do': 'fromscratch',
                            'rgkmax': 8.0,
                            'ngridk': [2, 2, 2],
                            'xctype': "GGA_PBE_SOL",
                            'epsengy': 1.e-6,
                            'gmaxvr': 16.0,
                            'deband': 0.001,
                            'maxscl': 30,
                            }

    ground_state = ExcitingGroundStateInput(**ground_state_options)
    structure = ExcitingStructure(atoms, species_properties=species_properties)
    input = ExcitingInputXML(structure=structure, title=title, groundstate=ground_state)
    input_str = input.to_xml_str()
    print(input_str)

But to taper your expectations, there is no way you’ll be able to run a ground state with hundreds of atoms with exciting. It is simply too expensive.

Cheers,
Alex

Thank you, Alex! Your reply helps a lot.

Besides, thank you for reminding me the calculation consumption thing. But I have seen there are already some published articles using Exciting codes for SHG calculations:
https://doi.org/10.1038/s41467-023-38590-7
My system is basically a bit larger, so I am still deciding to give it a try. SHG calculation is increasingly important for my research.

Thank you again!
Ming-Yu Guo

I just realised you’re probably using the release version of exciting. That version of excitingtools has some bugs in relating to units. As such, I updated PyPi - you should get the latest version from there

From now, each time we update the version in our development repository, it will automatically deploy to PyPi.

W.r.t. the paper, I had a quick skim. They also use VASP. My assumption is that exciting is used for some property that can be computed using a smaller cell.

If however you still wish to try exciting for > 100 atoms, and have access to a large GPU, I recommend trying out exciting+sirius. I would expect ~ 200 atoms to be possible. The catch being that it’s still developmental, and the build is difficult. See exciting/INSTALL.md “Compiling with exciting with SIRIUS” for more info, and ask if you have any questions.

Cheers,
Alex

Thank you very much! I finally succeeded to run Exciting code for my structure.

Best regards,
Ming-Yu Guo

Hello @Scat, I am currently in the process of simulating a structure consisting of approximately 120 atoms. Could you please share your approach to successfully running your simulations? Did you follow the suggestions provided by @abuccheri?
P.S.: I am new to the EXCITING code and would greatly appreciate your insights.