def get_frequency_set(qm, qu, dim): """ Returns set of unique frequencies in Fourier series Parameters ---------- qm: int Maximum number of wave frequencies in Fourier Sum representing intrinsic surface dim: float, array_like; shape=(3) XYZ dimensions of simulation cell Returns ------- q_set: float, array_like Set of unique frequencies q2_set: float, array_like Set of unique frequencies to bin coefficients to """ u_array, v_array = wave_arrays(qm) indices = wave_indices(qu, u_array, v_array) q, q2 = calculate_frequencies(u_array[indices], v_array[indices], dim) q_set = np.unique(q)[1:] q2_set = np.unique(q2)[1:] return q_set, q2_set
def xi_var(coeff, qm, qu): """Calculate average variance of surface heights Parameters ---------- coeff: float, array_like; shape=(n_frame, n_waves**2) Optimised surface coefficients qm: int Maximum number of wave frequencies in Fourier Sum representing intrinsic surface qu: int Upper limit of wave frequencies in Fourier Sum representing intrinsic surface Returns ------- calc_var: float Variance of surface heights across whole surface """ u_array, v_array = wave_arrays(qm) indices = wave_indices(qu, u_array, v_array) Psi = vcheck(u_array[indices], v_array[indices]) / 4. coeff_filter = coeff[:, :, indices] mid_point = len(indices) / 2 av_coeff = np.mean(coeff_filter[:, :, mid_point], axis=0) av_coeff_2 = np.mean(coeff_filter**2, axis=(0, 1)) * Psi calc_var = np.sum(av_coeff_2) - np.mean(av_coeff**2, axis=0) return calc_var
def dxy_dxi(x, y, coeff, qm, qu, dim): """ Function returning derivatives of intrinsic surface at position (x,y) wrt x and y Parameters ---------- x: float Coordinate in x dimension y: float Coordinate in y dimension coeff: float, array_like; shape=(n_waves**2) Optimised surface coefficients qm: int Maximum number of wave frequencies in Fourier Sum representing intrinsic surface qu: int Upper limit of wave frequencies in Fourier Sum representing intrinsic surface dim: float, array_like; shape=(3) XYZ dimensions of simulation cell Returns ------- dx_dxi: float Derivative of intrinsic surface in x dimension dy_dxi: float Derivative of intrinsic surface in y dimension """ if np.isscalar(x): u_array, v_array = wave_arrays(qm) indices = wave_indices(qu, u_array, v_array) wave_x = wave_function_array(x, u_array[indices], dim[0]) wave_y = wave_function_array(y, v_array[indices], dim[1]) wave_dx = d_wave_function_array(x, u_array[indices], dim[0]) wave_dy = d_wave_function_array(y, v_array[indices], dim[1]) dx_dxi = np.sum(wave_dx * wave_y * coeff[indices]) dy_dxi = np.sum(wave_x * wave_dy * coeff[indices]) else: dx_dxi = np.zeros(x.shape) dy_dxi = np.zeros(x.shape) for u in range(-qu, qu + 1): for v in range(-qu, qu + 1): j = (2 * qm + 1) * (u + qm) + (v + qm) wave_x = wave_function(x, u, dim[0]) wave_y = wave_function(y, v, dim[1]) wave_dx = d_wave_function(x, u, dim[0]) wave_dy = d_wave_function(y, v, dim[1]) dx_dxi += wave_dx * wave_y * coeff[j] dy_dxi += wave_x * wave_dy * coeff[j] return dx_dxi, dy_dxi
def surface_tension_coeff(coeff_2, qm, qu, dim, T): """ Returns spectrum of surface tension, corresponding to the frequencies in q2_set Parameters ---------- coeff_2: float, array_like; shape=(n_waves**2) Square of optimised surface coefficients qm: int Maximum number of wave frequencies in Fourier Sum representing intrinsic surface qu: int Upper limit of wave frequencies in Fourier Sum representing intrinsic surface dim: float, array_like; shape=(3) XYZ dimensions of simulation cell T: float Average temperature of simulation (K) Returns ------- unique_q: float, array_like Set of frequencies for power spectrum histogram av_gamma: float, array_like Surface tension histogram of Fourier series frequencies """ u_array, v_array = wave_arrays(qm) indices = wave_indices(qu, u_array, v_array) q, q2 = calculate_frequencies(u_array[indices], v_array[indices], dim) int_A = dim[0] * dim[1] * q2 * coeff_2[indices] * vcheck( u_array[indices], v_array[indices]) / 4 gamma = con.k * T * 1E23 / int_A unique_q, av_gamma = filter_frequencies(q, gamma) return unique_q, av_gamma
def power_spectrum_coeff(coeff_2, qm, qu, dim): """ Returns power spectrum of average surface coefficients, corresponding to the frequencies in q2_set Parameters ---------- coeff_2: float, array_like; shape=(n_waves**2) Square of optimised surface coefficients qm: int Maximum number of wave frequencies in Fourier Sum representing intrinsic surface qu: int Upper limit of wave frequencies in Fourier Sum representing intrinsic surface dim: float, array_like; shape=(3) XYZ dimensions of simulation cell Returns ------- unique_q: float, array_like Set of frequencies for power spectrum histogram av_fourier: float, array_like Power spectrum histogram of Fourier series coefficients """ u_array, v_array = wave_arrays(qm) indices = wave_indices(qu, u_array, v_array) q, q2 = calculate_frequencies(u_array[indices], v_array[indices], dim) fourier = coeff_2[indices] / 4 * vcheck(u_array[indices], v_array[indices]) # Remove redundant frequencies unique_q, av_fourier = filter_frequencies(q, fourier) return unique_q, av_fourier
def intrinsic_area(coeff, qm, qu, dim): """ Calculate the intrinsic surface area from coefficients at resolution qu Parameters ---------- coeff: float, array_like; shape=(n_waves**2) Optimised surface coefficients qm: int Maximum number of wave frequencies in Fourier Sum representing intrinsic surface qu: int Upper limit of wave frequencies in Fourier Sum representing intrinsic surface dim: float, array_like; shape=(3) XYZ dimensions of simulation cell Returns ------- int_A: float Relative size of intrinsic surface area, compared to cell cross section XY """ u_array, v_array = wave_arrays(qm) indices = wave_indices(qu, u_array, v_array) q2 = np.pi**2 * (u_array[indices]**2 / dim[0]**2 + v_array[indices]**2 / dim[1]**2) int_A = q2 * coeff[indices]**2 * vcheck(u_array[indices], v_array[indices]) int_A = 1 + 0.5 * np.sum(int_A) return int_A