-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from antelmor/master
Merge algorithm for non-collinear systems
- Loading branch information
Showing
8 changed files
with
239 additions
and
410 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import sisl | ||
|
||
def rotate_siesta_DM(DM, noncollinear=False): | ||
|
||
angles_list = [ [0.0, 90.0, 0.0], [0.0, 90.0, 90.0] ] | ||
if noncollinear: | ||
angles_list += [[0.0, 45.0, 0.0], [0.0, 90.0, 45.0], [0.0, 45.0, 90.0]] | ||
|
||
for angles in angles_list: | ||
yield DM.spin_rotate(angles) | ||
|
||
def read_label(fdf_fname): | ||
|
||
label = 'siesta' | ||
with open(fdf_fname, 'r') as File: | ||
for line in File: | ||
corrected_line = line.lower().replace('.', '').replace('-', '') | ||
if 'systemlabel' in corrected_line: | ||
label = line.split()[1] | ||
break | ||
|
||
return label | ||
|
||
def rotate_DM(fdf_fname, noncollinear=False): | ||
|
||
fdf = sisl.get_sile(fdf_fname) | ||
DM = fdf.read_density_matrix() | ||
label = read_label(fdf_fname) | ||
|
||
rotated = rotate_siesta_DM(DM, noncollinear=noncollinear) | ||
|
||
for i, rotated_DM in enumerate(rotated): | ||
rotated_DM.write(f"{label}_{i+1}.DM") | ||
DM.write(f"{label}_0.DM") | ||
|
||
print(f"The output has been written to the {label}_i.DM files. {label}_0.DM contains the reference density matrix.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
from TB2J.rotate_siestaDM import rotate_DM | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="") | ||
parser.add_argument( | ||
"--fdf_fname", help="Name of the *.fdf siesta file." | ||
) | ||
parser.add_argument( | ||
"--noncollinear", | ||
action="store_true", | ||
help="If present, six different configurations will be generated. These are required for non-collinear systems." | ||
) | ||
|
||
args = parser.parse_args() | ||
rotate_DM(args.fdf_fname, noncollinear=args.noncollinear) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters