Skip to content

Commit be0d4fc

Browse files
committed
fixes
1 parent f34bcfd commit be0d4fc

1 file changed

Lines changed: 12 additions & 25 deletions

File tree

src/lammpsparser/compatibility/structure.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ def structure(self) -> Optional[Atoms]:
2828
"""
2929
return self._structure
3030

31-
@property
32-
def molecule_ids(self):
33-
if self._molecule_ids is None or len(self._molecule_ids) == 0:
34-
return np.ones(len(self.structure), dtype=int)
35-
return self._molecule_ids
36-
37-
@molecule_ids.setter
38-
def molecule_ids(self, val):
39-
self._molecule_ids = val
40-
4131
@structure.setter
4232
def structure(self, structure):
4333
"""
@@ -49,11 +39,11 @@ def structure(self, structure):
4939
5040
"""
5141
self._structure = structure
52-
if self._atom_type == "full":
42+
if self.atom_type == "full":
5343
input_str = self.structure_full()
54-
elif self._atom_type == "bond":
44+
elif self.atom_type == "bond":
5545
input_str = self.structure_bond()
56-
elif self._atom_type == "charge":
46+
elif self.atom_type == "charge":
5747
input_str = self.structure_charge()
5848
else: # self.atom_type == 'atomic'
5949
input_str = self.structure_atomic()
@@ -67,6 +57,7 @@ def structure_bond(self):
6757
6858
"""
6959
species_lammps_id_dict = self.get_lammps_id_dict(self.el_eam_lst)
60+
self.molecule_ids = None
7061
# analyze structure to get molecule_ids, bonds, angles etc
7162
coords = self.rotate_positions(self._structure)
7263

@@ -124,7 +115,7 @@ def structure_bond(self):
124115
bond_type[i, j] = count
125116
bond_type[j, i] = count
126117

127-
if getattr(self.structure, "bonds", None) is None:
118+
if self.structure.bonds is None:
128119
if self.cutoff_radius is None:
129120
bonds_lst = get_bonds(structure=self.structure, max_shells=1)
130121
else:
@@ -174,25 +165,20 @@ def structure_full(self):
174165
175166
"""
176167
species_lammps_id_dict = self.get_lammps_id_dict(self.el_eam_lst)
168+
self.molecule_ids = None
177169
coords = self.rotate_positions(self._structure)
178170

179171
# extract electric charges from potential file
180-
if self.potential is not None:
181-
q_dict = {
182-
species_name: self.potential.get_charge(species_name)
183-
for species_name in set(self.structure.get_chemical_symbols())
184-
}
185-
else:
186-
q_dict = {
187-
species_name: 0.0
188-
for species_name in set(self.structure.get_chemical_symbols())
189-
}
172+
q_dict = {
173+
species_name: self.potential.get_charge(species_name)
174+
for species_name in set(self.structure.get_chemical_symbols())
175+
}
190176

191177
bonds_lst, angles_lst = [], []
192178
bond_type_lst, angle_type_lst = [], []
193179
# Using a cutoff distance to draw the bonds instead of the number of neighbors
194180
# Only if any bonds are defined
195-
if self._bond_dict is not None and len(self._bond_dict.keys()) > 0:
181+
if len(self._bond_dict.keys()) > 0:
196182
cutoff_list = list()
197183
for val in self._bond_dict.values():
198184
cutoff_list.append(np.max(val["cutoff_list"]))
@@ -343,6 +329,7 @@ def get_bonds(
343329
tolerance=2,
344330
id_list=None,
345331
width_buffer=1.2,
332+
allow_ragged=None,
346333
mode="ragged",
347334
norm_order=2,
348335
)

0 commit comments

Comments
 (0)