-
Notifications
You must be signed in to change notification settings - Fork 4
/
PhaseFieldMultiCrystal.m
1015 lines (896 loc) · 39.6 KB
/
PhaseFieldMultiCrystal.m
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
% Ran Ma
% 11/29/2019
% multi-phase-field crystal plasticity
% Voigt notation: 11, 22, 33, 12, 13, 23
%
% Na, S., & Sun, W. (2018). Computational thermomechanics of crystalline rock,
% Part I: A combined multi-phase-field/crystal plasticity approach for single
% crystal simulations. Computer Methods in Applied Mechanics and Engineering,
% 338, 657-691.
%
% update 12/6/2019: reduce to 1 phase field for fracture
% update 12/9/2019: update to my phase field fracture formulation
% update 12/9/2019: twinning phase field
% update 12/15/2019: remove yield surface, improve robustness
%
classdef PhaseFieldMultiCrystal < handle
properties
% Input parameters
K;
nu;
tau_ini;
hardening;
prm_Q; % Activation energy
prm_C; % Fitting parameter
exponent; % Power-law parameter
% Euler_Theta;
% Euler_Phi;
Euler_phi1;
Euler_phi;
Euler_phi2;
verbose = 0; % bool
% Computed Parameters
% Elastic moduli
lambda;
mu;
youngs;
viscosity;
% Temperature, time increment
temperature;
dt;
% Stresses, Strains, Moduli
new_stress; % SymmetricTensor<2,3>
old_stress; % SymmetricTensor<2,3>
new_strain; % SymmetricTensor<2,3>
old_strain; % SymmetricTensor<2,3>
new_elastic_strain; % SymmetricTensor<2,3>
old_elastic_strain; % SymmetricTensor<2,3>
old_old_elastic_strain; % SymmetricTensor<2,3>
elastic_strain_tr; % SymmetricTensor<2,3>
new_plastic_strain; % SymmetricTensor<2,3>
old_plastic_strain; % SymmetricTensor<2,3>
new_equiv_plastic_strain;
old_equiv_plastic_strain;
new_cto; % SymmetricTensor<4,3>
elastic_cto; % SymmetricTensor<4,3>
elastic_cto_damage; % SymmetricTensor<4,3>
% Internal Variables
new_plastic_slip;
old_plastic_slip;
old_old_plastic_slip;
new_plastic_slip_i;
old_plastic_slip_i;
old_old_plastic_slip_i;
% NaCl Slip system
% ALL slip systems with different orientation
% Do NOT include the same slip system
% with opposite normal or shear direction
% 0: rock salt
% 1: FCC
% 2: beta-HMX
slip_type;
num_slip_system;
slip_normal;
slip_direct;
% Yield stress
new_tau;
old_tau;
hard_ratio;
% phase field fracture
Gc_c;
l0_c;
k_c;
Hn_c;
Hn1_c;
g_c;
gp_c;
gpp_c;
% phase field twinning
alpha_t; % constant in representative function
gamma0_t; % magnitude of twinning shear
Gc_t; % twin boundary energy
l0_t; % equilibrium boundary thickness
A_t; % double-well energy parameter
k_t; % gradient energy parameter
phi_t; % representative function
phip_t; % 1st order derivative of representative function
phipp_t; % 2nd order derivative of representative function
sm_t; % twinning strain mode
strain_twin_n1; % twinning strain of current step
strain_twin_n; % twinning strain of previous step
tau_t; % shear stress on the twinning plane
svec_t = [1; 0; 0]; % shear direction of twinning plane
mvec_t = [0; 1; 0]; % normal direction of twinning plane
Q_t; % rotation matrix of twinning deformation
% tangent stiffness
dtau_dpft;
dtau_dpfc;
dH_dpft;
dH_dpfc;
dH_deps;
dtau_deps;
dsigma_dpft;
dsigma_dpfc;
% temporary variable to perform initial guess
% for local stress integration
dgamma_deps;
% slip system
P_Schmid_notw;
P_Schmid_twin;
% constants
tol = 1.0e-9;
end
methods
% constructor without default input value
function obj = PhaseFieldMultiCrystal(s_type)
obj.slip_type = s_type;
if s_type == 0 % rock salt
obj.num_slip_system = 6;
obj.slip_normal = [ 1.0, 1.0, 0.0;
1.0,-1.0, 0.0;
1.0, 0.0, 1.0;
1.0, 0.0,-1.0;
0.0, 1.0, 1.0;
0.0, 1.0,-1.0];
obj.slip_direct = [1.0,-1.0, 0.0;
1.0, 1.0, 0.0;
1.0, 0.0,-1.0;
1.0, 0.0, 1.0;
0.0, 1.0,-1.0;
0.0, 1.0, 1.0];
obj.hard_ratio = ones(obj.num_slip_system, 1);
elseif s_type == 1 % FCC
obj.num_slip_system = 12;
obj.slip_normal = zeros(obj.num_slip_system, 3);
obj.slip_direct = zeros(obj.num_slip_system, 3);
f = 1/sqrt(2.0D0);
obj.slip_direct(1,1)=0;
obj.slip_direct(1,2)=-f;
obj.slip_direct(1,3)=f;
obj.slip_direct(2,1)=f;
obj.slip_direct(2,2)=0;
obj.slip_direct(2,3)=-f;
obj.slip_direct(3,1)=-f;
obj.slip_direct(3,2)=f;
obj.slip_direct(3,3)=0;
obj.slip_direct(4,1)=0;
obj.slip_direct(4,2)=f;
obj.slip_direct(4,3)=f;
obj.slip_direct(5,1)=f;
obj.slip_direct(5,2)=0;
obj.slip_direct(5,3)=f;
obj.slip_direct(6,1)=f;
obj.slip_direct(6,2)=-f;
obj.slip_direct(6,3)=0;
obj.slip_direct(7,1)=0;
obj.slip_direct(7,2)=-f;
obj.slip_direct(7,3)=f;
obj.slip_direct(8,1)=-f;
obj.slip_direct(8,2)=0;
obj.slip_direct(8,3)=-f;
obj.slip_direct(9,1)=f;
obj.slip_direct(9,2)=f;
obj.slip_direct(9,3)=0;
obj.slip_direct(10,1)=0;
obj.slip_direct(10,2)=f;
obj.slip_direct(10,3)=f;
obj.slip_direct(11,1)=f;
obj.slip_direct(11,2)=0;
obj.slip_direct(11,3)=-f;
obj.slip_direct(12,1)=-f;
obj.slip_direct(12,2)=-f;
obj.slip_direct(12,3)=0;
f = 1/sqrt(3.0D0);
obj.slip_normal(1,1)=f;
obj.slip_normal(1,2)=f;
obj.slip_normal(1,3)=f;
obj.slip_normal(2,1)=f;
obj.slip_normal(2,2)=f;
obj.slip_normal(2,3)=f;
obj.slip_normal(3,1)=f;
obj.slip_normal(3,2)=f;
obj.slip_normal(3,3)=f;
obj.slip_normal(4,1)=-f;
obj.slip_normal(4,2)=-f;
obj.slip_normal(4,3)=f;
obj.slip_normal(5,1)=-f;
obj.slip_normal(5,2)=-f;
obj.slip_normal(5,3)=f;
obj.slip_normal(6,1)=-f;
obj.slip_normal(6,2)=-f;
obj.slip_normal(6,3)=f;
obj.slip_normal(7,1)=-f;
obj.slip_normal(7,2)=f;
obj.slip_normal(7,3)=f;
obj.slip_normal(8,1)=-f;
obj.slip_normal(8,2)=f;
obj.slip_normal(8,3)=f;
obj.slip_normal(9,1)=-f;
obj.slip_normal(9,2)=f;
obj.slip_normal(9,3)=f;
obj.slip_normal(10,1)=f;
obj.slip_normal(10,2)=-f;
obj.slip_normal(10,3)=f;
obj.slip_normal(11,1)=f;
obj.slip_normal(11,2)=-f;
obj.slip_normal(11,3)=f;
obj.slip_normal(12,1)=f;
obj.slip_normal(12,2)=-f;
obj.slip_normal(12,3)=f;
obj.hard_ratio = ones(obj.num_slip_system, 1);
elseif s_type == 2 % beta HMX
obj.num_slip_system = 6;
obj.slip_normal = [0, 0, 1;
0, 0.5911, 0.8066;
0, 0.5911, 0.8066;
0, 0.344, 0.939;
0.7, 0, 0.7141;
0.7, 0, 0.7141];
obj.slip_direct = [1, 0, 0;
0.0881, 0.8035, -0.5888;
1, 0, 0;
1, 0, 0;
0.7141, 0, -0.7;
0, 1, 0];
obj.hard_ratio(1) = 1.0;
obj.hard_ratio(2) = 1.0;
obj.hard_ratio(3) = 1.0;
obj.hard_ratio(4) = 1.0;
obj.hard_ratio(5) = 1.0;
obj.hard_ratio(6) = 1.0;
else
error('>>> Error: Unknown slip type!');
end
end
function initialize(obj)
% Parse Parameters
obj.K = 36.7e3; % bulk modulus
obj.nu = 0.276; % poisson ratio
obj.tau_ini = 3; % critical resolved shear stress
obj.hardening = 100; % hardening parameter
obj.prm_Q = 14; % activation energy
obj.prm_C = 1.0; % shape factor
obj.exponent = 10.0;
% obj.Euler_Theta = 10.0 * pi / 180;
% obj.Euler_Phi = 30.0 * pi / 180;
% obj.Euler_phi1 = 30.0 * pi / 180;
% obj.Euler_phi = 50.0 * pi / 180;
% obj.Euler_phi2 = 10.0 * pi / 180;
obj.Euler_phi1 = 0;
obj.Euler_phi = 0;
obj.Euler_phi2 = 0;
obj.verbose = 0;
% Elastic Tangent Operator
obj.youngs = 3 * obj.K * (1 - 2*obj.nu);
obj.mu = 0.5 * obj.youngs / (1 + obj.nu);
obj.lambda = obj.K - 2*obj.mu/3;
I2 = [1; 1; 1; 0; 0; 0];
I2I2 = I2 * transpose(I2);
I4 = eye(6);
I4(4,4) = 0.5; I4(5,5) = 0.5; I4(6,6) = 0.5;
obj.elastic_cto = obj.lambda*I2I2 + 2*obj.mu*I4;
% Plastic Internal Variable / Strain
obj.new_plastic_strain = zeros(3,1);
obj.new_equiv_plastic_strain = 0;
obj.new_plastic_slip = 0;
obj.new_plastic_slip_i = zeros(obj.num_slip_system, 1);
obj.old_plastic_slip_i = zeros(obj.num_slip_system, 1);
obj.old_old_plastic_slip_i = zeros(obj.num_slip_system, 1);
obj.old_tau = obj.tau_ini;
obj.new_tau = obj.tau_ini;
% phase field fracture
obj.Gc_c = 115000;
obj.l0_c = 1.0e-6;
obj.k_c = 1e-3;
obj.Hn_c = 0;
obj.Hn1_c = 0;
obj.g_c = 1;
obj.gp_c = 2 * ( obj.k_c - 1 );
obj.gpp_c = 2 * ( 1 - obj.k_c );
% phase field twinning
obj.Gc_t = 1.17e-4; % mJ/(mm^2)
obj.l0_t = 1.0e-6; % mm
obj.alpha_t = 3;
obj.gamma0_t = 0.1295;
obj.A_t = 12 * obj.Gc_t / obj.l0_t;
obj.k_t = 0.75 * obj.Gc_t * obj.l0_t;
obj.phi_t = 0;
obj.phip_t = 0;
obj.phipp_t = 2 * obj.alpha_t;
obj.sm_t = zeros(6,1);
obj.strain_twin_n1 = zeros(6,1);
obj.strain_twin_n = zeros(6,1);
% extra initiation for tensor variables
obj.new_stress = zeros(6,1);
obj.old_stress = zeros(6,1);
obj.new_strain = zeros(6,1);
obj.old_strain = zeros(6,1);
obj.new_elastic_strain = zeros(6,1);
obj.old_elastic_strain = zeros(6,1);
obj.old_old_elastic_strain = zeros(6,1);
obj.elastic_strain_tr = zeros(6,1);
obj.new_plastic_strain = zeros(6,1);
obj.old_plastic_strain = zeros(6,1);
obj.new_cto = obj.elastic_cto;
% temporary variable to perform initial guess
% for local stress integration
obj.dgamma_deps = zeros(obj.num_slip_system, 6);
obj.update_slip_plane();
obj.save_state();
end
function set_stress(obj, in_situ_stress)
obj.new_stress = in_situ_stress;
obj.new_elastic_strain = obj.elastic_cto \ in_situ_stress;
obj.save_state();
end
function update(obj, incr_strain)
if length(incr_strain) == 3
incr_strain_2d = zeros(6,1);
incr_strain_2d(1) = incr_strain(1);
incr_strain_2d(2) = incr_strain(2);
incr_strain_2d(4) = incr_strain(3);
strain_n1 = obj.old_strain + incr_strain_2d;
obj.run_3D_update(strain_n1);
else
strain_n1 = obj.old_strain + incr_strain;
obj.run_3D_update(strain_n1);
end
end
function update_parameters(obj, pass_temp, pass_time)
obj.temperature = pass_temp + 273.0;
obj.dt = pass_time;
end
function update_phasefield(obj, pft, pfc)
% fracture
one = 1.0e0;
two = 2.0e0;
three = 3.0e0;
four = 4.0e0;
six = 6.0e0;
twelve = 12.0e0;
onemk = 1 - obj.k_c;
obj.g_c = onemk * (one - pfc) * (one - pfc) + obj.k_c;
obj.gp_c = two * onemk * (pfc - one);
obj.gpp_c = two * onemk;
% twinning
a1 = obj.alpha_t;
a2 = two - a1;
a3 = a1 - three;
pft2 = pft * pft;
pft3 = pft * pft2;
pft4 = pft * pft3;
obj.phi_t = a1*pft2 + two*a2*pft3 + a3*pft4;
obj.phip_t = two*a1*pft + six*a2*pft2 + four*a3*pft3;
obj.phipp_t = two*a1 + twelve*a2*pft + twelve*a3*pft2;
obj.strain_twin_n1 = obj.gamma0_t * obj.phi_t * obj.sm_t;
end
function update_slip_plane(obj)
rot_matrix = obj.update_R_matrix();
% update twinning plane
svec = obj.svec_t / norm(obj.svec_t);
mvec = obj.mvec_t / norm(obj.mvec_t);
svec = rot_matrix * svec;
mvec = rot_matrix * mvec;
sm = zeros(6,1);
sm(1:3) = svec .* mvec;
sm(4) = svec(1)*mvec(2) + svec(2)*mvec(1);
sm(5) = svec(1)*mvec(3) + svec(3)*mvec(1);
sm(6) = svec(2)*mvec(3) + svec(3)*mvec(2);
obj.sm_t = sm;
% proper twinning rotation matrix
% Clayton, Knap, 2011
% rotate around mvec for 180 degree
% -Q*v is the mirror of v w.r.t. the mvec plane
obj.Q_t = 2 * mvec * transpose(mvec) - eye(3);
% initialize slip plane from crystal to spatial
nslip = obj.num_slip_system;
P_Schmid = zeros(6,nslip);
for ii = 1:nslip
m_normal = transpose(obj.slip_normal(ii,1:3));
s_direct = transpose(obj.slip_direct(ii,1:3));
% Normalize
m_normal = m_normal / norm(m_normal);
s_direct = s_direct / norm(s_direct);
% Assemble Schmid tensor alpha
P_Schmid_tmp = 0.5*rot_matrix*(m_normal*s_direct' + s_direct*m_normal')*transpose(rot_matrix);
P_Schmid(1,ii) = P_Schmid_tmp(1,1);
P_Schmid(2,ii) = P_Schmid_tmp(2,2);
P_Schmid(3,ii) = P_Schmid_tmp(3,3);
P_Schmid(4,ii) = P_Schmid_tmp(1,2)+P_Schmid_tmp(2,1);
P_Schmid(5,ii) = P_Schmid_tmp(1,3)+P_Schmid_tmp(3,1);
P_Schmid(6,ii) = P_Schmid_tmp(2,3)+P_Schmid_tmp(3,2);
end
obj.P_Schmid_notw = P_Schmid;
% initialize slip system in twinning region
Q66 = obj.mm10_RT2RVE(obj.Q_t);
obj.P_Schmid_twin = Q66 * P_Schmid;
end
function update_strain_energy(obj)
I2 = [1; 1; 1; 0; 0; 0];
I4 = diag([1, 1, 1, 0.5, 0.5, 0.5]);
%----------------------------------------------------%
% Decomposition %
%----------------------------------------------------%
one_third = 1/3;
% Construct stress from tensile stress + compressive stress
tr_eps = obj.new_elastic_strain(1) + obj.new_elastic_strain(2) ...
+ obj.new_elastic_strain(3);
tr_eps_plus = max(0.0, tr_eps);
tr_eps_minus = tr_eps - tr_eps_plus;
dev_starin = obj.new_elastic_strain - one_third*tr_eps*I2;
new_stress_plus = obj.K* tr_eps_plus*I2 + 2*obj.mu*I4*dev_starin;
new_stress_minus = obj.K* tr_eps_minus*I2;
obj.new_stress = obj.g_c * new_stress_plus + new_stress_minus;
% shear stress on twinning plane
obj.tau_t = transpose(obj.new_stress) * obj.sm_t;
% Update strain history variable
strain_energy_plus = 0.5*obj.K*tr_eps_plus*tr_eps_plus...
+ obj.mu*transpose(dev_starin)*I4*dev_starin;
plastic_energy = 0.5*obj.hardening*(...
transpose(obj.new_plastic_slip_i) * obj.new_plastic_slip_i);
% Update H plus for multiphase
strain_energy = strain_energy_plus+plastic_energy;
if strain_energy > obj.Hn_c
obj.Hn1_c = strain_energy;
else
obj.Hn1_c = obj.Hn_c;
end
% obj.new_cto = obj.g_c * obj.new_cto;
end
function save_state(obj)
% Stress
obj.old_stress = obj.new_stress;
% Elastic strain
obj.old_old_elastic_strain = obj.old_elastic_strain;
obj.old_elastic_strain = obj.new_elastic_strain;
% Others
obj.old_plastic_strain = obj.new_plastic_strain;
obj.old_strain = obj.new_strain;
obj.old_equiv_plastic_strain = obj.new_equiv_plastic_strain;
obj.old_tau = obj.new_tau;
% Plastic slip
obj.old_old_plastic_slip = obj.old_plastic_slip;
obj.old_plastic_slip = obj.new_plastic_slip;
obj.old_old_plastic_slip_i = obj.old_plastic_slip_i;
obj.old_plastic_slip_i = obj.new_plastic_slip_i;
% Driving force
obj.Hn_c = obj.Hn1_c;
% twinning strain
obj.strain_twin_n = obj.strain_twin_n1;
end
function recover_state(obj)
% Stress
obj.new_stress = obj.old_stress;
% Elastic strain
obj.new_elastic_strain = obj.old_elastic_strain;
obj.old_elastic_strain = obj.old_old_elastic_strain;
% Others
obj.new_plastic_strain = obj.old_plastic_strain;
obj.new_strain = obj.old_strain;
obj.new_equiv_plastic_strain = obj.old_equiv_plastic_strain;
obj.new_tau = obj.old_tau;
% Plastic slip
obj.new_plastic_slip = obj.old_plastic_slip;
obj.old_plastic_slip = obj.old_old_plastic_slip;
obj.new_plastic_slip_i = obj.old_plastic_slip_i;
obj.old_plastic_slip_i = obj.old_old_plastic_slip_i;
% Driving force
obj.Hn1_c = obj.Hn_c;
% twinning strain
obj.strain_twin_n1 = obj.strain_twin_n;
end
function sigma = stress(obj)
sigma = obj.new_stress;
end
function sigma = full_stress(obj)
sigma = obj.new_stress;
end
function eps = strain(obj)
eps = obj.new_strain;
end
function eps = full_strain(obj)
eps = obj.new_strain;
end
function vlms = volumetric_strain(obj)
vlms = obj.new_plastic_strain(1) ...
+ obj.new_plastic_strain(2) ...
+ obj.new_plastic_strain(3);
end
function dvts = deviatoric_strain(obj)
one_third = 1/3;
I2 = [1; 1; 1; 0; 0; 0];
vlms = obj.new_plastic_strain(1) ...
+ obj.new_plastic_strain(2) ...
+ obj.new_plastic_strain(3);
dev_strain = obj.new_plastic_strain ...
- one_third * vlms * I2;
dvts = dev_strain(1)*dev_strain(1) ...
+ dev_strain(2)*dev_strain(2) ...
+ dev_strain(3)*dev_strain(3) ...
+ 0.5 * dev_strain(4)*dev_strain(4) ...
+ 0.5 * dev_strain(5)*dev_strain(5) ...
+ 0.5 * dev_strain(6)*dev_strain(6);
end
function eqpls = equiv_plastic_strain(obj)
eqpls = obj.new_equiv_plastic_strain;
end
function stiff = cto(obj)
stiff = obj.new_cto;
end
function bkm = bulk_mod(obj)
bkm = obj.K;
end
function shm = shear_mod(obj)
shm = obj.mu;
end
function psn = plastic_slip_new(obj)
psn = obj.new_plastic_slip;
end
function plsl = plastic_slip_old(obj)
plsl = obj.old_plastic_slip;
end
% Energy dissipation
function temp = old_plastic_dissipation(obj)
old_plastic_slip_rate = obj.old_plastic_slip - obj.old_old_plastic_slip;
if (old_plastic_slip_rate < 0)
old_plastic_slip_rate = 0.0;
end
temp = obj.old_tau * old_plastic_slip_rate;
end
function temp = old_hardening_dissipation(obj)
old_plastic_slip_rate_i = obj.old_plastic_slip_i - obj.old_old_plastic_slip_i;
old_hds_i = obj.hardening * obj.old_plastic_slip_i * old_plastic_slip_rate_i;
tmp_hds = sum(old_hds_i);
temp = -tmp_hds;
end
function temp = old_elastic_strain_rate(obj)
tmp_elastic_strain = obj.old_elastic_strain - obj.old_old_elastic_strain;
temp = tmp_elastic_strain(1) + tmp_elastic_strain(2) + tmp_elastic_strain(3);
end
% Update
function run_3D_update(obj,strain_n1)
% Compute a trial state in which the increment is assumed to be fully elastic
% obj.new_elastic_strain = obj.old_elastic_strain + incr_strain;
mxit = 30;
obj.elastic_strain_tr = strain_n1 - obj.old_plastic_strain - obj.strain_twin_n1;
obj.new_cto = obj.elastic_cto;
obj.new_stress = obj.new_cto*obj.elastic_strain_tr;
obj.new_plastic_strain = obj.old_plastic_strain;
obj.new_equiv_plastic_strain = obj.old_equiv_plastic_strain;
obj.new_plastic_slip = obj.old_plastic_slip;
obj.new_plastic_slip_i = obj.old_plastic_slip_i;
obj.new_tau = obj.old_tau;
eps_tr = strain_n1(1) + strain_n1(2) + strain_n1(3);
I2 = [1; 1; 1; 0; 0; 0];
I4 = diag([1, 1, 1, 0.5, 0.5, 0.5]);
I2I2 = I2 * transpose(I2);
if eps_tr >= 0
obj.elastic_cto_damage = obj.g_c * obj.elastic_cto;
else
obj.elastic_cto_damage = obj.K * I2I2 + ...
obj.g_c * 2 * obj.mu * (I4 - I2I2 / 3);
end
prm_R = 1.986e-3; % Gas constant (kcal/(mol.K))
obj.viscosity = 1.0/(obj.prm_C*exp((-1.0)*obj.prm_Q/(prm_R*obj.temperature)));
% Assign crystal slip system
nslip = obj.num_slip_system;
P_Schmid = (1-obj.phi_t) * obj.P_Schmid_notw + obj.phi_t * obj.P_Schmid_twin;
%% preprocessing for initial guess
Gamma0 = zeros(nslip, 1);
[resid, jacobian] = obj.formR(Gamma0, P_Schmid);
Gamma0 = jacobian \ resid;
obj.new_elastic_strain = obj.elastic_strain_tr - P_Schmid * Gamma0;
% Update Jacobian inverse - Pseudo inverse
[U,S,V] = svd(jacobian);
CTO_jacobian_inv = obj.update_jacobian_inverse(S,U,V);
% Update variables
obj.update_tan_utc(CTO_jacobian_inv, Gamma0);
Gamma0 = obj.dgamma_deps * ( strain_n1 - obj.old_strain - obj.strain_twin_n1 + obj.strain_twin_n );
%% actural Newton iteration
[resid, jacobian] = obj.formR(Gamma0, P_Schmid);
resid_ini = norm(resid);
resid_a = resid_ini;
resid_r = resid_a / resid_ini;
Gamma = Gamma0;
N_iter = 0;
while resid_r > 1.0e-10 && resid_a > 1.0e-20 && N_iter < mxit
Gamma = Gamma + jacobian \ resid;
% [U,S,V] = svd(jacobian);
% jacobian_inv = obj.update_jacobian_inverse(S,U,V);
% Gamma = Gamma + jacobian_inv * resid;
% delete
[resid, jacobian] = obj.formR(Gamma, P_Schmid);
resid_a = norm(resid);
resid_r = resid_a / resid_ini;
N_iter = N_iter + 1;
end
fprintf('NR iterations: %i\n', N_iter);
if N_iter == mxit
error('>>> Error: material model fails to converge!');
end
% update state variables
tmp_plastic_strain = P_Schmid * Gamma;
tmp_plastic_slip_i = abs( Gamma );
tmp_plastic_slip = sum( tmp_plastic_slip_i );
tmp_elastic_strain = obj.elastic_strain_tr - tmp_plastic_strain;
obj.new_plastic_slip = obj.old_plastic_slip + tmp_plastic_slip;
obj.new_plastic_slip_i = obj.old_plastic_slip_i + tmp_plastic_slip_i;
obj.new_stress = obj.elastic_cto * tmp_elastic_strain;
obj.new_tau = obj.old_tau + obj.hardening*tmp_plastic_slip;
% Update Jacobian inverse - Pseudo inverse
[U,S,V] = svd(jacobian);
CTO_jacobian_inv = obj.update_jacobian_inverse(S,U,V);
% Update CTO
tau_s = transpose( P_Schmid ) * obj.new_stress;
obj.new_cto = obj.elastic_cto_damage;
for ii = 1:nslip
for jj = 1:nslip
ptaup = obj.exponent * ( abs( tau_s(jj) ) ) ^ ( obj.exponent - 1 );
tmp_Schmid_a = obj.elastic_cto * P_Schmid(:,ii);
tmp_Schmid_b = obj.elastic_cto * P_Schmid(:,jj);
obj.new_cto = obj.new_cto - obj.g_c * ptaup * CTO_jacobian_inv(ii,jj) * tmp_Schmid_a * transpose(tmp_Schmid_b);
end
end
% Update variables
obj.new_elastic_strain = tmp_elastic_strain;
obj.new_plastic_strain = obj.old_plastic_strain + tmp_plastic_strain;
tmp_plastic_strain(4:6) = tmp_plastic_strain(4:6) * sqrt(0.5);
obj.new_equiv_plastic_strain = obj.old_equiv_plastic_strain ...
+ sqrt( 2 / 3 ) * norm(tmp_plastic_strain);
% obj.new_strain = obj.new_elastic_strain + obj.new_plastic_strain;
obj.new_strain = strain_n1;
obj.update_strain_energy();
% update coupled stiffness
obj.update_tan_utc(CTO_jacobian_inv, Gamma);
end
function [R,J] = formR(obj, Gamma, P_Schmid)
% attention: J = - d(R) / d(gamma)
% verified against finite difference
nslip = obj.num_slip_system;
tmp_plastic_strain = P_Schmid * Gamma;
tmp_plastic_slip_i = abs( Gamma );
tmp_plastic_slip = sum( tmp_plastic_slip_i );
tmp_elastic_strain = obj.elastic_strain_tr - tmp_plastic_strain;
fd_new_stress = obj.elastic_cto * tmp_elastic_strain;
% Isotropic hardening
% fd_new_tau = obj.old_tau + obj.hardening*tmp_plastic_slip;
fd_new_tau = ( obj.old_tau + obj.hardening*tmp_plastic_slip ) * obj.hard_ratio;
% Residual
tau = transpose(P_Schmid) * fd_new_stress;
% R = ( abs(tau) ) .^ (obj.exponent) .* sign(tau) ...
% - obj.viscosity / obj.dt * (fd_new_tau^(obj.exponent)) .* Gamma;
% Jacobian matrix for local return mapping
R = zeros(nslip,1);
J = zeros(nslip, nslip);
for ii = 1 : nslip
R(ii) = ( abs(tau(ii)) ) ^ (obj.exponent) * sign(tau(ii)) ...
- obj.viscosity / obj.dt * ( fd_new_tau(ii)^(obj.exponent) ) * Gamma(ii);
for jj = 1 : nslip
tmp_beta = obj.elastic_cto*P_Schmid(:,jj);
J(ii,jj) = transpose(P_Schmid(:,ii)) * tmp_beta * obj.exponent * (abs(tau(ii))^(obj.exponent-1) )...
+ obj.hard_ratio(ii) * obj.hardening ...
*obj.exponent*fd_new_tau(ii)^(obj.exponent-1)*obj.viscosity/obj.dt*Gamma(ii)*sign(Gamma(jj));
if (ii == jj)
J(ii,jj) = J(ii,jj) ...
+ fd_new_tau(ii)^(obj.exponent)*(obj.viscosity/obj.dt);
end
end
end
end
function euler_matrix = update_R_matrix(obj)
% Note: R matrix here is different from the one from MTEX
% In fact, R = transpose(R_mtex)
% Reason: https://mtex-toolbox.github.io/MTEXvsBungeConvention.html
cos_phi1 = cos(obj.Euler_phi1);
sin_phi1 = sin(obj.Euler_phi1);
cos_phi = cos(obj.Euler_phi);
sin_phi = sin(obj.Euler_phi);
cos_phi2 = cos(obj.Euler_phi2);
sin_phi2 = sin(obj.Euler_phi2);
phi1_matrix = zeros(3);
phi_matrix = zeros(3);
phi2_matrix = zeros(3);
% Assign each element (Miehe and Schroder, 2001)
% rotation w.r.t. z axis
phi1_matrix(1,1) = cos_phi1;
phi1_matrix(1,2) = sin_phi1;
phi1_matrix(1,3) = 0.0;
phi1_matrix(2,1) = -sin_phi1;
phi1_matrix(2,2) = cos_phi1;
phi1_matrix(2,3) = 0.0;
phi1_matrix(3,1) = 0.0;
phi1_matrix(3,2) = 0.0;
phi1_matrix(3,3) = 1.0;
% rotation w.r.t. x axis
phi_matrix(1,1) = 1.0;
phi_matrix(1,2) = 0.0;
phi_matrix(1,3) = 0.0;
phi_matrix(2,1) = 0.0;
phi_matrix(2,2) = cos_phi;
phi_matrix(2,3) = sin_phi;
phi_matrix(3,1) = 0.0;
phi_matrix(3,2) = -sin_phi;
phi_matrix(3,3) = cos_phi;
% rotation w.r.t. z axis
phi2_matrix(1,1) = cos_phi2;
phi2_matrix(1,2) = sin_phi2;
phi2_matrix(1,3) = 0.0;
phi2_matrix(2,1) = -sin_phi2;
phi2_matrix(2,2) = cos_phi2;
phi2_matrix(2,3) = 0.0;
phi2_matrix(3,1) = 0.0;
phi2_matrix(3,2) = 0.0;
phi2_matrix(3,3) = 1.0;
euler_matrix = phi2_matrix * phi_matrix * phi1_matrix;
end
% update coupled tangent stiffness
function update_tan_utc(obj, Dinv, Gamma)
% (0) volumetric stress and deviatoric stress
I2 = [1; 1; 1; 0; 0; 0];
I4 = diag([1, 1, 1, 0.5, 0.5, 0.5]);
one_third = 1/3;
tr_eps = obj.new_elastic_strain(1) + obj.new_elastic_strain(2) ...
+ obj.new_elastic_strain(3);
tr_eps_plus = max(0.0, tr_eps);
% tr_eps_minus = tr_eps - tr_eps_plus;
dev_starin = obj.new_elastic_strain - one_third*tr_eps*I2;
new_stress_plus = obj.K* tr_eps_plus*I2 + 2*obj.mu*I4*dev_starin;
stress_hat = obj.elastic_cto * obj.new_elastic_strain;
% new_stress_minus = obj.K* tr_eps_minus*I2;
% (1) depends on original data
% strain_n1 = obj.new_elastic_strain + obj.new_plastic_strain + obj.strain_twin_n1;
% strain_tr = obj.new_elastic_strain + obj.new_plastic_strain - obj.old_plastic_strain;
strain_tr = obj.elastic_strain_tr;
P_Schmid = (1-obj.phi_t) * obj.P_Schmid_notw + obj.phi_t * obj.P_Schmid_twin;
dP_dpft = obj.phip_t * (obj.P_Schmid_twin - obj.P_Schmid_notw);
depst_dpft = obj.gamma0_t * obj.phip_t * obj.sm_t;
sslip = obj.new_plastic_slip_i;
% tau_s = transpose( P_Schmid ) * obj.new_stress;
tau_s = transpose( P_Schmid ) * stress_hat;
ptaup = obj.exponent * ( abs( tau_s ) ) .^ ( obj.exponent - 1 );
% (2) depends on (1)
depstr_dpft = - depst_dpft;
obj.dgamma_deps = Dinv * ( repmat(ptaup,1,6) .* transpose(P_Schmid) * obj.elastic_cto );
dgamma_dpft = Dinv * ( ptaup .* ( ...
transpose(dP_dpft) * obj.elastic_cto * strain_tr ...
+ transpose(P_Schmid) * obj.elastic_cto * depstr_dpft ...
- transpose(dP_dpft) * obj.elastic_cto * P_Schmid * Gamma ...
- transpose(P_Schmid) * obj.elastic_cto * dP_dpft * Gamma ) );
% (3) depends on (2)
depsp_dpft = P_Schmid * dgamma_dpft + dP_dpft * Gamma;
% (4) final results
obj.dH_dpft = obj.hardening * transpose(sslip) * ( dgamma_dpft .* sign( Gamma ) ) ...
- transpose( new_stress_plus ) * ( depsp_dpft + depst_dpft );
obj.dH_dpfc = 0;
obj.dH_deps = new_stress_plus - transpose(obj.dgamma_deps) * transpose(P_Schmid) * new_stress_plus ...
+ obj.hardening * transpose(obj.dgamma_deps) * ( sslip .* sign( Gamma ) );
obj.dsigma_dpft = - obj.g_c * obj.elastic_cto * (depsp_dpft + depst_dpft);
obj.dsigma_dpfc = obj.gp_c * new_stress_plus;
obj.dtau_dpft = transpose(obj.dsigma_dpft) * obj.sm_t;
obj.dtau_dpfc = transpose(obj.dsigma_dpfc) * obj.sm_t;
obj.dtau_deps = transpose(obj.new_cto) * obj.sm_t;
end
% A whole bunch of 'get' function
function fren = get_Gc_c(obj)
fren = obj.Gc_c;
end
function lgsc = get_l0_c(obj)
lgsc = obj.l0_c;
end
function tmp = get_A_t(obj)
tmp = obj.A_t;
end
function tmp = get_k_t(obj) % k = 3 * Gamma * l / 4
tmp = obj.k_t;
end
function tmp = get_tau(obj) % return resolved shear stress
tmp = obj.tau_t;
end
function tmp = get_gamma0_t(obj)
tmp = obj.gamma0_t;
end
function tmp = get_phip_t(obj)
tmp = obj.phip_t;
end
function tmp = get_phipp_t(obj)
tmp = obj.phipp_t;
end
function tmp = get_g_c(obj)
tmp = obj.g_c;
end
function tmp = get_gp_c(obj)
tmp = obj.gp_c;
end
function tmp = get_gpp_c(obj)
tmp = obj.gpp_c;
end
function tmp = get_dtau_dpft(obj)
tmp = obj.dtau_dpft;
end
function tmp = get_dtau_dpfc(obj)
tmp = obj.dtau_dpfc;
end
function tmp = get_dH_dpft(obj)
tmp = obj.dH_dpft;
end
function tmp = get_Hn1_c(obj)
tmp = obj.Hn1_c;
end
function tmp = get_dH_dpfc(obj)
tmp = obj.dH_dpfc;
end
function tmp = get_dH_deps(obj)
tmp = obj.dH_deps;
end
function tmp = get_dtau_deps(obj)
tmp = obj.dtau_deps;
end
function tmp = get_dsigma_dpft(obj)
tmp = obj.dsigma_dpft;
end
function tmp = get_dsigma_dpfc(obj)
tmp = obj.dsigma_dpfc;
end
end
methods (Static)
function jacobian_inv = update_jacobian_inverse(S, U, V)
s_size = length(S);
S_inv = zeros(s_size, s_size);
for ii = 1:s_size
% if S(ii,ii)/S(1,1) < 1.0e-6
% S_inv(ii,ii) = 0;
% else
% S_inv(ii,ii) = 1 / S(ii,ii);
% end
S_inv(ii,ii) = 1 / S(ii,ii);
end
jacobian_inv = V * S_inv * transpose(U);
end
function RV = mm10_RT2RVE(RT)
% implicit none
% double precision, dimension(3,3), intent(in) :: RT
% double precision, dimension(6,6), intent(out) :: RV
%
% voigt notation: 11, 22, 33, 12, 13, 23
% for strain type tensor only
RV(1,1)=RT(1,1)^2;
RV(1,2)=RT(1,2)^2;
RV(1,3)=RT(1,3)^2;
RV(1,4)=RT(1,1)*RT(1,2);
RV(1,5)=RT(1,1)*RT(1,3);
RV(1,6)=RT(1,3)*RT(1,2);
RV(2,1)=RT(2,1)^2;
RV(2,2)=RT(2,2)^2;
RV(2,3)=RT(2,3)^2;
RV(2,4)=RT(2,1)*RT(2,2);
RV(2,5)=RT(2,1)*RT(2,3);
RV(2,6)=RT(2,3)*RT(2,2);
RV(3,1)=RT(3,1)^2;
RV(3,2)=RT(3,2)^2;
RV(3,3)=RT(3,3)^2;
RV(3,4)=RT(3,1)*RT(3,2);
RV(3,5)=RT(3,1)*RT(3,3);
RV(3,6)=RT(3,3)*RT(3,2);
RV(4,1)=2*RT(1,1)*RT(2,1);
RV(4,2)=2*RT(1,2)*RT(2,2);
RV(4,3)=2*RT(1,3)*RT(2,3);
RV(4,4)=RT(1,1)*RT(2,2)+RT(2,1)*RT(1,2);
RV(4,5)=RT(1,1)*RT(2,3)+RT(1,3)*RT(2,1);
RV(4,6)=RT(1,2)*RT(2,3)+RT(1,3)*RT(2,2);
RV(5,1)=2*RT(1,1)*RT(3,1);
RV(5,2)=2*RT(1,2)*RT(3,2);