-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomcalc.f77
1278 lines (1278 loc) · 31.8 KB
/
domcalc.f77
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
PROGRAM Domcalc
************************************************************************
* Magnetic antidot simulation - XY Model v.6.1 *
* --------------------------------------------- *
* This code is an variation of the XY model, metropolis algorithm. *
* It simulates the time-evolution of an array of variable spin *
* elements at various temperatures with periodic antidots. *
************************************************************************
* This version includes the following features:
* Energy & magnetization effects to the first nearest neighbor
* Susceptibility, heat capacity & 4th order cumulant
* Demagnetization, external field & anisotropy are enabled
* Magnetization statistics of subdomains
* flip frequency monitoring
************************************************************************
************************************************************************
* Copyright (C) 2006 Brian Weir
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
************************************************************************
Define initial variables
INTEGER ITRNUM, L, K, DLOOP, NEG, I, J, RNGSED, N, SINC
INTEGER STPNUM, Q, T, TP, IDX, MSNAP, LX, LY
C Define array variables
REAL*8 EX, EY, SX(10000), SY(10000), NNX, NNY
C Define calculation variables
REAL*4 RAND, TMPSTP
REAL*8 TMPKTJ, OP, ENET, M, PROB, ENETT
REAL*8 PI, TWOPI
CHARACTER*12 FNAME, LVAR
LOGICAL MFLIP, TMPFLIP, CTFLIP
DIMENSION ENET(6000000), OP(6000000)
C Define variables for susceptibility, heat capacity and cumulant
56
REAL*8 X, C, SUMOP, SUMMAG, SUME, SQE, SQOP, U, SQQOP
REAL*8 ENSUM, MOPSUM, CEN, COP, SQRNOP, RANOP, SUMX, SQX
REAL*8 MX, MY, SX2, SY2, EI, DE, E
REAL*8 SQENET(6000000)
C Define quantum anti-dot properties
INTEGER DOTX, DOTY, SPACX, SPACY
INTEGER NN, SN, NT
COMMON /DOT/ DOTX, DOTY, SPACX, SPACY
COMMON /NN/ LX, LY, NN(10000,4)
COMMON /NN2/ SX, SY, SN(100000)
COMMON /EN/ ENET, SQENET, K
C Define complex Hamiltonian variables
REAL*8 HEXTX, HEXTY, D, EISO, ISODIR, HANGL, HEXT
COMMON /VAR/ EISO, HEXTX, HEXTY
C Extra info variables
REAL*4 RND1, RND2
REAL*8 SX1, SY1
INTEGER CHANGE(100000)
REAL*8 MBIN1X(110), MBIN1Y(110), MBIN2X(110)
REAL*8 MBIN2Y(110), MBIN3X(110), MBIN3Y(110)
REAL*8 MBIN1(110), MBIN2(110), MBIN3(110)
REAL*8 X1, X2, X3, BINSIZE(110)
COMMON /DOM1/ BINSIZE,MBIN1,MBIN1X,MBIN1Y,MBIN2,MBIN2X,MBIN2Y,
% MBIN3,MBIN3X,MBIN3Y,X1,X2,X3,TMPKTJ, ITRNUM, NT
C Define demagnetization calculation variables
REAL*8 DMA(10000,10), DMB(10000,10), DMC(10000,10), DMD(10000,10),
% DME(10000,10)
REAL*8 MXA(10000,10), MXB(10000,10), MXC(10000,10), MXD(10000,10),
% MXE(10000,10)
REAL*8 MYA(10000,10), MYB(10000,10), MYC(10000,10), MYD(10000,10),
% MYE(10000,10)
REAL*8 DMAG, HDMAG
REAL*8 DMDISTH(20,2), DMDISTV(20,2)
INTEGER IDM
COMMON /DMG/ DMA, DMB, DMC, DMD, DME,
% MXA, MXB, MXC, MXD, MXE,
% MYA, MYB, MYC, MYD, MYE
COMMON /DMG2/ DMAG, HDMAG, IDM
COMMON /DIST/ DMDISTH, DMDISTV
C More variables for spin pictures
INTEGER NPASSPICT, ANS5, IP, ANS4,ANS3
CHARACTER*12 FSPINPICT
c CHANGE tracks how often a site flips
57
C Ask for user defined variables
C Define the array
PRINT *, 'Enter array length: '
READ (*,*) LX
PRINT *, 'Enter array width: '
READ (*,*) LY
C set initial values
ANS5 = 0
ANS4=0
ANS3=0
IP = 0
ITRNUM = 1
N = LX*LY
NT = N
ENETT = -2*N
TMPNUM = 20
PI = 3.141592653589793d0
TWOPI = 2.0D0*PI
HEXT = 0
EISO = 0
DMAG = 0
IDM = 1
fspinpict = 'spins.txt'
C Initialize the entire array to initial energy, +1
DO 10 I = 1, N
SX(I) = 1
SY(I) = 0
SN(I) = 1
CHANGE(I) = 0
C NOTE: I is used for columns while J is used for rows
10 CONTINUE
c Initialize the bins for unit cell statistics
DO I = 1, 102
MBIN1X(I) = 0
MBIN1Y(I) = 0
MBIN1(I) = 0
MBIN2X(I) = 0
MBIN2Y(I) = 0
MBIN2(I) = 0
MBIN3X(I) = 0
MBIN3Y(I) = 0
MBIN3(I) = 0
c Store statistics in 'bins'
c bins range from '-1' to '1'
58
c each bin is magnitude '0.02' wide, 100 total
BINSIZE(I) = -1 + 0.02*(I-1)
END DO
C Call NEARBR to initialize the nearest neighbor array
CALL NEARBR
C Ask for file
PRINT *, 'Name the file to record to'
READ (*,*) FNAME
CLOSE (UNIT = 1)
C Ask for multiple temperatures
PRINT *, 'Run a range of temperatures? (Y/N)'
READ (*,*) LVAR
IF (LVAR .EQ. 'y') THEN
TMPFLIP = .TRUE.
PRINT *, 'Enter initial temperature in kT/J'
READ (*,*) TMPKTJ
PRINT *, 'Enter temperature step size'
READ (*,*) TMPSTP
PRINT *, 'How many steps?'
READ (*,*) STPNUM
ELSE
TMPFLIP = .FALSE.
PRINT *, 'Enter temperature in kT/J'
READ (*,*) TMPKTJ
TMPSTP = 0
STPNUM = 1
END IF
C Ask for anti-dot generation
PRINT *, 'Use anti-dots? (Y/N)'
READ (*,*) LVAR
IF (LVAR .EQ. 'y') THEN
PRINT *, 'Use square dots?'
READ (*,*) LVAR
PRINT *, 'Dot diameter(X)?'
READ (*,*) DOTX
IF (LVAR .EQ. 'y') THEN
DOTY = DOTX
ELSE
PRINT *, 'Dot height(y)?'
READ (*,*) DOTY
END IF
PRINT *, 'Dot X spacing?'
59
READ (*,*) SPACX
PRINT *, 'Dot Y spacing?'
READ (*,*) SPACY
CALL DOTGEN
NT = 0
ENETT = 0
DO I = 1, N
NT = NT + SN(I)
ENETT = ENETT - SN(I)*(SN(NN(I, 1)) + SN(NN(I, 2)))
END DO
END IF
E = ENETT
EI = ENETT
PRINT *, 'Enter number of passes'
READ (*,*) ITRNUM
PRINT *, 'Enter RNG seed'
READ (*,*) RNGSED
C This allows the system to reach some equilibrium before recording data
PRINT *, 'Skip how many passes before recording?'
READ (*,*) DLOOP
C Ask for complex Hamiltonian variables
PRINT *, 'Use anisotropy? (y/n)'
READ (*,*) LVAR
IF (LVAR .EQ. 'y') THEN
PRINT *, 'Anisotropy energy?'
READ (*,*) EISO
C PRINT *, 'Direction of the anisotropy? (+1/-1)'
C READ (*,*) ISODIR
ELSE
EISO = 0
END IF
PRINT *, 'Use external field? (y/n)'
READ (*,*) LVAR
IF (LVAR .EQ. 'y') THEN
PRINT *, 'Enter the magnitude of the field'
READ (*,*) HEXT
PRINT *, 'Enter the angle of the field'
READ (*,*) HANGL
HANGL = (HANGL * PI) / 180
HEXTX = HEXT*DCOS(HANGL)
HEXTY = HEXT*DSIN(HANGL)
ELSE
60
HEXT = 0
END IF
PRINT *, 'Include demagnitization? (y/n)'
READ (*,*) LVAR
IF (LVAR .EQ. 'y') THEN
PRINT *, 'Enter the magnitude of the field'
READ (*,*) DMAG
C Call the remaining 4 nearest neighbor arrays
CALL NEARBR2
CALL NEARBR3
CALL NEARBR4
CALL NEARBR5
C precalculate neighbor distances
CALL DMDIST
ELSE
DMAG = 0
END IF
write(*,*) 'Print out spin pictures?'
READ (*,*) LVAR
IF (LVAR .EQ. 'y') THEN
ANS5 = 1
write(*,*) 'Enter lattice pass number for pictures:'
read(*,*) npasspict
IP = NPASSPICT
c write(*,*) 'Enter file name for pictures:'
c read(*,*) fspinpict
fspinpict = 'spins.txt'
else
ANS5 = 0
endif
write(*,*) 'Record flip-rate statistics?'
READ (*,*) LVAR
IF (LVAR .EQ. 'y') THEN
ANS4 = 1
else
ANS4=0
end if
write(*,*) 'Record domain data?'
READ (*,*) LVAR
IF (LVAR .EQ. 'y') THEN
ANS3 = 1
else
ANS3=0
end if
61
************************************************************************
* Write additional information to file:
OPEN (UNIT = 1, FILE = 'data.txt')
C Write parameters
WRITE (1, *) 'Lattice size:', LX, 'x', LY
WRITE (1, *) 'Number of passes:', ITRNUM
WRITE (1, *) 'Number of skipped passes:', DLOOP
WRITE (1, *) 'Number generator seed:', RNGSED
C Write dot parameters
WRITE (1, *) 'Antidot geometry:', DOTX, DOTY, SPACX, SPACY
C Write variables
WRITE (1, *) 'Anisotropy Magnitude:', EISO
WRITE (1, *) 'External Field Magnitude:', HEXT
WRITE (1, *) 'External Field Angle:', HANGL
WRITE (1, *) 'Demagnitization Magnitude:', DMAG
C Write output headings
close(unit=1,status='save')
OPEN (UNIT = 1, FILE = FNAME)
WRITE (1, 15) 'TMPKTJ', 'OP', 'X', 'M', 'MX', 'MY'
15 FORMAT(6(5X, A6))
c CLOSE(UNIT = 1)
C Prepare domain data
IF(ans3 .eq.1) then
close(unit=1,status='save')
OPEN (UNIT = 1, FILE = 'domain.txt')
WRITE (1, 16) 'Bin', 'OP1', 'M1X', 'M1Y', 'OP2', 'M2X',
% 'M2Y', 'OP3', 'M3X', 'M3Y', 'X1', 'X2', 'X3'
16 FORMAT(13(5X, A6))
close(unit=1,status='save')
open(unit=1,file=fname, STATUS='OLD')
end if
c Prepare spin statistics data
IF(ans3 .eq.1) then
close(unit=1,status='save')
OPEN (UNIT = 1, FILE = fspinpict)
write(1,17) 'i,','sn(i),','sx(i),','sy(i),'
17 FORMAT(10(5X, A6))
close(unit=1,status='save')
OPEN (UNIT = 1, FILE = FNAME, STATUS = 'OLD')
endif
********************
C RAN2 requires a negative seed, so we'll just correct it instead of asking
RNGSED = -ABS(RNGSED)
********************
PRINT *, 'Randomizing system, please wait...'
62
C Here's a loop to start up with DLOOP skipped passes
DO K=1, DLOOP
DO 30 I=1,N
IDM = I
SX1 = SX(I)
SY1 = SY(I)
C Make sure holes are not counted
IF (SN(I) .EQ. 1) THEN
NNX = 0
NNY = 0
DO J=1,4
NNX = NNX + SX(NN(I,J))
NNY = NNY + SY(NN(I,J))
END DO
CALL RAN2(RNGSED, RAND)
RND1 = RAND
SX2 = DCOS(RND1*TWOPI)
SY2 = DSIN(RND1*TWOPI)
EX= SX2*NNX
EY= SY2*NNY
CALL DMAGC
EI = -(NNX*SX(I) + NNY*SY(I))
% -EISO * (SX(I)**2)
% -HEXTX*SX(I) -HEXTY*SY(I)
% -HDMAG
SX(I) = SX2
SY(I) = SY2
CALL DMAGC
E = -(EX + EY)
% -EISO * (SX(I)**2)
% -HEXTX*SX(I)- HEXTY*SY(I)
% -HDMAG
DE = E - EI
IF (DE .LT. 0) THEN
SY(I) = SY2
SX(I) = SX2
ENETT = ENETT + DE
ELSE
CALL RAN2(RNGSED, RAND)
63
IF (RAND .LE. EXP(-DE / TMPKTJ)) THEN
SY(I) = SY2
SX(I) = SX2
ENETT = ENETT + DE
ELSE
SX(I) = SX1
SY(I) = SY1
END IF
END IF
END IF
30 CONTINUE
ENDDO
********************
C We begin our temperature outer loop now
DO Q = 1, STPNUM
PRINT *, 'Evaluating temperature', TMPKTJ
********************
C Reset sums before starting next temperature
SUMMAG = 0
SUMOP = 0
SUME = 0
SQOP = 0
SQE = 0
SQQOP = 0
********************
C Now we evaluate the system ITRNUM times
DO K = 1, ITRNUM
C K is a placeholder variable
C Here begins the logic loop for evaluating each item
C we will use row-wise processing because its easier for neighbors
C We include nearest-neighbors here, but
DO 20 I=1,N
IDM = I
SX1 = SX(I)
SY1 = SY(I)
C Make sure holes are not counted
IF (SN(I) .EQ. 1) THEN
NNX = 0
NNY = 0
DO J=1,4
64
NNX = NNX + SX(NN(I,J))
NNY = NNY + SY(NN(I,J))
END DO
C Now, we evaluate the energy
CALL RAN2(RNGSED, RAND)
RND1 = RAND
SX2 = DCOS(RND1*TWOPI)
SY2 = DSIN(RND1*TWOPI)
EX= SX2*NNX
EY= SY2*NNY
CALL DMAGC
EI = -(NNX*SX(I) + NNY*SY(I))
% -EISO * (SX(I)**2)
% -HEXTX*SX(I)- HEXTY*SY(I)
% -HDMAG
SX(I) = SX2
SY(I) = SY2
CALL DMAGC
E = -(EX + EY)
% -EISO * (SX(I)**2)
% -HEXTX*SX(I)- HEXTY*SY(I)
% -HDMAG
DE = E - EI
C call random number here. RAND is a number from 0->1
C for high temperatures, S is more likely to flip
C allow for temperature effects here
IF (DE .LT. 0) THEN
SY(I) = SY2
SX(I) = SX2
ENETT = ENETT + DE
CHANGE(I) = CHANGE(I) + 1
ELSE
CALL RAN2(RNGSED, RAND)
IF (RAND .LE. EXP(-DE / TMPKTJ)) THEN
SY(I) = SY2
SX(I) = SX2
ENETT = ENETT + DE
CHANGE(I) = CHANGE(I) + 1
ELSE
SX(I) = SX1
SY(I) = SY1
END IF
END IF
END IF
20 CONTINUE
65
********************
C Resolve Magnetization, M = ( POS - NEG ) / MSIZE**2
M = 0
MX = 0
MY = 0
DO I = 1, N
MX = MX + SX(I)
MY = MY + SY(I)
END DO
M = SQRT(MX**2 + MY**2)
M = M / NT
C The order parameter is the absolute value of the magnetization
OP(K) = ABS(M)
C Set the Energy and Order Parameter averages now
SUMMAG = SUMMAG + M
SUMOP = SUMOP + OP(K)
SQOP = SQOP + OP(K)*OP(K)
SQQOP = SQQOP + OP(K)**4
c Recalculate energies for the full lattice
E = 0
SUME = 0
SQE = 0
ENET(K)=0
SQENET(K)=0
DO I=1,N
IDM = I
NNX = 0
NNY = 0
DO J=1,2
NNX = NNX + SX(NN(I,J))
NNY = NNY + SY(NN(I,J))
END DO
CALL DMAGC
E = -(NNX*SX(I) + NNY*SY(I))
% -EISO * (SX(I)**2)
% -(HEXTX*SX(I) + HEXTY*SY(I))
% -HDMAG
ENET(K) = ENET(K) + E
SQENET(K) = SQENET(K) + E*E
c this ends the energy recalculation here
end do
c take spin picture data if necessary
66
if(ans5.eq.1) then
if((K/NPASSPICT).eq.0) then
close(unit=1,status='save')
open(unit=1,file=fspinpict, STATUS='OLD')
do i=1,N
write(1,42) i,sn(i),sx(i),sy(i)
42 format(2x,i5,',',i2,',',f9.5,',',f9.5)
enddo
close(unit=1,status='save')
open(unit=1,file=fname, STATUS='OLD')
endif
endif
IF(ANS3.EQ.1) THEN
CALL DOMAIN
end if
C this ends the iteration loop here, K
ENDDO
DO K=1, ITRNUM
SUME = SUME+ENET(K)
SQE = SQE+ENET(K)*ENET(K)
END DO
SUME = SUME/ITRNUM
SQE = SQE/ITRNUM
********************
C Calculate the susceptibility, heat capacity and cumulant
X = (NT / TMPKTJ) * ( (SQOP/ITRNUM) - (SUMOP/ITRNUM)**2 )
C = ( (SQE) - (SUME)**2 ) / (NT * TMPKTJ * TMPKTJ )
U = 1 - ( (SQQOP/ITRNUM) / (3 * ((SQOP/ITRNUM)**2)) )
C Store data per temperature
OPEN (UNIT = 1, FILE = FNAME, STATUS='OLD')
WRITE (1, 70) TMPKTJ, (SUMOP/ITRNUM), X, M, MX, MY
70 FORMAT(6(2X, E12.5))
C Print domain data
IF(ANS3.EQ.1) THEN
close(unit=1,status='save')
OPEN (UNIT = 1, FILE = 'domain.txt', STATUS='OLD')
DO I =1,101
WRITE (1, 72) BINSIZE(I), ABS(MBIN1(I)), MBIN1X(I), MBIN1Y(I),
% ABS(MBIN2(I)), MBIN2X(I), MBIN2Y(I), ABS(MBIN3(I)),
% MBIN3X(I), MBIN3Y(I), X1, X2, X3
72 FORMAT(13(2X, E12.5))
67
END DO
close(unit=1,status='save')
open(unit=1,file=fname, STATUS='OLD')
END IF
C End temperature loop
TMPKTJ = TMPKTJ + TMPSTP
END DO
C Add rate-of-change data
if(ANS4.EQ.1)THEN
close(unit=1,status='save')
OPEN (UNIT = 1, FILE = 'roc.txt', STATUS='OLD')
DO I = 1, LY
WRITE(1,80) (CHANGE(LX*(I-1)+J),J=1,LX)
80 FORMAT(2X, 40(I7,1X))
END DO
CLOSE(UNIT = 1, STATUS='SAVE')
end if
C End Program
END
************************************************************************
* NEARBR: a nearest-neighbor indexing array subroutine *
************************************************************************
subroutine NEARBR
C Sitenum is the lattice location, 1-N
C nnidx is the nn location, 1-4 clockwise
INTEGER I, J, WX, WY, NR
COMMON /NN/ WX, WY, NR(10000, 4)
C Here, W corresponds to L, and NR() to NN()
DO I = 1, WX*WY
C Set locations of nearest neighbors
NR(I, 1) = I - WX
NR(I, 2) = I + 1
NR(I, 3) = I + WX
NR(I, 4) = I - 1
C Correct if an edge
C right side
IF (MOD(I,WX) .EQ. 0) THEN
NR(I, 2) = I - WX + 1
C left side
ELSE IF (MOD((I-1),WX) .EQ. 0) THEN
NR(I, 4) = I + WX - 1
END IF
C Top
68
IF (I .LE. WX) THEN
NR(I, 1) = I + WX*(WY-1)
C Bottom
ELSE IF (I .GT. WX*(WY-1)) THEN
NR(I, 3) = I - WX*(WY-1)
END IF
END DO
RETURN
END
************************************************************************
* DOTGEN: an anti-dot generator *
************************************************************************
SUBROUTINE DOTGEN
INTEGER A, B, C, D
INTEGER NUMX, NUMY, VAR
INTEGER X, Y, SPX, SPY
INTEGER L, NN
REAL*8 SX, SY
INTEGER SN
COMMON /DOT/ X, Y, SPX, SPY
COMMON /NN/ LX, LY, NN(10000,4)
COMMON /NN2/ SX(10000), SY(10000), SN(100000)
VAR = 0
NUMX = INT( LX / (X + SPX) )
NUMY = INT( LY / (Y + SPY) )
PRINT *, "Generating holes..."
C All dots begin in the upper left corner
C Take each point in the original dot and copy it at regular intervals
DO A = 1, Y
C Repeat each y point in the first dot NUMY times
DO B = 1, NUMY
C Now, repeat each x point NUMX times
DO C = 1, X
DO D = 1, NUMX
VAR = (A + (B-1)*(Y+SPY) -1)*LX + C + (X+SPX)*(D-
1)
SN(VAR) = 0
SX(VAR) = 0
SY(VAR) = 0
END DO
END DO
69
END DO
END DO
END
************************************************************************
* RAN2: a random number generator that actually works *
************************************************************************
Subroutine RAN2(idum,rn)
c from Press in Comp. Phys. v6 522 (1992)
Parameter (IM1=2147483563, IM2=2147483399, AM=1./IM1,
& IMM1=IM1-1, IA1=40014, IA2=40692, IQ1=53668, IQ2=52774,
& IR1=12211, IR2=3791, NTAB=32, NDIV=1+IMM1/NTAB,
& EPS=1.2e-7, RNMX=1.-EPS)
Integer idum2, j, k, iv(NTAB), iy
Save iv, iy, idum2
Data idum2/123456789/, iv/NTAB*0/, iy/0/
if(idum.le.0) then !initialize
idum=max(-idum,1)
idum2=idum
do j=NTAB+8,1,-1
k=idum/IQ1
idum=IA1*(idum-k*IQ1)-k*IR1
if(idum.lt.0) idum=idum+IM1
if(j.le.NTAB) iv(j)=idum
enddo
iy=iv(1)
endif
k=idum/IQ1 !start here when not initializing
idum=IA1*(idum-k*IQ1)-k*IR1
if(idum.lt.0) idum=idum+IM1
k=idum2/IQ2
idum2=IA2*(idum2-k*IQ2)-k*IR2
if(idum2.lt.0) idum2=idum2+IM2
j=1+iy/NDIV
iy=iv(j)-idum2
iv(j)=idum
if(iy.lt.1) iy=iy+IMM1
rn=min(AM*iy,RNMX)
return
end
************************************************************************
70
* DOMAIN: A domain magnetization tracking subroutine *
* *
* ___________ *
* | 4 | 1 | *
* |____|____| *
* | 3 | 2 | *
* |____|____| *
* *
************************************************************************
SUBROUTINE DOMAIN
INTEGER X, Y, SPX, SPY
INTEGER I, J, K, A, B
INTEGER LX, LY, NN
REAL*8 SX, SY
REAL*8 MX1, MY1, MX2, MY2, MX3, MY3
REAL*8 M1, M2, M3
REAL*8 MBIN1X(110), MBIN1Y(110), MBIN2X(110)
REAL*8 MBIN2Y(110), MBIN3X(110), MBIN3Y(110)
REAL*8 MBIN1(110), MBIN2(110), MBIN3(110)
REAL*8 BINSIZE(110)
INTEGER SN, NT
REAL*8 SQOP1, SQOP2, SQOP3
REAL*8 X1, X2, X3, TMPKTJ, S1, S2, S3
COMMON /DOT/ X, Y, SPX, SPY
COMMON /NN/ LX, LY, NN(10000,4)
COMMON /NN2/ SX(10000), SY(10000), SN(100000)
COMMON /DOM1/ BINSIZE,MBIN1,MBIN1X,MBIN1Y,MBIN2,MBIN2X,MBIN2Y,
% MBIN3,MBIN3X,MBIN3Y, X1, X2, X3, TMPKTJ, ITRNUM, NT
A = 0
B = 0
MX1 = 0
MY1 = 0
MX2 = 0
MY2 = 0
MX3 = 0
MY3 = 0
S1 = 0
S2 = 0
S3 = 0
J = 1
X1 = 0
X2 = 0
X3 = 0
K = 0
71
C outer loop checks each row
do I=1, LY
c A is the first location of the current row
A = (I-1)*LX + 1
c inner loop checks each cell in the row
do J=1, LX
c B is the current location in the lattice
B = (I-1)*LX + J
IF (SN(A) .EQ. 0) THEN
c this is a row with a hole
c hole rows contain holes (#4) and cell #1
IF (SN(B) .EQ. 1) THEN
MX1 = SX(B)
MY1 = SY(B)
M1 = SQRT(MX1**2 + MY1**2)
DO K = 1,101
IF(M1 .GE. BINSIZE(K) .AND. M1 .LT. BINSIZE(K+1)) THEN
MBIN1(K) = MBIN1(K)+1
END IF
IF(MX1 .GE. BINSIZE(K) .AND. MX1 .LT. BINSIZE(K+1)) THEN
MBIN1X(K) = MBIN1X(K)+1
END IF
IF(MY1 .GE. BINSIZE(K) .AND. MY1 .LT. BINSIZE(K+1)) THEN
MBIN1Y(K) = MBIN1Y(K)+1
END IF
end do
ELSE
END IF
ELSE
c this is a row without a hole
c non-hole rows contain cell #s 2 & 3
IF (SN(J) .EQ. 0) THEN
MX3 = SX(B)
MY3 = SY(B)
M3 = SQRT(MX3**2 + MY3**2)
DO K = 1,101
IF(M3 .GE. BINSIZE(K).AND. M3 .LT. BINSIZE(K+1)) THEN
MBIN3(K) = MBIN3(K)+1
END IF
IF(MX3 .GE. BINSIZE(K).AND. MX3 .LT. BINSIZE(K+1)) THEN
MBIN3X(K) = MBIN3X(K)+1
END IF
IF(MY3 .GE. BINSIZE(K).AND. MY3 .LT. BINSIZE(K+1)) THEN
MBIN3Y(K) = MBIN3Y(K)+1
END IF
END DO
ELSE
MX2 = SX(B)
MY2 = SY(B)
72
M2 = SQRT(MX2**2 + MY2**2)
DO K = 1,101
IF(M2 .GE. BINSIZE(K).AND. M2 .LT. BINSIZE(K+1)) THEN
MBIN2(K) = MBIN2(K)+1
END IF
IF(MX2 .GE. BINSIZE(K).AND. MX2 .LT. BINSIZE(K+1)) THEN
MBIN2X(K) = MBIN2X(K)+1
END IF
IF(MY2 .GE. BINSIZE(K).AND. MY2 .LT. BINSIZE(K+1)) THEN
MBIN2Y(K) = MBIN2Y(K)+1
END IF
END DO
END IF
END IF
end do
end do
RETURN
END
************************************************************************
* NEARBR2: A 2nd nearest neighbor arranging subroutine *
* *
************************************************************************
SUBROUTINE NEARBR2
INTEGER A, B, C, D
INTEGER NUMX, NUMY, VAR
INTEGER X, Y, SPX, SPY
INTEGER L, NN
INTEGER SN, I, J, N
REAL*8 SX, SY
REAL*8 DMA(10000,10), DMB(10000,10), DMC(10000,10), DMD(10000,10),
% DME(10000,10)
REAL*8 MXA(10000,10), MXB(10000,10), MXC(10000,10), MXD(10000,10),
% MXE(10000,10)
REAL*8 MYA(10000,10), MYB(10000,10), MYC(10000,10), MYD(10000,10),
% MYE(10000,10)
REAL*8 DMAG, HDMAG, U
COMMON /DOT/ X, Y, SPX, SPY
COMMON /NN/ LX, LY, NN(10000,4)
COMMON /NN2/ SX(10000), SY(10000), SN(100000)
COMMON /DMG/ DMA, DMB, DMC, DMD, DME,
% MXA, MXB, MXC, MXD, MXE,
% MYA, MYB, MYC, MYD, MYE
COMMON /DMG2/ DMAG, HDMAG
73
I = 1
J = 1
N = LX*LY
C Designations for neighbor locations follow this pattern:
c DM[position]([location], [site number])
c where position is A-E in order of neighbor distance
c and location is in order, clockwise from the top
c and distance is edge distance
C Convert 1st nearest neighbors to new format
DO I=1,N
DMA(I,1) = NN(I,1)
DMA(I,2) = NN(I,2)
DMA(I,3) = NN(I,3)
DMA(I,4) = NN(I,4)
DO J = 5,8
DMA(I,J) = 0
END DO
ENDDO
C Record the site location of each neighbor
DO I=1,N
DMB(I,1) = I - LX + 1
DMB(I,2) = I + LX + 1
DMB(I,3) = I + LX - 1
DMB(I,4) = I - LX -1
C Correct the neighbor locations
C top
IF (I .LE. LX) THEN
DMB(I,1) = DMB(I,1) + N
DMB(I,4) = DMB(I,4) + N
ENDIF
C bottom
IF (I .GT. LX*(LY-1)) THEN
DMB(I,2) = DMB(I,2) - N
DMB(I,3) = DMB(I,3) - N
ENDIF
C left side
IF (MOD((I-1),LX) .EQ. 0) THEN
DMB(I,4) = DMB(I,4) + LX
DMB(I,3) = DMB(I,3) + LX
ENDIF
C right side
IF (MOD(I,LX) .EQ. 0) THEN
DMB(I,1) = DMB(I,1) - LX
DMB(I,2) = DMB(I,2) - LX
74
ENDIF
ENDDO
RETURN
END
************************************************************************
* NEARBR3: A 3rd nearest neighbor arranging subroutine *
* *
************************************************************************
SUBROUTINE NEARBR3
INTEGER A, B, C, D
INTEGER NUMX, NUMY, VAR
INTEGER X, Y, SPX, SPY
INTEGER L, NN
INTEGER SN, I, J, N
REAL*8 SX, SY
REAL*8 DMA(10000,10), DMB(10000,10), DMC(10000,10), DMD(10000,10),
% DME(10000,10)
REAL*8 MXA(10000,10), MXB(10000,10), MXC(10000,10), MXD(10000,10),
% MXE(10000,10)
REAL*8 MYA(10000,10), MYB(10000,10), MYC(10000,10), MYD(10000,10),
% MYE(10000,10)
REAL*8 DMAG, HDMAG, U
COMMON /DOT/ X, Y, SPX, SPY
COMMON /NN/ LX, LY, NN(10000,4)
COMMON /NN2/ SX(10000), SY(10000), SN(100000)
COMMON /DMG/ DMA, DMB, DMC, DMD, DME,
% MXA, MXB, MXC, MXD, MXE,
% MYA, MYB, MYC, MYD, MYE
COMMON /DMG2/ DMAG, HDMAG
I = 1
J = 1
N = LX*LY
C Designations for neighbor locations follow this pattern:
c DM[position]([location], [site number])
c where position is A-E in order of neighbor distance
c and location is in order, clockwise from the top
c and distance is edge distance
C Record the site location of each neighbor
DO I=1,N
DMC(I,1) = I - 2*LX
DMC(I,2) = I + 2
DMC(I,3) = I + 2*LX
75
DMC(I,4) = I - 2
C Correct the neighbor locations
C top
IF (I .LE. 2*LX) THEN
DMC(I,1) = DMC(I,1) + N
ENDIF
C bottom
IF (I .GT. (N - 2*LX)) THEN
DMC(I,3) = DMC(I,3) - N
ENDIF
C left side
IF (MOD((I-1),LX) .EQ. 0) THEN
DMC(I,4) = DMC(I,4) + LX
ELSE IF (MOD((I-2),LX) .EQ. 0) THEN
DMC(I,4) = DMC(I,4) + LX
ENDIF
C right side
IF (MOD(I,LX) .EQ. 0) THEN
DMC(I,2) = DMC(I,2) - LX
ELSE IF (MOD(I+1,LX) .EQ. 0) THEN
DMC(I,2) = DMC(I,2) - LX
ENDIF
ENDDO
RETURN
END
************************************************************************
* NEARBR4: A 4th nearest neighbor arranging subroutine *
* *
************************************************************************
SUBROUTINE NEARBR4
INTEGER A, B, C, D
INTEGER NUMX, NUMY, VAR
INTEGER X, Y, SPX, SPY
INTEGER L, NN
INTEGER SN, I, J, N
REAL*8 SX, SY
REAL*8 DMA(10000,10), DMB(10000,10), DMC(10000,10), DMD(10000,10),
% DME(10000,10)
REAL*8 MXA(10000,10), MXB(10000,10), MXC(10000,10), MXD(10000,10),
% MXE(10000,10)
REAL*8 MYA(10000,10), MYB(10000,10), MYC(10000,10), MYD(10000,10),
% MYE(10000,10)
REAL*8 DMAG, HDMAG, U
COMMON /DOT/ X, Y, SPX, SPY
76
COMMON /NN/ LX, LY, NN(10000,4)
COMMON /NN2/ SX(10000), SY(10000), SN(100000)
COMMON /DMG/ DMA, DMB, DMC, DMD, DME,
% MXA, MXB, MXC, MXD, MXE,
% MYA, MYB, MYC, MYD, MYE
COMMON /DMG2/ DMAG, HDMAG
I = 1
J = 1
N = LX*LY
C Designations for neighbor locations follow this pattern:
c DM[position]([location], [site number])
c where position is A-E in order of neighbor distance
c and location is in order, clockwise from the top
c and distance is edge distance
C Record the site location of each neighbor
DO I=1,N
DMD(I,1) = I - 2*LX + 1
DMD(I,2) = I - LX + 2
DMD(I,3) = I + LX + 2
DMD(I,4) = I + 2*LX +1
DMD(I,5) = I + 2*LX - 1
DMD(I,6) = I + LX - 2
DMD(I,7) = I - LX - 2
DMD(I,8) = I - 2*LX - 1
C Correct the neighbor locations
C top
IF (I .LE. LX) THEN
DMD(I,1) = DMD(I,1) + N
DMD(I,2) = DMD(I,2) + N
DMD(I,7) = DMD(I,7) + N
DMD(I,8) = DMD(I,8) + N
ENDIF
IF ((I .GT. LX) .AND. (I .LE. 2*LX)) THEN
DMD(I,1) = DMD(I,1) + N
DMD(I,8) = DMD(I,8) + N
ENDIF
C bottom
IF (I .GT. LX*(LY-1)) THEN
DMD(I,3) = DMD(I,3) - N
DMD(I,4) = DMD(I,4) - N
DMD(I,5) = DMD(I,5) - N
DMD(I,6) = DMD(I,6) - N
ENDIF
IF ((I .GT. LX*(LY-2)) .AND. (I .LT. N-LX)) THEN
DMD(I,4) = DMD(I,4) - N
77
DMD(I,5) = DMD(I,5) - N
ENDIF
C left side
IF (MOD((I-1),LX) .EQ. 0) THEN
DMD(I,5) = DMD(I,5) + LX
DMD(I,6) = DMD(I,6) + LX
DMD(I,7) = DMD(I,7) + LX
DMD(I,8) = DMD(I,8) + LX
ENDIF
IF (MOD((I-2),LX) .EQ. 0) THEN
DMD(I,6) = DMD(I,6) + LX
DMD(I,7) = DMD(I,7) + LX
ENDIF
C right side
IF (MOD(I,LX) .EQ. 0) THEN
DMD(I,1) = DMD(I,1) - LX
DMD(I,2) = DMD(I,2) - LX
DMD(I,3) = DMD(I,3) - LX
DMD(I,4) = DMD(I,4) - LX
ENDIF
IF (MOD((I+1),LX) .EQ. 0) THEN
DMD(I,2) = DMD(I,2) - LX
DMD(I,3) = DMD(I,3) - LX
ENDIF
ENDDO
RETURN
END
************************************************************************
* NEARBR5: A 5th nearest neighbor arranging subroutine *
* *