()
Use SymPy to generate the 3D matrices for diffusion_stencil_3d.
Use SymPy to generate the 3D matrices for diffusion_stencil_3d.
Use SymPy to generate the 3D matrices for diffusion_stencil_3d .
def _symbolic_rotation_helper():
    """Use SymPy to generate the 3D matrices for diffusion_stencil_3d."""
    # pylint: disable=import-error,import-outside-toplevel
    from sympy import symbols, Matrix

    cpsi, spsi = symbols('cpsi, spsi')
    cth, sth = symbols('cth, sth')
    cphi, sphi = symbols('cphi, sphi')
    Rpsi = Matrix([[cpsi, spsi, 0], [-spsi, cpsi, 0], [0, 0, 1]])
    Rth = Matrix([[1, 0, 0], [0, cth, sth], [0, -sth, cth]])
    Rphi = Matrix([[cphi, sphi, 0], [-sphi, cphi, 0], [0, 0, 1]])

    Q = Rpsi * Rth * Rphi

    epsy, epsz = symbols('epsy, epsz')
    A = Matrix([[1, 0, 0], [0, epsy, 0], [0, 0, epsz]])

    D = Q * A * Q.T

    for i in range(3):
        for j in range(3):
            print(f'D[{i}, {j}] = {D[i, j]}')
def _symbolic_rotation_helper ( ) : # pylint: disable=import-error,import-outside-toplevel from sympy import symbols , Matrix cpsi , spsi = symbols ( 'cpsi, spsi' ) cth , sth = symbols ( 'cth, sth' ) cphi , sphi = symbols ( 'cphi, sphi' ) Rpsi = Matrix ( [ [ cpsi , spsi , 0 ] , [ - spsi , cpsi , 0 ] , [ 0 , 0 , 1 ] ] ) Rth = Matrix ( [ [ 1 , 0 , 0 ] , [ 0 , cth , sth ] , [ 0 , - sth , cth ] ] ) Rphi = Matrix ( [ [ cphi , sphi , 0 ] , [ - sphi , cphi , 0 ] , [ 0 , 0 , 1 ] ] ) Q = Rpsi * Rth * Rphi epsy , epsz = symbols ( 'epsy, epsz' ) A = Matrix ( [ [ 1 , 0 , 0 ] , [ 0 , epsy , 0 ] , [ 0 , 0 , epsz ] ] ) D = Q * A * Q . T for i in range ( 3 ) : for j in range ( 3 ) : print ( f'D[{i}, {j}] = {D[i, j]}' )