ENH: Add functionality to guess atomic numbers from atomic masses in `read_lammps_data`
Currently, unless Z_of_type
is explicitly specified, read_lammps_data
crudely assigns dummy atomic numbers of 1 (H), 2 (He), etc. to atom types of 1, 2, etc. In this merge request, the behavior is modified such that, if there is the "Masses" section, the code automatically chooses and assigns the corresponding atomic numbers.
The biggest benefit with this change would be that we can assign proper atomic numbers only based on the information in the data file to be read (= no need of Z_of_type
). This allows us e.g. to convert the LAMMPS data file to another format without referring to other sources.
This probably closes #1168 (closed).
I note that the guessing is based on the comparison of written atomic masses with the ASE default values. In case untypical atomic masses (e.g. the deuterium or the tritium mass for hydrogen) are written in the LAMMPS data file, the guess does not work properly. In such cases, one should still specify Z_of_type
explicitly by oneself.
Testing is done by extending what I implemented in !2891 (merged). In addition to the cases where one specifies Z_of_type
explicitly (_check_explicit_numbers
), the cases without Z_of_type
(_check_masses2numbers
) are also added.
There are also a few minor refactoring commits; most of them are just to pass mypy linter tests.