-
Notifications
You must be signed in to change notification settings - Fork 2
/
stress_measures.py
65 lines (55 loc) · 2.38 KB
/
stress_measures.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
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 29 12:29:12 2015
@author: Administrator
"""
import numpy as np
import matplotlib.pyplot as plt
from simulation import MAX_RADIUS, dist_key_list
from simulation import SimFiber, stim_num
measure_list = ['msmaxprin', 'msmidprin', 'msminprin', 'msmises']
class StressMeasureFiber(SimFiber):
def __init__(self, factor='SkinThick', level=2, control='Displ'):
SimFiber.__init__(self, factor, level, control, stim_num)
self.get_stress_measures()
return
def get_stress_measures(self):
self.get_dist(key_list=dist_key_list + measure_list)
return
if __name__ == '__main__':
stressMeasureFiber = StressMeasureFiber()
# %% Plot distributions
fig, axs = plt.subplots(1, 1)
# Plot the surface pressure
xscale = 1e3
mscale = 1e-3
axs.plot(stressMeasureFiber.dist[2]['mxold'][-1] * xscale,
-stressMeasureFiber.dist[2]['msminprin'][-1] * mscale,
label='Min principal (max compressive) stress')
axs.plot(stressMeasureFiber.dist[2]['mxold'][-1] * xscale,
-stressMeasureFiber.dist[2]['msmidprin'][-1] * mscale,
label='Mid principal stress')
axs.plot(stressMeasureFiber.dist[2]['mxold'][-1] * xscale,
-stressMeasureFiber.dist[2]['msmaxprin'][-1] * mscale,
label='Max principal stress')
axs.plot(stressMeasureFiber.dist[2]['mxold'][-1] * xscale,
stressMeasureFiber.dist[2]['msmises'][-1] * mscale,
label='Von Mises stress')
axs.plot(stressMeasureFiber.dist[2]['cxold'][-1] * xscale,
stressMeasureFiber.dist[2]['cpress'][-1] * mscale,
label='Contact pressure')
axs.legend(loc=2)
axs.set_xlim(0, MAX_RADIUS * xscale)
axs.set_xlabel('Location (mm)')
axs.set_ylabel('Stress (kPa)')
fig.savefig('./plots/stress_measures.png', dpi=300)
fig.savefig('./plots/stress_measures.pdf', dpi=300)
plt.close(fig)
# Print out the relative ratio
total_int = stressMeasureFiber.dist[2]['msmaxprinint'] +\
stressMeasureFiber.dist[2]['msmidprinint'] +\
stressMeasureFiber.dist[2]['msminprinint']
ratio_int = np.array([stressMeasureFiber.dist[2]['msminprinint'],
stressMeasureFiber.dist[2]['msmidprinint'],
stressMeasureFiber.dist[2]['msmaxprinint']]
) / total_int