Exemplo n.º 1
0
threshold = 1e-4 # Threshold, below which ignore differences
diffs = np.zeros((fieldssmallest, 6), dtype=floattype)
for ID, name in fields.items():
    max = np.amax(np.abs(new[:fieldssmallest,ID]))
    if max < threshold:
        diffs[:,ID] = 0
        diffsum = 0
        print('Detected differences of less than {} when comparing {} field component, therefore set as zero.'.format(threshold, fields[ID]))
    else:
        diffs[:,ID] = (np.abs(new[:fieldssmallest,ID] - old[:fieldssmallest,ID]) / max) * 100
        diffsum = (np.sum(np.abs(new[:fieldssmallest,ID] - old[:fieldssmallest,ID])) / np.sum(np.abs(new[:fieldssmallest,ID]))) * 100
    print('Total differences in field component {}: {:.1f}%'.format(name, diffsum))

# Plot new
fig1, plt1 = plot_Ascan(newfile + ' versus ' + oldfile, timenew, new[:,0], new[:,2], new[:,4], new[:,1], new[:,3], new[:,5])

# Add old and set legend
for index, ax in enumerate(fig1.axes):
    if plotorder[index] in [0, 2, 4]:
        ax.plot(timeold, old[:,plotorder[index]], 'r', label='old', lw=2, ls='--')
    else:
        ax.plot(timeold, old[:,plotorder[index]], label='old', lw=2, ls='--')
    ax.set_xlim(0, timeold[-1])
    handles, existlabels = ax.get_legend_handles_labels()
    ax.legend(handles, ['Model (new code)', 'Model (old C code)'])

# Plots of differences
fig2, plt2 = plot_Ascan('Deltas: ' + newfile + ' versus ' + oldfile, timenew[:timesmallest], diffs[:,0], diffs[:,2], diffs[:,4], diffs[:,1], diffs[:,3], diffs[:,5])
[ax.set_xlim(0, timenew[timesmallest - 1]) for ax in fig2.axes]
[ax.set_ylim(0, np.ceil(np.amax(np.abs(diffs)))) for ax in fig2.axes]
# Differences
threshold = 1e-4 # Threshold, below which ignore differences
diffs = np.zeros((iterations, 6), dtype=floattype)
for ID, name in fields.items():
    max = np.amax(np.abs(analytical[:,ID]))
    if max < threshold:
        diffs[:,ID] = 0
        diffsum = 0
        print('Detected differences of less than {} when comparing {} field component, therefore set as zero.'.format(threshold, fields[ID]))
    else:
        diffs[:,ID] = (np.abs(analytical[:,ID] - model[:,ID]) / max) * 100
        diffsum = (np.sum(np.abs(analytical[:,ID] - model[:,ID])) / np.sum(np.abs(analytical[:,ID]))) * 100
    print('Total differences in field component {}: {:.1f}%'.format(name, diffsum))

# Plot model
fig1, plt1 = plot_Ascan(modelfile + ' versus analytical solution', time, model[:,0], model[:,1], model[:,2], model[:,3], model[:,4], model[:,5])

# Add analytical solution and set legend
for index, ax in enumerate(fig1.axes):
    if index in [0, 2, 4]:
        ax.plot(time, analytical[:,plotorder[index]], 'r', label='analytical', lw=2, ls='--')
    else:
        ax.plot(time, analytical[:,plotorder[index]], label='analytical', lw=2, ls='--')
    ax.set_xlim(0, time[-1])
    handles, existlabels = ax.get_legend_handles_labels()
    ax.legend(handles, ['Model', 'Analytical'])

# Plots of differences
fig2, plt2 = plot_Ascan('Deltas: ' + modelfile + ' versus analytical solution', time, diffs[:,0], diffs[:,1], diffs[:,2], diffs[:,3], diffs[:,4], diffs[:,5])
[ax.set_xlim(0, time[-1]) for ax in fig2.axes]
[ax.set_ylim(0, np.ceil(np.amax(np.abs(diffs)))) for ax in fig2.axes]
Exemplo n.º 3
0
    if max < threshold:
        diffs[:, ID] = 0
        diffsum = 0
        print(
            'Detected differences of less than {} when comparing {} field component, therefore set as zero.'
            .format(threshold, fields[ID]))
    else:
        diffs[:, ID] = (np.abs(analytical[:, ID] - model[:, ID]) / max) * 100
        diffsum = (np.sum(np.abs(analytical[:, ID] - model[:, ID])) /
                   np.sum(np.abs(analytical[:, ID]))) * 100
    print('Total differences in field component {}: {:.1f}%'.format(
        name, diffsum))

# Plot model
fig1, plt1 = plot_Ascan(modelfile + ' versus analytical solution', time,
                        model[:, 0], model[:, 1], model[:, 2], model[:, 3],
                        model[:, 4], model[:, 5])

# Add analytical solution and set legend
for index, ax in enumerate(fig1.axes):
    if index in [0, 2, 4]:
        ax.plot(time,
                analytical[:, plotorder[index]],
                'r',
                label='analytical',
                lw=2,
                ls='--')
    else:
        ax.plot(time,
                analytical[:, plotorder[index]],
                label='analytical',