def get_rel_LInf_errors(target_dirs): d_list = [] for outdir in target_dirs: r = ASCIIReader(outdir) __, d = r.get_time_and_detonation_velocity() d_list.append(d) errors_LInf = [float('NaN')] for i, d in enumerate(d_list): if i == 0: continue d_1 = d_list[i - 1] d_2 = d_list[i] error = linalg.norm(d_1 - d_2, np.Inf) / linalg.norm(d_2, np.Inf) errors_LInf.append(error) assert len(target_dirs) == len(errors_LInf) errors_LInf_array = np.asarray(errors_LInf) return errors_LInf_array
def get_modes_list(target_dirs): modes_list = [] for outdir in target_dirs: r = ASCIIReader(outdir) modes = r.get_stability_info() modes_list.append(modes) return modes_list
def plot_time_series(E_act): r = ASCIIReader('_output/q=050.00-e_act=0{:4.2f}/n12=0160/'.format(E_act)) t, d = r.get_time_and_detonation_velocity() plt.figure() plt.plot(t, d, '-') plt.xlabel('time') plt.ylabel(r"$\psi '$") plt.tight_layout(pad=0.1) savefig('time-series-e_act={:4.2f}.pdf'.format(E_act))
def znd_read_data(): output_dir = '_output' dirs = os.listdir(output_dir) dirs.sort() x = [] rho = [] u = [] p = [] lamda = [] for d in dirs: dirname = os.path.join(output_dir, d) r = ASCIIReader(dirname) znd_data = r.get_znd_data() x.append(znd_data['x']) rho.append((d, znd_data['rho'])) u.append((d, znd_data['u_lab'])) p.append((d, znd_data['p'])) lamda.append((d, znd_data['lamda'])) return x, rho, u, p, lamda
return outdir if __name__ == '__main__': q = 50.0 n12_list = [20, 40, 80, 160, 320, 640, 1280, 2560] tasks = [(q, n12) for n12 in n12_list] with mp.Pool(processes=12) as pool: results = pool.map(_run_solver, tasks) assert results == sorted(results) sim_results = [] for r in results: reader = ASCIIReader(r) __, d = reader.get_time_and_detonation_velocity() sim_results.append(d) for i, n12 in enumerate(n12_list[:-1]): print('*** Difference between N12={} and N12={}'.format( n12_list[i], n12_list[i + 1])) d_1 = sim_results[i] d_2 = sim_results[i + 1] print(' L2-norm of difference: {}'.format(linalg.norm(d_1 - d_2, 2))) print(' LInf-norm of difference: {}'.format( linalg.norm(d_1 - d_2, np.Inf)))
#!/usr/bin/env python import os import matplotlib.pyplot as plt from saf.euler1d.linear.asciireader import ASCIIReader from matplotlib.ticker import FormatStrFormatter from helpers import FIGSIZE_TWO_SUBPLOTS_TWO_ROWS as figsize r_35 = ASCIIReader('_output/q=050.00-e_act=035.00/n12=0640') r_40 = ASCIIReader('_output/q=050.00-e_act=040.00/n12=0640') t_35, d_35 = r_35.get_time_and_detonation_velocity() t_40, d_40 = r_40.get_time_and_detonation_velocity() fig, ax = plt.subplots(nrows=2, ncols=1, figsize=figsize) ax[0].plot(t_35, d_35, '-') ax[0].set_xlim((0, 50)) ax[0].set_ylim((-0.1, 0.85)) #ax[0].set_ylim((-1e-4, 1e-4)) ax[0].set_xlabel(r'$t$') ax[0].set_ylabel(r"$\psi '$") f_1_x = FormatStrFormatter('%6.1f') ax[0].yaxis.set_major_formatter(f_1_x) ax[0].text(0.9, 0.85, '(a)', transform=ax[0].transAxes) ax[1].plot(t_40, d_40, '-') ax[1].set_ylim((-100, 2000)) ax[1].set_ylabel(r"$\psi '$") ax[1].set_xlabel(r'$t$')