Yes, you can fix the direction of magnetic moments of atoms in a CASTEP geometry optimization calculation. To do this, you need to set up the calculation input file (.cell file) with the appropriate settings.
Here are the steps you should follow:
Define the initial magnetic moments for each atom:
In the .cell file, specify the initial magnetic moment of each atom using the "spin" keyword in the "%BLOCK POSITIONS_FRAC" or "%BLOCK POSITIONS_ABS" section. For example:
===================================
%BLOCK POSITIONS_FRAC
Fe 0.0 0.0 0.0 spin=2.0
Fe 0.5 0.5 0.0 spin=-2.0
%ENDBLOCK POSITIONS_FRAC
===================================
Then set the "fixed spin moment" option:
To fix the direction of magnetic moments, you need to use the "fixed_spin_moment" keyword in the "spin" section of the .param file. This keyword ensures that the direction of the magnetic moment is fixed during the geometry optimization.
Here's an example of how your .param file should look like:
===================================
task : geometryoptimization
xc_functional : PBE
cut_off_energy : 400 eV
spin :
{
polarized
fixed_spin_moment
}
===================================
This will ensure that the direction of the magnetic moments of the atoms is fixed during the geometry optimization process. Note that the direction is fixed, but the magnitudes of the moments can still change during the calculation.
There are "spin_polarized" and "spin" keywords in the .param file. Spin_polarized gets values of true or false. Spin gets a number that is the initial spin. I used syntax, as you mentioned,
spin :
{
0
fixed_spin_moment
}
However, the calculation stopped with the message "Label "{" not in keyword list".
Could you check this problem? I am using Castep version 2020.
I apologize for delay in answer, it appears that the CASTEP version you are using (2020) does not support the block-style syntax for the .param file as I had previously mentioned. In that case, please try using the following settings:
In your .param file, simply add the spin_polarized keyword with a value of true:
========================
task : geometryoptimization
xc_functional : PBE
cut_off_energy : 400 eV
spin_polarized : true
========================
Then, in your .cell file, specify the fixed spin moment (FSM) constraint for each atom by adding the "constraint" keyword along with "spin" keyword in the "%BLOCK POSITIONS_FRAC" or "%BLOCK POSITIONS_ABS" section, as shown below:
=======================
%BLOCK POSITIONS_FRAC
Fe 0.0 0.0 0.0 spin=2.0 constraint=fsm
Fe 0.5 0.5 0.0 spin=-2.0 constraint=fsm
%ENDBLOCK POSITIONS_FRAC
=======================
This should set up the calculation with fixed spin moment constraints for the specified atoms, ensuring that their magnetic moment directions are fixed during the geometry optimization. Remember that the direction is fixed, but the magnitudes of the moments can still change during the calculation.
Please let me know if you encounter any further issues.
I tried to add "constraint=fsm" as you said. However, my calculation stopped with the message "ERROR reading cell file: do not know about (real) atom attribute constraint"
It appears that the "constraint=fsm" option is not supported in CASTEP 2020. In this case, please try using the following workaround:
Instead of fixing the spin moment direction directly in CASTEP, perform the geometry optimization without the constraint on the magnetic moments' directions. Then, post-process the resulting optimized structure to maintain the desired spin directions manually or by using a separate script.
Here's a step-by-step procedure:
Perform the geometry optimization without any constraints on the magnetic moment directions, but make sure to specify the initial magnetic moments in the .cell file:
%BLOCK POSITIONS_FRAC
Fe 0.0 0.0 0.0 spin=2.0
Fe 0.5 0.5 0.0 spin=-2.0
%ENDBLOCK POSITIONS_FRAC
In the .param file, set the "spin_polarized" keyword to true:
task : geometryoptimization
xc_functional : PBE
cut_off_energy : 400 eV
spin_polarized : true
After the geometry optimization is complete, you will obtain an optimized structure. Inspect the magnetic moments of the atoms in the final structure.
Manually (or using a script) adjust the magnetic moments' directions to the desired values while keeping their magnitudes unchanged. This can be done by adjusting the sign of the magnetic moment or by rotating the magnetic moment vector while keeping its magnitude constant.
Use the modified structure as the input for further calculations, such as electronic structure calculations or additional geometry optimizations.
Although this workaround is not as straightforward as specifying the constraint directly in the CASTEP input files, it can still help you achieve your goal of fixing the magnetic moments' directions in the final optimized structure.
Please let me know if you have any further questions or issues.