def calc_omega_residual(self, q): nu = self.nu sigma_w = self.sigma_w beta_0 = self.beta_0 gamma_w = self.gamma_w y = self.y u, k, omega = get_var(q) uy = diff(self.y, u) ky = diff(self.y, k) omegay = diff(self.y, omega) omegayy = diff2(self.y, omega) if self.model == None: fac = self.beta elif self.model == "linear": fac = 1.0 + 2*y*y #fac[0] = 1.0 elif self.model == "nn": #print self.beta.shape self.nn.set_from_vector(self.beta) fac = 1.0 + self.nn.veval(self.y) #fac[0] = 1.0 #print fac.shape R = fac*gamma_w*uy**2 - beta_0*omega**2 + nu*omegayy + sigma_w*(omegay*(ky/omega - k*omegay/omega**2) + k/omega*omegayy) R[0] = -(omega[0] - 5000000*nu/0.005**2) R[-1] = 1/(y[-1] - y[-2])*(1.5*omega[-1] - 2.0*omega[-2] + 0.5*omega[-3]) return R
def calc_momentum_residual(self, q): u, R11, R12, R22, R33, omega = get_var(q) y = self.y uy = diff(y, u) uyy = diff2(y, u) R = self.nu*uyy - self.dp/self.rho R12y = diff(y, R12) R = R + R12y R[0] = -u[0] R[-1] = (1.5*u[-1] - 2.0*u[-2] + 0.5*u[-3])/(y[-1] - y[-2]) return R
def calc_momentum_residual(self, q): u, k, omega = get_var(q) y = self.y uy = diff(y, u) uyy = diff2(y, u) nut = k/(omega+1e-16) nuty = diff(y, nut) R = self.nu*uyy - self.dp/self.rho R = R + nut*uyy + nuty*uy; R[0] = -u[0] R[-1] = (1.5*u[-1] - 2.0*u[-2] + 0.5*u[-3])/(y[-1] - y[-2]) return R
def calc_k_residual(self, q): nu = self.nu sigma_k = self.sigma_k beta_s = self.beta_s y = self.y u, k, omega = get_var(q) uy = diff(self.y, u) ky = diff(self.y, k) kyy = diff2(self.y, k) omegay = diff(self.y, omega) R = k/omega*uy**2 - beta_s*k*omega + nu*kyy + sigma_k*(kyy*k/omega + ky*(ky/omega - k/omega**2*omegay)) R[0] = -k[0] R[-1] = 1/(y[-1] - y[-2])*(1.5*k[-1] - 2*k[-2] + 0.5*k[-3]) return R
def calc_omega_residual(self, q): nu = self.nu sigma_w = self.sigma_w beta_0 = self.beta_0 gamma_w = self.gamma_w y = self.y u, k, omega = get_var(q) uy = diff(self.y, u) ky = diff(self.y, k) omegay = diff(self.y, omega) omegayy = diff2(self.y, omega) R = self.beta*gamma_w*uy**2 - beta_0*omega**2 + nu*omegayy + sigma_w*(omegay*(ky/omega - k*omegay/omega**2) + k/omega*omegayy) R[0] = -(omega[0] - 5000000*nu/0.005**2) R[-1] = 1/(y[-1] - y[-2])*(1.5*omega[-1] - 2.0*omega[-2] + 0.5*omega[-3]) return R
def calc_k_residual(self, q): nu = self.nu sigma_k = self.sigma_k y = self.y u, k, tau = get_var(q) uy = diff(self.y, u) ky = diff(self.y, k) kyy = diff2(self.y, k) tauy = diff(self.y, tau) nut = self.calc_nut(q) nuty = diff(self.y, nut) R = nut*uy**2 - k/(tau + 1e-16) + kyy*(nu + nut/sigma_k) + nuty*ky/sigma_k R[0] = -k[0] R[-1] = 1/(y[-1] - y[-2])*(1.5*k[-1] - 2*k[-2] + 0.5*k[-3]) return R
def calc_R33_residual(self, q): sigma_star = 0.6 nu = self.nu y = self.y u, R11, R12, R22, R33, omega = get_var(q) R = np.zeros_like(u) R33y = diff(y, R33) R33yy = diff2(y, R33) R = -self.P33 + self.eps_hat - self.PI33 + R33yy*(self.nu + self.nut*sigma_star) + sigma_star*self.nuty*R33y R[0] = -R33[0] R[-1] = (1.5*R33[-1] - 2.0*R33[-2] + 0.5*R33[-3])/(y[-1] - y[-2]) return R
def calc_R12_residual(self, q): sigma_star = 0.6 nu = self.nu y = self.y u, R11, R12, R22, R33, omega = get_var(q) R = np.zeros_like(u) R12y = diff(y, R12) R12yy = diff2(y, R12) R = -self.P12 - self.PI12 + R12yy*(self.nu + self.nut*sigma_star) + sigma_star*self.nuty*R12y R[0] = -R12[0] R[-1] = -R12[-1] return R
def calc_omega_residual(self, q): nu = self.nu alpha = 13.0/25.0 sigma = 0.5 beta_0 = 0.0708 y = self.y u, R11, R12, R22, R33, omega = get_var(q) k = self.k nut = self.nut nuty = diff(self.y, nut) uy = diff(self.y, u) ky = diff(self.y, k) omegay = diff(self.y, omega) omegayy = diff2(self.y, omega) beta11, beta12, beta22, beta33 = get_beta(self.beta) lastterm = 1/(omega + 1e-16)*ky*omegay R = alpha*omega/(k + 1e-16)*R12*diff(y, u) - beta11*beta_0*omega**2 + omegayy*(nu + nut*sigma) + sigma*nuty*omegay + np.maximum(lastterm/8.0, 0.0) R[0] = -(omega[0] - 5000000*nu/0.005**2) R[-1] = 1/(y[-1] - y[-2])*(1.5*omega[-1] - 2.0*omega[-2] + 0.5*omega[-3]) return R
def calc_R22_residual(self, q): sigma_star = 0.6 nu = self.nu y = self.y u, R11, R12, R22, R33, omega = get_var(q) R = np.zeros_like(u) R22y = diff(y, R22) R22yy = diff2(y, R22) beta11, beta12, beta22, beta33 = get_beta(self.beta) R = -self.P22 + beta22*self.eps_hat - self.PI22 + R22yy*(self.nu + self.nut*sigma_star) + sigma_star*self.nuty*R22y R[0] = -R22[0] R[-1] = (1.5*R22[-1] - 2.0*R22[-2] + 0.5*R22[-3])/(y[-1] - y[-2]) return R
def load_solution_stressomega(dir_): try: y = np.loadtxt("%s/y" % dir_).astype(np.complex) except: y = np.loadtxt("base_solution/y").astype(np.complex) u = np.loadtxt("%s/u" % dir_).astype(np.complex) omega = np.loadtxt("%s/omega" % dir_).astype(np.complex) k = np.loadtxt("%s/k" % dir_).astype(np.complex) dudy = diff(y, u) nut = k / (omega + 1e-16) R11 = np.loadtxt("%s/R11" % dir_).astype(np.complex)[:201] R12 = np.loadtxt("%s/R12" % dir_).astype(np.complex)[:201] R22 = np.loadtxt("%s/R22" % dir_).astype(np.complex)[:201] R33 = np.loadtxt("%s/R33" % dir_).astype(np.complex)[:201] return y, u, R11, R12, R22, R33, omega
def calc_tau_residual(self, q): nu = self.nu sigma_tau2 = self.sigma_tau2 sigma_tau1 = self.sigma_tau1 Ceps1 = self.Ceps1 Ceps2 = self.Ceps2 A2 = self.A2 y = self.y u, k, tau = get_var(q) uy = diff(self.y, u) ky = diff(self.y, k) tauy = diff(self.y, tau) tauyy = diff2(self.y, tau) nut = self.calc_nut(q) nuty = diff(self.y, nut) utau = self.Retau*self.nu*2.0 yp = utau*self.y/self.nu Ret = k*tau/self.nu f2 = (1.0 - 2.0/9.0*np.exp(-Ret**2/36.0))*(1 - np.exp(-yp/A2))**2 R = (1.0 - Ceps1)*tau/(k+1e-16)*nut*uy**2 + (Ceps2*f2-1) + tauyy*(nu + nut/sigma_tau2) + tauy*nuty/sigma_tau2 - 2.0/(tau + 1e-16)*(nu + nut/sigma_tau2)*tauy**2 + 2.0/(k+1e-16)*(nu + nut/sigma_tau1)*ky*tauy R[0] = -tau[0] R[-1] = 1/(y[-1] - y[-2])*(1.5*tau[-1] - 2.0*tau[-2] + 0.5*tau[-3]) return R
def calc_prod_dest_pi(self, q): C1 = 9./5. C2 = 10./19. alpha_h = (8. + C2)/11. alpha = 13.0/25.0 sigma = 0.5 beta_0 = 0.0708 beta_star = 9.0/100.0 sigma_star = 0.6 sigma_do = 1.0/8.0 beta_0 = 0.0708 alpha_hat = (8.0 + C2)/11.0 beta_hat = (8.0*C2 - 2.0)/11.0 gamma_hat = (60.0*C2 - 4.0)/55.0 nu = self.nu y = self.y u, R11, R12, R22, R33, omega = get_var(q) P11 = 2.0*R12*diff(y, u) P12 = R22*diff(y, u) P22 = np.zeros_like(u) P33 = np.zeros_like(u) D11 = np.zeros_like(u) D12 = R11*diff(y, u) D22 = 2.0*R12*diff(y, u) D33 = np.zeros_like(u) S11 = np.zeros_like(u) S12 = 0.5*diff(y, u) S22 = np.zeros_like(u) S33 = np.zeros_like(u) k = -0.5*(R11 + R22 + R33) P_trace = 0.5*(P11 + P22 + P33) S_trace = (S11 + S22 + S33) PI11 = beta_star*C1*omega*(R11 + 2.0/3.0*k) - alpha_hat*(P11 - 2.0/3.0*P_trace) - beta_hat*(D11 - 2.0/3.0*P_trace) PI12 = beta_star*C1*omega*R12 - alpha_hat*P12 - beta_hat*D12 - gamma_hat*k*S12 PI22 = beta_star*C1*omega*(R22 + 2.0/3.0*k) - alpha_hat*(P22 - 2.0/3.0*P_trace) - beta_hat*(D22 - 2.0/3.0*P_trace) PI33 = beta_star*C1*omega*(R33 + 2.0/3.0*k) - alpha_hat*(P33 - 2.0/3.0*P_trace) - beta_hat*(D33 - 2.0/3.0*P_trace) nut = k/(omega + 1e-16) eps_hat = 2.0/3.0*beta_star*omega*k self.P11 = P11 self.P12 = P12 self.P22 = P22 self.P33 = P33 self.D11 = D11 self.D12 = D12 self.D22 = D22 self.D33 = D33 self.PI11 = PI11 self.PI12 = PI12 self.PI22 = PI22 self.PI33 = PI33 self.eps_hat = eps_hat # this might be dangerous # global scoping of something # that will be used as multiple places self.k = k self.nut = nut self.nuty = diff(y, self.nut)