def uavgGrad(n_chunk,chunk_bounds,T,uavg,zeta,profile=True): ''' returns the time averaged sensitivity of the mean x-velocity profile to the mass averaged velocity. Inputs are the number of time chunks, the starting and ending step index of each chunk (chunk_bounds), total simulation time T, the time averaged mean x-velocity profile uavg, and time dilation terms zeta (length n_chunk vector) if profile = 1, sensitivity of the entire profile is compute, otherwise only the sesitivity of the centerline velocity is computed ''' if profile: grad = np.zeros(c_channel.c_qpts()) else: grad = 0.0 y, w = quad() for i in range(n_chunk): start_step = chunk_bounds[i] end_step = chunk_bounds[i+1] vavg = IvelAvg(start_step,end_step,T,profile) uEnd = (vel(end_step).mean(2)).mean(0) if not(profile): uEnd = uEnd[c_channel.c_qpts()/2 + 1] grad = grad + vavg + (1./T) * zeta[i]*(uEnd-uavg) return grad
def velAvg(start_step,end_step,T,profile=True): ''' returns the time averaged velocity profile ''' if profile: uavg = np.zeros(c_channel.c_qpts()) else: uavg = 0.0 y, w = quad() assert 0 <= start_step <= end_step <= c_channel.c_nsteps() for i in range(start_step,end_step): u = vel(i) u = (u.mean(2)).mean(0) if not(profile): u = u[c_channel.c_qpts()/2 + 1] uavg = uavg + (dt/T) * u return uavg
def IvelAvg(start_step,end_step,T,profile=True): ''' returns the time averaged mean velocity sensitivity profile ''' if profile: vavg = np.zeros(c_channel.c_qpts()) else: vavg = 0.0 y, w = quad() assert 0 <= start_step <= end_step <= c_channel.c_nsteps() for i in range(start_step,end_step): v = Ivel(i,project = False) v = (v.mean(2)).mean(0) if not(profile): v = v[c_channel.c_qpts()/2 + 1] vavg = vavg + (dt/T) * v return vavg
def spec2phys(solution): if isinstance(solution, str): solution = read_solution(solution) if isinstance(solution, int): solution = get_solution(solution, copy=False) assert solution.dtype == complex assert solution.shape == (c_channel.c_Nz(), 2, c_channel.c_dimR(), c_channel.c_Nx() / 2) flow = np.zeros([3, int(c_channel.c_Nx() * 3 / 2), c_channel.c_qpts(), int(c_channel.c_Nz() * 3 / 2)], np.float64) c_channel.c_spec2phys(solution, flow) return flow