|
1 | | -import numpy as np |
2 | 1 | import matplotlib.pyplot as plt |
| 2 | +import numpy as np |
3 | 3 |
|
4 | 4 | cells = 15625 |
5 | 5 |
|
|
11 | 11 | anisotropic_results_magpylib = np.load('anisotropic_results_magpylib_%d.npy' % cells) |
12 | 12 |
|
13 | 13 |
|
14 | | -isotropic_results_ansys = isotropic_results_ansys.reshape((6,-1,3)) |
15 | | -anisotropic_results_ansys = anisotropic_results_ansys.reshape((6,-1,3)) |
16 | | -isotropic_results_magpylib = isotropic_results_magpylib.reshape((6,-1,3)) |
17 | | -anisotropic_results_magpylib = anisotropic_results_magpylib.reshape((6,-1,3)) |
| 14 | +isotropic_results_ansys = isotropic_results_ansys.reshape((6, -1, 3)) |
| 15 | +anisotropic_results_ansys = anisotropic_results_ansys.reshape((6, -1, 3)) |
| 16 | +isotropic_results_magpylib = isotropic_results_magpylib.reshape((6, -1, 3)) |
| 17 | +anisotropic_results_magpylib = anisotropic_results_magpylib.reshape((6, -1, 3)) |
18 | 18 |
|
19 | 19 |
|
20 | 20 | isotropic_results_ansys_abs = np.linalg.norm(isotropic_results_ansys, axis=-1) |
|
25 | 25 |
|
26 | 26 | for i in range(6): |
27 | 27 | fig, (ax1, ax2) = plt.subplots(1, 2) |
28 | | - print('evaluation line ', i) |
29 | | - ax1.plot(isotropic_results_ansys[i,:,0], label='isotropic ansys x', color='C0', linestyle='-') |
30 | | - ax1.plot(isotropic_results_ansys[i,:,1], label='isotropic ansys y', color='C0', linestyle='--') |
31 | | - ax1.plot(isotropic_results_ansys[i,:,2], label='isotropic ansys z', color='C0', linestyle='-.') |
32 | | - ax1.plot(isotropic_results_magpylib[i,:,0], label='isotropic magpylib x', color='C1', linestyle='-') |
33 | | - ax1.plot(isotropic_results_magpylib[i,:,1], label='isotropic magpylib y', color='C1', linestyle='--') |
34 | | - ax1.plot(isotropic_results_magpylib[i,:,2], label='isotropic magpylib z', color='C1', linestyle='-.') |
35 | | - ax1.plot(anisotropic_results_ansys[i,:,0], label='anisotropic ansys x', color='C2', linestyle='-') |
36 | | - ax1.plot(anisotropic_results_ansys[i,:,1], label='anisotropic ansys y', color='C2', linestyle='--') |
37 | | - ax1.plot(anisotropic_results_ansys[i,:,2], label='anisotropic ansys z', color='C2', linestyle='-.') |
38 | | - ax1.plot(anisotropic_results_magpylib[i,:,0], label='anisotropic magpylib x', color='C3', linestyle='-') |
39 | | - ax1.plot(anisotropic_results_magpylib[i,:,1], label='anisotropic magpylib y', color='C3', linestyle='--') |
40 | | - ax1.plot(anisotropic_results_magpylib[i,:,2], label='anisotropic magpylib z', color='C3', linestyle='-.') |
41 | | - ax1.set_xlabel('point along avaluation line') |
42 | | - ax1.set_ylabel('field components [T]') |
| 28 | + print("evaluation line ", i) |
| 29 | + ax1.plot( |
| 30 | + isotropic_results_ansys[i, :, 0], |
| 31 | + label="isotropic ansys x", |
| 32 | + color="C0", |
| 33 | + linestyle="-", |
| 34 | + ) |
| 35 | + ax1.plot( |
| 36 | + isotropic_results_ansys[i, :, 1], |
| 37 | + label="isotropic ansys y", |
| 38 | + color="C0", |
| 39 | + linestyle="--", |
| 40 | + ) |
| 41 | + ax1.plot( |
| 42 | + isotropic_results_ansys[i, :, 2], |
| 43 | + label="isotropic ansys z", |
| 44 | + color="C0", |
| 45 | + linestyle="-.", |
| 46 | + ) |
| 47 | + ax1.plot( |
| 48 | + isotropic_results_magpylib[i, :, 0], |
| 49 | + label="isotropic magpylib x", |
| 50 | + color="C1", |
| 51 | + linestyle="-", |
| 52 | + ) |
| 53 | + ax1.plot( |
| 54 | + isotropic_results_magpylib[i, :, 1], |
| 55 | + label="isotropic magpylib y", |
| 56 | + color="C1", |
| 57 | + linestyle="--", |
| 58 | + ) |
| 59 | + ax1.plot( |
| 60 | + isotropic_results_magpylib[i, :, 2], |
| 61 | + label="isotropic magpylib z", |
| 62 | + color="C1", |
| 63 | + linestyle="-.", |
| 64 | + ) |
| 65 | + ax1.plot( |
| 66 | + anisotropic_results_ansys[i, :, 0], |
| 67 | + label="anisotropic ansys x", |
| 68 | + color="C2", |
| 69 | + linestyle="-", |
| 70 | + ) |
| 71 | + ax1.plot( |
| 72 | + anisotropic_results_ansys[i, :, 1], |
| 73 | + label="anisotropic ansys y", |
| 74 | + color="C2", |
| 75 | + linestyle="--", |
| 76 | + ) |
| 77 | + ax1.plot( |
| 78 | + anisotropic_results_ansys[i, :, 2], |
| 79 | + label="anisotropic ansys z", |
| 80 | + color="C2", |
| 81 | + linestyle="-.", |
| 82 | + ) |
| 83 | + ax1.plot( |
| 84 | + anisotropic_results_magpylib[i, :, 0], |
| 85 | + label="anisotropic magpylib x", |
| 86 | + color="C3", |
| 87 | + linestyle="-", |
| 88 | + ) |
| 89 | + ax1.plot( |
| 90 | + anisotropic_results_magpylib[i, :, 1], |
| 91 | + label="anisotropic magpylib y", |
| 92 | + color="C3", |
| 93 | + linestyle="--", |
| 94 | + ) |
| 95 | + ax1.plot( |
| 96 | + anisotropic_results_magpylib[i, :, 2], |
| 97 | + label="anisotropic magpylib z", |
| 98 | + color="C3", |
| 99 | + linestyle="-.", |
| 100 | + ) |
| 101 | + ax1.set_xlabel("point along avaluation line") |
| 102 | + ax1.set_ylabel("field components [T]") |
43 | 103 | ax1.grid() |
44 | 104 | ax1.legend() |
45 | 105 |
|
46 | | - |
47 | | - ax2.plot(isotropic_results_magpylib[i,:,0]-isotropic_results_ansys[i,:,0], label='isotropic error x', color='C4', linestyle='-') |
48 | | - ax2.plot(isotropic_results_magpylib[i,:,1]-isotropic_results_ansys[i,:,1], label='isotropic error y', color='C4', linestyle='--') |
49 | | - ax2.plot(isotropic_results_magpylib[i,:,2]-isotropic_results_ansys[i,:,2], label='isotropic error z', color='C4', linestyle='-.') |
50 | | - ax2.plot(anisotropic_results_magpylib[i,:,0]-anisotropic_results_ansys[i,:,0], label='anisotropic error x', color='C5', linestyle='-') |
51 | | - ax2.plot(anisotropic_results_magpylib[i,:,1]-anisotropic_results_ansys[i,:,1], label='anisotropic error y', color='C5', linestyle='--') |
52 | | - ax2.plot(anisotropic_results_magpylib[i,:,2]-anisotropic_results_ansys[i,:,2], label='anisotropic error z', color='C5', linestyle='-.') |
53 | | - ax2.set_xlabel('point along avaluation line') |
54 | | - ax2.set_ylabel('field components difference [T]') |
55 | | - ax2.grid() |
| 106 | + ax2.plot( |
| 107 | + isotropic_results_magpylib[i, :, 0] - isotropic_results_ansys[i, :, 0], |
| 108 | + label="isotropic error x", |
| 109 | + color="C4", |
| 110 | + linestyle="-", |
| 111 | + ) |
| 112 | + ax2.plot( |
| 113 | + isotropic_results_magpylib[i, :, 1] - isotropic_results_ansys[i, :, 1], |
| 114 | + label="isotropic error y", |
| 115 | + color="C4", |
| 116 | + linestyle="--", |
| 117 | + ) |
| 118 | + ax2.plot( |
| 119 | + isotropic_results_magpylib[i, :, 2] - isotropic_results_ansys[i, :, 2], |
| 120 | + label="isotropic error z", |
| 121 | + color="C4", |
| 122 | + linestyle="-.", |
| 123 | + ) |
| 124 | + ax2.plot( |
| 125 | + anisotropic_results_magpylib[i, :, 0] - anisotropic_results_ansys[i, :, 0], |
| 126 | + label="anisotropic error x", |
| 127 | + color="C5", |
| 128 | + linestyle="-", |
| 129 | + ) |
| 130 | + ax2.plot( |
| 131 | + anisotropic_results_magpylib[i, :, 1] - anisotropic_results_ansys[i, :, 1], |
| 132 | + label="anisotropic error y", |
| 133 | + color="C5", |
| 134 | + linestyle="--", |
| 135 | + ) |
| 136 | + ax2.plot( |
| 137 | + anisotropic_results_magpylib[i, :, 2] - anisotropic_results_ansys[i, :, 2], |
| 138 | + label="anisotropic error z", |
| 139 | + color="C5", |
| 140 | + linestyle="-.", |
| 141 | + ) |
| 142 | + ax2.set_xlabel("point along avaluation line") |
| 143 | + ax2.set_ylabel("field components difference [T]") |
| 144 | + ax2.grid() |
56 | 145 | ax2.legend() |
57 | | - fig.suptitle('evaluation line %d' % i) |
| 146 | + fig.suptitle("evaluation line %d" % i) |
58 | 147 | plt.show() |
59 | 148 |
|
60 | 149 |
|
61 | 150 | for i in range(6): |
62 | 151 | fig, (ax1, ax2) = plt.subplots(1, 2) |
63 | | - print('evaluation line ', i) |
64 | | - ax1.plot(isotropic_results_ansys_abs[i,:], label='isotropic_results', color='C0') |
65 | | - ax1.plot(isotropic_results_magpylib_abs[i,:], label='isotropic_results_magpylib', color='C1') |
66 | | - ax1.plot(anisotropic_results_ansys_abs[i,:], label='anisotropic_results', color='C2') |
67 | | - ax1.plot(anisotropic_results_magpylib_abs[i,:], label='anisotropic_results_magpylib', color='C3') |
68 | | - ax1.set_xlabel('point along avaluation line') |
69 | | - ax1.set_ylabel('field amplitude [T]') |
| 152 | + print("evaluation line ", i) |
| 153 | + ax1.plot(isotropic_results_ansys_abs[i, :], label="isotropic_results", color="C0") |
| 154 | + ax1.plot( |
| 155 | + isotropic_results_magpylib_abs[i, :], |
| 156 | + label="isotropic_results_magpylib", |
| 157 | + color="C1", |
| 158 | + ) |
| 159 | + ax1.plot( |
| 160 | + anisotropic_results_ansys_abs[i, :], label="anisotropic_results", color="C2" |
| 161 | + ) |
| 162 | + ax1.plot( |
| 163 | + anisotropic_results_magpylib_abs[i, :], |
| 164 | + label="anisotropic_results_magpylib", |
| 165 | + color="C3", |
| 166 | + ) |
| 167 | + ax1.set_xlabel("point along avaluation line") |
| 168 | + ax1.set_ylabel("field amplitude [T]") |
70 | 169 | ax1.grid() |
71 | 170 | ax1.legend() |
72 | 171 |
|
73 | | - ax2.plot((isotropic_results_magpylib_abs[i,:]-isotropic_results_ansys_abs[i,:])/isotropic_results_ansys_abs[i,:]*100, label='isotropic_results_magpylib', color='C4') |
74 | | - ax2.plot((anisotropic_results_magpylib_abs[i,:]-anisotropic_results_ansys_abs[i,:])/anisotropic_results_ansys_abs[i,:]*100, label='anisotropic_results_magpylib', color='C5') |
75 | | - ax2.set_xlabel('point along avaluation line') |
76 | | - ax2.set_ylabel('field amplitude difference [%]') |
| 172 | + ax2.plot( |
| 173 | + (isotropic_results_magpylib_abs[i, :] - isotropic_results_ansys_abs[i, :]) |
| 174 | + / isotropic_results_ansys_abs[i, :] |
| 175 | + * 100, |
| 176 | + label="isotropic_results_magpylib", |
| 177 | + color="C4", |
| 178 | + ) |
| 179 | + ax2.plot( |
| 180 | + (anisotropic_results_magpylib_abs[i, :] - anisotropic_results_ansys_abs[i, :]) |
| 181 | + / anisotropic_results_ansys_abs[i, :] |
| 182 | + * 100, |
| 183 | + label="anisotropic_results_magpylib", |
| 184 | + color="C5", |
| 185 | + ) |
| 186 | + ax2.set_xlabel("point along avaluation line") |
| 187 | + ax2.set_ylabel("field amplitude difference [%]") |
77 | 188 | ax2.grid() |
78 | 189 | ax2.legend() |
79 | | - fig.suptitle('evaluation line %d' % i) |
| 190 | + fig.suptitle("evaluation line %d" % i) |
80 | 191 | plt.show() |
81 | | - |
82 | | - |
|
0 commit comments