-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdrop.f90
467 lines (371 loc) · 13.4 KB
/
drop.f90
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
! Copyright (c) 2017,
! Eyal Shalev ([email protected])
! Vladimir Lyakhovsky
! All rights reserved to Geological Survey of Israel (GSI)
!
! Redistribution and use in source and binary forms, with or without
! modification, are permitted provided that the following conditions are met:
! * Redistributions of source code must retain the above copyright
! notice, this list of conditions and the following disclaimer.
! * Redistributions in binary form must reproduce the above copyright
! notice, this list of conditions and the following disclaimer in the
! documentation and/or other materials provided with the distribution.
! * Neither the name of Eyal Shalev or Vladimir Lyakhovsky, nor the
! names of its contributors may be used to endorse or promote products
! derived from this software without specific prior written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
! DISCLAIMED. IN NO EVENT SHALL Eyal Shalev & Vladimir Lyakhovsky
! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!------------Stress drop -----------------------
!--- F90 damage & porosity ---------------------
!> @brief Calculates stress drop in failed elements
!> @details Uses explicit time step for iterrative solution
!> of equations of motion. Append data to file "catalog" with
!> information about failed elements
!>
!> @param[in] time, time step
!> @param[out] None
subroutine drop (time,dt)
use sizes
use element_data
use node_data
use boundary_node_data
implicit none
!------------- Variables ------------------------
logical:: event,dynamic,space
integer::n,j,ndrop,mm,nd,nfl,ii,i
real(kind=8):: time,vvv0,dt,vvv,factor
real(kind=8):: alp0,dist,si2
real(kind=8):: dadt,dsf,dsf1,d_al,s(6),rle,rme
real(kind=8):: d_coup,din,fx,fy,cst,df_el
real(kind=8):: p_mean,s_mean,pot,sdrop,xx,yy,zz
real(kind=8):: s11,s22,s33,s12,s13,s23
real(kind=8):: p11,p22,p33,p12,p13,p23
! final ksi is estimated according to the yield envelope
!-------------------------------------------------
!---------calculate co-seismic velocity related to event
!--- repeat iterrations until boff < boff_min and vvv < vvv0
vvv0 = 1.e-4
factor = 1.e-3
print *,' '
print *,' ===== START DROP EVENT ======= '
!--------------------------------------------------------
!$OMP PARALLEL
!$OMP DO PRIVATE(n,j)
do n = 1,ne
do j = 1,6
stress0(j,n) = stress(j,n)
strain0(j,n) = strain(j,n) - strainp(j,n)
end do
end do
!$OMP END DO
!$OMP END PARALLEL
!------- search for epicenter --------------------
!------- create a list of failed elements --------
!------- index(ndrop); ndrop - number of failed elements ----
ndrop = 0
do n = 1,ne
if(flag(n).eq.1 .or. flag(n).eq.2 ) then
ndrop = ndrop + 1
el_drop(ndrop) = n
alpha(n) = 1.0_8
write(6,*)' epicenter: ',el_drop(ndrop),flag(n)
write(6,*) alpha(n),phi(n),ksi(n),pf_el(n)
if ( flag(n) .eq. 2 ) then ! search for target ksi
call ksi_final(n)
end if
end if
end do
!-----------------------------------------------------
! Start main loop for co-seismic displacements
co_seism: do
dynamic = .false.
! reset arrays
force=0.0_8
balance=0.0_8
!$OMP PARALLEL
!$OMP DO PRIVATE(n,j)
do n = 1,ne
! calculate elastic strains for all elements
do j=1,6
str_e(j,n) = strain(j,n) - strainp(j,n)
end do
! update fluid pressure
pf_el(n) = m_biot(n)*(zi_el(n) - phi(n) - al_biot(n)*i1(n))
end do
!$OMP END DO
!$OMP END PARALLEL
! calculate stress in non-failed elements
do n = 1,ne
! Stress for SOLID elements
if ( flag(n) .eq. 0 ) then
! Check to see if anything failed, elastic returns event=.true.
! and flag(n)=1 or 2 if the damage above critical value
event=.false.
call elastic(n,event,s)
if(event)then
! Another element failed, add to the list
write(6,*)' Damage above critical value, element ',n,flag(n),alpha(n),phi(n),pf_el(n)
ndrop = ndrop + 1
el_drop(ndrop) = n
alpha(n) = 1.0_8
dynamic = .true.
! Search for target ksi
call ksi_final(n)
else
! Add fluid pressure
! Stress for next step
do j=1,3
stress(j,n) = s(j) - al_biot(n)* pf_el(n)
stress(j+3,n) = s(j+3)
end do
end if
end if
end do
!---------------------------------------------
! calculate stress in failed elements
do nd = 1,ndrop
n = el_drop(nd)
! Flow-rules for MODE-II elements
if(flag(n).eq.2) then
! Mode-2
!-------- stress relaxation in mode-2 ---------------------
! until element is above yield
!
! Coupling coefficient
d_coup = coupl(n,1) + coupl(n,3)*num_drop(n) + &
coupl(n,2)*phi(n) + coupl(n,3)*alpha(n)
!---use ksi(n) from previous step ----
event = .true.
if(ksi(n)*(1.0_8-d_coup*(abs(i1(n))**power)) .le. ksi0(n) ) then
! Back to solid
event = .false.
call elastic(n,event,s)
else if (event) then
! Relaxation of elastic strain and porosity change
dynamic = .true.
si2 = dsqrt(i2(n))
fx = -d_coup*(power+1.0_8)*(abs(i1(n))**power)*si2 + &
d_coup*(abs(i1(n))**(power+1.0_8))*ksi(n)/3.0_8 + &
2./3.*i1(n)*(ksi(n)-ksi0(n)) + si2*(1.0_8-ksi(n)*ksi(n)/3.0_8)
fy = (ksi(n)-2.0_8*ksi0(n)-ksi(n)*d_coup*(abs(i1(n))**power) )
df_el = fx/100.0_8
phi(n) = phi(n) + df_el
! print *,' Coup ',d_coup,si2,ksi(n),phi(n),fx
! print *,' Poro ',n,phi(n),i1(n),ksi(n),ksif(n)
! print *,' Factor ',factor,fx,fy,df_el,pf_el(n)
! print *,' Sp ',stress(:,n)
! print *,' Sn ',s
do j=1,3
strainp(j, n) = strainp(j, n) + df_el/3.0_8
strainp(j, n) = strainp(j, n) + fy*(str_e(j,n)-i1(n)/3.0_8)/100.0_8
strainp(j+3,n) = strainp(j+3,n) + fy*str_e(j+3,n)/100.0_8
str_e(j, n) = strain(j, n) - strainp(j, n)
str_e(j+3,n) = strain(j+3,n) - strainp(j+3,n)
end do
! invariants of elastic strain
call strain_invariants(n,si2)
! print *,' Update ',i1(n),phi(n),ksi(n),i2(n)-i1(n)*i1(n)/3.
! effective moduli
rle = lambda(n) - gr(n)/ksif(n)
rme = mu(n) + gr(n)*(ksi0(n) - 0.5_8*ksif(n))
do j=1,3
s(j) = rle*i1(n) + 2.0_8*rme*str_e(j,n)
s(j+3) = 2.0_8*rme*str_e(j+3,n)
end do
end if
s_mean = s(1)+ s(2)+ s(3)
if(s_mean .gt. 0.0_8 ) then
flag(n) = 1 ! mode changed
print *,' Mode changed (tension): ',n,flag(n),s_mean
end if
end if
!-------- stress relaxation in mode-1 ---------------------
if(flag(n).eq.1.or.flag(n).eq.3) then
! Mode-1
s = 0.0_8
end if
! Add fluid pressure
! Save stress for EFDLM and next step
do j=1,3
stress(j,n) = factor*(s(j)-al_biot(n)*pf_el(n)-stress(j,n))+stress(j,n)
stress(j+3,n) = factor*(s(j+3)-stress(j+3,n))+stress(j+3,n)
end do
! print *,ksi(n),ksif,dynamic
end do
!-------------------------------------------
! ------ steps from EFDLM ---------------
do n=1,ne
! calculate and transfer element forces onto nodes
call force_balance(n)
end do
! calculate other forces on nodes
call n_force_balance(dt)
! Estimation max balance-off in system (boff)
call boff_calc(dt,vvv)
if(vvv .le. 100.0_8*vvv0) then
factor = factor*(1.+adp)
if (factor .ge. 1.0) factor = 1.0
else
factor = 1.0e-3_8
end if
!------------------ Move Grid ------------------
call move_grid (dt)
!-------- change time step ------------------------
if ( boff .ge. boff_max ) then
den_scale = den_scale*(1.-adp)
if ( den_scale .lt. 1. ) den_scale = 1.
dt = 0.25 / sqrt(vp2 / den_scale)
else if ( boff .le. boff_min ) then
den_scale = den_scale*(1.+adp)
dt = 0.25 / sqrt(vp2 / den_scale)
end if
!------------------------------------------------
!--- finish or repeate iterration --------------
if ( .not. dynamic) then
if ( boff .ge. boff_min ) dynamic = .true. ! repeate until boff < boff_min
if ( vvv .ge. vvv0 ) dynamic = .true. ! repeate until velocity is big
end if
!---------------------------------------------------------
if ( .not. dynamic) then ! test for rupture front (dynamic weakening)
do n = 1,ne
if(flag(n).eq.0) then
alp0 = alpha(n)
! calculate elastic strains
do j=1,6
str_e(j,n) = strain(j,n) - strainp(j,n)
end do
! invariants of elastic strain
call strain_invariants(n,si2)
if ( ksi(n) .gt. ksi0(n) ) then
!--------------Damage rate correction------------
dadt = rate(n,1)*i2(n)*(ksi(n)-ksi0(n) )
!----- Inv-distance factor ------------------
dsf = 0.0_8
do mm = 1, ndrop
dist= ( field(n,1) - field(el_drop(mm),1) )**2 + &
( field(n,2) - field(el_drop(mm),2) )**2 + &
( field(n,3) - field(el_drop(mm),3) )**2
dsf1 = 1.0_8/dist
if(dsf .le. dsf1) dsf = dsf1
end do
d_al = sqrt(rate(n,4)*dadt*dsf)
alpha(n) = alp0 + d_al
event=.false.
call elastic(n,event,s)
if(event)then
! Another element failed, add to the list
print *,' Dynamic drop: ',n,flag(n),alpha(n),phi(n),d_al,pf_el(n)
ndrop = ndrop + 1
el_drop(ndrop) = n
alpha(n) = 1.0_8
dynamic = .true.
else
alpha(n) = alp0
end if
end if
end if
end do
end if
if ( .not. dynamic) exit co_seism
end do co_seism
!---------------------------------------------------------
!--- Only here we really finished iterrations !!!!!!
!
! New plastic strain and output final result
open (11,file='catalog',position='append')
do nd = 1,ndrop
n = el_drop(nd)
!-------- stress drop occured in this element ------------
nfl = flag(n)
if ( flag(n) .eq. 1 ) then
flag(n) = 3
strainp(1,n) = strain(1,n)
strainp(2,n) = strain(2,n)
strainp(3,n) = strain(3,n)
strainp(4,n) = strain(4,n)
strainp(5,n) = strain(5,n)
strainp(6,n) = strain(6,n)
end if
if ( flag(n) .eq. 2 ) flag(n) = 0
num_drop(n) = num_drop(n) + 1
d_coup = coupl(n,1) + coupl(n,3)*num_drop(n) + &
coupl(n,2)*phi(n) + coupl(n,3)*alpha(n)
if(d_coup .le. 0.0) then
num_drop(n) = num_drop(n) - 1
flag(n) = 3
end if
! stress drop in the element
s11 = stress(1,n) - stress0(1,n)
s22 = stress(2,n) - stress0(2,n)
s33 = stress(3,n) - stress0(3,n)
s12 = stress(4,n) - stress0(4,n)
s13 = stress(5,n) - stress0(5,n)
s23 = stress(6,n) - stress0(6,n)
sdrop = dsqrt((s11**2+s22**2+s33**2)/2.0_8 &
+ s12**2+s13**2+s23**2)*el_vol(n)
! potency in the element
p11 = strain(1,n) - strain0(1,n)
p22 = strain(2,n) - strain0(2,n)
p33 = strain(3,n) - strain0(3,n)
p12 = strain(4,n) - strain0(4,n)
p13 = strain(5,n) - strain0(5,n)
p23 = strain(6,n) - strain0(6,n)
pot = dsqrt((p11**2+p22**2+p33**2)/2.0_8 &
+ p12**2+p13**2+p23**2)*el_vol(n)
print *,' drop ', nd, n, time,' mode-',nfl,alpha(n),phi(n),ksi(n),i2(n),pf_el(n)
! center of the element
xx = field(n,1)
yy = field(n,2)
zz = field(n,3)
write (11,100) nd,n,nfl,time,xx,yy,zz,sdrop,pot,pf_el(n)
end do
100 format(i4,i8,' mode-',i1,1x,g15.8,7(1x,g15.5))
close(11)
return
end subroutine drop
subroutine ksi_final(n)
use sizes
use element_data
implicit none
integer:: n
real(kind=8):: fx,fy,d_coup,si2,i1_0,sh_0,factor,csi
logical:: yld
call strain_invariants(n,si2)
if ( i1(n) .ge. 0.0 ) then
ksif(n) = -dsqrt(3.0_8)*0.1 + ksi0(n)*0.9_8
else
factor = 1.0e-3_8
! Coupling coefficient
d_coup = coupl(n,1) + coupl(n,3)*num_drop(n) + &
coupl(n,2)*phi(n) + coupl(n,3)*alpha(n)
sh_0 = dsqrt(i2(n) - i1(n)*i1(n)/3.0_8)
i1_0 = i1(n)
if(ksi(n)*(1.0_8-d_coup*(abs(i1(n))**power)) .ge. ksi0(n) ) yld = .true.
if(yld) print *,' Elelement ',n,' is above yield ',i1(n),ksi(n)
do while( yld )
fx = -d_coup*(power+1.0_8)*(abs(i1(n))**power)*si2 + &
d_coup*(abs(i1(n))**(power+1.0_8))*ksi(n)/3.0_8 + &
2./3.*i1(n)*(ksi(n)-ksi0(n)) + si2*(1.0_8-ksi(n)*ksi(n)/3.0_8)
fy = sh_0 * (ksi(n)-2.0_8*ksi0(n)-ksi(n)*d_coup*(abs(i1(n))**power) )
i1_0 = i1_0 - fx*factor
sh_0 = sh_0 - fy*factor
csi = i1_0 / dsqrt(i1_0*i1_0/3.0_8 + sh_0*sh_0)
! print *,yld,i1_0,sh_0,fx,fy,csi,d_coup
! print *,d_coup,power,i1(n),si2,ksi(n),fx
if(csi*(1.0_8-d_coup*(abs(i1_0)**power)) .le. ksi0(n) ) yld = .false.
end do
ksif(n) = csi
print *,' Target ksi-value ',ksif(n),' expected porosity change ',i1_0-i1(n)
end if
return
end subroutine ksi_final