|
30 | 30 |
|
31 | 31 | _, samples = read_h5(file_name, data_path, [temp1, temp2], get_mesh=False)
|
32 | 32 |
|
33 |
| -strains = np.random.normal(size=(n_loading_directions, strain_dof)) |
| 33 | +strains = np.random.normal(size=(n_loading_directions, mesh['strain_dof'])) |
34 | 34 | strains /= la.norm(strains, axis=1)[:, None]
|
35 | 35 |
|
36 | 36 | n_approaches = 5
|
|
54 | 54 | Eref = ref[idx]['strain_localization']
|
55 | 55 | ref_C = ref[idx]['mat_stiffness']
|
56 | 56 | ref_eps = ref[idx]['mat_thermal_strain']
|
57 |
| - plastic_modes = ref[idx]['plastic_modes'] |
58 | 57 | normalization_factor_mech = ref[idx]['normalization_factor_mech']
|
59 | 58 |
|
60 |
| - Sref = construct_stress_localization(Eref, ref_C, ref_eps, plastic_modes, mat_id, n_gauss, strain_dof) |
| 59 | + Sref = construct_stress_localization(Eref, ref_C, ref_eps, mat_id, n_gauss, strain_dof) |
61 | 60 | effSref = volume_average(Sref)
|
62 | 61 |
|
63 | 62 | # interpolated quantities using an explicit interpolation scheme with one DOF
|
64 | 63 | approx_C, approx_eps = naive(alpha, sampling_C, sampling_eps, ref_C, ref_eps)
|
65 | 64 | Enaive = interpolate_temp(E0, E1)
|
66 |
| - Snaive = construct_stress_localization(Enaive, ref_C, ref_eps, plastic_modes, mat_id, n_gauss, strain_dof) |
| 65 | + Snaive = construct_stress_localization(Enaive, ref_C, ref_eps, mat_id, n_gauss, strain_dof) |
67 | 66 | effSnaive = volume_average(Snaive)
|
68 | 67 |
|
69 | 68 | # interpolated quantities using an explicit interpolation scheme with one DOF
|
70 |
| - Eopt0, _ = interpolate_fluctuation_modes(E01, approx_C, approx_eps, plastic_modes, mat_id, n_gauss, strain_dof, n_modes, |
71 |
| - n_gp) |
72 |
| - Sopt0 = construct_stress_localization(Eopt0, ref_C, ref_eps, plastic_modes, mat_id, n_gauss, strain_dof) |
| 69 | + Eopt0, _ = interpolate_fluctuation_modes(E01, approx_C, approx_eps, mat_id, n_gauss, strain_dof, n_modes, n_gp) |
| 70 | + Sopt0 = construct_stress_localization(Eopt0, ref_C, ref_eps, mat_id, n_gauss, strain_dof) |
73 | 71 | effSopt0 = volume_average(Sopt0)
|
74 | 72 |
|
75 | 73 | # interpolated quantities using an implicit interpolation scheme with one DOF
|
76 | 74 | approx_C, approx_eps = opt1(sampling_C, sampling_eps, ref_C, ref_eps)
|
77 |
| - Eopt1, _ = interpolate_fluctuation_modes(E01, approx_C, approx_eps, plastic_modes, mat_id, n_gauss, strain_dof, n_modes, |
78 |
| - n_gp) |
79 |
| - Sopt1 = construct_stress_localization(Eopt1, ref_C, ref_eps, plastic_modes, mat_id, n_gauss, strain_dof) |
| 75 | + Eopt1, _ = interpolate_fluctuation_modes(E01, approx_C, approx_eps, mat_id, n_gauss, strain_dof, n_modes, n_gp) |
| 76 | + Sopt1 = construct_stress_localization(Eopt1, ref_C, ref_eps, mat_id, n_gauss, strain_dof) |
80 | 77 | effSopt1 = volume_average(Sopt1)
|
81 | 78 |
|
82 | 79 | # interpolated quantities using an implicit interpolation scheme with two DOF
|
83 | 80 | approx_C, approx_eps = opt2(sampling_C, sampling_eps, ref_C, ref_eps)
|
84 |
| - Eopt2, _ = interpolate_fluctuation_modes(E01, approx_C, approx_eps, plastic_modes, mat_id, n_gauss, strain_dof, n_modes, |
85 |
| - n_gp) |
86 |
| - Sopt2 = construct_stress_localization(Eopt2, ref_C, ref_eps, plastic_modes, mat_id, n_gauss, strain_dof) |
| 81 | + Eopt2, _ = interpolate_fluctuation_modes(E01, approx_C, approx_eps, mat_id, n_gauss, strain_dof, n_modes, n_gp) |
| 82 | + Sopt2 = construct_stress_localization(Eopt2, ref_C, ref_eps, mat_id, n_gauss, strain_dof) |
87 | 83 | effSopt2 = volume_average(Sopt2)
|
88 | 84 |
|
89 | 85 | # interpolated quantities using an implicit interpolation scheme with four DOF
|
90 | 86 | approx_C, approx_eps = opt4(sampling_C, sampling_eps, ref_C, ref_eps)
|
91 |
| - Eopt4, _ = interpolate_fluctuation_modes(E01, approx_C, approx_eps, plastic_modes, mat_id, n_gauss, strain_dof, n_modes, |
92 |
| - n_gp) |
93 |
| - Sopt4 = construct_stress_localization(Eopt4, ref_C, ref_eps, plastic_modes, mat_id, n_gauss, strain_dof) |
| 87 | + Eopt4, _ = interpolate_fluctuation_modes(E01, approx_C, approx_eps, mat_id, n_gauss, strain_dof, n_modes, n_gp) |
| 88 | + Sopt4 = construct_stress_localization(Eopt4, ref_C, ref_eps, mat_id, n_gauss, strain_dof) |
94 | 89 | effSopt4 = volume_average(Sopt4)
|
95 | 90 |
|
96 | 91 | err = lambda x, y: np.mean(la.norm(x - y, axis=(-1, -2)) / la.norm(y, axis=(-1, -2))) * 100
|
|
102 | 97 | err(effSopt2, effSref), err(effSopt4, effSref)]
|
103 | 98 |
|
104 | 99 | for strain_idx, strain in enumerate(strains):
|
105 |
| - zeta = np.hstack((strain, 1, np.ones(plastic_modes.shape[-1]))) |
| 100 | + zeta = np.hstack((strain, 1)) |
106 | 101 |
|
107 | 102 | eff_stress_ref = effSref @ zeta
|
108 | 103 | err_eff_stress[:, idx * n_loading_directions + strain_idx] = \
|
|
117 | 112 | stress_opt4 = np.einsum('ijk,k', Sopt4, zeta, optimize='optimal')
|
118 | 113 |
|
119 | 114 | residuals = compute_residual_efficient([stress_naive, stress_opt0, stress_opt1, stress_opt2, stress_opt4],
|
120 |
| - global_gradient) |
| 115 | + mesh['global_gradient']) |
121 | 116 |
|
122 | 117 | err_f[:, idx * n_loading_directions + strain_idx] = la.norm(residuals, np.inf, axis=0) / normalization_factor_mech * 100
|
123 | 118 |
|
|
0 commit comments