-
Notifications
You must be signed in to change notification settings - Fork 4
/
Plasticity_DEM_GPU.py
118 lines (89 loc) · 3 KB
/
Plasticity_DEM_GPU.py
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
from DEM_Lib import *
EXAMPLE = 3
# Material properties
YM = 1000
PR = 0.3
sig_y0 = 50.
def FlowStressLinear( eps_p_eff ):
return sig_y0 + ( YM / 2. ) * eps_p_eff
def FlowStressKinematic( eps_p_eff ):
return sig_y0 + 0 * eps_p_eff
def HardeningModulusLinear( eps_p_eff ):
return YM / 2.
# Setup examples
UNIFORM = True
if EXAMPLE == 1:
print('Constrained shear')
KINEMATIC = False
FlowStress = FlowStressLinear
HardeningModulus = HardeningModulusLinear
if UNIFORM: # Get stress-strain curve
ref_file = 'shear10_iso'
KINEMATIC = True
FlowStress = FlowStressKinematic
ref_file = 'shear10_kine'
# disp_schedule = np.linspace( 0. , 1. , 11 )
disp_schedule = [ 0. , 1./3. , 2./3. , 1. , 2./3. , 1./3. , 0. , -1./3. , -2./3. , -1. , -2./3. , -1./3. , 0. ]
rel_tol = np.ones( 13 ) * 1e-6
else: # Compare with DCM
ref_file = 'shearWave'
KINEMATIC = True
FlowStress = FlowStressKinematic
ref_file = 'ShearWave_kine'
disp_schedule = [ 0. , 0.5 ]
rel_tol = [ 1e-6 ]
BoundingBox = [ 4. , 4. , 1. ] # Size of bounding box
GeometryFile = 'Shear'
elif EXAMPLE == 2:
print('Plate with hole, cyclic loading')
ISO = True
if ISO:
KINEMATIC = False
FlowStress = FlowStressLinear
ref_file = 'Hole'
rel_tol = np.ones(4) * 2e-5
else:
KINEMATIC = True
FlowStress = FlowStressKinematic
ref_file = 'HoleKine'
rel_tol = np.ones(4) * 2e-5
HardeningModulus = HardeningModulusLinear
BoundingBox = [ 4. , 4. , 1. ] # Size of bounding box
GeometryFile = 'Hole'
disp_schedule = [ 0. , 0.2 , -0.2 , 0.4 , -0.4 ]
elif EXAMPLE == 3:
print('Bimaterial plate')
KINEMATIC = False
FlowStress = FlowStressLinear
HardeningModulus = HardeningModulusLinear
ref_file = 'BiMat'
disp_schedule = [ 0. , 0.5 ]
rel_tol = np.ones( 1 ) * 1.e-6
BoundingBox = [ 4. , 4. , 1. ] # Size of bounding box
GeometryFile = 'BiMat'
base = './Example' + str(EXAMPLE) + '/'
# Setup domain
domain = setup_domain( base + GeometryFile , BoundingBox )
print('Number of nodes is ', domain['nN'])
print('Number of elements is ', domain['nE'])
# All misc model settings
step_max = len(disp_schedule) - 1
LBFGS_Iteration = 35
Num_Newton_itr = 1
Settings = [ KINEMATIC , FlowStress , HardeningModulus , disp_schedule , rel_tol , step_max , LBFGS_Iteration , Num_Newton_itr , EXAMPLE , YM , PR , sig_y0 , base , UNIFORM ]
# Hyper parameters
x_var = { 'x_lr' : 0.5 ,
'neuron' : 100 ,
'act_func' : 'tanh' }
lr = x_var['x_lr']
H = int(x_var['neuron'])
act_fn = x_var['act_func']
print( 'LR: ' + str(lr) + ', H: ' + str(H) + ', act fn: ' + act_fn )
f = open( base + 'DiffLog','w')
f.close()
# Begin training
snet = S_Net( 3 , H , 3 , act_fn )
DEM = DeepMixedMethod( [ snet , lr , domain , Settings ] )
all_diff = DEM.train_model( disp_schedule , ref_file )
fn_ = base + 'AllDiff.npy'
np.save( fn_ , all_diff )