|
10 | 10 | from pathlib import Path
|
11 | 11 | from typing import Dict
|
12 | 12 |
|
| 13 | +import numpy as np |
| 14 | + |
13 | 15 | from koopmans import pseudopotentials, utils
|
14 | 16 | from koopmans.bands import Bands
|
15 | 17 | from koopmans.calculators import (KoopmansHamCalculator, PWCalculator,
|
@@ -280,20 +282,29 @@ def _run(self):
|
280 | 282 | self, dft_ham_files=dft_ham_files, koopmans_ham_files=koopmans_ham_files)
|
281 | 283 | ui_workflow.run(subdirectory='postproc' + spin_suffix)
|
282 | 284 |
|
283 |
| - # Plotting |
284 |
| - self.plot_bandstructure() |
| 285 | + # Plotting |
| 286 | + if self._perform_ham_calc: |
| 287 | + self.plot_bandstructure() |
285 | 288 |
|
286 | 289 | def plot_bandstructure(self):
|
287 | 290 | if not all(self.atoms.pbc):
|
288 | 291 | return
|
289 | 292 |
|
290 | 293 | # Identify the relevant calculators
|
291 |
| - kc_ham_calc = [c for c in self.calculations if isinstance(c, KoopmansHamCalculator)][-1] |
| 294 | + n_calc = 2 if self.parameters.spin_polarized else 1 |
| 295 | + kc_ham_calcs = [c for c in self.calculations if isinstance(c, KoopmansHamCalculator)][-n_calc:] |
292 | 296 |
|
293 | 297 | # Plot the bandstructure if the band path has been specified
|
294 |
| - bs = kc_ham_calc.results['band structure'] |
295 |
| - if bs.path.path: |
296 |
| - super().plot_bandstructure(bs.subtract_reference()) |
| 298 | + bandstructures = [c.results['band structure'] for c in kc_ham_calcs] |
| 299 | + ref = max([b.reference for b in bandstructures]) |
| 300 | + bs_to_plot = bandstructures[0].subtract_reference(ref) |
| 301 | + if not bs_to_plot.path.path: |
| 302 | + return |
| 303 | + |
| 304 | + if self.parameters.spin_polarized: |
| 305 | + bs_to_plot._energies = np.append(bs_to_plot._energies, bandstructures[1]._energies - ref, axis=0) |
| 306 | + |
| 307 | + super().plot_bandstructure(bs_to_plot) |
297 | 308 |
|
298 | 309 | def new_calculator(self, calc_presets, **kwargs):
|
299 | 310 | return internal_new_calculator(self, calc_presets, **kwargs)
|
|
0 commit comments