Skip to content

Commit

Permalink
Code refining in settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mikibonacci committed Oct 2, 2024
1 parent 96ad9be commit ba5a5b5
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/aiidalab_qe_vibroscopy/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ def change_supercell(_=None):
super().__init__(**kwargs)

# we define a block for the estimation of the supercell if we ask for hint,
# so that we call the estimator at the end (we don't lose time).
# so that we call the estimator only at the end of the supercell hint generator,
# and now each time after the x, y, z generation (i.e., we don't lose time).
# see the methods below.
self.block = False

Expand Down Expand Up @@ -329,12 +330,9 @@ def _estimate_supercells(self, _=None):
if self.block:
return

if self.symmetry_symprec.value > 1:
self.symmetry_symprec.value = 1
elif self.symmetry_symprec.value < 1e-5:
self.symmetry_symprec.value = 1e-5
symprec_value = self.symmetry_symprec.value

symprec = self.symmetry_symprec.value
self.symmetry_symprec.value = max(1e-5, min(symprec_value, 1))

self.supercell_number_estimator.value = spinner_html

Expand All @@ -348,7 +346,7 @@ def _estimate_supercells(self, _=None):
[0, self._sc_y.value, 0],
[0, 0, self._sc_z.value],
],
symprec=symprec,
symprec=self.symmetry_symprec.value,
distinguish_kinds=False,
is_symmetry=True,
)
Expand Down Expand Up @@ -384,10 +382,7 @@ def _reset_supercell(self, _=None):
for direction, periodic in zip(
[self._sc_x, self._sc_y, self._sc_z], self.input_structure.pbc
):
if periodic:
reset_supercell.append(2)
else:
reset_supercell.append(1)
reset_supercell.append(2 if periodic else 1)
(self._sc_x.value, self._sc_y.value, self._sc_z.value) = reset_supercell
self.block = False
self._estimate_supercells()
Expand Down

0 comments on commit ba5a5b5

Please sign in to comment.