Skip to content

[BUG] avoid AssertionError when using qe pwscf  #683

@pee8379

Description

@pee8379

As discussed in deepmodeling/deepmd-kit#1518 , deepmd-kit accept initial systems (DFT results) with less elements type.

However, when try to input similarly to "sys_configs" in param.json when using qe pwscf, it is stuck at step 02.fp, because file dpgen/generator/lib/pwscf.py
allow only POSCAR file with same number of element with "type_map" in param.json, and produce AssertionError if not.

(line 83-86)
ntypes = len(atom_names)
assert(ntypes == len(atom_names))
assert(ntypes == len(atom_masses))
assert(ntypes == len(pps))

This can be solved by modify line 2096 - 2097 of dpgen/generator/run.py

sys_data['atom_masses'] = jdata['mass_map']
ret = make_pwscf_input(sys_data, fp_pp_files, fp_params, user_input = user_input)

to

sys_data['atom_masses'] = []
pps = []
for iii in sys_data['atom_names']:
sys_data['atom_masses'].append(jdata['mass_map'][jdata['type_map'].index(iii)])
pps.append(fp_pp_files[jdata['type_map'].index(iii)])
ret = make_pwscf_input(sys_data, pps, fp_params, user_input = user_input)

I wish this help others.
Please tell me if I did something dumb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions