Skip to content

Commit

Permalink
Move spin overwrite outside try block #80
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-austin committed Jun 9, 2023
1 parent 159b188 commit 1a52518
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pymuonsuite/calculate/uep/charged.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def __init__(self, seedname, gw_fac=3, path=""):
self._elec_den = FMTReader(seedpath + ".den_fmt")
with silence_stdio():
self._struct = io.read(seedpath + ".castep")
# Set all spins to 0 rather than use the CASTEP results
spins = [0] * len(self._struct.positions)
self._struct.set_initial_magnetic_moments(spins)

ppots = parse_castep_ppots(seedpath + ".castep")

Expand All @@ -85,11 +88,7 @@ def __init__(self, seedname, gw_fac=3, path=""):
cppot = None
try:
with silence_stdio():
structure = io.read(seedpath + ".cell")
# Set all spins to 0 rather than use the CASTEP results
spins = [0] * len(self._struct.positions)
self._struct.set_initial_magnetic_moments(spins)
cppot = structure.calc.cell.species_pot.value
cppot = io.read(seedpath + ".cell").calc.cell.species_pot.value
except IOError:
print(f"WARNING: cell file {seedpath}.cell not found")
if cppot is not None:
Expand Down

0 comments on commit 1a52518

Please sign in to comment.