Skip to content

Commit d1279dc

Browse files
committed
Fix bug for nspin=2 in DOS
1 parent 60bd534 commit d1279dc

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

src/abacusagent/modules/dos.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def abacus_dos_run(
8585
input_file = os.path.join(abacus_inputs_path, "INPUT")
8686
input_params = ReadInput(input_file)
8787
nspin = input_params.get("nspin", 1)
88-
if nspin in [2, 4]:
89-
raise ValueError("Currently DOS calculation can only be plotted using for nspin=1")
88+
if nspin in [4]:
89+
raise ValueError("Currently DOS calculation can only be plotted using for nspin=1 and nspin=2")
9090

9191
metrics_scf = abacus_dos_run_scf(abacus_inputs_path)
9292
metrics_nscf = abacus_dos_run_nscf(metrics_scf["scf_work_path"],
@@ -477,16 +477,9 @@ def plot_dos(file_path: List[Path],
477477
data = np.loadtxt(file_path[1], usecols=(0, 1))
478478
dos_dn = data[:, 1]
479479

480-
# Determine y limits based on data within x range
481-
x_min, x_max = -fermi_level, fermi_level
482-
mask = (energy >= x_min) & (energy <= x_max)
483-
484-
if not any(mask):
485-
y_min, y_max = 0, 1
486-
else:
487-
y_min = -0.1 * np.max(dos[mask])
488-
y_max = 1.1 * np.max(dos[mask])
489-
480+
# Determine energy limits based on data within x range
481+
x_min, x_max = max(min(energy), -20), min(20, max(energy))
482+
490483
# Create plot
491484
plt.figure(figsize=(8, 6))
492485
if nspin == 1:

0 commit comments

Comments
 (0)