def quasilinear_eigenvectors_left(self, q, x, t): # TODO: needs to be implemented errors.MissingImplementation(self.class_str, "quasilinear_eigenvectors_left") g = self.gravity_constant p = swme.get_primitive_variables(q) h = p[0] u = p[1] eigenvectors = np.zeros((self.num_moments + 2, self.num_moments + 2)) if self.num_moments == 0: sqrt_gh = np.sqrt(g * h) eigenvectors[0, 0] = 0.5 * (u + sqrt_gh) / sqrt_gh eigenvectors[0, 1] = -0.5 / sqrt_gh eigenvectors[1, 0] = -0.5 * (u - sqrt_gh) / sqrt_gh eigenvectors[1, 1] = 0.5 / sqrt_gh elif self.num_moments == 1: s = p[2] ghs2 = g * h + s * s sqrt_gh_s2 = np.sqrt(ghs2) eigenvectors[0, 0] = ( 1.0 / 6.0 * (3.0 * g * h - s * s + 3.0 * sqrt_gh_s2 * u) / ghs2 ) eigenvectors[0, 1] = -0.5 / sqrt_gh_s2 eigenvectors[0, 2] = 1.0 / 3.0 * s / ghs2 eigenvectors[1, 0] = 4.0 / 3.0 * s * s / ghs2 eigenvectors[1, 1] = 0.0 eigenvectors[1, 2] = -2.0 / 3.0 * s / ghs2 eigenvectors[2, 0] = ( -1.0 / 6.0 * (3.0 * ghs2 * u - (3.0 * g * h - s * s) * sqrt_gh_s2) / np.power(ghs2, 1.5) ) eigenvectors[2, 1] = 0.5 / sqrt_gh_s2 eigenvectors[2, 2] = 1.0 / 3.0 * s / ghs2 elif self.num_moments == 2: raise errors.NotImplementedParameter( "ShallowWaterLinearizedMomentEquations.quasilinear_eigenvectors_left", "num_moments", 2, ) elif self.num_moments == 3: raise errors.NotImplementedParameter( "ShallowWaterLinearizedMomentEquations.quasilinear_eigenvectors_left", "num_moments", 3, ) return eigenvectors
def roe_averaged_states(self, left_state, right_state, x, t): errors.MissingImplementation(self.class_str, "roe_averaged_states") p_left = swme.get_primitive_variables(left_state) p_right = swme.get_primitive_variables(right_state) # roe averaged primitive variables p_avg = np.zeros(p_left.shape) # h_avg p_avg[0] = 0.5 * (p_left[0] + p_right[0]) d = np.sqrt(p_left[0]) + np.sqrt(p_right[0]) for i in range(1, self.num_moments + 2): # u_avg, s_avg, k_avg, m_avg p_avg[i] = (np.sqrt(p_left[0]) * p_left[i] + np.sqrt(p_right[0]) * p_right[i]) / d # transform back to conserved variables return swme.get_conserved_variables(p_avg)
def quasilinear_eigenvectors_right(self, q, x, t): # TODO: needs to be implemented errors.MissingImplementation(self.class_str, "quasilinear_eigenvectors_right") g = self.gravity_constant p = swme.get_primitive_variables(q) h = p[0] u = p[1] eigenvectors = np.zeros((self.num_moments + 2, self.num_moments + 2)) if self.num_moments == 0: sqrt_gh = np.sqrt(g * h) eigenvectors[0, 0] = 1.0 eigenvectors[1, 0] = u - sqrt_gh eigenvectors[0, 1] = 1.0 eigenvectors[1, 1] = u + sqrt_gh elif self.num_moments == 1: s = p[2] sqrt_gh_s2 = np.sqrt(g * h + s * s) eigenvectors[0, 0] = 1.0 eigenvectors[1, 0] = u - sqrt_gh_s2 eigenvectors[2, 0] = 2.0 * s eigenvectors[0, 1] = 1.0 eigenvectors[1, 1] = u eigenvectors[2, 1] = -0.5 * (3.0 * g * h - s * s) / s eigenvectors[0, 2] = 1.0 eigenvectors[1, 2] = u + sqrt_gh_s2 eigenvectors[2, 2] = 2.0 * s elif self.num_moments == 2: raise errors.NotImplementedParameter( "ShallowWaterLinearizedMomentEquations.quasilinear_eigenvalues_right", "num_moments", 2, ) elif self.num_moments == 3: raise errors.NotImplementedParameter( "ShallowWaterLinearizedMomentEquations.quasilinear_eigenvectors_right", "num_moments", 3, ) return eigenvectors
def do_q_jacobian_eigenvectors(self, q): # Flux Jacobian Eigenvectors are very complex for even 1 moment # Code should need eigenvectors of quasilinear matrix instead errors.MissingImplementation(self.class_str, "do_q_jacobian_eigenvectors")
def roe_averaged_states(self, left_state, right_state, x, t): raise errors.MissingImplementation("ShallowWaterMomentEquations2D", "roe_averaged_states")
def mesh_norm(self, elem_slice=None, ord=None): # norm of coefficients including element volume raise errors.MissingImplementation("DGSolution", "mesh_norm")
def quasilinear_eigenvectors_left(self, q, x, t, n): # TODO: needs to be implemented errors.MissingImplementation(self.class_str, "quasilinear_eigenvectors_left")