-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbraneCount.py
More file actions
1732 lines (1287 loc) · 61.3 KB
/
Copy pathbraneCount.py
File metadata and controls
1732 lines (1287 loc) · 61.3 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
"""Methods to count the number of vacua for the T6/Z2xZ2 orientifold."""
import numpy as np
from scipy.optimize import linprog
import braneCreate
import braneMatrix
import matplotlib.pyplot as plt
from itertools import product, combinations, permutations
import time
def getTIbounds_AJ12_2(J1, J2, T, bix2):
if [J1, J2] == [0, 1]:
if T == 1: return [10, 10]
if T == 2: return [10, 10]
if T == 3: return [12, 10]
if T == 4: return [46, 30]
if T == 5:
if np.array_equal(bix2, [0, 0, 0]): return [80, 35]
if np.array_equal(bix2, [0, 0, 1]): return [80, 35]
if np.array_equal(bix2, [0, 1, 0]): return [80, 35]
if np.array_equal(bix2, [1, 0, 0]): return [80, 35]
if np.array_equal(bix2, [0, 1, 1]): return [50, 20]
if np.array_equal(bix2, [1, 0, 1]): return [80, 35]
if np.array_equal(bix2, [1, 1, 0]): return [80, 35]
if np.array_equal(bix2, [1, 1, 1]): return [50, 20]
if T == 6:
if np.array_equal(bix2, [0, 0, 0]): return [170, 90]
if np.array_equal(bix2, [0, 0, 1]): return [155, 55]
if np.array_equal(bix2, [0, 1, 0]): return [155, 55]
if np.array_equal(bix2, [1, 0, 0]): return [170, 90]
if np.array_equal(bix2, [0, 1, 1]): return [65, 25]
if np.array_equal(bix2, [1, 0, 1]): return [155, 55]
if np.array_equal(bix2, [1, 1, 0]): return [155, 55]
if np.array_equal(bix2, [1, 1, 1]): return [65, 25]
if T == 7:
if np.array_equal(bix2, [0, 0, 0]): return [570, 115]
if np.array_equal(bix2, [0, 0, 1]): return [320, 115]
if np.array_equal(bix2, [0, 1, 0]): return [320, 115]
if np.array_equal(bix2, [1, 0, 0]): return [570, 115]
if np.array_equal(bix2, [0, 1, 1]): return [125, 70]
if np.array_equal(bix2, [1, 0, 1]): return [320, 115]
if np.array_equal(bix2, [1, 1, 0]): return [320, 115]
if np.array_equal(bix2, [1, 1, 1]): return [125, 70]
if T == 8:
if np.array_equal(bix2, [0, 0, 0]): return [800, 225]
if np.array_equal(bix2, [0, 0, 1]): return [800, 130]
if np.array_equal(bix2, [0, 1, 0]): return [800, 130]
if np.array_equal(bix2, [1, 0, 0]): return [800, 150]
if np.array_equal(bix2, [0, 1, 1]): return [205, 80]
if np.array_equal(bix2, [1, 0, 1]): return [800, 130]
if np.array_equal(bix2, [1, 1, 0]): return [800, 130]
if np.array_equal(bix2, [1, 1, 1]): return [205, 65]
elif [J1, J2] == [0, 2]:
if T == 1: return [4, 2]
if T == 2: return [4, 2]
if T == 3: return [5, 3]
if T == 4: return [5, 3]
if T == 5: return [15, 5]
if T == 6: return [25, 6]
if T == 7: return [35, 7]
if T == 8: return [60, 8]
elif [J1, J2] == [0, 3]:
if T == 1: return [4, 2]
if T == 2: return [4, 2]
if T == 3: return [5, 3]
if T == 4: return [5, 3]
if T == 5: return [8, 4]
if T == 6: return [8, 4]
if T == 7: return [10, 4]
if T == 8: return [25, 4]
elif [J1, J2] == [1, 2]:
return [T, T]
elif [J1, J2] == [1, 3]:
return [T, T//2]
elif [J1, J2] == [2, 3]:
return [T, T//2]
else:
print('Unexpected J1/J2:', J1, J2)
return
def getTIbounds_AJ12_3(J1, J2, T, bix2):
if [J1, J2] == [0, 1]:
if T == 1: return [5, 3]
if T == 2: return [5, 3]
if T == 3: return [15, 10]
if T == 4: return [15, 10]
if T == 5:
if np.array_equal(bix2, [0, 0, 0]): return [27, 12]
if np.array_equal(bix2, [0, 0, 1]): return [17, 9]
if np.array_equal(bix2, [0, 1, 0]): return [17, 9]
if np.array_equal(bix2, [1, 0, 0]): return [27, 12]
if np.array_equal(bix2, [0, 1, 1]): return [15, 8]
if np.array_equal(bix2, [1, 0, 1]): return [15, 8]
if np.array_equal(bix2, [1, 1, 0]): return [15, 8]
if np.array_equal(bix2, [1, 1, 1]): return [15, 8]
if T == 6:
if np.array_equal(bix2, [0, 0, 0]): return [100, 35]
if np.array_equal(bix2, [0, 0, 1]): return [55, 22]
if np.array_equal(bix2, [0, 1, 0]): return [55, 22]
if np.array_equal(bix2, [1, 0, 0]): return [100, 35]
if np.array_equal(bix2, [0, 1, 1]): return [16, 10]
if np.array_equal(bix2, [1, 0, 1]): return [55, 22]
if np.array_equal(bix2, [1, 1, 0]): return [55, 22]
if np.array_equal(bix2, [1, 1, 1]): return [20, 10]
if T == 7:
if np.array_equal(bix2, [0, 0, 0]): return [110, 40]
if np.array_equal(bix2, [0, 0, 1]): return [70, 40]
if np.array_equal(bix2, [0, 1, 0]): return [70, 40]
if np.array_equal(bix2, [1, 0, 0]): return [110, 40]
if np.array_equal(bix2, [0, 1, 1]): return [40, 20]
if np.array_equal(bix2, [1, 0, 1]): return [70, 40]
if np.array_equal(bix2, [1, 1, 0]): return [70, 40]
if np.array_equal(bix2, [1, 1, 1]): return [40, 20]
if T == 8:
if np.array_equal(bix2, [0, 0, 0]): return [195, 65]
if np.array_equal(bix2, [0, 0, 1]): return [140, 50]
if np.array_equal(bix2, [0, 1, 0]): return [130, 45]
if np.array_equal(bix2, [1, 0, 0]): return [195, 65]
if np.array_equal(bix2, [0, 1, 1]): return [75, 30]
if np.array_equal(bix2, [1, 0, 1]): return [140, 45]
if np.array_equal(bix2, [1, 1, 0]): return [140, 45]
if np.array_equal(bix2, [1, 1, 1]): return [75, 30]
elif [J1, J2] == [0, 2]:
if T == 1: return [4, 3]
if T == 2: return [4, 2]
if T == 3: return [3, 3]
if T == 4: return [4, 4]
if T == 5: return [5, 5]
if T == 6: return [15, 6]
if T == 7: return [25, 7]
if T == 8: return [35, 8]
elif [J1, J2] == [0, 3]:
if T == 1: return [4, 0]
if T == 2: return [4, 1]
if T == 3: return [3, 1]
if T == 4: return [4, 2]
if T == 5: return [5, 2]
if T == 6: return [6, 3]
if T == 7: return [10, 3]
if T == 8: return [20, 4]
elif [J1, J2] == [1, 2]:
return [T, T]
elif [J1, J2] == [1, 3]:
return [T, T//2]
elif [J1, J2] == [2, 3]:
return [T, T//2]
else:
print('Unexpected J1/J2:', J1, J2)
return
def getTIbounds_AJ123(J1, J2, J3, T, bix2):
if [J1, J2, J3] == [0, 1, 2]:
if T == 1: return [5, 5, 1]
if T == 2: return [8, 6, 2]
if T == 3: return [8, 6, 3]
if T == 4: return [8, 6, 4]
if T == 5: return [8, 6, 5]
if T == 6: return [8, 6, 6]
if T == 7: return [14, 4, 3]
if T == 8: return [30, 5, 4]
elif [J1, J2, J3] == [0, 1, 3]:
return [T, T, T//2]
elif [J1, J2, J3] == [0, 2, 3]:
return [T, T, T//2]
elif [J1, J2, J3] == [1, 2, 3]:
return [T, T, T//2]
else:
print('Unexpected J1/J2/J3:', J1, J2, J3)
return
def getMatrices_1xJ(J, T, bix2, save=False):
"""Find all constraint matrices which result from combining only A[`J`] branes.
Parameters
----------
J : {0, 1, 2, 3}
Which type of A brane to use.
T : int
Tadpole (positive integer).
bix2 : array_like
Tori tilts. `bix2` should have three entries, each either 0 (untilted) or 1 (tilted).
save : bool, optional
Whether results are saved to a file or returned.
"""
# Since, XI > |XJ| for I < J, the negative tadpole is larger than T only for A[0] branes
TJneg_max = T
if J == 0:
TJneg_max = T**3
print('\n' + 100*'=')
print('Building all constraint matrices for T={} and 2*bi={}{}{}'.format(T, *bix2))
print('using only A[{}] branes'.format(J), end='')
print(' subject to T{}- <= {}'.format(J, TJneg_max))
print(100*'-' + '\n')
# Build tadpole bounds
TIpos_max = T * np.ones(4, dtype='int')
TIneg_max = np.zeros(4, dtype='int')
XImax = T * np.ones(4, dtype='int')
XImax[J] = TJneg_max
TIneg_max[J] = TJneg_max
# Get all A[J] branes given XI bounds
print('Getting A[{}] branes...'.format(J), end=' ')
As = braneCreate.typeAJ(J, XImax, bix2)
print('{} found'.format(len(As)))
# Prepare arrays to store matrix objects
matrices_AJ_rank1 = np.empty([0], dtype='object')
matrices_AJ_rank2 = np.empty([0], dtype='object')
matrices_AJ_rank3 = np.empty([0], dtype='object')
if len(As) > 0:
# Make matrix objects for lone A[J] branes
for a in As:
M1 = IRREF3(a[2])
if gaugeFixed(M1):
newMatrix = braneMatrix.matrix(M1, As=[a])
matrices_AJ_rank1 = np.append(matrices_AJ_rank1, [newMatrix])
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J, J))
# Get (upper triangular) compatibility matrix then restrict
# to those which appear in one or more pairs
compatPairs = buildCompatibilityMatrix(As, As, T, TIpos_max, TIneg_max, [J], remove_diag=True)
used = np.max(compatPairs, axis=0)
compatPairs = compatPairs[used]
compatPairs = compatPairs[:, used]
compatPairs = np.triu(compatPairs)
As = As[used]
ii_list, jj_list = np.where(compatPairs)
pairs = zip(ii_list, jj_list)
if len(ii_list) == 0:
print('\nNo compatible A[{}]/A[{}] pairs found.'.format(J, J))
else:
print('\nScanning through {} compatible A[{}]/A[{}] pairs...'.format(len(ii_list), J, J))
t0 = time.time()
for index in range(len(ii_list)):
# Display progress (roughly every 10%)
if (10*index) // len(ii_list) != (10*(index+1)) // len(ii_list):
print('{} / {} = {:.2f} %\t{:.2} min'.format(index, len(ii_list), (100*index)/len(ii_list), (time.time() - t0)/60))
# Get next pair of compatible A branes
ii, jj = next(pairs)
a1 = As[ii]
a2 = As[jj]
# Get combined constraints
M12 = IRREF3(a1[2], a2[2])
# This pair gives an admissible matrix which will always be rank-2
if gaugeFixed(M12):
matrices_AJ_rank2 = np.append(matrices_AJ_rank2, [braneMatrix.matrix(M12, As=[a1, a2])])
# Get other A[J] branes which are compatible with BOTH a1 and a2
whr_1 = np.where(compatPairs[ii])[0]
whr_2 = np.where(compatPairs[jj])[0]
kk_list = np.intersect1d(whr_1, whr_2)
a3s = As[kk_list]
if len(a3s) == 0:
continue
# Get list of constraint matrices obtained by adding in these a3 branes
M123s = np.array([IRREF3(M12, YI) for YI in a3s[:, 2]])
M123s_unique, inverse = np.unique(M123s, axis=0, return_inverse=True)
# a3 branes which do not increase the constraint matrix's rank are potentially
# compatible with all triples
whr_rank2 = np.where([np.array_equal(M123, M12) for M123 in M123s_unique])[0]
# Scan through all M123 constraint matrices
for mm, M123 in enumerate(M123s_unique):
if not intersectsModulusCone(M123):
continue
# Get all branes compatible with the matrix M123
a3s_subset = a3s[inverse == mm]
if len(whr_rank2) > 0:
a3s_subset = np.append(a3s_subset, a3s[inverse == whr_rank2[0]], axis=0)
# Determine if there is a linear combination which satisfies all tadpole bounds
possible, TIneg = findLinearCombination_2_more(a1, a2, a3s_subset, T)
# If so, create matrix object and add to list based on rank
if possible:
newMatrix = braneMatrix.matrix(M123, As=[a1, a2, *a3s_subset])
if newMatrix.rankM == 2:
if gaugeFixed(M123):
matrices_AJ_rank2 = np.append(matrices_AJ_rank2, newMatrix)
else:
matrices_AJ_rank3 = np.append(matrices_AJ_rank3, newMatrix)
# Combine repeated constraint matrices, collecting all compatible
# A[J] branes into single matrix object
matrices_AJ_rank1 = combineRepeats(matrices_AJ_rank1)
matrices_AJ_rank2 = combineRepeats(matrices_AJ_rank2)
matrices_AJ_rank3 = combineRepeats(matrices_AJ_rank3)
# Print summary:
print('\nTotal constraint matrices found:')
print(' Rank 1: {:5}'.format(len(matrices_AJ_rank1)))
print(' Rank 2: {:5}'.format(len(matrices_AJ_rank2)))
print(' Rank 3: {:5}'.format(len(matrices_AJ_rank3)))
if save:
filename_rank1 = 'matrixdata/T={}/2bi={}{}{}/matrices_A[{}]_rank1.txt'.format(T, *bix2, J)
filename_rank2 = 'matrixdata/T={}/2bi={}{}{}/matrices_A[{}]_rank2.txt'.format(T, *bix2, J)
filename_rank3 = 'matrixdata/T={}/2bi={}{}{}/matrices_A[{}]_rank3.txt'.format(T, *bix2, J)
saveToFile(filename_rank1, matrices_AJ_rank1)
saveToFile(filename_rank2, matrices_AJ_rank2)
saveToFile(filename_rank3, matrices_AJ_rank3)
return
else:
return matrices_AJ_rank1, matrices_AJ_rank2, matrices_AJ_rank3
def getMatrices_2xJ_2xStack(Js, T, bix2, TJ12neg_max=None, save=False):
"""Find all constraint matrices which result from combining exactly one A[J1] brane stack
with exactly one A[J2] brane stack.
Parameters
----------
Js : array_like
Array for values J1, J2 (0,1,2,3), the types of A branes to combine.
T : int
Tadpole (positive integer).
bix2 : array_like
Tori tilts. `bix2` should have three entries, each either 0 (untilted) or 1 (tilted).
TJ12neg_max : array_like, optional
Two bounds on the negative tadpoles. If not given, values are set by getTIbounds_AJ12_2().
save : bool, optional
Whether results are saved to a file or returned.
"""
# Unpack values of J1, J2
J1, J2 = Js
if TJ12neg_max is None:
TJ12neg_max = getTIbounds_AJ12_2(J1, J2, T, bix2)
print('\n' + 100*'=')
print('Building all constraint matrices for T={} and 2*bi={}{}{}'.format(T, *bix2), end='')
print('using exactly one A[{}] brane and one A[{}] brane'.format(J1, J2), end='')
print(' subject to T{}- <= {}'.format(J1, TJ12neg_max[0]), end='')
print(' and T{}- <= {}'.format(J2, TJ12neg_max[1]))
print(100*'-' + '\n')
# Build tadpole bounds
TIneg_max = np.zeros(4, dtype='int')
TIneg_max[[J1, J2]] = TJ12neg_max
TIpos_max = T + TIneg_max
XI1max = TIpos_max.copy()
XI1max[J1] = TIneg_max[J1]
XI2max = TIpos_max.copy()
XI2max[J2] = TIneg_max[J2]
# Slightly improve bounds since will be looking for solutions with 2+ stacks
for J in range(4):
if J not in [J1, J2]:
XI1max[J] -= 1
XI2max[J] -= 1
# Get all A[J1] and A[J2] branes compatible with bounds
print('Getting A[{}] branes...'.format(J1), end=' ')
A1s = braneCreate.typeAJ(J1, XI1max, bix2)
print('{} found'.format(len(A1s)))
print('Getting A[{}] branes...'.format(J2), end=' ')
A2s = braneCreate.typeAJ(J2, XI2max, bix2)
print('{} found'.format(len(A2s)))
# Prepare arrays to store matrix objects
matrices_AJ12_2_rank2 = np.empty([0], dtype='object')
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J1, J2))
# Keep track of TIneg
TIneg_counts = np.zeros([TJ12neg_max[0] + 1, TJ12neg_max[1] + 1], dtype='int')
t0 = time.time()
# Loop through all A[J1] branes
for index, a1 in enumerate(A1s):
if (10*index) // len(A1s) != (10*(index+1)) // len(A1s):
print('{} / {} = {:.2f} %\t{:.2} min'.format(index, len(A1s), (100*index)/len(A1s), (time.time() - t0)/60))
# Get all compatible A[J2] branes
whr_pos_2 = np.where(np.max(a1[0] + A2s[:, 0] - TIpos_max, axis=1) <= 0)[0]
whr_neg_2 = np.where(np.max(a1[1] + A2s[whr_pos_2, 1] - TIneg_max, axis=1) <= 0)[0]
whr_2 = whr_pos_2[whr_neg_2]
improved = [satisfiesImprovedTIbounds(a1[0] + a2[0], a1[1] + a2[1],
TIpos_max, TIneg_max, T, J_addable=[J1, J2])
for a2 in A2s[whr_2]]
whr_2 = whr_2[improved]
M12s = np.array([IRREF3(a1[2], a2[2]) for a2 in A2s[whr_2]])
cone = np.where([intersectsModulusCone(M) for M in M12s])[0]
whr_2 = whr_2[cone]
M12s = M12s[cone]
for a2, M12 in zip(A2s[whr_2], M12s):
possible, TIneg = findLinearCombination_2(a1, a2, T)
if possible and (TIneg <= TIneg_max).all():
TIneg_counts[TIneg[J1], TIneg[J2]] += 1
if gaugeFixed(M12):
newMatrix = braneMatrix.matrix(M12, As=[a1, a2])
matrices_AJ12_2_rank2 = np.append(matrices_AJ12_2_rank2, newMatrix)
matrices_AJ12_2_rank2 = combineRepeats(matrices_AJ12_2_rank2)
# Print summary:
print('\nTotal constraint matrices found:')
print(' Rank 2: {:8}'.format(len(matrices_AJ12_2_rank2)))
whr = np.where(TIneg_counts > 0)
if len(whr[0]) > 0:
print('\nT{}- bound: {}\tT{}- bound: {}'.format(J1, TJ12neg_max[0], J2, TJ12neg_max[1]))
print('Max found: {}\tMax found: {}'.format(max(whr[0]), max(whr[1])))
toPlot = TIneg_counts.T
toPlot[toPlot != 0] += np.max(toPlot)//2
plt.imshow(toPlot, origin='lower', cmap='magma', aspect='auto')
plt.title('T={}, 2bi={}{}{}, A[{}{}]$_2$'.format(T, *bix2, J1, J2))
plt.xlabel('$T_-^{}$'.format(J1))
plt.ylabel('$T_-^{}$'.format(J2))
plt.tight_layout()
if save:
plt.savefig('matrixdata/T={}/2bi={}{}{}/A[{}{}]2.png'.format(T, *bix2, J1, J2), dpi=300)
else:
plt.show()
if save:
filename_rank2 = 'matrixdata/T={}/2bi={}{}{}/matrices_A[{}{}]_2_rank2.txt'.format(T, *bix2, J1, J2)
saveToFile(filename_rank2, matrices_AJ12_2_rank2)
return
else:
return matrices_AJ12_2_rank2
def getMatrices_2xJ_3xStack(Js, T, bix2, TJ12neg_max=None, save=False):
J1, J2 = Js
if TJ12neg_max is None:
TJ12neg_max = getTIbounds_AJ12_3(J1, J2, T, bix2)
print('\n' + 100*'=')
print('Building all constraint matrices for T={} and 2*bi={}{}{}'.format(T, *bix2), end='')
print('using at least one A[{}] brane and at least one A[{}] brane'.format(J1, J2))
print('(three or more in total) subject to T{}- <= {}'.format(J1, TJ12neg_max[0]), end='')
print(' and T{}- <= {}'.format(J2, TJ12neg_max[1]))
print(100*'-' + '\n')
# Build tadpole bounds
TIneg_max = np.zeros(4, dtype='int')
TIneg_max[[J1, J2]] = TJ12neg_max
TIpos_max = T + TIneg_max
XI1max = TIpos_max.copy()
XI1max[J1] = TIneg_max[J1]
XI2max = TIpos_max.copy()
XI2max[J2] = TIneg_max[J2]
# Slightly improve bounds since will be looking for solutions with 2+ stacks
for J in range(4):
if J not in [J1, J2]:
XI1max[J] -= 2
XI2max[J] -= 2
# Get all A[J1] and A[J2] branes compatible with bounds
print('Getting A[{}] branes...'.format(J1), end=' ')
A1s = braneCreate.typeAJ(J1, XI1max, bix2)
print('{} found'.format(len(A1s)))
print('Getting A[{}] branes...'.format(J2), end=' ')
A2s = braneCreate.typeAJ(J2, XI2max, bix2)
print('{} found'.format(len(A2s)))
# Prepare arrays to store matrix objects
matrices_AJ12_3_rank2 = np.empty([0], dtype='object')
matrices_AJ12_3_rank3 = np.empty([0], dtype='object')
# Keep track of TIneg
TIneg_counts = np.zeros([TJ12neg_max[0] + 1, TJ12neg_max[1] + 1], dtype='int')
# Build three compatibility matrices. Solutions must containt at least one A[J1] brane
# and one A[J2] branes, so compatPairs_12 will form the basis of candidate pairs/triples/etc.
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J1, J1))
compatPairs_11 = buildCompatibilityMatrix(A1s, A1s, T, TIpos_max, TIneg_max, [J1, J2], remove_diag=True)
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J2, J2))
compatPairs_22 = buildCompatibilityMatrix(A2s, A2s, T, TIpos_max, TIneg_max, [J1, J2], remove_diag=True)
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J1, J2))
compatPairs_12 = buildCompatibilityMatrix(A1s, A2s, T, TIpos_max, TIneg_max, [J1, J2])
ii_list, jj_list = np.where(compatPairs_12)
pairs_12 = zip(ii_list, jj_list)
print('\nScanning through {} compatible A[{}]/A[{}] pairs...'.format(len(ii_list), J1, J2))
t0 = time.time()
# Loop through all compatible A[J1]--A[J2] pairs
for index in range(len(ii_list)):
if (10*index) // len(ii_list) != (10*(index+1)) // len(ii_list):
print('{} / {} = {:.2f} %\t{:.2} min'.format(index, len(ii_list), (100*index)/len(ii_list), (time.time() - t0)/60))
ii, jj = next(pairs_12)
a1 = A1s[ii]
a2 = A2s[jj]
M12 = IRREF3(a1[2], a2[2])
# Get other A1s/A2s compatible with a1/a2, respectively
kk1_list = np.where(compatPairs_11[ii])[0]
kk2_list = np.where(compatPairs_22[jj])[0]
# Restrict to those which are compatible with both a1/a2
kk1_list = kk1_list[compatPairs_12[kk1_list, jj]]
kk2_list = kk2_list[compatPairs_12[ii, kk2_list]]
a3s = np.concatenate([A1s[kk1_list], A2s[kk2_list]])
if len(a3s) == 0:
continue
M123s = [IRREF3(M12, YI) for YI in a3s[:, 2]]
M123s_unique, inverse = np.unique(M123s, axis=0, return_inverse=True)
whr_rank2 = np.where([np.array_equal(M123, M12) for M123 in M123s_unique])[0]
for mm, M123 in enumerate(M123s_unique):
if not intersectsModulusCone(M123):
continue
a3s_subset = a3s[inverse == mm]
if len(whr_rank2) > 0:
a3s_subset = np.append(a3s_subset, a3s[inverse == whr_rank2[0]], axis=0)
possible, TIneg = findLinearCombination_2_more(a1, a2, a3s_subset, T)
if possible and (TIneg <= TIneg_max).all():
TIneg_counts[TIneg[J1], TIneg[J2]] += 1
newMatrix = braneMatrix.matrix(M123, As=[a1, a2, *a3s_subset])
if newMatrix.rankM == 2:
if gaugeFixed(M123):
matrices_AJ12_3_rank2 = np.append(matrices_AJ12_3_rank2, newMatrix)
else:
matrices_AJ12_3_rank3 = np.append(matrices_AJ12_3_rank3, newMatrix)
matrices_AJ12_3_rank2 = combineRepeats(matrices_AJ12_3_rank2)
matrices_AJ12_3_rank3 = combineRepeats(matrices_AJ12_3_rank3)
# Print summary:
print('\nTotal constraint matrices found:')
print(' Rank 2: {:8}'.format(len(matrices_AJ12_3_rank2)))
print(' Rank 3: {:8}'.format(len(matrices_AJ12_3_rank3)))
whr = np.where(TIneg_counts > 0)
if len(whr[0]) > 0:
print('\nT{}- bound: {}\tT{}- bound: {}'.format(J1, TJ12neg_max[0], J2, TJ12neg_max[1]))
print('Max found: {}\tMax found: {}'.format(max(whr[0]), max(whr[1])))
toPlot = TIneg_counts.T
toPlot[toPlot != 0] += np.max(toPlot)//2
plt.imshow(toPlot, origin='lower', cmap='magma', aspect='auto')
plt.title('T={}, 2bi={}{}{}, A[{}{}]$_3$'.format(T, *bix2, J1, J2))
plt.xlabel('$T_-^{}$'.format(J1))
plt.ylabel('$T_-^{}$'.format(J2))
plt.tight_layout()
if save:
plt.savefig('matrixdata/T={}/2bi={}{}{}/A[{}{}]3.png'.format(T, *bix2, J1, J2), dpi=300)
else:
plt.show()
if save:
filename_rank2 = 'matrixdata/T={}/2bi={}{}{}/matrices_A[{}{}]_3_rank2.txt'.format(T, *bix2, J1, J2)
filename_rank3 = 'matrixdata/T={}/2bi={}{}{}/matrices_A[{}{}]_3_rank3.txt'.format(T, *bix2, J1, J2)
saveToFile(filename_rank2, matrices_AJ12_3_rank2)
saveToFile(filename_rank3, matrices_AJ12_3_rank3)
return
else:
return matrices_AJ12_3_rank2, matrices_AJ12_3_rank3
def getMatrices_3xJ(Js, T, bix2, TJ123neg_max=None, save=False):
J1, J2, J3 = Js
if TJ123neg_max is None:
TJ123neg_max = getTIbounds_AJ123(J1, J2, J3, T, bix2)
print('\n' + 100*'=')
print('Building all constraint matrices for T={} and 2*bi={}{}{}'.format(T, *bix2), end='')
print('using at least one A[{}] brane, at least one A[{}] brane and at least one A[{}] brane'.format(J1, J2, J3))
print('subject to T{}- <= {}'.format(J1, TJ123neg_max[0]), end='')
print(', T{}- <= {} and T{}- <= {}'.format(J2, TJ123neg_max[1], J3, TJ123neg_max[2]))
print(100*'-' + '\n')
# Build tadpole bounds
TIneg_max = np.zeros(4, dtype='int')
TIneg_max[[J1, J2, J3]] = TJ123neg_max
TIpos_max = T + TIneg_max
XI1max = TIpos_max.copy()
XI1max[J1] = TIneg_max[J1]
XI2max = TIpos_max.copy()
XI2max[J2] = TIneg_max[J2]
XI3max = TIpos_max.copy()
XI3max[J3] = TIneg_max[J3]
# Slightly improve bounds since will be looking for solutions with 3+ stacks
for J in range(4):
if J not in [J1, J2, J3]:
XI1max[J] -= 2
XI2max[J] -= 2
XI3max[J] -= 2
# Get all A[J1], A[J2] and A[J3] branes compatible with bounds
print('Getting A[{}] branes...'.format(J1), end=' ')
A1s = braneCreate.typeAJ(J1, XI1max, bix2)
print('{} found'.format(len(A1s)))
print('Getting A[{}] branes...'.format(J2), end=' ')
A2s = braneCreate.typeAJ(J2, XI2max, bix2)
print('{} found'.format(len(A2s)))
print('Getting A[{}] branes...'.format(J3), end=' ')
A3s = braneCreate.typeAJ(J3, XI3max, bix2)
print('{} found'.format(len(A3s)))
# Prepare arrays to store matrix objects
matrices_AJ123_rank2 = np.empty([0], dtype='object')
matrices_AJ123_rank3 = np.empty([0], dtype='object')
# Keep track of TIneg
TIneg_counts = np.zeros([TJ123neg_max[0] + 1, TJ123neg_max[1] + 1, TJ123neg_max[2] + 1], dtype='int')
# Build six compatibility matrices. Solutions must containt at least one A[J1], one A[J2]
# and one A[J3] brane
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J1, J1))
compatPairs_11 = buildCompatibilityMatrix(A1s, A1s, T, TIpos_max, TIneg_max, [J1, J2], remove_diag=True)
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J2, J2))
compatPairs_22 = buildCompatibilityMatrix(A2s, A2s, T, TIpos_max, TIneg_max, [J1, J2], remove_diag=True)
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J3, J3))
compatPairs_33 = buildCompatibilityMatrix(A3s, A3s, T, TIpos_max, TIneg_max, [J1, J2], remove_diag=True)
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J1, J2))
compatPairs_12 = buildCompatibilityMatrix(A1s, A2s, T, TIpos_max, TIneg_max, [J1, J2])
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J1, J3))
compatPairs_13 = buildCompatibilityMatrix(A1s, A3s, T, TIpos_max, TIneg_max, [J1, J2])
print('\nFinding compatible A[{}]/A[{}] pairs...'.format(J2, J3))
compatPairs_23 = buildCompatibilityMatrix(A2s, A3s, T, TIpos_max, TIneg_max, [J1, J2])
ii2_list, ii3_list = np.where(compatPairs_23)
pairs_23 = zip(ii2_list, ii3_list)
print('\nScanning through {} compatible A[{}]/A[{}] pairs...'.format(len(ii2_list), J2, J3))
t0 = time.time()
# Loop through all compatible A[J2]--A[J3] pairs
for index in range(len(ii2_list)):
if (10*index) // len(ii2_list) != (10*(index+1)) // len(ii2_list):
print('{} / {} = {:.2f} %\t{:.2} min'.format(index, len(ii2_list), (100*index)/len(ii2_list), (time.time() - t0)/60))
ii2, ii3 = next(pairs_23)
a2 = A2s[ii2]
a3 = A3s[ii3]
M23 = IRREF3(a2[2], a3[2])
# Get A1s compatible with both a2/a3
ii1_list = np.where(compatPairs_12[:, ii2] * compatPairs_13[:, ii3])[0]
whr_pos = np.where(np.max(a2[0] + a3[0] + A1s[ii1_list, 0] - TIpos_max, axis=1) <= 0)[0]
whr_neg = np.where(np.max(a2[1] + a3[1] + A1s[ii1_list, 1] - TIneg_max, axis=1) <= 0)[0]
whr_tad = np.intersect1d(whr_pos, whr_neg)
ii1_list = ii1_list[whr_tad]
M123s = np.array([IRREF3(M23, a1[2]) for a1 in A1s[ii1_list]])
cone = [intersectsModulusCone(M) for M in M123s]
M123s = M123s[cone]
ii1_list = ii1_list[cone]
for ii1, M123 in zip(ii1_list, M123s):
a1 = A1s[ii1]
jj1_list = np.where(compatPairs_11[ii1])[0]
jj2_list = np.where(compatPairs_22[ii2])[0]
jj3_list = np.where(compatPairs_33[ii3])[0]
a_subset = np.concatenate([A1s[jj1_list], A2s[jj2_list], A3s[jj3_list]])
M1234s = np.array([IRREF3(M123, a[2]) for a in a_subset])
cone = [intersectsModulusCone(M) for M in M1234s]
a_subset = a_subset[cone]
M1234s = M1234s[cone]
#Just use a1/a2/a3
possible, TIneg = findLinearCombination_3(a1, a2, a3, T)
if possible and (TIneg <= TIneg_max).all():
TIneg_counts[TIneg[J1], TIneg[J2], TIneg[J3]] += 1
newMatrix = braneMatrix.matrix(M123, As=[a1, a2, a3])
if newMatrix.rankM == 2:
if gaugeFixed(M123):
matrices_AJ123_rank2 = np.append(matrices_AJ123_rank2, newMatrix)
else:
matrices_AJ123_rank3 = np.append(matrices_AJ123_rank3, newMatrix)
if len(a_subset) > 0:
M1234s_unique, inverse = np.unique(M1234s, axis=0, return_inverse=True)
# a branes which do not increase the constraint matrix's rank are potentially
# compatible with all triples
whr_unchanged = np.where([np.array_equal(M1234, M123) for M1234 in M1234s_unique])[0]
# Scan through all M123 constraint matrices
for mm, M1234 in enumerate(M1234s_unique):
# Get all branes compatible with the matrix M123
a4s_subset = a_subset[inverse == mm]
if len(whr_unchanged) > 0:
a4s_subset = np.append(a4s_subset, a_subset[inverse == whr_unchanged[0]], axis=0)
# Determine if there is a linear combination which satisfies all tadpole bounds
possible, TIneg = findLinearCombination_3_more(a1, a2, a3, a4s_subset, T)
if possible and (TIneg <= TIneg_max).all():
TIneg_counts[TIneg[J1], TIneg[J2], TIneg[J3]] += 1
newMatrix = braneMatrix.matrix(M1234, As=[a1, a2, a3, *a4s_subset])
if newMatrix.rankM == 2:
if gaugeFixed(M1234):
matrices_AJ123_rank2 = np.append(matrices_AJ123_rank2, newMatrix)
else:
matrices_AJ123_rank3 = np.append(matrices_AJ123_rank3, newMatrix)
matrices_AJ123_rank2 = combineRepeats(matrices_AJ123_rank2)
matrices_AJ123_rank3 = combineRepeats(matrices_AJ123_rank3)
# Print summary:
print('\nTotal constraint matrices found:')
print(' Rank 2: {:8}'.format(len(matrices_AJ123_rank2)))
print(' Rank 3: {:8}'.format(len(matrices_AJ123_rank3)))
whr = np.where(TIneg_counts > 0)
if len(whr[0]) > 0:
print('\nT{}- bound: {}\tT{}- bound: {}\tT{}- bound: {}'.format(J1, TJ123neg_max[0], J2, TJ123neg_max[1], J3, TJ123neg_max[2]))
print('Max found: {}\tMax found: {}\tMax found: {}'.format(max(whr[0]), max(whr[1]), max(whr[2])))
toPlot = np.sum(TIneg_counts, axis=2).T
toPlot[toPlot != 0] += np.max(toPlot)//2
plt.imshow(toPlot, origin='lower', cmap='magma', aspect='auto')
plt.title('T={}, 2bi={}{}{}, A[{}{}{}]$_3$'.format(T, *bix2, J1, J2, J3))
plt.xlabel('$T_-^{}$'.format(J1))
plt.ylabel('$T_-^{}$'.format(J2))
plt.tight_layout()
if save:
plt.savefig('matrixdata/T={}/2bi={}{}{}/A[{}{}{}]3.png'.format(T, *bix2, J1, J2, J3), dpi=300)
else:
plt.show()
if save:
filename_rank2 = 'matrixdata/T={}/2bi={}{}{}/matrices_A[{}{}{}]_rank2.txt'.format(T, *bix2, J1, J2, J3)
filename_rank3 = 'matrixdata/T={}/2bi={}{}{}/matrices_A[{}{}{}]_rank3.txt'.format(T, *bix2, J1, J2, J3)
saveToFile(filename_rank2, matrices_AJ123_rank2)
saveToFile(filename_rank3, matrices_AJ123_rank3)
return
else:
return matrices_AJ123_rank2, matrices_AJ123_rank3
def getMatrices_Bonly(T, bix2, save=False):
"""Find all constraint matrices which result from combining only B branes.
Parameters
----------
T : int
Tadpole (positive integer).
bix2 : array_like
Tori tilts. `bix2` should have three entries, each either 0 (untilted) or 1 (tilted).
save : bool, optional
Whether results are saved to a file or returned.
"""
print('\n' + 100*'=')
print('Building all constraint matrices using only B branes for T={}'.format(T), end='')
print(' and 2*bi={}{}{}'.format(*bix2))
print(100*'-' + '\n')
# Prepare arrays for matrix objects
matrices_B_rank1 = np.empty([0], dtype='object')
matrices_B_rank2 = np.empty([0], dtype='object')
matrices_B_rank3 = np.empty([0], dtype='object')
# Get complete lists of all six B brane types
Bs = np.empty([0, 2, 4], dtype='int')
for J1, J2 in combinations(range(4), 2):
print('Getting B[{}{}] branes...'.format(J1, J2), end=' ')
BIJs = braneCreate.typeBIJ(J1, J2, [T, T], bix2)
print('{} found'.format(len(BIJs)))
Bs = np.append(Bs, BIJs, axis=0)
# Get constraints in reduced form and find list of unique constraints
YIs = [YI // np.gcd.reduce(YI) for YI in Bs[:, 1]]
YIunique, YIinverse = np.unique(YIs, axis=0, return_inverse=True)
# Build rank-1 matrices and save
for ii, YI in enumerate(YIunique):
whr = np.where(YIinverse == ii)[0]
M1 = IRREF3(YI)
if gaugeFixed(M1):
newMatrix = braneMatrix.matrix(M1, Bs=Bs[whr])
matrices_B_rank1 = np.append(matrices_B_rank1, [newMatrix])
# Find all pairs of unique YI which lead to admissible constraint matrix and can satisfy tadpole
print('\nFinding all compatible B/B pairs...')
# Array for recording compatible pairs
compatible = np.zeros([len(YIunique), len(YIunique)], dtype='bool')
# Scan through all pairs
numPairs = len(YIunique)*(len(YIunique) - 1) // 2
indexPairs = combinations(range(len(YIunique)), 2)
t0 = time.time()
for index in range(numPairs):
# Display progress (roughly every 10%)
if (10*index) // numPairs != (10*(index+1)) // numPairs:
print('{} / {} = {:.2f} %\t{:.2} min'.format(index, numPairs, (100*index)/numPairs, (time.time() - t0)/60))
# Get next pair and corresponding constraints
ii, jj = next(indexPairs)
YaI = YIunique[ii]
YbI = YIunique[jj]
# The combined constraint matrix
Mab = IRREF3(YaI, YbI)
if intersectsModulusCone(Mab):
# Get all branes which have one of these constraints
whr_a = np.where(YIinverse == ii)[0]
whr_b = np.where(YIinverse == jj)[0]
XaI_list = Bs[whr_a, 0]
XbI_list = Bs[whr_b, 0]
# Look at pairs of these branes to see if the tadpole bounds can be satisfied
for XaI, XbI in product(XaI_list, XbI_list):
if max(XaI + XbI) <= T:
compatible[ii, jj] = True
break
pairs = np.array(np.where(compatible)).T
# Triples of B branes (to give rank-3 constraint matrices) can be found
# by looking for mutually-compatible pairs
print('\nScanning through {} compatible B/B pairs...'.format(len(pairs)))
t0 = time.time()
for index in range(len(pairs)):
# Display progress (roughly every 10%)
if (10*index) // len(pairs) != (10*(index+1)) // len(pairs):
print('{} / {} = {:.2f} %\t{:.2} min'.format(index, len(pairs), (100*index)/len(pairs), (time.time() - t0)/60))
# Get the next compatible pair and the constraints
ii, jj = pairs[index]
YaI = YIunique[ii]
YbI = YIunique[jj]
# Find B branes with these constraints
whr_a = np.where(YIinverse == ii)[0]
whr_b = np.where(YIinverse == jj)[0]
# Combined constraint matrix
Mab = IRREF3(YaI, YbI)
# We already know this pair is admissible - create matrix object and save
if gaugeFixed(Mab):
newMatrix = braneMatrix.matrix(Mab, Bs=[*Bs[whr_a], *Bs[whr_b]])
matrices_B_rank2 = np.append(matrices_B_rank2, [newMatrix])
# Find all constraints which are compatible with BOTH of those in the pair being considered
kk_list = np.where(compatible[ii] * compatible[jj])[0]
# Restrict to those which give an admissible rank-3 matrix
Ms = np.array([IRREF3(Mab, YI) for YI in YIunique[kk_list]])
cone = [intersectsModulusCone(M) for M in Ms]
kk_list = kk_list[cone]
Ms = Ms[cone]
for kk, Mabc in zip(kk_list, Ms):
# Find B branes with this third constraint
whr_c = np.where(YIinverse == kk)[0]
# Get lists of B branes with these three constraints
XaI_list = Bs[whr_a, 0]
XbI_list = Bs[whr_b, 0]
XcI_list = Bs[whr_c, 0]
# Loop through triples and look for a combination which satisfies the tadpole bounds
for XaI, XbI, XcI in product(XaI_list, XbI_list, XcI_list):
if max(XaI + XbI + XcI) <= T:
newMatrix = braneMatrix.matrix(Mabc, Bs=[*Bs[whr_a], *Bs[whr_b], *Bs[whr_c]])
# Only need to save if rank-3 (rank-2 would have already been saved)
if newMatrix.rankM == 3: