Update to dispersion analysis for case where there is no waveform in a simulation.

这个提交包含在:
Craig Warren
2017-02-28 17:26:23 +00:00
父节点 51306923f2
当前提交 a22b8c4f1d
共有 2 个文件被更改,包括 45 次插入42 次删除

查看文件

@@ -165,11 +165,11 @@ def dispersion_analysis(G):
"""
# Physical phase velocity error (percentage); grid sampling density; material with maximum permittivity; maximum significant frequency
results = {'deltavp': False, 'N': False, 'material': False, 'maxfreq': []}
results = {'deltavp': False, 'N': False, 'waveform': True, 'material': False, 'maxfreq': []}
# Find maximum significant frequency
if G.waveforms:
for waveform in G.waveforms:
if waveform.type == 'sine' or waveform.type == 'contsine':
results['maxfreq'].append(4 * waveform.freq)
@@ -208,8 +208,11 @@ def dispersion_analysis(G):
freq = np.where((np.amax(power[freqmaxpower::]) - power[freqmaxpower::]) > G.highestfreqthres)[0][0] + 1
results['maxfreq'].append(freqs[freq])
# If waveform is truncated don't do any further analysis
else:
results['waveformID'] = waveform.ID
results['waveform'] = False
else:
results['waveform'] = False
if results['maxfreq']:
results['maxfreq'] = max(results['maxfreq'])

查看文件

@@ -172,8 +172,8 @@ def run_model(args, currentmodelrun, numbermodelruns, inputfile, usernamespace):
# Check to see if numerical dispersion might be a problem
results = dispersion_analysis(G)
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)
if not results['waveform']:
print(Fore.RED + "\nWARNING: Numerical dispersion analysis not carried out as either no waveform detected or waveform does not fit within specified time window and is therefore being truncated." + 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: