Aiida-vibroscopy: Raman in magnetic semiconductors

Hi @bastonero

I am working on Raman of magnetic semiconductor. It is complaining about magnetization in input but I have put in overrides.yaml file (please see below).

I got this error:


(aiidaENV) rkarkee@ch-fe2:/lustre/scratch5/rkarkee> verdi process report 2378
2024-03-20 11:30:21 [1191 | REPORT]: [2378|IRamanSpectraWorkChain|run_spectra]: submitting `HarmonicWorkChain` <PK=2380>
2024-03-20 11:30:23 [1192 | REPORT]:   [2380|HarmonicWorkChain|run_phonon]: submitting `PhononWorkChain` <PK=2383>
2024-03-20 11:30:24 [1193 | REPORT]:   [2380|HarmonicWorkChain|run_dielectric]: submitting `DielectricWorkChain` <PK=2384>
2024-03-20 11:30:24 [1194 | REPORT]:     [2384|DielectricWorkChain|setup]: system is treated to be magnetic because `nspin != 1` in `scf.pw.parameters` input.
2024-03-20 11:30:24 [1195 | REPORT]:     [2384|DielectricWorkChain|on_except]: Traceback (most recent call last):
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/plumpy/process_states.py", line 228, in execute
    result = self.run_fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/aiida/engine/processes/workchains/workchain.py", line 296, in run
    return self._do_step()
           ^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/aiida/engine/processes/workchains/workchain.py", line 313, in _do_step
    finished, stepper_result = self._stepper.step()
                               ^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/plumpy/workchains.py", line 295, in step
    finished, result = self._child_stepper.step()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/plumpy/workchains.py", line 246, in step
    return True, self._fn(self._workchain)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/aiida_vibroscopy/workflows/dielectric/base.py", line 377, in setup
    raise NameError('Missing `*_magnetization` input in `scf.pw.parameters` while `nspin == 2`.')
NameError: Missing `*_magnetization` input in `scf.pw.parameters` while `nspin == 2`.

My inputs are:
overrides.yaml as:

clean_workdir: true # whether to clean the working directiories
dielectric:
  clean_workdir: true
  kpoints_parallel_distance: 0.2 # kpoints distance in Angstrom^-1 to sample the BZ parallel to the electric field. If used, it should help in converging faster the final results
  property: raman
  # central_difference: # if you know what you are doing, custom numerical derivatives with respect to electric field
  #   accuracy: 2
  #   electric_field_step: 0.0005
  scf:
    pseudo_family: CrSBr
    kpoints_distance: 0.4 # kpoints distance in Angstrom^-1 to sample the BZ
    kpoints_force_parity: false
    max_iterations: 20
    pw:
      metadata:
        options:
          max_wallclock_seconds: 57600
          resources:
            num_machines: 1
            num_mpiprocs_per_machine: 256
              #queue_name: standard # for SLURM
          # account: account_name # for SLURM, also for project etc
          withmpi: true
      settings:
        cmdline: ['-pd', '.true.']
      parameters:
        ELECTRONS:
          conv_thr: 2.0e-12
          electron_maxstep: 100
          mixing_beta: 0.3
        SYSTEM:
          ecutrho: 600.0
          ecutwfc: 100.0
          vdw_corr: Grimme-D2
          occupations: smearing
          degauss: 0.0002
          nspin: 2
          starting_magnetization(1): 2




  settings:
    sleep_submission_time: 1.0
phonon:
  clean_workdir: true
  displacement_generator:
    distance: 0.005 # atomic displacements for phonon calculation, in Angstrom
  scf:
    pseudo_family: CrSBr
    kpoints_distance: 0.15 # kpoints distance in Angstrom^-1 to sample the BZ
    kpoints_force_parity: false
    max_iterations: 20
    pw:
      metadata:
        options:
          max_wallclock_seconds: 57600
          resources:
            num_machines: 1
            num_mpiprocs_per_machine: 256
          # queue_name: partition_name # for SLURM
          # account: account_name # for SLURM, also for project etc
          withmpi: true
      settings:
        cmdline: ['-pd', '.true.']
        # gamma_only: True # to use only if KpointsData has only a mesh 1 1 1 0 0 0 (i.e. Gamma not shifted)
      parameters:
        ELECTRONS:
          conv_thr: 2.0e-12
          electron_maxstep: 80
          mixing_beta: 0.3
        SYSTEM:

          ecutwfc: 100.0
          ecutrho: 600

          vdw_corr: Grimme-D2
          occupations: smearing
          degauss: 0.0002
          nspin: 2
          starting_magnetization(1): 2




  settings:
    sleep_submission_time: 1.0 # waiting time in seconds between different submission of SCF calculation. Recommended to be at least 1 second, to not overload.
settings:
  run_parallel: true
  use_primitive_cell: false
symmetry:
  distinguish_kinds: false
  is_symmetry: true
  symprec: 1.0e-05

and submitted through:

# -*- coding: utf-8 -*-
# pylint: disable=line-too-long,wildcard-import,pointless-string-statement,unused-wildcard-import
"""Submit an IRamanSpectraWorkChain via the get_builder_from_protocol using the overrides."""
from pathlib import Path

from aiida import load_profile
from aiida.engine import submit
from aiida.orm import *
from aiida_quantumespresso.common.types import ElectronicType

from aiida_vibroscopy.workflows.spectra.iraman import IRamanSpectraWorkChain

load_profile()

# =============================== INPUTS =============================== #
# Please, change the following inputs.
mesh = [[10, 8, 5], [0.5, 0.5, 0.5]]
pseudo_family_name='CrSBr'
pw_code_label = 'qe-7.3@newhpc'
structure_id = 1681  # PK or UUID of your AiiDA StructureData
protocol = 'fast'  # also 'moderate' and 'precise'; 'moderate' should be good enough in general
overrides_filepath = './overrides_crsbr.yaml'  # should be a path, e.g. /path/to/overrides.yaml. Format is YAML
# Consult the documentation for HOW-TO for how to use properly the overrides.
# !!!!! FOR FULL INPUT NESTED STRUCTURE: https://aiida-vibroscopy.readthedocs.io/en/latest/topics/workflows/spectra/iraman.html
# You can follow the input structure provided on the website to fill further the overrides.
# ====================================================================== #
# If you don't have a StructureData, but you have a CIF or XYZ, or similar, file
# you can import your structure uncommenting the following:
# from ase.io import read
# atoms = read('/path/to/file.cif')
# structure = StructureData(ase=atoms)
# structure.store()
# structure_id =  structure.pk
# print(f"Your structure has been stored in the database with PK={structure_id}")


def main():
    """Submit an IRamanSpectraWorkChain calculation."""
    code = load_code(pw_code_label)
    structure = load_node(structure_id)
    kwargs = {'electronic_type': ElectronicType.INSULATOR}

    kpoints = KpointsData()
    kpoints.set_kpoints_mesh(mesh[0], mesh[1])

    #pseudo_family = load_group(pseudo_family_name)
    #pseudos = pseudo_family.get_pseudos(structure=structure)

    builder = IRamanSpectraWorkChain.get_builder_from_protocol(
        code=code,
        structure=structure,
        protocol=protocol,
        overrides=Path(overrides_filepath),
        **kwargs,
    )

    builder.dielectric.scf.kpoints = kpoints
    builder.dielectric.pop('kpoints_parallel_distance', None)
    builder.dielectric.scf.pop('kpoints_distance', None)
    builder.phonon.scf.kpoints = kpoints

    #builder.dielectric.scf.pw.pseudos = pseudos
    #builder.phonon.scf.pw.pseudos = pseudos

    calc=submit(builder)

    print(f'Submitted IRamanSpectraWorkChain with PK={calc.pk} and UUID={calc.uuid}')
    print('Register *at least* the PK number, e.g. in you submit script.')
    print('You can monitor the status of your calculation with the following commands:')
    print('  * verdi process status PK')
    print('  * verdi process list -L IRamanSpectraWorkChain # list all running IRamanSpectraWorkChain')
    print(
        '  * verdi process list -ap1 -L IRamanSpectraWorkChain # list all IRamanSpectraWorkChain submitted in the previous 1 day'
    )
    print('If the WorkChain finishes with exit code 0, then you can inspect the outputs and post-process the data.')
    print('Use the command')
    print('  * verdi process show PK')
    print('To show further information about your WorkChain. When finished, you should see some outputs.')
    print('The main output can be accessed via `load_node(PK).outputs.vibrational_data.numerical_accuracy_*`.')
    print('You have to complete the remaning `*`, which depends upond the accuracy of the calculation.')
    print('See also the documentation and the reference paper for further details.')


if __name__ == '__main__':
    """Run script."""
    main()

Please, post questions unrelated to the manuscript on discourse.

This is discourse, isnt it?

I am seeing this post here:
https://aiida.discourse.group/latest

I am sorry, I thought your message was on the other thread of the email exchange we had.

In aiida-quantumespresso it is recommended to set such variables in a different manner, which should make your life easier as well. For such quantity, simply write

starting_magnetization: {β€˜Cr’: 0.5, …}

Just a side note for the expectations: Raman intensities for ferromagnetic structures cannot be computed with the current technique. You can only do structures with 0 net magnetization. You can still get the peak positions though via the PhononWorkChain.

Hi @bastonero

Would the same input works for PhononWorkChain? Because in IRamanSpectraWorkChain also has PhononWorkChain, so just wondering. If not, how can I achieve the peak positions (and how do I access it) from PhononWorkChain? Anything I need to change in submit.py or overrides.yaml?

So the IRamanWorkChain does not work if the magnetic material is semiconductor?

Best
Rijan

Regarding general usage of overrides, please have a look here: Protocols and overrides β€” aiida-vibroscopy 1.1.0 documentation
Let me know if you found it useful (in general is very simple, as you mentioned the workflows call each other, so it is simple to understand the input structure).

Regarding IRamanSpectraWorkChain: magnetic semiconductors work, but only antiferromagnetic/paramagnetic, NOT ferromagnetic.

The PhononWorkChain will give you a PhonopyData, which is very similar to the VibrationalData, but w/o the Raman tensors, but with the force constants. You can then you the following to get peak positions:

from aiida_vibroscopy.calculations.spectra_utils import compute_active_modes

node = load_node(PK)  # PK of the PhononWorkChain
phonopy_data = node.outputs.phonopy_data
phonopy_instance = phonopy_data.get_phonopy_instance() # you can do this also for VibrationalData
frequencies, _, labels = compute_active_modes(
  phonopy_instance = phonopy_instance,
  selection_rule = 'raman', # or 'ir' for infrared
)

Other details or other post-processing using the phonopy_instance you can find them here: aiida_vibroscopy.calculations.spectra_utils β€” aiida-vibroscopy 1.1.0 documentation
Since the phonopy_instance is then a Phonopy object, you can also use the post-processing utilities of phonopy. See e.g.: Phonopy API for Python β€” Phonopy v.2.22.0

(note: in the phonopy documentation, phonopy_instance is sometimes referred to as phonon or ph)

Let me know if this is helpful.

Thanks Lorenzo.

Here is overrides.yaml file and submit files I prepared. Not sure if I still should keep property: raman in dielectric section., or not sure if I even need dielectric part.

clean_workdir: true # whether to clean the working directiories
dielectric:
  clean_workdir: true
  kpoints_parallel_distance: 0.2 # kpoints distance in Angstrom^-1 to sample the BZ parallel to the electric field. If used, it should help in converging faster the final results
  property: raman
  # central_difference: # if you know what you are doing, custom numerical derivatives with respect to electric field
  #   accuracy: 2
  #   electric_field_step: 0.0005
  scf:
    pseudo_family: CrSBr
    kpoints_distance: 0.4 # kpoints distance in Angstrom^-1 to sample the BZ
    kpoints_force_parity: false
    max_iterations: 20
    pw:
      metadata:
        options:
          max_wallclock_seconds: 57600
          resources:
            num_machines: 1
            num_mpiprocs_per_machine: 256
              #queue_name: standard # for SLURM
          # account: account_name # for SLURM, also for project etc
          withmpi: true
      settings:
        cmdline: ['-pd', '.true.']
      parameters:
        ELECTRONS:
          conv_thr: 2.0e-12
          electron_maxstep: 100
          mixing_beta: 0.3
        SYSTEM:
          ecutrho: 600.0
          ecutwfc: 100.0
          vdw_corr: Grimme-D2
          occupations: smearing
          degauss: 0.0002
          nspin: 2
          starting_magnetization: {'Cr':2}




  settings:
    sleep_submission_time: 1.0
phonon:
  clean_workdir: true
  displacement_generator:
    distance: 0.005 # atomic displacements for phonon calculation, in Angstrom
  scf:
    pseudo_family: CrSBr
    kpoints_distance: 0.15 # kpoints distance in Angstrom^-1 to sample the BZ
    kpoints_force_parity: false
    max_iterations: 20
    pw:
      metadata:
        options:
          max_wallclock_seconds: 57600
          resources:
            num_machines: 1
            num_mpiprocs_per_machine: 256
          # queue_name: partition_name # for SLURM
          # account: account_name # for SLURM, also for project etc
          withmpi: true
      settings:
        cmdline: ['-pd', '.true.']
        # gamma_only: True # to use only if KpointsData has only a mesh 1 1 1 0 0 0 (i.e. Gamma not shifted)
      parameters:
        ELECTRONS:
          conv_thr: 2.0e-12
          electron_maxstep: 80
          mixing_beta: 0.3
        SYSTEM:

          ecutwfc: 100.0
          ecutrho: 600

          vdw_corr: Grimme-D2
          occupations: smearing
          degauss: 0.0002
          nspin: 2
          starting_magnetization: {'Cr':2}




  settings:
    sleep_submission_time: 1.0 # waiting time in seconds between different submission of SCF calculation. Recommended to be at least 1 second, to not overload.
settings:
  run_parallel: true
  use_primitive_cell: false
symmetry:
  distinguish_kinds: false
  is_symmetry: true
  symprec: 1.0e-05

And submit.py as

from pathlib import Path

from aiida import load_profile
from aiida.engine import submit
from aiida.orm import *
from aiida_quantumespresso.common.types import ElectronicType

from aiida_vibroscopy.workflows.phonons.phonon import PhononWorkChain

load_profile()

# =============================== INPUTS =============================== #
# Please, change the following inputs.
mesh = [[10, 8, 5], [0.5, 0.5, 0.5]]
pseudo_family_name='CrSBr'
pw_code_label = 'qe-7.3@newhpc'
structure_id = 2358  # PK or UUID of your AiiDA StructureData
protocol = 'fast'  # also 'moderate' and 'precise'; 'moderate' should be good enough in general
overrides_filepath = './overrides_crsbr.yaml'  # should be a path, e.g. /path/to/overrides.yaml. Format is YAML


def main():
    code = load_code(pw_code_label)
    structure = load_node(structure_id)
    kwargs = {'electronic_type': ElectronicType.INSULATOR}

    kpoints = KpointsData()
    kpoints.set_kpoints_mesh(mesh[0], mesh[1])


    builder = PhononWorkChain.get_builder_from_protocol(
        code=code,
        structure=structure,
        protocol=protocol,
        overrides=Path(overrides_filepath),
        **kwargs,
    )

    builder.dielectric.scf.kpoints = kpoints
    builder.dielectric.pop('kpoints_parallel_distance', None)
    builder.dielectric.scf.pop('kpoints_distance', None)
    builder.phonon.scf.kpoints = kpoints


    calc=submit(builder)

    print(f'Submitted IRamanSpectraWorkChain with PK={calc.pk} and UUID={calc.uuid}')


if __name__ == '__main__':
    """Run script."""
    main()

Do these inputs look good in this ferromagnetic case?

Since the DielectricWorkChain is not called, you should remove all dielectric overrides. Since you call PhononWorkChain, you should drop phonon from the overrides. E.g.

clean_workdir: true
displacement_generator:
  distance: 0.005
scf:
    pseudo_family: CrSBr
    kpoints_distance: 0.15
    kpoints_force_parity: false
    max_iterations: 20
    pw:
        metadata:
            options:
                max_wallclock_seconds: 57600
                resources:
                    num_machines: 1
                    num_mpiprocs_per_machine: 256
        settings:
            cmdline: ['-pd', '.true.']
        parameters:
            ELECTRONS:
                conv_thr: 2.0e-12
                electron_maxstep: 80
                mixing_beta: 0.3
            SYSTEM:
                ecutwfc: 100
                ecutrho: 600
                vdw_corr: Grimme-D2
                occupations: smearing
                degauss: 0.0002
                nspin: 2
                starting_magnetization: {'Cr':2}
settings:
  sleep_submission_time: 1.0
symmetry:
  distinguish_kinds: false
  is_symmetry: true
  symprec: 1.0e-05

Remove:

    builder.dielectric.scf.kpoints = kpoints
    builder.dielectric.pop('kpoints_parallel_distance', None)
    builder.dielectric.scf.pop('kpoints_distance', None)

And change

    builder.phonon.scf.kpoints = kpoints

To

    builder.scf.kpoints = kpoints

Thanks.
Where can I learn those (for example what to remove and all)?
I read Protocols and overrides β€” aiida-vibroscopy 1.1.0 documentation but its not there.
I understood why remove dielectric overrides but I did not understand why you also dropped phonon in overrides.yaml

Luckily this material I am working also has AFM state, which I guess I can compute Raman of in a usual way right? (Just specifying magnetism right?) As shown below or is there something extra I need to add to treat AFM for Raman?

clean_workdir: true # whether to clean the working directiories
dielectric:
  clean_workdir: true
  kpoints_parallel_distance: 0.2 # kpoints distance in Angstrom^-1 to sample the BZ parallel to the electric field. If used, it should help in converging faster the final results
  property: raman
  # central_difference: # if you know what you are doing, custom numerical derivatives with respect to electric field
  #   accuracy: 2
  #   electric_field_step: 0.0005
  scf:
    pseudo_family: CrSBr
    kpoints_distance: 0.4 # kpoints distance in Angstrom^-1 to sample the BZ
    kpoints_force_parity: false
    max_iterations: 20
    pw:
      metadata:
        options:
          max_wallclock_seconds: 57600
          resources:
            num_machines: 1
            num_mpiprocs_per_machine: 256
              #queue_name: standard # for SLURM
          # account: account_name # for SLURM, also for project etc
          withmpi: true
      settings:
        cmdline: ['-pd', '.true.']
      parameters:
        ELECTRONS:
          conv_thr: 2.0e-12
          electron_maxstep: 100
          mixing_beta: 0.3
        SYSTEM:
          ecutrho: 600.0
          ecutwfc: 100.0
          vdw_corr: Grimme-D2
          occupations: smearing
          degauss: 0.0002
          nspin: 2
          starting_magnetization: {'Cr1':2, 'Cr2':-2}




  settings:
    sleep_submission_time: 1.0
phonon:
  clean_workdir: true
  displacement_generator:
    distance: 0.005 # atomic displacements for phonon calculation, in Angstrom
  scf:
    pseudo_family: CrSBr
    kpoints_distance: 0.15 # kpoints distance in Angstrom^-1 to sample the BZ
    kpoints_force_parity: false
    max_iterations: 20
    pw:
      metadata:
        options:
          max_wallclock_seconds: 57600
          resources:
            num_machines: 1
            num_mpiprocs_per_machine: 256
          # queue_name: partition_name # for SLURM
          # account: account_name # for SLURM, also for project etc
          withmpi: true
      settings:
        cmdline: ['-pd', '.true.']
        # gamma_only: True # to use only if KpointsData has only a mesh 1 1 1 0 0 0 (i.e. Gamma not shifted)
      parameters:
        ELECTRONS:
          conv_thr: 2.0e-12
          electron_maxstep: 80
          mixing_beta: 0.3
        SYSTEM:

          ecutwfc: 100.0
          ecutrho: 600

          vdw_corr: Grimme-D2
          occupations: smearing
          degauss: 0.0002
          nspin: 2
          starting_magnetization: {'Cr1':2, 'Cr2':-2}




  settings:
    sleep_submission_time: 1.0 # waiting time in seconds between different submission of SCF calculation. Recommended to be at least 1 second, to not overload.
settings:
  run_parallel: true
  use_primitive_cell: false
symmetry:
  distinguish_kinds: false
  is_symmetry: true
  symprec: 1.0e-05

The input structure of the overrides should resemble the one that you find here: PhononWorkChain β€” aiida-vibroscopy 1.1.0 documentation
In general, you can find the input structures here: Workflows β€” aiida-vibroscopy 1.1.0 documentation
Note that the get_builder_from_protocol is a strategic way to fill the inputs of the builder. You can still change inputs via the usual way:

builder['some']['input'] = DataNode(...)

As you have already done in the scripts. Again, the structure of the inputs and their type (e.g. KpointsData, Int, Float, StructureData, …) is found at the mentioned links. This is in general how you would fill the inputs of the workflows/WorkChain in AiiDA.

If you StructureData has the correct kinds Cr1 and Cr2, your input should work.

I am not sure if StructureData has that kind.

...
 occupations='smearing'
 degauss=0.0002
 nspin=2
starting_magnetization(2)= 2
starting_magnetization(3)= -2




/

&ELECTRONS
    conv_thr         =  1.00000e-12
    electron_maxstep = 200
    mixing_beta      =  0.3
    diagonalization  = "david"

/
&IONS
ion_dynamics='fire'
/
&CELL
press_conv_thr=0.01
/

K_POINTS {automatic}
10 8 5  1 1 1

ATOMIC_SPECIES
Br     79.904  Br.upf
Cr1     51.9961  Cr.upf
Cr2     51.9961  Cr.upf
S      32.065  S.upf


CELL_PARAMETERS (angstrom)
   3.518412588   0.000000000   0.000000000
   0.000000000   4.720510050   0.000000000
   0.000000000   0.000000000   8.046274521

ATOMIC_POSITIONS (crystal)
Br               0.2500000000        0.7500000000        0.1519353965
Br               0.7500000000        0.2500000000        0.8480646035
Cr1               0.7500000000        0.7500000000        0.3751287750
Cr2               0.2500000000        0.2500000000        0.6248712250
S                0.2500000000        0.7500000000        0.5746033020
S                0.7500000000        0.2500000000        0.4253966980

I am using this script to load structure from pw.x input for above input file. Not sure if it satisfies that.

from aiida import load_profile
load_profile()

from ase.io import read
from aiida.orm import *

atoms=read('/path/to/scf.in')
structure=StructureData(ase=atoms)
pk=structure.store()
print(pk)

Maybe you should have a look into the AiiDA docs: Data types β€” AiiDA 2.5.1.post0 documentation

E.g.: load_node(pk).sites should give you an idea whether it has been correctly loaded, or which kinds there are.

If you want to be more secure, use the following:

aiida-quantumespresso data structure import qe.in

Looks like first method does not work. It does not do Cr1 and Cr2 although in inputs it has Cr1 and Cr2.

[<Site: kind name 'Br' @ 0.879603147,3.5403825375,1.222513909696>, <Site: kind name 'Br' @ 2.638809441,1.1801275125,6.823760611304>, <Site: kind name 'Cr' @ 2.638809441,3.5403825375,3.0183891043764>, <Site: kind name 'Cr' @ 0.879603147,1.1801275125,5.0278854166236>, <Site: kind name 'S' @ 0.879603147,3.5403825375,4.6234159085651>, <Site: kind name 'S' @ 2.638809441,1.1801275125,3.4228586124349>]

Here, is qe.in the path to scf.in ? Or how exactly do I use this?

I tried following and got error:

(aiidaENV) rkarkee@ch-fe2:~> aiida-quantumespresso data structure import /lustre/scratch4/turquoise/rkarkee/CrSBr/PBE/scf.in
Traceback (most recent call last):
  File "/users/rkarkee/conda/envs/aiidaENV/bin/aiida-quantumespresso", line 8, in <module>
    sys.exit(cmd_root())
             ^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/aiida/cmdline/utils/decorators.py", line 80, in wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/users/rkarkee/conda/envs/aiidaENV/lib/python3.11/site-packages/aiida_quantumespresso/cli/data/structure.py", line 23, in cmd_import
    with open(filename, 'r', encoding='utf-8') as input_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not TextIOWrapper

Ok, it seems it is broken. @sphuber @mbercx can you confirm that:

aiida-quantumespresso data structure import qe.in

doesn’t work anymore?

In your case, you should be able to import it via ase using kinds in the following way:

from aiida import load_profile
load_profile()

from ase.io import read
from aiida.orm import *

atoms=read('/path/to/scf.in')
atoms.set_tags([0,0,1,2,0,0]) 
structure=StructureData(ase=atoms)
pk=structure.store()
print(pk)

Hi @bastonero
Can you please explain what that tags are doing?

Is it setting unique identifier to each atom?

In that case I suppose it should be [[0, 0, 1,2,3,3]] because last two atoms are different from first two.

Or is it something else?

Thanks

It should not, as symbols and numbers are used too. However, please refer to ASE documentation for further information on how that works. But AFAIK, it should work to do the job.

1 Like