OpenMX Spin Input Write Issue: Colinear Spin, All Magnetic Moments Converted to Positive Values
Checklist
- [v] The issue remains in the development version of ASE.
- [v] A minimal example is provided to reproduce the issue.
Summary
Issue Description: When attempting to perform calculations for an antiferromagnetic colinear spin system by setting the initial magnetic moments to [3, -3], the values are unexpectedly changed to [3, 3]. This behavior results in an incorrect setup for antiferromagnetic calculations.
Potential Cause:
Magnetic moment values are treated as floats for colinear spin configurations, whereas they are handled as arrays for non-collinear spins.
In the case of colinear spins, the issue seems to arise from the line magmom = np.linalg.norm(magmom)
,
which inadvertently converts magnetic moments into absolute values, thereby forcing them always to be positive.
A minimal example
Set initial magnetic moments: +3 for the first atom, -3 for the second
# %%
from ase.build import bulk
from ase.calculators.openmx import OpenMX
from ase import Atoms
import os
# Set proper paths
os.environ['OPENMX_DFT_DATA_PATH'] = "/home/users2/bluehope/work_local/DFTcodes/openmx/openmx/DFT_DATA19"
os.environ['ASE_OPENMX_COMMAND'] = 'openmx'
# Create bulk Fe with a body-centered cubic (bcc) structure
a = 2.87 # Lattice parameter
bcc_fe = Atoms('Fe2',
positions=[(0, 0, 0), (a/2, a/2, a/2)],
cell=[a, a, a],
pbc=True)
# Set initial magnetic moments: +3 for the first atom, -3 for the second
bcc_fe.set_initial_magnetic_moments([3, -3])
openmx_params = {
'eigensolver' : 'Band', # Specify the eigensolver
'scf_maxiter': 100, # Maximum number of SCF iterations
'directory': '.', # Directory to run the calculation
'spinpol': True, # Enable spin polarization
}
calculator = OpenMX(**openmx_params)
bcc_fe.set_calculator(calculator)
bcc_fe.calc.write_input(bcc_fe)
But all initial magnetic moments are positive.
<Atoms.SpeciesAndCoordinates
1 Fe 0.0 0.0 0.0 8.5 5.5
2 Fe 1.435 1.435 1.435 8.5 5.5
Atoms.SpeciesAndCoordinates>
openmx.dat
System.CurrentDirectory .
System.Name openmx
DATA.PATH /home/users2/bluehope/work_local/DFTcodes/openmx/openmx/DFT_DATA19
Species.Number 1
<Definition.of.Atomic.Species
Fe Fe8.0-s3p3d2 Fe_CA19S
Definition.of.Atomic.Species>
Atoms.Number 2
Atoms.SpeciesAndCoordinates.Unit Ang
<Atoms.SpeciesAndCoordinates
1 Fe 0.0 0.0 0.0 8.5 5.5
2 Fe 1.435 1.435 1.435 8.5 5.5
Atoms.SpeciesAndCoordinates>
Atoms.UnitVectors.Unit Ang
<Atoms.UnitVectors
2.87 0.0 0.0
0.0 2.87 0.0
0.0 0.0 2.87
Atoms.UnitVectors>
scf.maxIter 100
scf.energycutoff 150
scf.XcType LDA
scf.SpinPolarization On
scf.EigenvalueSolver Band
scf.Mixing.Type Rmm-Diis