Skip to content

Commit 2c2040f

Browse files
author
Julius Herb
committed
Documentation, minor changes
1 parent b30d041 commit 2c2040f

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

eg8_plot_localization.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@
5757
# %%
5858

5959

60-
def plot_localization(ax, E, i=0, idx=0):
61-
"""Plots the euclidean norm of the `i`-th row of
62-
a localization operator `E` on the y-z-cross section at x=idx.
60+
def plot_localization(ax, E, idx=0):
61+
"""Plots the effective total strain/stress norm (not the deviatoric part)
62+
of a given localization operator `E` on the y-z-cross section at x=idx.
6363
6464
Args:
6565
ax: matplotlib axis
6666
E (np.ndarray): localization operator with shape (nx*ny*nz*ngauss, 6, 7)
67-
i (int, optional): row no. of E to be plotted. Defaults to 0.
6867
idx (int, optional): y-z-cross section index. Defaults to 0.
6968
"""
7069
assert E.ndim == nodal_dof
@@ -75,27 +74,27 @@ def plot_localization(ax, E, i=0, idx=0):
7574
E_ra = np.mean(E_r, axis=3) # average over gauss points
7675
# compute the effective total strain norm (not the deviatoric part);
7776
# account for Mandel notation, i.e. activation strain with all components being 1.0
78-
E_rai = np.einsum('ijklm,m',E_ra, np.asarray([1, 1, 1, np.sqrt(2), np.sqrt(2), np.sqrt(2),1]))
79-
effective_strain = np.sqrt(2/3) * la.norm(E_rai,axis=-1)
80-
# plot y-z-cross section at x=0
81-
ax.imshow(effective_strain[idx, :, :], interpolation="spline16")
77+
E_rai = np.einsum('ijklm,m', E_ra, np.asarray([1, 1, 1, np.sqrt(2), np.sqrt(2), np.sqrt(2), 1]))
78+
effective_strain = np.sqrt(2/3) * la.norm(E_rai, axis=-1)
79+
# plot y-z-cross section at x=idx
80+
ax.imshow(effective_strain[idx, :, :], interpolation="gaussian")
8281

8382

8483
# Plot strain localization operator E at different temperatures
8584
fig, ax = plt.subplots(1, 3)
86-
plot_localization(ax[0], E0, i=0)
85+
plot_localization(ax[0], E0, idx=0)
8786
ax[0].set_title(
8887
r"$\underline{\underline{E}}\;\mathrm{at}\;\theta="
8988
+ f"{temp0:.2f}"
9089
+ r"\mathrm{K}$"
9190
)
92-
plot_localization(ax[1], Ea, i=0)
91+
plot_localization(ax[1], Ea, idx=0)
9392
ax[1].set_title(
9493
r"$\underline{\underline{E}}\;\mathrm{at}\;\theta="
9594
+ f"{tempa:.2f}"
9695
+ r"\mathrm{K}$"
9796
)
98-
plot_localization(ax[2], E1, i=0)
97+
plot_localization(ax[2], E1, idx=0)
9998
ax[2].set_title(
10099
r"$\underline{\underline{E}}\;\mathrm{at}\;\theta="
101100
+ f"{temp1:.2f}"
@@ -106,23 +105,25 @@ def plot_localization(ax, E, i=0, idx=0):
106105

107106
# Plot stress localization operator S at different temperatures
108107
fig, ax = plt.subplots(1, 3)
109-
plot_localization(ax[0], S0, i=0)
108+
plot_localization(ax[0], S0, idx=0)
110109
ax[0].set_title(
111110
r"$\underline{\underline{S}}\;\mathrm{at}\;\theta="
112111
+ f"{temp0:.2f}"
113112
+ r"\mathrm{K}$"
114113
)
115-
plot_localization(ax[1], Sa, i=0)
114+
plot_localization(ax[1], Sa, idx=0)
116115
ax[1].set_title(
117116
r"$\underline{\underline{S}}\;\mathrm{at}\;\theta="
118117
+ f"{tempa:.2f}"
119118
+ r"\mathrm{K}$"
120119
)
121-
plot_localization(ax[2], S1, i=0)
120+
plot_localization(ax[2], S1, idx=0)
122121
ax[2].set_title(
123122
r"$\underline{\underline{S}}\;\mathrm{at}\;\theta="
124123
+ f"{temp1:.2f}"
125124
+ r"\mathrm{K}$"
126125
)
127126
plt.savefig("output/S.png", dpi=300)
128127
plt.show()
128+
129+
# %%

0 commit comments

Comments
 (0)