Skip to content

Commit

Permalink
abacus: fix bug in reading nspin2 results (#758)
Browse files Browse the repository at this point in the history
fix #757 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced handling of magnetic moments and forces to ensure consistent
three-dimensional vector representation.
- Updated input parameters for calculation configuration to reflect
changes in naming conventions and spin configurations.

- **Tests**
- Introduced a new test method to validate behavior with the updated
input file, improving test coverage and ensuring accuracy in results.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: root <pxlxingliang>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pxlxingliang and pre-commit-ci[bot] authored Nov 26, 2024
1 parent 5916b4f commit 5cb41f8
Show file tree
Hide file tree
Showing 4 changed files with 610 additions and 4 deletions.
10 changes: 8 additions & 2 deletions dpdata/abacus/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,20 @@ def get_mag_force(outlines):
j = i + 2
mag = []
while "-------------------------" not in outlines[j]:
mag.append([float(ii) for ii in outlines[j].split()[1:]])
imag = [float(ii) for ii in outlines[j].split()[1:]]
if len(imag) == 1:
imag = [0, 0, imag[0]]
mag.append(imag)
j += 1
mags.append(mag)
if "Magnetic force (eV/uB)" in line:
j = i + 2
magforce = []
while "-------------------------" not in outlines[j]:
magforce.append([float(ii) for ii in outlines[j].split()[1:]])
imagforce = [float(ii) for ii in outlines[j].split()[1:]]
if len(imagforce) == 1:
imagforce = [0, 0, imagforce[0]]
magforce.append(imagforce)
j += 1
magforces.append(magforce)
return np.array(mags), np.array(magforces)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
INPUT_PARAMETERS
suffix ABACUS
suffix ABACUS-nspin2
calculation scf
ecutwfc 100
scf_thr 1e-07
Expand All @@ -14,7 +14,7 @@ basis_type lcao
symmetry 0
noncolin 1
lspinorb 0
nspin 4
nspin 2
out_mul true
sc_mag_switch 1
decay_grad_switch 1
Expand Down
Loading

0 comments on commit 5cb41f8

Please sign in to comment.