-
Notifications
You must be signed in to change notification settings - Fork 5
/
utils.f
705 lines (618 loc) · 20.7 KB
/
utils.f
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
C *************************************************
C *************************************************
C * UTILITY SUBROUTINES *
C *************************************************
C *************************************************
C
C *************************************************
C * TRACE OF A 3X3 MATRIX *
C *************************************************
real*8 function trace(A)
real*8, intent(in):: A(3,3)
trace = A(1,1)+A(2,2)+A(3,3)
return
end function
!Trace for any size of square matrix
! real*8 function trace(A)
! real*8, intent(in):: A(:,:)
! real*8 :: X
! integer :: N
!
! X = 0.
! do i=1,ubound(A,1)
! X = X+ A(i,i)
! end do
! trace = X
! return
! end function
C *************************************************
C * TRANSFER 3X3 MATRIX TO 6X1 COLUMN VECTOR *
C *************************************************
SUBROUTINE KMATVEC6(DMIN,DVOUT)
INCLUDE 'aba_param.inc'
PARAMETER (M=3,N=3,K=6)
DIMENSION DMIN(M,N),DVOUT(K)
DO I=1,M
DVOUT(I)=DMIN(I,I)
END DO
DVOUT(4) = DMIN(1,2)
DVOUT(5) = DMIN(1,3)
DVOUT(6) = DMIN(2,3)
RETURN
END
C *************************************************
C * TRANSFER 6X1 COLUMN VECTOR TO 3X3 MATRIX *
C *************************************************
SUBROUTINE KVECMAT6(DVIN,DMOUT)
INCLUDE 'aba_param.inc'
PARAMETER (M=3,N=3,K=6)
DIMENSION DVIN(K),DMOUT(M,N)
DO I=1,M
DMOUT(I,I) = DVIN(I)
END DO
DMOUT(1,2) = DVIN(4)
DMOUT(2,1) = DVIN(4)
DMOUT(1,3) = DVIN(5)
DMOUT(3,1) = DVIN(5)
DMOUT(3,2) = DVIN(6)
DMOUT(2,3) = DVIN(6)
RETURN
END
C *************************************************
C * VECTOR PRODUCT OF 3X1 WITH 3X1 GIVING 3X1 *
C *************************************************
SUBROUTINE KVECPROD(DVIN1,DVIN2,DVOUT)
INCLUDE 'ABA_PARAM.INC'
PARAMETER(M=3)
DIMENSION DVIN1(M),DVIN2(M),DVOUT(M)
DVOUT(1)=DVIN1(2)*DVIN2(3)-DVIN2(2)*DVIN1(3)
DVOUT(2)=DVIN2(1)*DVIN1(3)-DVIN1(1)*DVIN2(3)
DVOUT(3)=DVIN1(1)*DVIN2(2)-DVIN2(1)*DVIN1(2)
RETURN
END
C *************************************************
C * VECTOR PRODUCT OF 3X1 WITH 3X1 GIVING 3X1 *
C *************************************************
SUBROUTINE KDOTPROD(DVIN1,DVIN2,DVOUT)
INCLUDE 'ABA_PARAM.INC'
PARAMETER(M=3)
DIMENSION DVIN1(M),DVIN2(M)
DVOUT = DVIN1(1)*DVIN2(1)+DVIN1(2)*DVIN2(2)+DVIN1(3)*DVIN2(3)
DVOUT = abs(DVOUT)
RETURN
END
C *************************************************
C *TRANSFER GENERAL 3X3 MATRIX TO 6X1 COLUMN VECTOR *
C *************************************************
SUBROUTINE KGMATVEC6(DMIN,DVOUT)
INCLUDE 'ABA_PARAM.INC'
PARAMETER (M=3,N=3,K=6)
DIMENSION DMIN(M,N),DVOUT(K)
DO I=1,M
DVOUT(I)=DMIN(I,I)
END DO
DVOUT(4) = DMIN(1,2)+DMIN(2,1)
DVOUT(5) = DMIN(3,1)+DMIN(1,3)
DVOUT(6) = DMIN(2,3)+DMIN(3,2)
RETURN
END
C *************************************************
C * INVERSE OF A MATRIX WITH LAPACK *
C *************************************************
!Checked inverse against python's numpy.linalg.inv
subroutine lapinverse(xmatin,M,info,xmatout)
implicit none
integer,intent(in) :: M
real*8,intent(in):: xmatin(M,M) !abaqus won't allow xmatin(:,:)
integer,parameter :: LWORK = 64
real*8,parameter :: zero=1.0e-12
integer :: i,j
integer,intent(out) :: INFO
real*8,intent(out):: xmatout(M,M)
integer :: IPIV(M)
real*8 :: A(M,M)
real*8 :: WORK(LWORK)
EXTERNAL DGETRI, DGETRF
! https://software.intel.com/en-us/mkl-developer-reference-fortran-getri#626EB2AE-CA6A-4233-A6FA-04F54EF7A6E6
xmatout = 0.
A = xmatin !Don't input array xmatin
call DGETRF( M, M, A, M, IPIV, INFO )
if(info == 0) then
call DGETRI( M, A, M, IPIV, WORK, LWORK, INFO )
!write(*,*) "work(1) == min LWORK needed", work(1)
else
xmatout = 0.
write (*,*)"DGETRF, illegal value at = ",-info,". No inverse"
end if
do i=1,m;
do j=1,m;
if (abs(A(i,j))<= zero) A(i,j) = 0.
end do
end do
xmatout = A
return
end subroutine
! subroutine lapinverseOLD(xmatin,m,info,xmatout)
! implicit none
!
! integer,intent(in) :: m
! real*8,intent(in):: xmatin(m,m) !abaqus won't allow xmatin(:,:)
!
! integer,parameter :: LWORK = 8000
! real*8,parameter :: zero=1.0e-6
! integer :: LDA,ialloc,i,n,j
!
! integer,intent(out) :: INFO
! real*8,intent(out):: xmatout(m,m)
! integer, allocatable :: IPIV(:)
! real*8, allocatable :: A(:,:)
! real*8 :: WORK(LWORK)
! EXTERNAL DGETRI, DGETRF
!
! LDA = max(1,m); n = m
! xmatout = 0.
!
! allocate(A(LDA,n),IPIV(min(m,n)),stat=ialloc)
!
! A = xmatin !Don't input array xmatin
!
! call DGETRF( M, N, A, LDA, IPIV, INFO )
!
! if(info < 0) then
!! write (6,*)"DGETRF, illegal value at = ",-info,". No inverse"
! xmatout = 0.
!
! else if(info > 0) then
!! write (6,*)"DGETRF, U(i,i) zero at i = ",info,". No inverse"
! xmatout = 0.
!
! else
! call DGETRI( N, A, LDA, IPIV, WORK, LWORK, INFO )
!
! do i=1,m; do j=1,m; if (abs(A(i,j))<= zero) A(i,j) = 0.
! end do; end do
! xmatout = A
!
! end if
!
! deallocate(A,IPIV)
! return
! end subroutine
C ****************************************************
C * INVERSE OF A MATRIX WITHOUT LAPACK *
C ****************************************************
subroutine nolapinverse(a,c,n)
!============================================================
! Inverse matrix
! Method: Based on Doolittle LU factorization for Ax=b
! Alex G. December 2009
!-----------------------------------------------------------
! input ...
! a(n,n) - array of coefficients for matrix A
! n - dimension
! output ...
! c(n,n) - inverse matrix of A
! comments ...
! the original matrix a(n,n) will be destroyed
! during the calculation
!===========================================================
implicit none
integer,intent(in) :: n
real*8 :: a(n,n)
real*8,intent(out) :: c(n,n)
real*8 :: L(n,n), U(n,n), b(n), d(n), x(n)
real*8 :: coeff
integer :: i, j, k
! step 0: initialization for matrices L and U and b
! Fortran 90/95 aloows such operations on matrices
L=0.0
U=0.0
b=0.0
! step 1: forward elimination
do k=1,n-1
do i=k+1,n
coeff=a(i,k)/a(k,k)
L(i,k) = coeff
do j=k+1,n
a(i,j) = a(i,j)-coeff*a(k,j)
end do
end do
end do
! Step 2: prepare L and U matrices
! L matrix is a matrix of the elimination coefficient
! + the diagonal elements are 1.0
do i=1,n
L(i,i) = 1.0
end do
! U matrix is the upper triangular part of A
do j=1,n
do i=1,j
U(i,j) = a(i,j)
end do
end do
! Step 3: compute columns of the inverse matrix C
do k=1,n
b(k)=1.0
d(1) = b(1)
! Step 3a: Solve Ld=b using the forward substitution
do i=2,n
d(i)=b(i)
do j=1,i-1
d(i) = d(i) - L(i,j)*d(j)
end do
end do
! Step 3b: Solve Ux=d using the back substitution
x(n)=d(n)/U(n,n)
do i = n-1,1,-1
x(i) = d(i)
do j=n,i+1,-1
x(i)=x(i)-U(i,j)*x(j)
end do
x(i) = x(i)/u(i,i)
end do
! Step 3c: fill the solutions x(n) into column k of C
do i=1,n
c(i,k) = x(i)
end do
b(k)=0.0
end do
end subroutine nolapinverse
C *************************************************
C * SUBROUTINE MATRIX SQURAE ROOT *
C *************************************************
SUBROUTINE KMSQRT(a,b)
INCLUDE 'ABA_PARAM.INC'
PARAMETER (n=3,nx=3)
DIMENSION a(n,n),diag(n,n),q(n,n),d(n),b(n,n),
+ qtrans(n,n),result(n,n)
diag=0.; b=0.; q=0.;result=0.;d=0.
call Kjacobi(a,n,d,q)
call Keigsrt(d,q,n)
C
do i=1,n
if (d(i) .ge. 0) then
diag(i,i)=sqrt(d(i))
else
write (6,*) 'the matrix is not positive definite'
end if
end do
result = matmul(q,diag)
b = matmul(result,transpose(q))
return
end
C
C
C *************************************************
C * SUBROUTINE MATRIX EIGENVALUES AND EIGENVECTORS*
C *************************************************
C
SUBROUTINE KJACOBI(a,n,d,v)
INCLUDE 'ABA_PARAM.INC'
PARAMETER (NMAX=500)
DIMENSION a(n,n),d(n),v(n,n),b(NMAX),z(NMAX),dial(n,n)
do ip=1,n
do iq=1,n
v(ip,iq)=0.
end do
v(ip,ip)=1.
end do
C
do ip=1,n
b(ip)=a(ip,ip)
d(ip)=b(ip)
z(ip)=0.
end do
C
nrot=0
do i=1,50
sm=0.
do ip=1,n-1
do iq=ip+1,n
sm=sm+abs(a(ip,iq))
end do
end do
C
if (sm .eq. 0.) return
if (i .lt. 4) then
tresh=0.2*sm/n**2
else
tresh=0.
end if
C
do ip=1,n-1
do iq=ip+1,n
g=100.*abs(a(ip,iq))
if ((i .gt. 4) .and. (abs(d(ip))+g .eq. abs(d(ip)))
+ .and. (abs(d(ip))+g .eq. abs(d(iq)))) then
a(ip,iq)=0.
else if (abs(a(ip,iq)) .gt. tresh) then
h=d(iq)-d(ip)
if (abs(h)+g .eq. abs(h)) then
t=a(ip,iq)/h
else
theta=0.5*h/a(ip,iq)
t=1./(abs(theta)+sqrt(1.+theta**2))
if (theta .lt. 0) t=-t
end if
c=1./sqrt(1+t**2)
s=t*c
ta=s/(1.+c)
h=t*a(ip,iq)
z(ip)=z(ip)-h
z(iq)=z(iq)+h
d(ip)=d(ip)-h
d(iq)=d(iq)+h
a(ip,iq)=0.
C
do j=1,ip-1
g=a(j,ip)
h=a(j,iq)
a(j,ip)=g-s*(h+g*ta)
a(j,iq)=h+s*(g-h*ta)
end do
C
do j=ip+1,iq-1
g=a(ip,j)
h=a(j,iq)
a(ip,j)=g-s*(h+g*ta)
a(j,iq)=h+s*(g-h*ta)
end do
C
do j=iq+1,n
g=a(ip,j)
h=a(iq,j)
a(ip,j)=g-s*(h+g*ta)
a(iq,j)=h+s*(g-h*ta)
end do
C
do j=1,n
g=v(j,ip)
h=v(j,iq)
v(j,ip)=g-s*(h+g*ta)
v(j,iq)=h+s*(g-h*ta)
end do
C
nrot=nrot+1
end if
end do
end do
C
do ip=1,n
b(ip)=b(ip)+z(ip)
d(ip)=b(ip)
z(ip)=0.
end do
end do
C
C
return
C
END
C *************************************************
C * SUBROUTINE SORT EIGENVALUES *
C *************************************************
SUBROUTINE kEIGSRT(D,V,N)
INCLUDE 'ABA_PARAM.INC'
DIMENSION D(N),V(N,N)
DO I=1,N-1
K=I
P=D(I)
DO J=I+1,N
IF(D(J).GE.P)THEN
K=J
P=D(J)
ENDIF
END DO
IF(K.NE.I)THEN
D(K)=D(I)
D(I)=P
DO J=1,N
P=V(J,I)
V(J,I)=V(J,K)
V(J,K)=P
END DO
ENDIF
END DO
RETURN
END
C *************************************************
C * THE DETERMINANT OF A 3X3 MATRIX *
C *************************************************
SUBROUTINE KDETER(DMIN,D)
INCLUDE 'ABA_PARAM.INC'
PARAMETER(M=3,N=3)
DIMENSION DMIN(M,N)
D=0.
D=DMIN(1,1)*DMIN(2,2)*DMIN(3,3)+DMIN(1,2)*
+ DMIN(2,3)*DMIN(3,1)+DMIN(2,1)*DMIN(3,2)*
+ DMIN(1,3)-DMIN(1,3)*DMIN(2,2)*DMIN(3,1)-
+ DMIN(1,1)*DMIN(2,3)*DMIN(3,2)-DMIN(1,2)*
+ DMIN(2,1)*DMIN(3,3)
RETURN
END
C *************************************************
C * Build 4th order rotation matrix (tsigma) *
C *************************************************
subroutine rotord4sig(xrot,tSigma)
real*8, intent(in) :: xrot(3,3)
real*8, intent(out) :: tSigma(6,6)
tSigma(1,1) = xRot(1,1)*xRot(1,1)
tSigma(1,2) = xRot(1,2)*xRot(1,2)
tSigma(1,3) = xRot(1,3)*xRot(1,3)
tSigma(1,4) = 2.0*xRot(1,1)*xRot(1,2)
tSigma(1,6) = 2.0*xRot(1,2)*xRot(1,3)
tSigma(1,5) = 2.0*xRot(1,3)*xRot(1,1)
tSigma(2,1) = xRot(2,1)*xRot(2,1)
tSigma(2,2) = xRot(2,2)*xRot(2,2)
tSigma(2,3) = xRot(2,3)*xRot(2,3)
tSigma(2,4) = 2.0*xRot(2,1)*xRot(2,2)
tSigma(2,6) = 2.0*xRot(2,2)*xRot(2,3)
tSigma(2,5) = 2.0*xRot(2,3)*xRot(2,1)
tSigma(3,1) = xRot(3,1)*xRot(3,1)
tSigma(3,2) = xRot(3,2)*xRot(3,2)
tSigma(3,3) = xRot(3,3)*xRot(3,3)
tSigma(3,4) = 2.0*xRot(3,1)*xRot(3,2)
tSigma(3,6) = 2.0*xRot(3,2)*xRot(3,3)
tSigma(3,5) = 2.0*xRot(3,3)*xRot(3,1)
tSigma(4,1) = xRot(1,1)*xRot(2,1)
tSigma(4,2) = xRot(1,2)*xRot(2,2)
tSigma(4,3) = xRot(1,3)*xRot(2,3)
tSigma(4,4) = xRot(1,1)*xRot(2,2) + xRot(1,2)*xRot(2,1)
tSigma(4,6) = xRot(1,2)*xRot(2,3) + xRot(2,2)*xRot(1,3)
tSigma(4,5) = xRot(1,3)*xRot(2,1) + xRot(2,3)*xRot(1,1)
tSigma(6,1) = xRot(2,1)*xRot(3,1)
tSigma(6,2) = xRot(2,2)*xRot(3,2)
tSigma(6,3) = xRot(2,3)*xRot(3,3)
tSigma(6,4) = xRot(2,1)*xRot(3,2) + xRot(3,1)*xRot(2,2)
tSigma(6,6) = xRot(2,2)*xRot(3,3) + xRot(2,3)*xRot(3,2)
tSigma(6,5) = xRot(2,3)*xRot(3,1) + xRot(3,3)*xRot(2,1)
tSigma(5,1) = xRot(3,1)*xRot(1,1)
tSigma(5,2) = xRot(3,2)*xRot(1,2)
tSigma(5,3) = xRot(3,3)*xRot(1,3)
tSigma(5,4) = xRot(3,1)*xRot(1,2) + xRot(1,1)*xRot(3,2)
tSigma(5,6) = xRot(3,2)*xRot(1,3) + xRot(1,2)*xRot(3,3)
tSigma(5,5) = xRot(3,3)*xRot(1,1) + xRot(3,1)*xRot(1,3)
return
end subroutine
C *************************************************
C * Build 4th order rotation matrix (tstran) *
C *************************************************
subroutine rotord4str(xrot,tStran)
real*8, intent(in) :: xrot(3,3)
real*8, intent(out) :: tStran(6,6)
tStran(1,1) = xRot(1,1)*xRot(1,1)
tStran(1,2) = xRot(1,2)*xRot(1,2)
tStran(1,3) = xRot(1,3)*xRot(1,3)
tStran(1,4) = xRot(1,1)*xRot(1,2)
tStran(1,6) = xRot(1,2)*xRot(1,3)
tStran(1,5) = xRot(1,3)*xRot(1,1)
tStran(2,1) = xRot(2,1)*xRot(2,1)
tStran(2,2) = xRot(2,2)*xRot(2,2)
tStran(2,3) = xRot(2,3)*xRot(2,3)
tStran(2,4) = xRot(2,1)*xRot(2,2)
tStran(2,6) = xRot(2,2)*xRot(2,3)
tStran(2,5) = xRot(2,3)*xRot(2,1)
tStran(3,1) = xRot(3,1)*xRot(3,1)
tStran(3,2) = xRot(3,2)*xRot(3,2)
tStran(3,3) = xRot(3,3)*xRot(3,3)
tStran(3,4) = xRot(3,1)*xRot(3,2)
tStran(3,6) = xRot(3,2)*xRot(3,3)
tStran(3,5) = xRot(3,3)*xRot(3,1)
tStran(4,1) = 2.0*xRot(1,1)*xRot(2,1)
tStran(4,2) = 2.0*xRot(1,2)*xRot(2,2)
tStran(4,3) = 2.0*xRot(1,3)*xRot(2,3)
tStran(4,4) = xRot(1,1)*xRot(2,2) + xRot(1,2)*xRot(2,1)
tStran(4,6) = xRot(1,2)*xRot(2,3) + xRot(2,2)*xRot(1,3)
tStran(4,5) = xRot(1,3)*xRot(2,1) + xRot(2,3)*xRot(1,1)
tStran(6,1) = 2.0*xRot(2,1)*xRot(3,1)
tStran(6,2) = 2.0*xRot(2,2)*xRot(3,2)
tStran(6,3) = 2.0*xRot(2,3)*xRot(3,3)
tStran(6,4) = xRot(2,1)*xRot(3,2) + xRot(3,1)*xRot(2,2)
tStran(6,6) = xRot(2,2)*xRot(3,3) + xRot(2,3)*xRot(3,2)
tStran(6,5) = xRot(2,3)*xRot(3,1) + xRot(3,3)*xRot(2,1)
tStran(5,1) = 2.0*xRot(3,1)*xRot(1,1)
tStran(5,2) = 2.0*xRot(3,2)*xRot(1,2)
tStran(5,3) = 2.0*xRot(3,3)*xRot(1,3)
tStran(5,4) = xRot(3,1)*xRot(1,2) + xRot(1,1)*xRot(3,2)
tStran(5,6) = xRot(3,2)*xRot(1,3) + xRot(1,2)*xRot(3,3)
tStran(5,5) = xRot(3,3)*xRot(1,1) + xRot(3,1)*xRot(1,3)
return
end subroutine
C *************************************************************
C * Build 4th order lower (and upper) tensor product *
C * NB: When contracted from 4th to the format used for *
C * C-matrix, it turns out that the upper and lower products *
C * are the same! *
C *************************************************************
subroutine ltprod(A,B,C)
real*8, intent(in) :: A(3,3),B(3,3)
real*8, intent(out) :: C(6,6)
C = 0.
C(1,1) = 2*A(1,1)*B(1,1)
C(1,2) = 2*A(1,2)*B(1,2)
C(1,3) = 2*A(1,3)*B(1,3)
C(1,4) = A(1,1)*B(1,2)+A(1,2)*B(1,1)
C(1,5) = A(1,1)*B(1,3)+A(1,3)*B(1,1)
C(1,6) = A(1,2)*B(1,3)+A(1,3)*B(1,2)
C(2,2) = 2*A(2,2)*B(2,2)
C(2,3) = 2*A(2,3)*B(2,3)
C(2,4) = A(2,1)*B(2,2)+A(2,2)*B(2,1)
C(2,5) = A(2,1)*B(2,3)+A(2,3)*B(2,1)
C(2,6) = A(2,2)*B(2,3)+A(2,3)*B(2,2)
C(3,3) = 2*A(3,3)*B(3,3)
C(3,4) = A(3,1)*B(3,2)+A(3,2)*B(3,1)
C(3,5) = A(3,1)*B(3,3)+A(3,3)*B(3,1)
C(3,6) = A(3,2)*B(3,3)+A(3,3)*B(3,2)
C(4,4) = A(1,1)*B(2,2)+A(1,2)*B(2,1)
C(4,5) = A(1,1)*B(2,3)+A(1,3)*B(2,1)
C(4,6) = A(1,2)*B(2,3)+A(1,3)*B(2,2)
C(5,5) = A(1,1)*B(3,3)+A(1,3)*B(3,1)
C(5,6) = A(1,2)*B(3,3)+A(1,3)*B(3,2)
C(6,6) = A(2,2)*B(3,3)+A(2,3)*B(3,2)
do i=2,6
do j=1,i-1
C(i,j)=C(j,i)
end do
end do
C = 0.5*C
return
end subroutine
C **************************************************
C * Build 4th order tensor product (kronecker)*
C **************************************************
subroutine tprod(A,B,C)
real*8, intent(in) :: A(3,3),B(3,3)
real*8, intent(out) :: C(6,6)
C = 0.
C(1,1) = 2*A(1,1)*B(1,1)
C(1,2) = 2*A(1,1)*B(2,2)
C(1,3) = 2*A(1,1)*B(3,3)
C(1,4) = A(1,1)*B(1,2)+A(1,1)*B(2,1)
C(1,5) = A(1,1)*B(1,3)+A(1,1)*B(3,1)
C(1,6) = A(1,1)*B(2,3)+A(1,1)*B(3,2)
C(2,2) = 2*A(2,2)*B(2,2)
C(2,3) = 2*A(2,2)*B(3,3)
C(2,4) = A(2,2)*B(1,2)+A(2,2)*B(2,1)
C(2,5) = A(2,2)*B(1,3)+A(2,2)*B(3,1)
C(2,6) = A(2,2)*B(2,3)+A(2,2)*B(3,2)
C(3,3) = 2*A(3,3)*B(3,3)
C(3,4) = A(3,3)*B(1,2)+A(3,3)*B(2,1)
C(3,5) = A(3,3)*B(1,3)+A(3,3)*B(3,1)
C(3,6) = A(3,3)*B(2,3)+A(3,3)*B(3,2)
C(4,4) = A(1,2)*B(1,2)+A(1,2)*B(2,1)
C(4,5) = A(1,2)*B(1,3)+A(1,2)*B(3,1)
C(4,6) = A(1,2)*B(2,3)+A(1,2)*B(3,2)
C(5,5) = A(1,3)*B(1,3)+A(1,3)*B(3,1)
C(5,6) = A(1,3)*B(2,3)+A(1,3)*B(3,2)
C(6,6) = A(2,3)*B(2,3)+A(2,3)*B(3,2)
do i=2,6
do j=1,i-1
C(i,j)=C(j,i)
end do
end do
C = 0.5*C
return
end subroutine
**
**
**************************************
** MULTIPLY MATRIX 1 *
**************************************
*USER SUBROUTINE
SUBROUTINE KMLT(DM1,DM2,DM)
C
INCLUDE 'ABA_PARAM.INC'
C
PARAMETER (M=3,N=3)
DIMENSION DM1(M,N),DM2(M,N),DM(M,N)
C
DO 10 I=1,M
DO 10 J=1,N
X=0.0
DO 20 K=1,M
X=X+DM1(I,K)*DM2(K,J)
20 CONTINUE
DM(I,J)=X
10 CONTINUE
RETURN
END