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