parameters: (self, reaction_function)
return_statement: return M
docstring: creates the mass matrix in matrix diagonal ordered form
docstring_summary: creates the mass matrix in matrix diagonal ordered form
docstring_tokens: creates the mass matrix in matrix diagonal ordered form
function: def mass_matrix(self, reaction_function):
          '''creates the mass matrix in matrix diagonal ordered form'''
          M = np.zeros((3,len(self.grid)))
          fun_qp = reaction_function(self.qp)
          if np.isscalar(fun_qp): fun_qp *= np.ones_like(self.qp)
          w = 1/2
          x1 = (1-1/np.sqrt(3))/2
          x2 = (1+1/np.sqrt(3))/2
          coeff_element_0 = (fun_qp[0,:]*(x1**2) + fun_qp[1,:]*(x2**2)) * self.grid.h * w
          coeff_element_1 = (fun_qp[0,:]*(x1*(1-x1)) + fun_qp[1,:]*(x2*(1-x2))) * self.grid.h * w
          M[0,1:]  = coeff_element_1
          M[1,:-1] = coeff_element_0
          M[1,1:] += coeff_element_0
          M[2,:-1] = M[0,1:]
          return M
function_tokens: def mass_matrix ( self , reaction_function ) : M = np . zeros ( ( 3 , len ( self . grid ) ) ) fun_qp = reaction_function ( self . qp ) if np . isscalar ( fun_qp ) : fun_qp *= np . ones_like ( self . qp ) w = 1 / 2 x1 = ( 1 - 1 / np . sqrt ( 3 ) ) / 2 x2 = ( 1 + 1 / np . sqrt ( 3 ) ) / 2 coeff_element_0 = ( fun_qp [ 0 , : ] * ( x1 ** 2 ) + fun_qp [ 1 , : ] * ( x2 ** 2 ) ) * self . grid . h * w coeff_element_1 = ( fun_qp [ 0 , : ] * ( x1 * ( 1 - x1 ) ) + fun_qp [ 1 , : ] * ( x2 * ( 1 - x2 ) ) ) * self . grid . h * w M [ 0 , 1 : ] = coeff_element_1 M [ 1 , : - 1 ] = coeff_element_0 M [ 1 , 1 : ] += coeff_element_0 M [ 2 , : - 1 ] = M [ 0 , 1 : ] return M