Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplotting.py
More file actions
Latest commit
122 lines (99 loc) · 4.98 KB
/
Copy pathplotting.py
File metadata and controls
122 lines (99 loc) · 4.98 KB
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
importnumpyasnp
importmatplotlib.pyplotasplt
fromcyclerimportcycler
importmatplotlib.pyplotasplt
defplot_latticestrain(axs, true_stress, latticestrain, axis, incs="*", xlim=None, ylim=None):
phase_names= [
'Ti_alpha',
'Ti_beta',
]
custom_cycler= (cycler(color=[
'#FFE800', '#9FDF00', '#0DCD52', '#00948D', # alpha colours
'#67001F', '#DF2179', '#CDA0CD'# beta colours
]) +
cycler(marker=[
's', 'h', '^', 'D', # alpha markers
'+', 'x', 'P'# beta markers
]))
axs.set_prop_cycle(custom_cycler)
latticestrain_mean= {}
forphase_name, latticestrain_phaseinlatticestrain[axis].items():
latticestrain_phase_mean= {}
forplane_label, strainsinlatticestrain_phase.items():
latticestrain_phase_mean[plane_label] =np.array([strain.mean() forstraininstrains])
latticestrain_mean[phase_name] =latticestrain_phase_mean
forphaseinphase_names:
forplane_label, mean_straininlatticestrain_mean[phase].items():
total_microstrain=np.array([0] +mean_strain) *1e6# convert to microstrain (1e6)
axs.plot(total_microstrain, true_stress, label=plane_label)
axs.title.set_text(f"{axis}")
axs.set_xlabel("Lattice Strain ($10^{-6}$)")
axs.set_xlim([None, xlim])
axs.set_ylabel("True Stress $\sigma$ (MPa)")
axs.set_ylim([None, ylim])
axs.legend()
defplot_truestrain_peakint(axs, plane_intensity, true_strain, axis, phase_labels, xlim=None, ylim=None):
# maybe the colours are just wrong??
custom_cycler= (cycler(color=[
'#FFE800', '#9FDF00', '#0DCD52', '#00948D', # alpha
'#67001F', '#DF2179', '#CDA0CD'# beta
]) +
cycler(marker=[
's', 'h', '^', 'D', # alpha
'+', 'x', 'P'# beta
]))
custom_cycler= (cycler(color=[
'#FFE800', '#9FDF00', '#0DCD52', '#00948D', # alpha
'#67001F', '#DF2179', '#CDA0CD'# beta
]) +
cycler(marker=[
's', 'h', '^', 'D', # alpha
'+', 'x', 'P'# beta
]))
axs.set_prop_cycle(custom_cycler)
forphaseinphase_labels:
forplane_label, peakintinplane_intensity[axis][phase].items():
# Elements of X-Ray Diffraction 2nd ed., B.D. Cullity, 1978 ISBN 0-201-01174-3
# alpha
ifplane_label=="{0002}":
peakint= [intensity/2forintensityinpeakint]
elifplane_label=="{10-10}":
peakint= [intensity/6forintensityinpeakint]
elifplane_label=="{10-11}":
peakint= [intensity/12forintensityinpeakint]
elifplane_label=="{11-20}":
peakint= [intensity/6forintensityinpeakint]
# beta
elifplane_label=="{200}":
peakint= [intensity/6forintensityinpeakint]
elifplane_label=="{110}":
peakint= [intensity/12forintensityinpeakint]
elifplane_label=="{220}":
peakint= [intensity/6forintensityinpeakint]
# ax.plot(true_strain, peakint, label=plane_label)
axs.plot(true_strain, peakint, label=plane_label)
axs.title.set_text(f"{axis}")
axs.set_xlabel(f"True Strain $\epsilon_{axis}^{{VM}}$")
axs.set_xlim([None, xlim])
axs.set_ylabel("Material Point Count")
axs.set_ylim([None, ylim])
axs.legend()
defplot_lattice_strain_dist_inc(axs, latticestrain, axis, phase, inc, bins=20, xmin=None, xlim=None, ymin=None, ylim=None):
ifphase=="Ti_beta":
colour=np.array(['#67001F', '#DF2179', '#CDA0CD'], dtype='object')
elifphase=="Ti_alpha":
colour=np.array(['#FFE800', '#9FDF00', '#0DCD52', '#00948D'], dtype='object')
print(f"phase: {phase} Direction: {axis}")
forplane_num, planeinenumerate(latticestrain[axis][phase].keys()):
print(f"\tplane: {plane}\tlattice strain ")
# calculate how many numbers within stdev around mean
lattstrain_dist=latticestrain[axis][phase][plane][inc]
axs.hist(lattstrain_dist*1e6, bins=bins,
alpha=0.4, color=colour[plane_num],
label=plane)
axs.legend()
axs.title.set_text(f"{axis}")
axs.set_xlabel("Lattice Strain")
axs.set_xlim(xmin, xlim)
axs.set_ylabel("Measurements")
axs.set_ylim(ymin, ylim)