def uniform(n, y_low = 0.001, y_high = 0.1, T_low = 250, T_high = 350, p_low = 1e4, p_high = 1e5): a = int(math.sqrt(n)) b = ((n - 1) // a) + 1 p = np.linspace(p_low, p_high, n) s_low = thermo.entropy(0, thermo.bar, T_low) s_high = thermo.entropy(0, thermo.bar, T_high) y_ = np.linspace(y_low, y_high, a) s_ = np.linspace(s_low, s_high, b) y, s = np.meshgrid(y_, s_, indexing = 'ij') return problem.Problem.from_yps(y.flatten()[:n], p, s.flatten()[:n])
def make_figure2(): plt.rc('font', size = 17) plt.rc('text', usetex = True) # Values for the pathological problem y0 = 0.5 y1 = 0 T0 = 335 # temperature at 1 bar T1 = 375 # temperature at 1 bar s0 = thermo.entropy(y0, thermo.bar, T0) s1 = thermo.entropy(y1, thermo.bar, T1) print ('value of w for wet parcel', thermo.compute_w(y0)) n = 10000 p = np.linspace(4e4, 6.5e4, n) dhdp0 = np.zeros((n,)) dhdp1 = np.zeros((n,)) Tv0 = np.zeros((n,)) Tv1 = np.zeros((n,)) for i in range(n): dhdp0[i] = thermo.enthalpy_dp(y0, p[i], s0) dhdp1[i] = thermo.enthalpy_dp(y1, p[i], s1) Tv0[i] = thermo.virtual_temperature(y0, thermo.bar, s0) Tv1[i] = thermo.virtual_temperature(y1, thermo.bar, s1) plt.clf() plt.plot(dhdp1, p / 100, '-', label = 'dry parcel') plt.plot(dhdp0, p / 100, '--', label = 'wet parcel') plt.xlabel("{\\huge $\\partial_p h$} (J kg$^{-1}$ Pa$^{-1}$)") plt.ylabel("Pressure (hPa)") plt.ylim(670, 380) plt.legend(loc = 'lower right', frameon = False) ax = plt.gca() ax.tick_params(direction='out', right=False, top = False) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) plt.subplots_adjust(bottom = 0.15, left = 0.125) plt.savefig('../output/Stansifer_Fig2.png') plt.savefig('../output/Stansifer_Fig2.ps', format='ps') plt.savefig('../output/Stansifer_Fig2.eps', format='eps') plt.savefig('../output/Stansifer_Fig2.pdf', format='pdf') plt.close()
def from_ypT(y, p, T): y = array1d(y) p = array1d(p) T = array1d(T) n = len(y) s = np.zeros((n,)) for i in range(n): s[i] = thermo.entropy(y[i], p[i], T[i]) return Problem.from_yps(y, p, s)
def pathological_problem(n, set_initial = False): y0 = 0.5 y1 = 0 # T0 = 335 # temperature at 1 atm # T1 = 375 # temperature at 1 atm # s0 = thermo.entropy(y0, thermo.atm, T0) # s1 = thermo.entropy(y1, thermo.atm, T1) T0 = 335 # temperature at 1 bar T1 = 375 # temperature at 1 bar s0 = thermo.entropy(y0, thermo.bar, T0) s1 = thermo.entropy(y1, thermo.bar, T1) y = np.array(([y0] * n) + ([y1] * (9 * n))) s = np.array(([s0] * n) + ([s1] * (9 * n))) p = np.linspace(4e4, 6.5e4, 10 * n) pr = problem.Problem.from_yps(y, p, s) if set_initial: # We re-order the parcels so that it starts in the worst initial condition. pr = reorder_worst(pr) return pr
V = u.dimensions[0] * u.dimensions[1] * u.dimensions[2] * 1e-30 / 512 out = [] for i in tqdm(range(10)): data = Data() data.index_res = i data.T = T data.V = V sel = "resnum {}".format(i) t_vec, vac_trn_vec, vac_rot_vec = vac.vac(data, u, sel) fft.dos(data, t_vec, vac_trn_vec, vac_rot_vec, T) thermo.entropy(data, u, sel) out.append(data) for i, data in enumerate(out): if i == 0: freq_vec = data.freq_vec dos_trn_vec = data.dos_trn_vec dos_rot_vec = data.dos_rot_vec else: dos_trn_vec += data.dos_trn_vec dos_rot_vec += data.dos_rot_vec dos_trn_vec /= len(out) dos_rot_vec /= len(out)