-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
when i run the code below:
dscriber = MBTR(species = self.atom_syms
, k1 = config.k1
, k2 = config.k2
, k3 = config.k3
, periodic = False
, normalization = "l2_each")
.....
lmbtr_feat = dscriber.create(self.atoms, centers = self.center_atom_idx)
the following problem seems to occur:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[4], [line 1](vscode-notebook-cell:?execution_count=4&line=1)
----> [1](vscode-notebook-cell:?execution_count=4&line=1) System.from_atoms(atoms)
File ~/soft/conda/2024.06.1/envs/python3.12/lib/python3.12/site-packages/dscribe/core/system.py:84, in System.from_atoms(atoms)
81 except AttributeError:
82 # ASE 3.26 replaced `_get_constraints` to `constraints` property (#160)
83 constraints = atoms.constraints
---> [84](https://file+.vscode-resource.vscode-cdn.net/home/iaw/DATA2/AAReact/src/util/~/soft/conda/2024.06.1/envs/python3.12/lib/python3.12/site-packages/dscribe/core/system.py:84) system = System(
85 symbols=atoms.get_chemical_symbols(),
86 positions=atoms.get_positions(),
87 tags=atoms.get_tags(),
88 momenta=atoms.get_momenta(),
89 masses=atoms.get_masses(),
90 magmoms=atoms.get_initial_magnetic_moments(),
91 charges=atoms.get_initial_charges(),
92 cell=atoms.get_cell(),
93 pbc=atoms.get_pbc(),
94 celldisp=atoms.get_celldisp(),
95 constraint=constraints,
96 calculator=atoms.get_calculator(),
97 info=atoms.info,
98 )
100 return system
File ~/soft/conda/2024.06.1/envs/python3.12/lib/python3.12/site-packages/dscribe/core/system.py:50, in System.__init__(self, symbols, positions, numbers, tags, momenta, masses, magmoms, charges, scaled_positions, cell, pbc, celldisp, constraint, calculator, info, wyckoff_positions, equivalent_atoms)
30 def __init__(
31 self,
32 symbols=None,
(...) 48 equivalent_atoms=None,
49 ):
---> [50](https://file+.vscode-resource.vscode-cdn.net/home/iaw/DATA2/AAReact/src/util/~/soft/conda/2024.06.1/envs/python3.12/lib/python3.12/site-packages/dscribe/core/system.py:50) super().__init__(
51 symbols,
52 positions,
53 numbers,
54 tags,
55 momenta,
56 masses,
57 magmoms,
58 charges,
59 scaled_positions,
60 cell,
61 pbc,
62 celldisp,
63 constraint,
64 calculator,
65 info,
66 )
68 self.wyckoff_positions = wyckoff_positions
69 self.equivalent_atoms = equivalent_atoms
File ~/soft/conda/2024.06.1/envs/python3.12/lib/python3.12/site-packages/ase/atoms.py:[1859](https://file+.vscode-resource.vscode-cdn.net/home/iaw/DATA2/AAReact/src/util/~/soft/conda/2024.06.1/envs/python3.12/lib/python3.12/site-packages/ase/atoms.py:1859), in Atoms.__init__(self, symbols, calculator, *args, **kwargs)
1858 def __init__(self, symbols=None, *args, calculator=None, **kwargs) -> None:
-> 1859 super().__init__(symbols, *args, **kwargs)
1860 if hasattr(symbols, 'get_positions'):
1861 atoms = symbols
File ~/soft/conda/2024.06.1/envs/python3.12/lib/python3.12/site-packages/ase/atoms.py:148, in _LimitedAtoms.__init__(self, symbols, positions, numbers, tags, momenta, masses, magmoms, charges, scaled_positions, cell, pbc, celldisp, constraint, info, velocities)
146 self.set_velocities(velocities)
147 else:
--> [148](https://file+.vscode-resource.vscode-cdn.net/home/iaw/DATA2/AAReact/src/util/~/soft/conda/2024.06.1/envs/python3.12/lib/python3.12/site-packages/ase/atoms.py:148) raise TypeError(
149 'Use only one of "momenta" and "velocities".')
151 if info is None:
152 self.info = {}
TypeError: Use only one of "momenta" and "velocities".
i check the file dscribe/descriptors/lmbtr.py:
571 # Calculate extended system
572 if self.periodic:
573 centers = new_system.get_positions()
574 ext_system, cell_indices = dscribe.utils.geometry.get_extended_system(
575 system,
576 radial_cutoff,
577 centers,
578 return_cell_indices=True,
579 )
580 ext_system = System.from_atoms(ext_system)
581 else:
582 ext_system = System.from_atoms(system)
i think this issue arises from the from_atoms in System Class:
@staticmethod
def from_atoms(atoms):
"""Creates a System object from ASE.Atoms object."""
try:
constraints = atoms._get_constraints()
except AttributeError:
# ASE 3.26 replaced `_get_constraints` to `constraints` property (#160)
constraints = atoms.constraints
system = System(
symbols=atoms.get_chemical_symbols(),
positions=atoms.get_positions(),
tags=atoms.get_tags(),
momenta=atoms.get_momenta(),
masses=atoms.get_masses(),
magmoms=atoms.get_initial_magnetic_moments(),
charges=atoms.get_initial_charges(),
cell=atoms.get_cell(),
pbc=atoms.get_pbc(),
celldisp=atoms.get_celldisp(),
constraint=constraints,
calculator=atoms.get_calculator(),
info=atoms.info,
)
return system
if info is an empty Dict, System will erroneously pass it to ASE's Atoms(_LimitedAtoms) through super().__init__(.....)
class _LimitedAtoms:
"""Atoms object with limited methods and attributes.
This class is only for smooth transition from ASE3 to ASE4 and not intended
to be used for any other purposes by users.
"""
ase_objtype = 'atoms' # For JSONability
def __init__(self, symbols=None,
positions=None, numbers=None,
tags=None, momenta=None, masses=None,
magmoms=None, charges=None,
scaled_positions=None,
cell=None, pbc=None, celldisp=None,
constraint=None,
info=None,
velocities=None):
Ultimately, info is assigned to velocities, which results in the error TypeError: Use only one of "momenta" and "velocities". I suggest modifying the super() call of the System class, and the corrected code is as follows:
super().__init__(
symbols=symbols,
positions=positions,
numbers=numbers,
tags=tags,
momenta=momenta,
masses=masses,
magmoms=magmoms,
charges=charges,
scaled_positions=scaled_positions,
cell=cell,
pbc=pbc,
celldisp=celldisp,
constraint=constraint,
calculator=calculator,
info=info,
)
Version Information:
Python 3.12.11
ase 3.27.0
dscribe 2.1.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels