Repository navigation
Expand file tree
/
Copy pathExamples.py
More file actions
1968 lines (1555 loc) · 87.2 KB
/
Copy pathExamples.py
File metadata and controls
1968 lines (1555 loc) · 87.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import numpy as np
from typing import List
from Atoms import Atom
from Material import Material
from Bonds import Bond
import numpy.linalg as la
import rotation as rotation
from Configurations import Config
import funtions as functions
############################################
# Main Examples (tested and up to date):
############################################
# NiO_input_file = "input_data\prefactors_results_ligand_field.dat"
# NiO_input_file = "input_data\prefactors_results_ligand_field_not_scaled.dat"
NiO_input_file = "input_data/prefactors_results_ligand_field_with_XAS.dat" #used in thesis
# NiO_input_file = "input_data/prefactors_results_ligand_field_scaled85_with_XAS.dat" #used in thesis
K2NiF4_input_file = "input_data/prefactors_results_ligand field K2NiF4.dat"
def NiO_incomm_1_atom_cell_NN_and_NNN(config:Config ,J_NN=-1.4,J_super_exchange=19,a=1, S1=1, S2=-1, T_domain_idx = 0, spin_dir=np.array([0,0,1]), add_all_domains = True, title_suffix = "", lattice_constant=4.17e-10):
#J_NN=-2.3,J_super_exchange=12,
#J_NN=-1.4,J_super_exchange=19,
if add_all_domains:
if T_domain_idx != 0:
config.warnings.add("set the first domain idx to 0 when adding all domains")
T_domain_idx = 0 #set as first domain index
#1= 12meV
S_domains = [np.array([1, -2, 1]), np.array([-2, 1, 1]), np.array([1, 1, -2]),-np.array([1, -2, 1]), -np.array([-2, 1, 1]), -np.array([1, 1, -2])]
# alignements = [np.array([1, 1, -2])]
#still fcc
A,B,C = 1/2*np.array([a, a, 0]), 1/2*np.array([0, a, a]), 1/2*np.array([a, 0, a])
lv = [A,B,C]
crystallographic_lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])]
S_domains = np.einsum("ij,vj->vi", rotation.rot_vec(T_domain_idx*1/2*np.pi, crystallographic_lv[2]), np.array(S_domains)) #roate S-domain vectors by 90 degrees around the z-axis to get the four different T domains
lv = np.einsum("ij,vj->vi", rotation.rot_vec(T_domain_idx*1/2*np.pi, crystallographic_lv[2]), np.array(lv)) #roate lattice vectors by 90 degrees around the z-axis to get the four different T domains
# ------------------------------geometry checks: are S and T-domains correctly implemented------------------------------
#these are the four normal vectors of the different T-domain planes, the first two lattice vectors of exactly one T_domain_idx should be orthogonal to one of these normal vectors
T_domains_normal_vectors = [np.array([1, 1, 1]), np.array([-1, 1, 1]), np.array([-1, -1, 1]),np.array([1, -1, 1])]
# #checks S_domain vectors should lay in the plane of the two first lattice vectors
# for S_vec in S_domains:
# if abs(np.dot(S_vec, np.cross(lv[0], lv[1]))) > 1e-5:
# raise ValueError("S_domain vector is not in the plane of the first two lattice vectors")
# #checks only one T_domain normal vector is orthogonal to the two first lattice vectors
# if T_domains_normal_vectors[T_domain_idx]@lv[0] > 1e-5 and T_domains_normal_vectors[T_domain_idx]@lv[1] > 1e-5:
# raise ValueError("rotated T_domain doesnt match the normal vector of the T_domain plane")
normal_vector = np.array([1,0,0])
#TODO: check this
# tau = np.array([0.5, 0, 0]) # incommensurate --> could define T-domain now (but also rotation of lv possible)
# tau = np.array([0, 0.5, 0])
# tau = np.array([0, 0, 0.5])
tau = np.array([0.5, 0.5, 0.5])
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=3, name=f"NiO incomm. NN_NNN T_domain_{T_domain_idx}_{title_suffix}",
extension=1, S_domains=S_domains , crystallographic_lv=crystallographic_lv, lattice_constant=lattice_constant,
fund_xray_prefactors_filename=NiO_input_file)
X,Y,Z = material.transform_from_cryst_basis_to_lv_basis(np.array(crystallographic_lv), transform_coefficients=True)#the absolute X,Y,Z vectors in lattice units
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
#TODO: Domains
Atom(np.array([0, 0, 0]), type=0, S=S1, spin_dir=spin_dir)
]
#set correct spin directions according to T_domains
# for atom in atoms[1:]:
# bond_to_atom_0 = atom.position - atoms[0].position
# bond_to_atom_1 = atom.position - atoms[1].position
# if np.dot(T_domains_normal_vectors[T_domain_idx], bond_to_atom_0) <= 1e-5:
# atom.spin_dir = atoms[0].spin_dir
# elif np.dot(T_domains_normal_vectors[T_domain_idx], bond_to_atom_1) <= 1e-5:
# atom.spin_dir = atoms[1].spin_dir
# else:
# raise ValueError("Atom position does not correspond to the selected T_domain_idx")
J_values = [J_NN,J_super_exchange]
# J_values= [J_super_exchange]
#this is not reliably working since I dont account for double counting correctly
bonds = []
combinations, distances = material.return_combinations_up_to_distance(atoms, 4*a)
for i,j_value in enumerate(J_values):
for combs in combinations[i]:
atom1, uc1, atom2, uc2 = combs
assert np.all(uc1==np.array([0,0,0])), "only bonds from origin unit cell implemented here"
bonds.append(Bond(material, atom1, atom2, unit_cell_of_atom_2=uc2, j=j_value))
# for c in combinations[0]:
# a1,u1,a2,u2 = c
# print(np.array(lv).T@(a1.position+u1))
# print(np.array(lv).T@(a2.position+u2))
# print(a1.position+u1)
# print(a2.position+u2)
# print("")
material.transform_from_cryst_basis_to_lv_basis(lv[0], False, True)
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2*X, 1/2*(X+Y), 1/2*(X+Y+Z), np.array([0,0,0])]
# Kx,Ky,Kz = np.array([1,0,1])/2, np.array([1,1,0])/2, np.array([0,1,1])/2
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2* np.array([1,0,1]), 1/2* np.array([0,1,1]), 1/2* np.array([0,0,0])]
#give in euclidean basis for better readability
relative_grid_points_path = [np.array([0,0,0]), np.array([1,0,0]), np.array([1,1,0]), np.array([1,1,1]), np.array([0,0,0])]
#transform to lattice vector basis
material.relative_grid_points_path = material.transform_from_cryst_basis_to_lv_basis(1/2*np.array(relative_grid_points_path),reciprocal=True, transform_coefficients=True, backtranform=False)
material.relative_grid_points_names = [r"$\Gamma$", "X", "M","R", r"$\Gamma$"]
if add_all_domains: #only the material of the first domain should have all other domains added
# add the additional domains
material.add_additional_domain_material([
NiO_incomm_1_atom_cell_NN_and_NNN(config, T_domain_idx=1, add_all_domains=False),
NiO_incomm_1_atom_cell_NN_and_NNN(config, T_domain_idx=2, add_all_domains=False),
NiO_incomm_1_atom_cell_NN_and_NNN(config, T_domain_idx=3, add_all_domains=False),
])
# all_atoms.append(atoms[0])
return material
def NiO_2_atom_cell_NN_and_NNN(config:Config ,J_NN=-1.4,J_super_exchange=19,a=1, S1=1, S2=-1, T_domain_idx = 0, spin_dir=np.array([0,0,1]), add_all_domains = True, title_suffix = "", lattice_constant=4.17e-10):
#J_NN=-2.3,J_super_exchange=12,
#J_NN=-1.4,J_super_exchange=19,
if add_all_domains:
if T_domain_idx != 0:
config.warnings.add("set the first domain idx to 0 when adding all domains")
T_domain_idx = 0 #set as first domain index
#1= 12meV
S_domains = [np.array([1, -2, 1]), np.array([-2, 1, 1]), np.array([1, 1, -2]),-np.array([1, -2, 1]), -np.array([-2, 1, 1]), -np.array([1, 1, -2])]
# alignements = [np.array([1, 1, -2])]
#TODO: test this!!!
A,B,C = np.array([a, a, 0]), np.array([0, a, a]), np.array([a, 0, a])
#TODO: make this nicer and more general
# A,B,C = A*T_domains[T_domain_idx], B*T_domains[T_domain_idx], C*T_domains[T_domain_idx]
lv = [1/2*(A-B), 1/2*(A-C), A]
crystallographic_lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])]
S_domains = np.einsum("ij,vj->vi", rotation.rot_vec(T_domain_idx*1/2*np.pi, crystallographic_lv[2]), np.array(S_domains)) #roate S-domain vectors by 90 degrees around the z-axis to get the four different T domains
lv = np.einsum("ij,vj->vi", rotation.rot_vec(T_domain_idx*1/2*np.pi, crystallographic_lv[2]), np.array(lv)) #roate lattice vectors by 90 degrees around the z-axis to get the four different T domains
# ------------------------------geometry checks: are S and T-domains correctly implemented------------------------------
#these are the four normal vectors of the different T-domain planes, the first two lattice vectors of exactly one T_domain_idx should be orthogonal to one of these normal vectors
T_domains_normal_vectors = [np.array([1, 1, 1]), np.array([-1, 1, 1]), np.array([-1, -1, 1]),np.array([1, -1, 1])]
#checks S_domain vectors should lay in the plane of the two first lattice vectors
for S_vec in S_domains:
if abs(np.dot(S_vec, np.cross(lv[0], lv[1]))) > 1e-5:
raise ValueError("S_domain vector is not in the plane of the first two lattice vectors")
#checks only one T_domain normal vector is orthogonal to the two first lattice vectors
if T_domains_normal_vectors[T_domain_idx]@lv[0] > 1e-5 and T_domains_normal_vectors[T_domain_idx]@lv[1] > 1e-5:
raise ValueError("rotated T_domain doesnt match the normal vector of the T_domain plane")
normal_vector = np.array([-1,1,0]) #arbitrary since commensurate case
tau = np.array([0, 0, 0]) # commensurate
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=3, name=f"NiO 2 atom cell NN_NNN T_domain_{T_domain_idx}_{title_suffix}",
extension=1, S_domains=S_domains , crystallographic_lv=crystallographic_lv, lattice_constant=lattice_constant,
fund_xray_prefactors_filename=NiO_input_file)
X,Y,Z = material.transform_from_cryst_basis_to_lv_basis(np.array(crystallographic_lv), transform_coefficients=True)#the absolute X,Y,Z vectors in lattice units
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
#TODO: Domains
Atom(np.array([0, 0, 0]), type=0, S=S1, spin_dir=spin_dir),
Atom(position=X, type=1, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
]
#set correct spin directions according to T_domains
for atom in atoms[1:]:
bond_to_atom_0 = atom.position - atoms[0].position
bond_to_atom_1 = atom.position - atoms[1].position
if np.dot(T_domains_normal_vectors[T_domain_idx], bond_to_atom_0) <= 1e-5:
atom.spin_dir = atoms[0].spin_dir
elif np.dot(T_domains_normal_vectors[T_domain_idx], bond_to_atom_1) <= 1e-5:
atom.spin_dir = atoms[1].spin_dir
else:
raise ValueError("Atom position does not correspond to the selected T_domain_idx")
J_values = [J_NN,J_super_exchange]
# J_values= [J_super_exchange]
#this is not reliably working since I dont account for double counting correctly
bonds = []
combinations, distances = material.return_combinations_up_to_distance(atoms, 4*a)
for i,j_value in enumerate(J_values):
for combs in combinations[i]:
atom1, uc1, atom2, uc2 = combs
assert np.all(uc1==np.array([0,0,0])), "only bonds from origin unit cell implemented here"
bonds.append(Bond(material, atom1, atom2, unit_cell_of_atom_2=uc2, j=j_value))
# for c in combinations[0]:
# a1,u1,a2,u2 = c
# print(np.array(lv).T@(a1.position+u1))
# print(np.array(lv).T@(a2.position+u2))
# print(a1.position+u1)
# print(a2.position+u2)
# print("")
material.transform_from_cryst_basis_to_lv_basis(lv[0], False, True)
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2*X, 1/2*(X+Y), 1/2*(X+Y+Z), np.array([0,0,0])]
# Kx,Ky,Kz = np.array([1,0,1])/2, np.array([1,1,0])/2, np.array([0,1,1])/2
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2* np.array([1,0,1]), 1/2* np.array([0,1,1]), 1/2* np.array([0,0,0])]
#give in euclidean basis for better readability
relative_grid_points_path = [np.array([0,0,0]), np.array([1,0,0]), np.array([1,1,0]), np.array([1,1,1]), np.array([0,0,0])]
#transform to lattice vector basis
material.relative_grid_points_path = material.transform_from_cryst_basis_to_lv_basis(1/2*np.array(relative_grid_points_path),reciprocal=True, transform_coefficients=True, backtranform=False)
material.relative_grid_points_names = [r"$\Gamma$", "X", "M","R", r"$\Gamma$"]
if add_all_domains: #only the material of the first domain should have all other domains added
# add the additional domains
material.add_additional_domain_material([
NiO_2_atom_cell_NN_and_NNN(config, T_domain_idx=1, add_all_domains=False),
NiO_2_atom_cell_NN_and_NNN(config, T_domain_idx=2, add_all_domains=False),
NiO_2_atom_cell_NN_and_NNN(config, T_domain_idx=3, add_all_domains=False),
])
# all_atoms.append(atoms[0])
return material
def K2NiF4(config:Config, a=1, J1 = 9.68, S=1, spin_dir = np.array([0,0,1]), lattice_constant=4.103e-10): #bond length: https://journals.iucr.org/paper?S0108768193003246
A,B,C = np.array([a, a, 0]), np.array([-a, a, 0]), np.array([0, 0, 50*a])
#TODO: make this nicer and more general
# A,B,C = A*T_domains[T_domain_idx], B*T_domains[T_domain_idx], C*T_domains[T_domain_idx]
lv = [A,B,C]
crystallographic_lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, 50*a])]
normal_vector = np.array([-1,1,0]) #arbitrary since commensurate case
tau = np.array([0, 0, 0]) # commensurate
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=2, name=f"K2NiF4", crystallographic_lv=crystallographic_lv, lattice_constant=lattice_constant,
fund_xray_prefactors_filename=K2NiF4_input_file,
symmetry_class= "D4h")
X,Y,Z = material.transform_from_cryst_basis_to_lv_basis(np.array(crystallographic_lv), transform_coefficients=True)
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
Atom(np.array([0, 0, 0]), S=S, spin_dir=spin_dir),
Atom(X, S=S, spin_dir=-spin_dir)
]
J_values = [J1]
# J_values= [J_super_exchange]
#this is not reliably working since I dont account for double counting correctly
bonds = []
combinations, distances = material.return_combinations_up_to_distance(atoms, 2*a)
for i,j_value in enumerate(J_values):
for combs in combinations[i]:
atom1, uc1, atom2, uc2 = combs
assert np.all(uc1==np.array([0,0,0])), "only bonds from origin unit cell implemented here"
bonds.append(Bond(material, atom1, atom2, unit_cell_of_atom_2=uc2, j=j_value))
# for c in combinations[0]:
# a1,u1,a2,u2 = c
# print(np.array(lv).T@(a1.position+u1))
# print(np.array(lv).T@(a2.position+u2))
# print(a1.position+u1)
# print(a2.position+u2)
# print("")
material.transform_from_cryst_basis_to_lv_basis(lv[0], False, True)
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2*X, 1/2*(X+Y), 1/2*(X+Y+Z), np.array([0,0,0])]
# Kx,Ky,Kz = np.array([1,0,1])/2, np.array([1,1,0])/2, np.array([0,1,1])/2
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2* np.array([1,0,1]), 1/2* np.array([0,1,1]), 1/2* np.array([0,0,0])]
#give in euclidean basis for better readability
relative_grid_points_path = [np.array([0,0,0]), np.array([1,0,0]), np.array([1,1,0]), np.array([0,0,0])]
#transform to lattice vector basis
material.relative_grid_points_path = material.transform_from_cryst_basis_to_lv_basis(1/2*np.array(relative_grid_points_path),reciprocal=True, transform_coefficients=True, backtranform=False)
material.relative_grid_points_names = [r"$\Gamma$", "M", "K", r"$\Gamma$"]
return material
#for accessing via input file
MATERIAL_BUILDERS = {
"NiO": NiO_2_atom_cell_NN_and_NNN,
"NiO_incomm_1_atom_cell_NN_and_NNN": NiO_incomm_1_atom_cell_NN_and_NNN,
"K2NiF4": K2NiF4,
}
############################################
# old Examples (Use with care, not tested and patly not up to date with new code structure):
############################################
def give_orthogonal_normal_vector(spin_dir: np.ndarray):
second_vector = np.array([0, 1, 0]) # arbitrary vector not parallel to spin_dir
if np.dot(spin_dir/la.norm(spin_dir), second_vector) > 0.95: # if spin_dir is too close to second_vector
second_vector = np.array([0, 0, 1])
normal_vector = np.cross(spin_dir, np.array([1, 0, 0])) # ensure normal vector is orthogonal to spin direction
return normal_vector
# examples --> trying to do the supercell (J1 J2 model) in general d
def General_D_FM_AFM_simple_cubic_J1_J2(config:Config,J1, J2 ,a1, a, S1, S2, d=3):
lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])]
normal_vector = np.array([-1,1,0])#this should be arbitrary as long as it is in the x,y plane --> bt it effects the shape of the Hamiltonian
if S1 * S2 < 0:
tau = np.array(
[0.5 for _ in range(d)]+[0 for _ in range(3-d)]
) # in direction of all lattice vectors the unit cell is turned by 180° every time (AFM)
else:
tau = np.array([0, 0, 0]) # FM no rotation
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=d)
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
Atom(np.array([0, 0, 0]), type=0, S=S1, spin_dir=np.array([0, 0, S1])),
Atom(1/np.sqrt(d)*np.array([a1]*d+[0]*(3-d)), type=0, S=S2, spin_dir=np.array([0, 0, np.abs(S2)]))
# ,Atom(np.array([a1,0,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,a1,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,0,a1]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
]
bonds = [
#1d
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([0, 0, 0]), j=J1
),
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([-1, 0, 0]), j=J2
),#2d
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([0, -1, 0]), j=J1
),
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([-1, -1, 0]), j=J2
),
#3d
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([0, 0, -1]), j=J1
),
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([-1, -1, -1]), j=J1
),
]
bonds = [bonds[i] for i in range(d)]
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
# all_atoms.append(atoms[0])
return material
# adding bonds to my code
def NiO_supercell(config: Config, J=1, a=1, lattice_constant=4.17e-10):
# if alignement == 0:
# spin_dir = np.array([1, -2, 1])
# elif alignement == 1:
# spin_dir = np.array([-2, 1, 1])
# elif alignement == 2:
# spin_dir = np.array([1, 1, -2])
# else:
# raise ValueError("Invalid alignment value. Must be 0, 1, or 2.")
alignements = [np.array([1, -2, 1]), np.array([-2, 1, 1]), np.array([1, 1, -2])]
# spin_dir = np.array([0,0,1])
# theta = 0.0* np.pi
# spin_dir = rotation.rot_vec(theta,np.array([1,0,0])) @ spin_dir
return DG_AFM_FM_simple_cubic_non_rotated_supercell_auto_bond(config, J=J, a=a, S1=1, S2=-1, spin_dir=np.array([0,0,1]), alignements=alignements)
def NiO_2_atom_cell(config:Config ,J=12,a=1, S1=1, S2=-1, spin_dir=np.array([0,0,1]), lattice_constant=4.17e-10):
alignements = [np.array([1, -2, 1]), np.array([-2, 1, 1]), np.array([1, 1, -2])]
# alignements = [np.array([1, 1, -2])]
lv = [np.array([a, a, 0]), np.array([0, a, a]), np.array([a, 0, a])]
crystallographic_lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])]
config.Gamma = 0.2
M = np.array(lv) #transformation from euclidean to lattice vector basis (A1 A2 A3) = (a1 a2 a3)T (a being the euclidean vectors)
la.inv(M.T)
X,Y,Z = np.array([1,-1,1])/2, np.array([1,1,-1])/2, np.array([-1,1,1])/2 #the absolute X,Y,Z vectors in lattice units
normal_vector = np.array([-1,1,0])#this should be arbitrary as long as it is in the x,y plane --> bt it effects the shape of the Hamiltonian
tau = np.array([0, 0, 0]) # commensurate
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=3, name="NiO 2 atom cell",
extension=1, S_domains=alignements , crystallographic_lv=crystallographic_lv, lattice_constant=lattice_constant)
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
Atom(np.array([0, 0, 0]), type=0, S=S1, spin_dir=spin_dir),
Atom(position=X, type=1, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
# ,Atom(np.array([a1,0,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,a1,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,0,a1]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
]
J_values = [J]
#this is not reliably working since I dont account for double counting correctly
bonds = []
combinations, distances = material.return_combinations_up_to_distance(atoms, 2*a)
for i,j_value in enumerate(J_values):
for combs in combinations[i]:
atom1, uc1, atom2, uc2 = combs
assert np.all(uc1==np.array([0,0,0])), "only bonds from origin unit cell implemented here"
bonds.append(Bond(material, atom1, atom2, unit_cell_of_atom_2=uc2, j=j_value))
# bonds = [
# Bond(
# material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([0, 0, 0]), j=J
# ),
# Bond(
# material, atoms[0], atoms[1], unit_cell_of_atom_2=(Z-X), j=J
# ),
# Bond(
# material, atoms[0], atoms[1], unit_cell_of_atom_2=(Y-X), j=J
# ),
# Bond(
# material, atoms[1], atoms[0], unit_cell_of_atom_2=(Z+X), j=J
# ),
# Bond(
# material, atoms[1], atoms[0], unit_cell_of_atom_2=X+Y, j=J
# ),
# Bond(
# material, atoms[1], atoms[0], unit_cell_of_atom_2=2*X, j=J
# )
# ]
# for c in combinations[0]:
# a1,u1,a2,u2 = c
# print(np.array(lv).T@(a1.position+u1))
# print(np.array(lv).T@(a2.position+u2))
# print(a1.position+u1)
# print(a2.position+u2)
# print("")
material.transform_from_cryst_basis_to_lv_basis(lv[0], False, True)
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2*X, 1/2*(X+Y), 1/2*(X+Y+Z), np.array([0,0,0])]
Kx,Ky,Kz = np.array([1,0,1])/2, np.array([1,1,0])/2, np.array([0,1,1])/2
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2* np.array([1,0,1]), 1/2* np.array([0,1,1]), 1/2* np.array([0,0,0])]
if material.extension ==2:
material.relative_grid_points_path = np.array([np.array([0,0,0]), 1/2*Kx, 1/2*(Kx+Ky), 1/2*(Kx+Ky+Kz), np.array([0,0,0])])
else:
material.relative_grid_points_path = np.array([np.array([0,0,0]), Kx, (Kx+Ky), (Kx+Ky+Kz), np.array([0,0,0])])
# all_atoms.append(atoms[0])
return material
def NiO_2NNN_6NN_atom_cell_NN_and_NNN(config:Config ,J_NN=0,J_super_exchange=1,a=1, S1=1, S2=-1, T_domain_idx = 0, spin_dir=np.array([0,0,1]), lattice_constant=4.17e-10):
S_domains = [np.array([1, -2, 1]), np.array([-2, 1, 1]), np.array([1, 1, -2])]
# alignements = [np.array([1, 1, -2])]
T_domains = [np.array([1, 1, 1]), np.array([1, 1, -1]), np.array([1, -1, 1]), np.array([-1, 1, 1])]
lv = [np.array([a, a, 0]), np.array([0, a, a]), np.array([a, 0, a])]
crystallographic_lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])]
config.Gamma = 0.2
M = np.array(lv) #transformation from euclidean to lattice vector basis (A1 A2 A3) = (a1 a2 a3)T (a being the euclidean vectors)
# la.inv(M.T)
X,Y,Z = np.array([1,-1,1])/2, np.array([1,1,-1])/2, np.array([-1,1,1])/2 #the absolute X,Y,Z vectors in lattice units
normal_vector = np.array([-1,1,0])#this should be arbitrary as long as it is in the x,y plane --> bt it effects the shape of the Hamiltonian
tau = np.array([0, 0, 0]) # commensurate
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=3, name="NiO 2 atom cell NN interactions",
extension=2, S_domains=S_domains , crystallographic_lv=crystallographic_lv)
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
#TODO: Domains
Atom(np.array([0, 0, 0]), type=0, S=S1, spin_dir=spin_dir),
Atom(position=X, type=1, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
Atom(position=1/2*(X+Y), type=0, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
Atom(position=1/2*(X+Z), type=1, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
Atom(position=1/2*(Z+Y), type=4, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
Atom(position=1/2*(X-Y), type=5, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
Atom(position=1/2*(X-Z), type=6, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
Atom(position=1/2*(Z-Y), type=7, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
# ,Atom(np.array([a1,0,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,a1,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,0,a1]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
]
# test if shifting by an arbitrary vector changes the energies
# shift_vector = np.array([0.3, 0.5, 0.2])
# for atom in atoms:
# atom.position = shift_vector + atom.position
#set correct spin directions according to T_domains
for atom in atoms[1:]:
bond_to_atom_0 = atom.position - atoms[0].position
bond_to_atom_1 = atom.position - atoms[1].position
if np.dot(T_domains[T_domain_idx], bond_to_atom_0) <= 1e-5:
atom.spin_dir = atoms[0].spin_dir
elif np.dot(T_domains[T_domain_idx], bond_to_atom_1) <= 1e-5:
atom.spin_dir = atoms[1].spin_dir
else:
raise ValueError("Atom position does not correspond to the selected T_domain_idx")
J_values = [J_NN,J_super_exchange]
J_values= [J_super_exchange]
#this is not reliably working since I dont account for double counting correctly
bonds = []
combinations, distances = material.return_combinations_up_to_distance(atoms, 4*a)
for i,j_value in enumerate(J_values):
for combs in combinations[i]:
atom1, uc1, atom2, uc2 = combs
assert np.all(uc1==np.array([0,0,0])), "only bonds from origin unit cell implemented here"
bonds.append(Bond(material, atom1, atom2, unit_cell_of_atom_2=uc2, j=j_value))
# bonds = [
# Bond(
# material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([0, 0, 0]), j=J
# ),
# Bond(
# material, atoms[0], atoms[1], unit_cell_of_atom_2=(Z-X), j=J
# ),
# Bond(
# material, atoms[0], atoms[1], unit_cell_of_atom_2=(Y-X), j=J
# ),
# Bond(
# material, atoms[1], atoms[0], unit_cell_of_atom_2=(Z+X), j=J
# ),
# Bond(
# material, atoms[1], atoms[0], unit_cell_of_atom_2=X+Y, j=J
# ),
# Bond(
# material, atoms[1], atoms[0], unit_cell_of_atom_2=2*X, j=J
# )
# ]
# for c in combinations[0]:
# a1,u1,a2,u2 = c
# print(np.array(lv).T@(a1.position+u1))
# print(np.array(lv).T@(a2.position+u2))
# print(a1.position+u1)
# print(a2.position+u2)
# print("")
material.transform_from_cryst_basis_to_lv_basis(lv[0], False, True)
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2*X, 1/2*(X+Y), 1/2*(X+Y+Z), np.array([0,0,0])]
Kx,Ky,Kz = np.array([1,0,1])/2, np.array([1,1,0])/2, np.array([0,1,1])/2
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2* np.array([1,0,1]), 1/2* np.array([0,1,1]), 1/2* np.array([0,0,0])]
if material.extension ==2:
material.relative_grid_points_path = [np.array([0,0,0]), 1/2*Kx, 1/2*(Kx+Ky), 1/2*(Kx+Ky+Kz), np.array([0,0,0])]
else:
material.relative_grid_points_path = [np.array([0,0,0]), Kx, (Kx+Ky), (Kx+Ky+Kz), np.array([0,0,0])]
# all_atoms.append(atoms[0])
return material
def NiO_2_atom_cell_NN_and_NNN_double_unit_cell(config:Config ,J_NN=-1.4,J_super_exchange=19,a=1, S1=1, S2=-1, T_domain_idx = 0, spin_dir=np.array([0,0,1]), add_all_domains = True, title_suffix = "", lattice_constant=4.17e-10): # lattice constant in m
#J_NN=-2.3,J_super_exchange=12,
#J_NN=-1.4,J_super_exchange=19,
if add_all_domains:
if T_domain_idx != 0:
config.warnings.add("set the first domain idx to 0 when adding all domains")
T_domain_idx = 0 #set as first domain index
#1= 12meV
S_domains = [np.array([1, -2, 1]), np.array([-2, 1, 1]), np.array([1, 1, -2]),-np.array([1, -2, 1]), -np.array([-2, 1, 1]), -np.array([1, 1, -2])]
# alignements = [np.array([1, 1, -2])]
#TODO: test this!!!
A,B,C = np.array([a, a, 0]), np.array([0, a, a]), np.array([a, 0, a])
#TODO: make this nicer and more general
# A,B,C = A*T_domains[T_domain_idx], B*T_domains[T_domain_idx], C*T_domains[T_domain_idx]
lv = [1/2*(A-B), 1/2*(A-C), 2*A]
crystallographic_lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])]
S_domains = np.einsum("ij,vj->vi", rotation.rot_vec(T_domain_idx*1/2*np.pi, crystallographic_lv[2]), np.array(S_domains)) #roate S-domain vectors by 90 degrees around the z-axis to get the four different T domains
lv = np.einsum("ij,vj->vi", rotation.rot_vec(T_domain_idx*1/2*np.pi, crystallographic_lv[2]), np.array(lv)) #roate lattice vectors by 90 degrees around the z-axis to get the four different T domains
# ------------------------------geometry checks: are S and T-domains correctly implemented------------------------------
#these are the four normal vectors of the different T-domain planes, the first two lattice vectors of exactly one T_domain_idx should be orthogonal to one of these normal vectors
T_domains_normal_vectors = [np.array([1, 1, 1]), np.array([-1, 1, 1]), np.array([-1, -1, 1]),np.array([1, -1, 1])]
#checks S_domain vectors should lay in the plane of the two first lattice vectors
for S_vec in S_domains:
if abs(np.dot(S_vec, np.cross(lv[0], lv[1]))) > 1e-5:
raise ValueError("S_domain vector is not in the plane of the first two lattice vectors")
#checks only one T_domain normal vector is orthogonal to the two first lattice vectors
if T_domains_normal_vectors[T_domain_idx]@lv[0] > 1e-5 and T_domains_normal_vectors[T_domain_idx]@lv[1] > 1e-5:
raise ValueError("rotated T_domain doesnt match the normal vector of the T_domain plane")
normal_vector = np.array([-1,1,0]) #arbitrary since commensurate case
tau = np.array([0, 0, 0]) # commensurate
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=3, name=f"NiO 2 atom cell NN_NNN T_domain_{T_domain_idx}_{title_suffix}",
extension=1, S_domains=S_domains , crystallographic_lv=crystallographic_lv, lattice_constant=lattice_constant)
X,Y,Z = material.transform_from_cryst_basis_to_lv_basis(np.array(crystallographic_lv), transform_coefficients=True)#the absolute X,Y,Z vectors in lattice units
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
Atom(np.array([0, 0, 0]), S=S1, spin_dir=spin_dir),
Atom(position=X, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
Atom(position=2*X, S=S1, spin_dir=spin_dir),
Atom(position=3*X, S=S1, spin_dir=-spin_dir), #[1,0,0] in absolute coords
]
#set correct spin directions according to T_domains
for atom in atoms[1:]:
bond_to_atom_0 = atom.position - atoms[0].position
bond_to_atom_1 = atom.position - atoms[1].position
bond_to_atom_2 = atom.position - atoms[2].position
bond_to_atom_3 = atom.position - atoms[3].position
if np.dot(T_domains_normal_vectors[T_domain_idx], bond_to_atom_0) <= 1e-5:
atom.spin_dir = atoms[0].spin_dir
elif np.dot(T_domains_normal_vectors[T_domain_idx], bond_to_atom_1) <= 1e-5:
atom.spin_dir = atoms[1].spin_dir
elif np.dot(T_domains_normal_vectors[T_domain_idx], bond_to_atom_2) <= 1e-5:
atom.spin_dir = atoms[2].spin_dir
elif np.dot(T_domains_normal_vectors[T_domain_idx], bond_to_atom_3) <= 1e-5:
atom.spin_dir = atoms[3].spin_dir
else:
raise ValueError("Atom position does not correspond to the selected T_domain_idx")
J_values = [J_NN,J_super_exchange]
# J_values= [J_super_exchange]
#this is not reliably working since I dont account for double counting correctly
bonds = []
combinations, distances = material.return_combinations_up_to_distance(atoms, 4*a)
for i,j_value in enumerate(J_values):
for combs in combinations[i]:
atom1, uc1, atom2, uc2 = combs
assert np.all(uc1==np.array([0,0,0])), "only bonds from origin unit cell implemented here"
bonds.append(Bond(material, atom1, atom2, unit_cell_of_atom_2=uc2, j=j_value))
# for c in combinations[0]:
# a1,u1,a2,u2 = c
# print(np.array(lv).T@(a1.position+u1))
# print(np.array(lv).T@(a2.position+u2))
# print(a1.position+u1)
# print(a2.position+u2)
# print("")
material.transform_from_cryst_basis_to_lv_basis(lv[0], False, True)
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2*X, 1/2*(X+Y), 1/2*(X+Y+Z), np.array([0,0,0])]
# Kx,Ky,Kz = np.array([1,0,1])/2, np.array([1,1,0])/2, np.array([0,1,1])/2
# material.relative_grid_points_path = [ np.array([0,0,0]), 1/2* np.array([1,0,1]), 1/2* np.array([0,1,1]), 1/2* np.array([0,0,0])]
#give in euclidean basis for better readability
relative_grid_points_path = [np.array([0,0,0]), np.array([1,0,0]), np.array([1,1,0]), np.array([1,1,1]), np.array([0,0,0])]
#transform to lattice vector basis
material.relative_grid_points_path = material.transform_from_cryst_basis_to_lv_basis(1/2*np.array(relative_grid_points_path),reciprocal=True, transform_coefficients=True, backtranform=False)
if add_all_domains: #only the material of the first domain should have all other domains added
# add the additional domains
material.add_additional_domain_material([
NiO_2_atom_cell_NN_and_NNN(config, T_domain_idx=1, add_all_domains=False),
NiO_2_atom_cell_NN_and_NNN(config, T_domain_idx=2, add_all_domains=False),
NiO_2_atom_cell_NN_and_NNN(config, T_domain_idx=3, add_all_domains=False),
])
# all_atoms.append(atoms[0])
return material
def NiO_8_atom_cell(config:Config ,J=1):
alignements = [np.array([1, -2, 1]), np.array([-2, 1, 1]), np.array([1, 1, -2])]
# alignements = [np.array([1, 1, -2])]
crystallographic_lv = [np.array([1, 0, 0]), np.array([0, 1, 0]), np.array([0, 0, 1])]# this is in order to align with the epxperiment
material = DG_AFM_FM_simple_cubic_non_rotated_supercell_auto_bond(config, J=1, a=2, S1=1, S2=1, J2=0, dimension=3, spin_dir=np.array([0, 0, 1]), relative_position_atom_2=1/2, alignements=alignements)
material.name = "NiO 8 atom cell"
material.set_crystallographic_lv(crystallographic_lv)
config.Gamma = 0.2
return material
def NiO(config:Config ,J=1,a=1, alignement=0):
#assert config.dimension == 3, "NiO configuration is only defined for 3D"
if alignement == 0:
spin_dir = np.array([1, -2, 1])
elif alignement == 1:
spin_dir = np.array([-2, 1, 1])
elif alignement == 2:
spin_dir = np.array([1, 1, -2])
else:
raise ValueError("Invalid alignment value. Must be 0, 1, or 2.")
#spin_dir = np.array([0,0,1])
return General_D_FM_AFM_simple_cubic(config, J, a, S1=1, S2=-1, d=3, spin_dir=spin_dir)
def RNiO_3(config:Config ,J_1=6.3/2,J_2=4.1, J_4=8.3,
anisotropy_K = -1.3 #being along this axis is energetically favorable
, a=1, S1=1/2*(1-0.4), S2=1/2*(1+0.4), add_all_domains = False, T_domain_idx = 0, lattice_constant=3.8e-10):
spin_direction_crystallographic_lv = np.array([1,1,1])#np.array([0.9,0,1.1])
S_domains = [spin_direction_crystallographic_lv]
# alignements = [np.array([1, 1, -2])]
# T_domains = [np.array([1, 1, 1]), np.array([-1, 1, 1]), np.array([1, -1, 1]), np.array([-1, -1, 1])]
#domain 1,1,1
A,B,C = np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])
#TODO: make this nicer and more general
# A,B,C = A*T_domains[T_domain_idx], B*T_domains[T_domain_idx], C*T_domains[T_domain_idx]
lv = [A-B, A-C,4*C]
crystallographic_lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])]
S_domains = np.einsum("ij,vj->vi", rotation.rot_vec(T_domain_idx*1/2*np.pi, crystallographic_lv[2]), np.array(S_domains)) #roate S-domain vectors by 90 degrees around the z-axis to get the four different T domains
lv = np.einsum("ij,vj->vi", rotation.rot_vec(T_domain_idx*1/2*np.pi, crystallographic_lv[2]), np.array(lv)) #roate lattice vectors by 90 degrees around the z-axis to get the four different T domains
normal_vector = np.array([0,1,-1])
rot = rotation.rotation_matrix_from_axis_angle(normal_vector, np.pi/2)
tau = np.array([0, 0, 0]) # commensurate
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=3, name=f"RNiO3_attempt_1",
extension=1, S_domains=S_domains , crystallographic_lv=crystallographic_lv, lattice_constant=lattice_constant)
X,Y,Z = material.transform_from_cryst_basis_to_lv_basis(np.array(crystallographic_lv), transform_coefficients=True)#the absolute X,Y,Z vectors in lattice units
spin_directions = [spin_direction_crystallographic_lv, rot@spin_direction_crystallographic_lv, rot@rot@spin_direction_crystallographic_lv, rot@rot@rot@spin_direction_crystallographic_lv]
# spin_directions = material.transform_from_cryst_basis_to_lv_basis(np.array(spin_directions), reciprocal=False, transform_coefficients=True, backtranform=False)
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
Atom(np.array([0, 0, 0]), type=0, S=S1, spin_dir=spin_directions[0]),
Atom(position=Z, type=1, S=S2, spin_dir=spin_directions[1]), #[1,0,0] in absolute coords
Atom(position=2*Z, type=2, S=S1, spin_dir=spin_directions[2]),
Atom(position=3*Z, type=3, S=S2, spin_dir=spin_directions[3])
]
J_values = [J_1, J_2,0, J_4]
# J_values= [J_super_exchange]
#this is not reliably working since I dont account for double counting correctly ??? is it not ?
bonds = []
combinations, distances = material.return_combinations_up_to_distance(atoms, 8*a)
for i,j_value in enumerate(J_values):
for combs in combinations[i]:
atom1, uc1, atom2, uc2 = combs
assert np.all(uc1==np.array([0,0,0])), "only bonds from origin unit cell implemented here"
bonds.append(Bond(material, atom1, atom2, unit_cell_of_atom_2=uc2, j=j_value))
easy_axis_list = [np.array([1,1,1]),np.array([2,-1,-1])]
#second one is the directions of the sublattice B spin_direction#[np.array([1,1,1]),np.array([-1,1,1]),np.array([1,-1,1]),np.array([1,1,-1])]
# for easy_axis in easy_axis_list:
# anisotropy_tensor = anisotropy_K * np.einsum('i,j->ij', easy_axis, easy_axis)/np.linalg.norm(easy_axis)**2 #easy axis * easy_axis^T normalized
# adding anisotropy terms
for atom in atoms:
if atom.index in [0,2]:#sublattice A
anisotropy_tensor = anisotropy_K * np.einsum('i,j->ij', easy_axis_list[0], easy_axis_list[0])/np.linalg.norm(easy_axis_list[0])**2
else:#sublattice B
anisotropy_tensor = anisotropy_K * np.einsum('i,j->ij', easy_axis_list[1], easy_axis_list[1])/np.linalg.norm(easy_axis_list[1])**2
bonds.append(Bond(material, atom, atom, unit_cell_of_atom_2=np.array([0,0,0]), j=anisotropy_tensor))
material.transform_from_cryst_basis_to_lv_basis(lv[0], False, True)
# material.transform_from_cryst_basis_to_lv_basis(easy_axis_list[1], reciprocal=False, transform_coefficients=True, backtranform=False)
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
#give in euclidean basis for better readability
relative_grid_points_path = [np.array([0,0,0]), np.array([1,1,1])]
#transform to lattice vector basis
#1/4 to match the paper --> here they vary q up to the magnetic ordering vector (1/4,1/4,1/4) in crystallographic basis
material.relative_grid_points_path = material.transform_from_cryst_basis_to_lv_basis(1/4*np.array(relative_grid_points_path),reciprocal=True, transform_coefficients=True, backtranform=False)
if add_all_domains: #only the material of the first domain should have all other domains added
assert False, "not working yet anisotropy terms are not correctly rotated to the other domains"
material.add_additional_domain_material([
RNiO_3(config, J_1, J_2, J_4, anisotropy_K, a, S1, S2, add_all_domains=False, T_domain_idx=1, lattice_constant=lattice_constant),
RNiO_3(config, J_1, J_2, J_4, anisotropy_K, a, S1, S2, add_all_domains=False, T_domain_idx=2, lattice_constant=lattice_constant),
RNiO_3(config, J_1, J_2, J_4, anisotropy_K, a, S1, S2, add_all_domains=False, T_domain_idx=3, lattice_constant=lattice_constant),
])
# for c in combinations[0]:
# a1,u1,a2,u2 = c
# print(np.array(lv).T@(a1.position+u1))
# print(np.array(lv).T@(a2.position+u2))
# print(a1.position+u1)
# print(a2.position+u2)
# print("")
# all_atoms.append(atoms[0])
return material
def D2_with_FM(config:Config ,J=1, J2=0.1, a=1, alignement=0, dimension=2):
#assert config.dimension == 2, "this configuration is only defined for 2D"
d = dimension
if alignement == 0:
spin_dir = np.array([1, -2, 1])
elif alignement == 1:
spin_dir = np.array([-2, 1, 1])
elif alignement == 2:
spin_dir = np.array([1, 1, -2])
else:
raise ValueError("Invalid alignment value. Must be 0, 1, or 2.")
spin_dir = np.array([0,0,1])
return D2_FM_AFM_simple_cubic_NNN_interactions(config=config,J_AFM=J, J_FM=J2, a=a, S=1, d=2, spin_dir=spin_dir)#tau=np.array([0.5]*d +[0]*(3-d)))
def D2_FM_AFM_simple_cubic_NNN_interactions(config: Config, J_AFM, J_FM, a, S, d=2, spin_dir=np.array([0, 0, 1])):
#has to be done as supercell calculations ?
assert d in [2], "Dimension must be 2"
#config.dimension = d
#d = 2
lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])]
normal_vector = give_orthogonal_normal_vector(spin_dir=spin_dir)
tau = np.array([0, 1/2, 0]) # in direction of all lattice vectors the unit cell is turned by 180° every time (AFM)
relative_grid_points_path =[np.array([0,0,0]),np.array([1/4,1/4,0]),np.array([0,1/2,0]),np.array([0,0,0])]
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=2, relative_grid_points_path=relative_grid_points_path, name="D2 FM AFM SC NNN interactions")
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
Atom(np.array([0, 0, 0]), type=0, S=S, spin_dir=np.sign(S)*spin_dir),
# ,Atom(np.array([a1,0,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,a1,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,0,a1]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
]
bonds = [
Bond(
material, atoms[0], atoms[0], unit_cell_of_atom_2=np.array([1, 1, 0]), j=J_AFM
),
Bond(
material, atoms[0], atoms[0], unit_cell_of_atom_2=np.array([1, -1, 0]), j=J_AFM
),
Bond(
material, atoms[0], atoms[0], unit_cell_of_atom_2=np.array([1, 0, 0]), j=J_FM
),
]
#bonds = [bonds[i] for i in range(d)]
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
# all_atoms.append(atoms[0])
return material
def D12_FM_AFM_simple_cubic_NNN_interactions_supercell(config: Config, J, J2, a, S1, S2, d=2, spin_dir=np.array([0, 0, 1]), tau=np.array([0, 0, 0])):
assert d in [2], "Dimension must be 2"
#config.dimension = d
#d = 2
lv = [np.array([a, 0, 0]), np.array([0, a, 0]), np.array([0, 0, a])]
normal_vector = give_orthogonal_normal_vector(spin_dir=spin_dir)
material = Material(config=config,lattice_vectors=lv, tau=tau, normal_vector_to_rotation_plane=normal_vector, dimension=2)
# Create atoms with specific bonds
atoms: List["Atom"] = []
atoms = [
Atom(np.array([0, 0, 0]), type=0, S=S1, spin_dir=np.sign(S1)*spin_dir),
#FM connections
Atom(1/2*np.array([a, 0, 0]), type=1, S=S2, spin_dir=np.sign(S2)*spin_dir),
Atom(1/2*np.array([0, a, 0]), type=1, S=S2, spin_dir=np.sign(S2)*spin_dir),
#AFM connection
Atom(1/2*np.array([a, a, 0]), type=2, S=-S1, spin_dir=-np.sign(S1)*spin_dir),
# ,Atom(np.array([a1,0,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,a1,0]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
# ,Atom(np.array([0,0,a1]),type=1,S=S2, spin_dir=np.array([0,0,S2]))
]
bonds = [
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([0, 0, 0]), j=J2
),
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([0, -1, 0]), j=J2
),
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([-1, 0, 0]), j=J2
),
Bond(
material, atoms[0], atoms[1], unit_cell_of_atom_2=np.array([-1, -1, 0]), j=J2
),
Bond(
material, atoms[0], atoms[2], unit_cell_of_atom_2=np.array([0, 0, 0]), j=J
),
Bond(
material, atoms[0], atoms[2], unit_cell_of_atom_2=np.array([-1, 1, 0]), j=J
),
Bond(
material, atoms[0], atoms[2], unit_cell_of_atom_2=np.array([0, 0, 0]), j=J
),
Bond(
material, atoms[0], atoms[2], unit_cell_of_atom_2=np.array([-1, 1, 0]), j=J
),
]
#bonds = [bonds[i] for i in range(d)]
material.set_bond_atoms(material.sort_atoms_for_type(atoms), bonds=bonds)
# all_atoms.append(atoms[0])
return material
def Fe2O3_hematite_hexagonal(
config,
J=None,
a: float = 5.0370072826930805, # a: float = 5.0346,
c: float = 12.848266139330695, #13.7473,
S_Fe: float = 5/2,
S_O: float = 0.0,
z_fe: float = 0.35517,
x_o: float = 0.3051,
spin_dir: np.ndarray = np.array([0.0, 0.0, 1.0]),
AFM: bool = True,
extension: int = 1,
name: str = "Fe2O3_hematite_hex_conventional"
):
"""
Build a Material for alpha-Fe2O3 (hematite) in the conventional hexagonal cell.
- Does NOT add bonds (user requested).
- Defaults (a, c, z_fe, x_o) taken from experimental CIFs (Finger & Hazen / AMCSD).
- Returns a Material instance with atoms filled in.
"""
config.warnings.add("Not sure if structure is correct")
# hexagonal conventional lattice vectors (Cartesian)
a1 = np.array([a, 0.0, 0.0])
a2 = np.array([-0.5 * a, 0.5 * np.sqrt(3) * a, 0.0])
a3 = np.array([0.0, 0.0, c])
lv = [a1, a2, a3]
# create material object (similar signature to your example)
normal_vector = np.array([1.0, 0.0, 0.0]) # placeholder; adjust if your pipeline needs specific rotation plane
material = Material(
config=config,
lattice_vectors=lv,
extension=extension,