|
| 1 | +import numpy as np |
| 2 | +import matplotlib.pyplot as plt |
| 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') |
| 10 | + |
| 11 | + |
| 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 | + |
| 17 | + |
| 18 | +isotropic_results_ansys_abs = np.linalg.norm(isotropic_results_ansys, axis=-1) |
| 19 | +anisotropic_results_ansys_abs = np.linalg.norm(anisotropic_results_ansys, axis=-1) |
| 20 | +isotropic_results_magpylib_abs = np.linalg.norm(isotropic_results_magpylib, axis=-1) |
| 21 | +anisotropic_results_magpylib_abs = np.linalg.norm(anisotropic_results_magpylib, axis=-1) |
| 22 | + |
| 23 | + |
| 24 | +for i in range(6): |
| 25 | + 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]') |
| 41 | + ax1.grid() |
| 42 | + ax1.legend() |
| 43 | + |
| 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() |
| 54 | + ax2.legend() |
| 55 | + fig.suptitle('evaluation line %d' % i) |
| 56 | + plt.show() |
| 57 | + |
| 58 | + |
| 59 | +for i in range(6): |
| 60 | + 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]') |
| 68 | + ax1.grid() |
| 69 | + ax1.legend() |
| 70 | + |
| 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 [%]') |
| 75 | + ax2.grid() |
| 76 | + ax2.legend() |
| 77 | + fig.suptitle('evaluation line %d' % i) |
| 78 | + plt.show() |
| 79 | + |
| 80 | + |
0 commit comments