-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUMAT_ModifiedCamClay.f
1463 lines (1216 loc) · 44.2 KB
/
UMAT_ModifiedCamClay.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
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
*USER SUBROUTINES
SUBROUTINE UMAT(STRESS,STATEV,DDSDDE,SSE,SPD,SCD,
1 RPL,DDSDDT,DRPLDE,DRPLDT,
2 STRAN,DSTRAN,TIME,DTIME,TEMP,DTEMP,PREDEF,DPRED,CMNAME,
3 NDI,NSHR,NTENS,NSTATEV,PROPS,NPROPS,COORDS,DROT,PNEWDT,
4 CELENT,DFGRD0,DFGRD1,NOEL,NPT,LAYER,KSPT,KSTEP,KINC)
!DEC$ ATTRIBUTES DLLEXPORT, ALIAS:"UMAT" :: UMAT
implicit double precision (a-h, o-z)
! implicit real(8) (a-h,o-z)
CHARACTER*80 CMNAME
DIMENSION STRESS(NTENS),STATEV(NSTATEV),
1 DDSDDE(NTENS,NTENS),DDSDDT(NTENS),DRPLDE(NTENS),
2 STRAN(NTENS),DSTRAN(NTENS),TIME(2),PREDEF(1),DPRED(1),
3 PROPS(NPROPS),COORDS(3),DROT(3,3),DFGRD0(3,3),DFGRD1(3,3)
! Userdefined parameters
Integer :: iounit = 0, i, ios
Save iounit
Character(255) :: PrjDir, dbg_file
real(8) :: xphics, xNu, xkappa, xlambda, xe0, zeta
real(8) :: pp0,p0,q0,pp,p,q, p_trial, q_trial, f,p1,q1
real(8) :: dEpsV, dEpsD, xJ2, dEps(6), theta
real(8) :: xK, xG, r
real(8) :: df_dp,df_dq,xA,d_xlambda,ddlambda
real(8) :: T, dT, dT_new dsubepsp, dsubepsq
real(8) :: dp, dq, d5p,d5q
real(8) :: F1,F2
real(8) :: dSig(6), Sig0(6), Sig(6), D(6,6)
real(8) :: yield
real(8) :: nu_u
Integer :: j
Integer, parameter :: MAXITER=100
!From usr_lib and usr_add
Integer :: iOpt
real(8) :: S1, S2, S3, xN1(3), xN2(3), xN3(3)
Integer :: sub
! Get parameters from Props and STATEV
xphics = Props(1)
xNu = Props(2)
xkappa = Props(3)
xlambda = Props(4)
xe0 = Props(5)
pp = STATEV(1)
! Accumulated plastic strains
do i = 1,NTENS
EpsP(i) = STATEV(1+i)
end do
zeta = (xe0 + 1) / (xlambda - xkappa) !helping parameter
! Calculate constitutive stresses
Sig=stress
dEps=dstran
! Set tolerance for yield surface
! Reccommended tolerance error (10-6 to 10-9)
FTOL = 1e-6
! Do the predictor corrector scheme. The subroutine calculate the plastic and elastic parts and returns the updated stress and state variables
MaxIter = 100000
call implicit_predictor_corrector_integration(xkappa,XNu,&
xe0,dEps,xphics,FTOL,MaxIter,zeta,Sig,EpsP,dEpsP,pp)
! update state variables
STATEV(1) = pp
do i = 1,NTENS
STATEV(1+i) = EpsP(i)
end do
! if (isundr == 1) then Calculation of pore pressure not needed because done outside the subroutine
! Swp = Swp0 - BulkW*(dEpsV)
! end if
! update stress
stress=Sig
! Calculate effective/elastic D-matrix
Call FormDEMCC(stress, xkappa, xNu, xe0, DDSDDE, 6, xG, xK) ! also updates K and G
End SUBROUTINE UMAT
Subroutine FormDEMCC(Sig0, xkappa,xNu, xe0, D, Id, xG, xK)
C***********************************************************************
C
C Function: To form the elastic material stiffness matrix for MCC model (Hooke)
C
C I xkappa : slope of the U/R line in e-ln(p') plane
C I xNu : Poisson's ratio
C I xe0 : initial void ratio
C O D(i,j) : Resulting matrix
C I Id : (First) dimension of D
C O xG : Shear modulus
C O xK : Bulk modulus
C
C D1 D2 D2 o o o
C Structure of D2 D1 D2 o o o
C elastic D matrix D2 D2 D1 o o o
C o o o G o o
C o o o o G o
C o o o o o G
C
C***********************************************************************
Implicit real(8) (A-H,O-Z)
Dimension D(Id,Id)
Dimension Sig0(6)
D = 0.0
P = MAX(-(Sig0(1)+Sig0(2)+Sig0(3))/3., 1d0)
xK = (xe0 + 1)/xkappa * P !bulk modulus at start of time step, assumed constant
r = 3. * ( 1. - 2.*xNu) / ( 2. * (1.+xNu))
xG = r*xK
FAC= 2*xG / (1D0 - 2*xNU)
D1 = FAC * (1D0 - xNU)
D2 = FAC * xNU
Do I=1,3
Do J=1,3
D(I,J)=D2
End Do
D(I,I)=D1
End Do
Do I=4,6
D(I,I)=xG
End Do
End
!-----------------------------------------------------------------------
! Function computing the yield function
!-----------------------------------------------------------------------
function yield(p, j, pp, theta, xphics)
!-----------------------------------------------------------------------
!
! function: computing the yield function
!
! input: p, q, pp, g_theta
! output: yield
!
!-----------------------------------------------------------------------
implicit none
real(8) :: p, j, pp, g_theta
real(8) :: yield
g_theta = cos(theta) + ( (sin(theta) * sin(xphics)) / sqrt(3) )
g_theta = sin(xphics) / g_theta
yield = ( j / (p*g_theta) )**2 - ((pp/p) - 1)
end function yield
!-----------------------------------------------------------------------
! Subroutine computing the derivatives
!-----------------------------------------------------------------------
subroutine derivatives(sig,p,j,xphics,theta,dgdp,dfdsig,dgdsig)
!-----------------------------------------------------------------------
! input: sig,p,j,xphics,theta
! output: dfdsig,dgdsig
!-----------------------------------------------------------------------
implicit none
real(8), intent(in) :: p, j, xphics, theta
real(8), intent(in), dimension(6) :: sig
real(8), intent(out), dimension(6) :: dgdp,dfdsig,dgdsig
! Local Variables
real(8) :: g_theta,dfdp,dfdj,dfdtheta,
real(8) :: dgdj,dgdtheta,dets
real(8), dimension(6) :: dpdsig,djdsig,d_dets_dsig,dthetadsig
g_theta = cos(theta) + ((sin(theta) * sin(xphics)) / sqrt(3.0d0))
g_theta = sin(xphics) / g_theta
dfdp = (1/p) * ( 1 - ( ( j / (p*g_theta) )**2) )
dfdj = (2*j) / ((p*g_theta)**2)
dfdtheta = (2*(j**2)) / (sqrt(3)*(p**2)*g_theta*(sin(xphics)))
dfdtheta = dfdtheta * ( (cos(theta)*sin(xphics)) - sin(theta))
dgdp = (1/p) * ( 1 - ( j / (p*g_theta) ) )
dgdj = (2*j) / ((p*g_theta)**2)
dgdtheta = 0
dpdsig = 0.33333333d0*[1.0d0,1.0d0,1.0d0,0.0d0,0.0d0,0.0d0]
djdsig = (1/(2*j))*[sig(1)-p, sig(2)-p, sig(3)-p, 2*sig(4), &
2*sig(5), 2*sig(6)]
d_dets_dsig = [ (((sig(2)-p)*(sig(3)-p)) - (sig(5)**2) ), &
(((sig(1)-p)*(sig(3)-p)) - (sig(6)**2) ), &
(((sig(1)-p)*(sig(2)-p)) - (sig(4)**2) ), &
(( 2* sig(4) * (p-sig(3)) ) + (2*sig(5)*sig(6)) ), &
(( 2* sig(5) * (p-sig(1)) ) + (2*sig(4)*sig(6)) ), &
(( 2* sig(6) * (p-sig(2)) ) + (2*sig(4)*sig(5)) ) ]
dets = ((sig(1)-p)*(sig(2)-p)*(sig(3)-p)) &
- ((sig(1)-p)*(sig(5)**2))
- ((sig(2)-p)*(sig(6)**2)) - ((sig(3)-p)*(sig(4)**2)) &
+ (2*sig(4)*sig(5)*sig(6))
dthetadsig = (((dets/j)*djdsig) - d_dets_dsig) * (sqrt(3)/2)
dthetadsig = dthetadsig / (cos((3.0d0)*theta)*(j**3))
dfdsig = (dfdp * dpdsig) + (dfdj * djdsig) + &
(dfdtheta * dthetadsig)
dgdsig = (dgdp * dpdsig) + (dgdj * djdsig) + &
(dgdtheta * dthetadsig)
end subroutine derivatives
!-----------------------------------------------------------------------
! Subroutine computing the material stiffness parameters
!-----------------------------------------------------------------------
subroutine stiffnessMCC(p,xe0,xkappa,xNu,xG,xK)
!-----------------------------------------------------------------------
! input: p,xe0,xkappa,xNu
! output: xG,xK
! local: r (xG-xK ratio)
!-----------------------------------------------------------------------
implicit none
real(8), intent(in) :: p,xe0,xkappa,xNu
real(8), intent(out) :: xG,xK
real(8) :: r, abs_p
abs_p = abs(p)
xK = (xe0 + 1)/xkappa * abs_p !bulk modulus at start of time step, assumed constant
r = 3. * ( 1. - 2.*xNu) / ( 2. * (1.+xNu))
xG = r*xK !shear modulus
end subroutine stiffnessMCC
!-----------------------------------------------------------------------
! Function computing dlambda
!-----------------------------------------------------------------------
function dlambda(dfdp,dfdq,dfdtheta,dgdp,dgdq,dgdtheta,xA,xK,xG,&
dep,deq)
!-----------------------------------------------------------------------
! input: dfdp,dfdq,dfdtheta,dgdp,dgdq,dgdtheta
! xK,xG
! dep,deq
! output: dlambda
!-----------------------------------------------------------------------
implicit none
real(8) :: dfdp,dfdq,dfdtheta,dgdp,dgdq,dgdtheta,xA,xK,xG
real(8) :: dep,deq
real(8) :: dlambda
dpdsig(1) = 1/3
dpdsig(2) = 1/3
dpdsig(3) = 1/3
dpdsig(4) = 0
dpdsig(5) = 0
dpdsig(6) = 0
dqdsig(1) = 1/ * (S3 + S1)
dqdsig(2) = 1/q * (S1 + S3)
dqdsig(3) = 1/q * (S1 + S3)
dqdsig(4) = 0
dqdsig(5) = 0
dqdsig(6) = 0
dlambda = (dfdp*xK*dep + dfdq*3.*xG*deq) /
& (dfdp**2*xK + dfdq**2*3.*xG + xA)
return
end function dlambda
subroutine error(dp, dq, p, q, d5p, d5q, dT,dT_new,T,sub)
!-----------------------------------------------------------------------
!
! function: estimating error and calculating dT_new if necessary
!
! input: dp,dq,d5p,d5q
! p,q
! dT, T
! output: dT_new
! sub
!
!-----------------------------------------------------------------------
implicit none
! arguments
real(8), intent(in) :: dp, dq, d5p, d5q, p, q
real(8), intent(in) :: dT,T
real(8), intent(out):: dT_new
integer, intent(out) :: sub ! control parameter
! local variables
real(8) :: R, beta
real(8), parameter :: SSTOL = 1e-6 ! not userdefined yet
! estimating error
R = sqrt( (d5p - dp)**2 + (d5q - dq)**2 )
R = R / sqrt( (p + dp)**2 + (q +dq)**2 )
! evaluating need for substepping
if (R > SSTOL) then
sub = 1 !the increment will be rejected
else
sub = 0 !the increment is accurate enough and will be accepted
end if
!compute new size of substep
beta = 0.8 * sqrt(SSTOL / R)
if (beta < 0.1) beta = 0.1
if (beta > 2.) beta = 2.
dT_new = beta * dT
! checking the accumulated substeps
! checking the accumulated substeps
if ((sub == 0).and.(T + dT + dT_new > 1.)) then
dT_new = 1. - (T+dT)
end if
end subroutine error
!-----------------------------------------------
! Subroutine with RKF45 stress estimate
!-----------------------------------------------
subroutine rk(p,q,pp,&
2 zeta, xM,phics,theta, xK, xG,
3 dep, deq,
4 dp,dq,dpstar,dqstar,d_xlambda)
!---------------------------------------------------------------
! input: zeta, xM, xK, xG material properties
! p,q,pp stress state
! dep,deq substep strain incr
! output: dp,dq,d5p,d5q stress increments RK4 and 5
! d_xlambda
!
! local: xT,xN
! dep1-6,deq1-6,dp1-6,dq1-6
!-------------------------------------------------------------------
implicit none
real(8),intent(in) :: p,q,pp,zeta,xM,phics,theta
real(8), intent(in) :: dep,deq
real(8), intent(in) :: xK,xG
real(8) :: dfdp,dfdq,xA
real(8) :: dlambda
real(8) :: d_xlambda,dp,dq,dpstar,dqstar
real(8) :: dptemp,dqtemp
real(8),dimension(2,7) :: dsig
real(8),dimension(7) :: gamma
real(8),dimension(6,6) :: koeff
integer :: i,j
DO j = 1,6
dsig(1,j) = 0.
dsig(2,j) = 0.
END DO
!Initialising the coefficient vectors of DOPRI54
gamma = (/5179./57600., 0., 7571./16695., 393./640.,
2 -92097./339200., 187./2100.,1./40./) !coefficients for order 5 stress update
!coefficients for order 4 not needed
koeff(1,:) = (/ 1./5., 0., 0.,
2 0., 0., 0./)
koeff(2,:) = (/ 3./40., 9./40., 0.,
2 0., 0., 0. /)
koeff(3,:) = (/ 44./45., -56./15.,32./9.,
2 0., 0., 0. /)
koeff(4,:) = (/ 19372./6561., -25360./2187., 64448./6561.,
2 -212./729., 0.,0./)
koeff(5,:) = (/ 9017./3168., -355./33., 46732./5247.,
2 49./176., -5103./18656.,0. /)
koeff(6,:) = (/ 35./384., 0., 500./1113.,
2 125./192., -2187./6784.,11./84. /)
! Computing the partial stress increments
DO i = 1,7
IF (i > 1) THEN
dptemp = sum(koeff(i-1,:)*dsig(1,1:i-1))
dqtemp = sum(koeff(i-1,:)*dsig(2,1:i-1))
ELSE
dptemp = 0.
dqtemp = 0.
END IF
1 CALL derivatives(p+dptemp,q+dqtemp,pp,zeta,xM,phics,theta,
2 dfdp,dfdq,dfdtheta,dgdp,dgdq,dgdtheta,xA)
if (i == 1) then
1 d_xlambda = dlambda(dfdp,dfdq,dfdtheta,dgdp,dgdq,
2 dgdtheta,xA,xK,xG,dep,deq)
end if
dsig(1,i) = xK*dep-d_xlambda*xK*dfdp
dsig(2,i) = 3.*xG*deq-d_xlambda*3.*xG*dfdq
END DO
dp = sum(dsig(1,:)*gamma)
dq = sum(dsig(2,:)*gamma)
!for error estimating
dpstar = dptemp
dqstar = dqtemp
end subroutine rk
Subroutine GetModelCount(nMod)
!
! Return the maximum model number (iMod) in this DLL
!
Integer (Kind=4) nMod
nMod = 1 ! Maximum model number (iMod) in current DLL
Return
End ! GetModelCount
Subroutine GetModelName( iMod , ModelName )
!
! Return the name of the different models
!
Integer iMod
Character (Len= * ) ModelName
Character (Len=255) tName
tName = 'MCC_Explicit'
LT = Len_Trim(tName)
ModelName= Char(lt) // tName(1:Lt)
Return
End ! GetModelName
Subroutine GetParamCount( iMod , nParam )
!
! Return the number of parameters of the different models
!
nParam = 5
Return
End ! GetParamCount
Subroutine GetParamName( iMod , iParam, ParamName )
!
! Return the parameters name of the different models
!
Character (Len=255) ParamName, Units
Call GetParamAndUnit(iMod,iParam,ParamName,Units)
Return
End
Subroutine GetParamUnit( iMod , iParam, Units )
!
! Return the units of the different parameters of the different models
!
Character (Len=255) ParamName, Units
Call GetParamAndUnit(iMod,iParam,ParamName,Units)
Return
End
Subroutine GetParamAndUnit( iMod , iParam, ParamName, Units )
!
! Return the parameters name and units of the different models
!
! Units: use F for force unit
! L for length unit
! T for time unit
!
Character (Len=255) ParamName, Units, tName
Select Case (iMod)
Case (1)
! ModName = 'DP'
Select Case (iParam)
Case (1)
ParamName = 'M' ; Units = '-'
Case (2)
ParamName = 'nu' ; Units = '-'
Case (3)
ParamName = 'kappa' ; Units = '-'
Case (4)
ParamName = 'lambda' ; Units = '-'
Case (5)
ParamName = 'e_0' ; Units = '-'
Case Default
ParamName = 'xxx' ; Units = '-'
End Select
Case Default
! model not in DLL
ParamName = ' N/A ' ; Units = ' N/A '
End Select
tName = ParamName
LT = Len_Trim(tName)
ParamName= Char(lt) // tName(1:Lt)
tName = Units
LT = Len_Trim(tName)
Units = Char(lt) // tName(1:Lt)
Return
End ! GetParamAndUnit
Subroutine MZEROI(I,K)
C
C***********************************************************************
C
C Function: To make an integre array I with Dimension K to zero
C
C***********************************************************************
C
Dimension I(*)
Do J=1,K
I(J)=0
End Do
Return
End
Subroutine SETRVAL(R,K,V)
C
C***********************************************************************
C
C Function: To fill a real array R with Dimension K with value V
C
C***********************************************************************
C
Implicit real(8) (A-H,O-Z)
Dimension R(*)
Do J=1,K
R(J)=V
End Do
Return
End
Subroutine SETIVAL(I,K,IV)
C
C***********************************************************************
C
C Function: To fill an integer array I with Dimension K with value IV
C
C***********************************************************************
C
Implicit real(8) (A-H,O-Z)
Dimension I(*)
Do J=1,K
I(J)=IV
End Do
Return
End
Subroutine COPYIVEC(I1,I2,K)
C
C***********************************************************************
C
C Function: To copy an integer array I1 with Dimension K to I2
C
C***********************************************************************
C
Implicit real(8) (A-H,O-Z)
Dimension I1(*),I2(*)
Do J=1,K
I2(J)=I1(J)
End Do
Return
End
C***********************************************************************
Subroutine MulVec(V,F,K)
C***********************************************************************
C
C Function: To multiply a real vector V with dimension K by F
C
C***********************************************************************
C
IMPLICIT real(8) (A-H,O-Z)
DIMENSION V(*)
Do J=1,K
V(J)=F*V(J)
End Do
Return
End ! Subroutine Mulvec
C***********************************************************************
Subroutine MatMatSq(n, xMat1, xMat2, xMatR)
C***********************************************************************
C
C Calculate xMatR = xMat1*xMat2 for square matrices, size n
C
C I n : Dimension of matrices
C I xMat1 : Matrix (n,*)
C I xMat2 : Matrix (n,*)
C O xMatR : Resulting matrix (n,*)
C
C***********************************************************************
Implicit real(8) (A-H,O-Z)
Dimension xMat1(n,*),xMat2(n,*),xMatR(n,*)
C**********************************************************************
Do I=1,n
Do J=1,n
X=0
Do K=1,n
X=X+xMat1(I,K)*xMat2(K,J)
End Do
xMatR(I,J)=X
End Do
End Do
Return
End ! Subroutine MatMatSq
C***********************************************************************
Subroutine WriVal ( io, C , V )
C***********************************************************************
C
C Write (Double) value to file unit io (when io>0)
C
C***********************************************************************
C
Implicit real(8) (A-H,O-Z)
Character C*(*)
If (io <= 0) Return
Write(io,*) C,V
1 Format( A,3x, 1x,1p,e12.5)
Return
End
C***********************************************************************
Subroutine WriIVl ( io, C , I )
C***********************************************************************
C
C Write (integer) value to file unit io (when io>0)
C
C***********************************************************************
Implicit real(8) (A-H,O-Z)
Character C*(*)
If (io <= 0) Return
Write(io,*) C,I
1 Format( A,3x, 1x,I6)
Return
End
C***********************************************************************
Subroutine WriIVc ( io, C , iV , n )
C***********************************************************************
C
C Write (integer) vector to file unit io (when io>0)
C
C***********************************************************************
Character C*(*)
Dimension iV(*)
If (io <= 0) Return
Write(io,*) C
Write(io,1) (iv(i),i=1,n)
1 Format( ( 2(3x,5i4) ) )
Return
End
C***********************************************************************
Subroutine WriVec ( io, C , V , n )
C***********************************************************************
C
C Write (Double) vector to file unit io (when io>0)
C 6 values per line
C***********************************************************************
Implicit real(8) (A-H,O-Z)
Character C*(*)
Dimension V(*)
If (io <= 0) Return
If (Len_Trim(C) <= 6) Then
Write(io,2) C,( V(i),i=1,n)
Else
Write(io,*) C
Write(io,1) ( V(i),i=1,n)
End If
1 Format( ( 2(1x, 3(1x,1p,e10.3) ) ) )
2 Format( A, ( T7, 2(1x, 3(1x,1p,e10.3) ) ) )
Return
End
C***********************************************************************
Subroutine WriVec5( io, C , V , n )
C***********************************************************************
C
C Write (Double) vector to file unit io (when io>0)
C 5 values per line
C***********************************************************************
Implicit real(8) (A-H,O-Z)
Character C*(*)
Dimension V(*)
If (io <= 0) Return
Write(io,*) C
Write(io,1) ( V(i),i=1,n)
1 Format( 5(1x,1p,e12.5) )
Return
End
C***********************************************************************
Subroutine WriMat ( io, C , V , nd, nr, nc )
C***********************************************************************
C
C Write (Double) matrix to file unit io (when io>0)
C 6 values per line
C***********************************************************************
Implicit real(8) (A-H,O-Z)
Character C*(*)
Dimension V(nd,*)
If (io <= 0) Return
Write(io,*) C
Do j=1,nr
Write(io,1) j,( V(j,i),i=1,nc)
End Do
1 Format(i4, ( T7,2(1x, 3(1x,1p,e10.3) ) ) )
Return
End
C***********************************************************************
subroutine setveclen(xn,n,xl)
C**********************************************************************
Implicit real(8) (A-H,O-Z)
Dimension xN(*)
x=0
do i=1,n
x=x+xn(i)**2
end do
if (x /= 0) Then
f=xl/sqrt(x)
do i=1,3
xn(i)=xn(i)*f
end do
end if
return
end ! setveclen
C***********************************************************************
Subroutine MatVec(xMat,IM,Vec,N,VecR)
C***********************************************************************
C
C Calculate VecR = xMat*Vec
C
C I xMat : (Square) Matrix (IM,*)
C I Vec : Vector
C I N : Number of rows/colums
C O VecR : Resulting vector
C
C***********************************************************************
Implicit real(8) (A-H,O-Z)
Dimension xMat(IM,*),Vec(*),VecR(*)
C***********************************************************************
Do I=1,N
X=0
Do J=1,N
X=X+xMat(I,J)*Vec(J)
End Do
VecR(I)=X
End Do
Return
End ! Subroutine MatVec
C***********************************************************************
Subroutine AddVec(Vec1,Vec2,R1,R2,N,VecR)
C***********************************************************************
C
C Calculate VecR() = R1*Vec1()+R2*Vec2()
C
C I Vec1,
C I Vec2 : Vectors
C I R1,R2 : Multipliers
C I N : Number of rows
C O VecR : Resulting vector
C
C***********************************************************************
Implicit real(8) (A-H,O-Z)
Dimension Vec1(*),Vec2(*),VecR(*)
C***********************************************************************
Do I=1,N
X=R1*Vec1(I)+R2*Vec2(I)
VecR(I)=X
End Do
Return
End ! Subroutine AddVec
C
C***********************************************************************
Subroutine CarSig(S1,S2,S3,xN1,xN2,xN3,SNew)
C***********************************************************************
C
C Returns the Cartesian stresses using the principal stresses S1..S3
C and the principal directions
C
C I S1..S3 : Principal stresses
C I xN1..xN3 : Principal directions (xNi for Si)
C
C***********************************************************************
Implicit real(8) (A-H,O-Z)
Dimension xN1(*),xN2(*),xN3(*),SNew(*)
Dimension SM(3,3),T(3,3),TT(3,3),STT(3,3)
C***********************************************************************
C
C**** Fill transformation (rotation) matrix
C
Do I=1,3
T(I,1) = xN1(I)
T(I,2) = xN2(I)
T(I,3) = xN3(I)
TT(1,I) = T(I,1)
TT(2,I) = T(I,2)
TT(3,I) = T(I,3)
End Do
! Call MatTranspose(T,3,TT,3,3,3)
Call MZeroR(SM,9)
SM(1,1) = S1
SM(2,2) = S2
SM(3,3) = S3
C
C**** SMnew = T*SM*TT
C
Call MatMat(SM ,3, TT,3 , 3,3,3 ,STT,3)
Call MatMat( T ,3, STT,3 , 3,3,3 ,SM ,3)
! Call MatMatSq(3, SM, TT, STT ) ! STT = SM*TT
! Call MatMatSq(3, T, STT, SM ) ! SM = T*STT
C
C**** Extract cartesian stress vector from stress matrix
C
Do I=1,3
SNew(I) = SM(I,I)
End Do
SNew(4) = SM(2,1)
SNew(5) = SM(3,2)
SNew(6) = SM(3,1)
Return
End ! Subroutine CarSig
C**********************************************************************
subroutine PrincipalSig(IOpt, S, xN1, xN2, xN3, S1, S2, S3,
1 P, Q,J,theta)
!-------------------------------------------------------------------
!
! Function: calculate principal stresses and directions
! from cartesian stress vector
!
! IOpt I I flag to calculate principal direction (IOpt = 1)
! IntGlo I I global ID of Gauss point or particle
! S I R() cartesian stress
! xN1, xN2, xN3 O R() principal direction
! S1, S2, S3 O R principal stress
! P O R isotropic stress (positive for tension)
! Q O R deviatoric stress
! J O R sqrt J2
! theta O R lode angle
!
!-------------------------------------------------------------------
implicit none
! arguments
integer, intent(in) :: IOpt
real(8), intent(in) :: S(6)
real(8), intent(out) :: xN1(3), xN2(3), xN3(3),
& S1, S2, S3, P, Q
if (IOpt .eq. 1) then
call Eig_3(0,S,xN1,xN2,xN3,S1,S2,S3,P,Q,J,theta) ! Calculate principal direction
else
call Eig_3a(0,S,S1,S2,S3,P,Q) ! Do not calculate principal direction
end if
end subroutine PrincipalSig
C**********************************************************************
subroutine Eig_3(iOpt, St, xN1, xN2, xN3, S1, S2, S3, P, Q, &
J, theta)
!-------------------------------------------------------------------
!
! Function: calculate principal stresses and directions
! from cartesian stress vector
!
! NB: Wim Bomhof 15/11/'01, adapted to principal stress calculation
!
! IOpt I I flag for output writing (IOpt = 1)
! St I R() cartesian stress (XX, YY, ZZ, XY, YZ, ZX)
! xN1, xN2, xN3 O R() principal direction
! S1, S2, S3 O R principal stress
! P O R isotropic stress (positive for tension)
! Q O R deviatoric stress
! J O R sqrt J2
! theta O R lode angle
!
!-------------------------------------------------------------------
implicit none
! arguments
integer, intent(in) :: IOpt
real(8), intent(in) :: St(6)
real(8), intent(out) :: xN1(3), xN2(3), xN3(3),
& S1, S2, S3, P, Q, J, theta
! local variables
real(8) :: A(3,3), V(3,3)
real(8) :: abs_max_s, tol
real(8) :: tau, sign_tau, t, c, s
real(8) :: temp1, temp2, temp3
integer :: i, k, it, itmax, ip, iq
integer :: iS1, iS2, iS3
! Put cartesian stress vector into matrix A
A(1,1) = St(1) ! xx
A(1,2) = St(4) ! xy = yx
A(1,3) = St(6) ! zx = xz
A(2,1) = St(4) ! xy = yx
A(2,2) = St(2) ! yy
A(2,3) = St(5) ! zy = yz
A(3,1) = St(6) ! zx = xz
A(3,2) = St(5) ! zy = yz
A(3,3) = St(3) ! zz
! Set V to unity matrix
V(1,1) = 1
V(2,1) = 0
V(3,1) = 0
V(1,2) = 0
V(2,2) = 1
V(3,2) = 0
V(1,3) = 0
V(2,3) = 0
V(3,3) = 1
! get maximum value of cartesian stress vector
abs_max_s = 0.0
do i = 1,6
if (abs(St(i)) .gt. abs_max_s) abs_max_s = abs(St(i))
end do
! set tolerance
tol = 1d-16 * abs_max_s
! get principal stresses and directions iteratively
it = 0
itmax = 50
do while ( (it .lt. itmax) .and.
& (abs(A(1,2)) + abs(A(2,3)) + abs(A(1,3)) .gt. tol) )
it = it + 1
do k = 1,3
if (k .eq. 1) then
ip = 1
iq = 2
else if (k .eq.2) then
ip = 2
iq = 3
else
ip = 1
iq = 3
end if