Updates to dispersion analysis function.

这个提交包含在:
Craig Warren
2017-02-22 12:27:07 +00:00
父节点 db4fdb167c
当前提交 117e6fa7fb
共有 2 个文件被更改,包括 12 次插入11 次删除

查看文件

@@ -164,15 +164,14 @@ def dispersion_analysis(G):
results (dict): Results from dispersion analysis
"""
# Physical phase velocity error (percentage); grid sampling density; material with maximum permittivity; maximum frequency of interest
results = {'deltavp': False, 'N': False, 'material': False, 'maxfreq': False}
# Physical phase velocity error (percentage); grid sampling density; material with maximum permittivity; maximum significant frequency
results = {'deltavp': False, 'N': False, 'material': False, 'maxfreq': []}
# Find maximum frequency
maxfreqs = []
# Find maximum significant frequency
for waveform in G.waveforms:
if waveform.type == 'sine' or waveform.type == 'contsine':
maxfreqs.append(4 * waveform.freq)
results['maxfreq'].append(4 * waveform.freq)
elif waveform.type == 'impulse':
pass
@@ -207,13 +206,13 @@ def dispersion_analysis(G):
# Set maximum frequency to a threshold drop from maximum power, ignoring DC value
freq = np.where((np.amax(power[freqmaxpower::]) - power[freqmaxpower::]) > G.highestfreqthres)[0][0] + 1
maxfreqs.append(freqs[freq])
results['maxfreq'].append(freqs[freq])
else:
print(Fore.RED + "\nWARNING: Duration of source waveform '{}' means it does not fit within specified time window and is therefore being truncated.".format(waveform.ID) + Style.RESET_ALL)
results['waveformID'] = waveform.ID
if maxfreqs:
results['maxfreq'] = max(maxfreqs)
if results['maxfreq']:
results['maxfreq'] = max(results['maxfreq'])
# Find minimum wavelength (material with maximum permittivity)
maxer = 0

查看文件

@@ -173,9 +173,11 @@ def run_model(args, currentmodelrun, numbermodelruns, inputfile, usernamespace):
# Check to see if numerical dispersion might be a problem
results = dispersion_analysis(G)
if results['N'] < G.mingridsampling:
if 'waveformID' in results:
print(Fore.RED + "\nWARNING: Numerical dispersion analysis not carried out as duration of waveform '{}' means it does not fit within specified time window and is therefore being truncated.".format(results['waveformID']) + Style.RESET_ALL)
elif results['N'] < G.mingridsampling:
raise GeneralError("Non-physical wave propagation: Material '{}' has wavelength sampled by {} cells, less than required minimum for physical wave propagation. Maximum significant frequency estimated as {:g}Hz".format(results['material'].ID, results['N'], results['maxfreq']))
elif results['deltavp'] and np.abs(results['deltavp']) > G.maxnumericaldisp and G.messages:
elif results['deltavp'] and np.abs(results['deltavp']) > G.maxnumericaldisp:
print(Fore.RED + "\nWARNING: Potentially significant numerical dispersion. Estimated largest physical phase-velocity error is {:.2f}% in material '{}' whose wavelength sampled by {} cells. Maximum significant frequency estimated as {:g}Hz".format(results['deltavp'], results['material'].ID, results['N'], results['maxfreq']) + Style.RESET_ALL)
elif results['deltavp'] and G.messages:
print("\nNumerical dispersion analysis: estimated largest physical phase-velocity error is {:.2f}% in material '{}' whose wavelength sampled by {} cells. Maximum significant frequency estimated as {:g}Hz".format(results['deltavp'], results['material'].ID, results['N'], results['maxfreq']))