Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import numpy as np 

2 

3 

4# The indices of the full stiffness matrix of (orthorhombic) interest 

5voigt_notation = [(0, 0), (1, 1), (2, 2), (1, 2), (0, 2), (0, 1)] 

6 

7 

8def full_3x3_to_voigt_6_index(i, j): 

9 if i == j: 

10 return i 

11 return 6 - i - j 

12 

13 

14def voigt_6_to_full_3x3_strain(strain_vector): 

15 """ 

16 Form a 3x3 strain matrix from a 6 component vector in Voigt notation 

17 """ 

18 e1, e2, e3, e4, e5, e6 = np.transpose(strain_vector) 

19 return np.transpose([[1.0 + e1, 0.5 * e6, 0.5 * e5], 

20 [0.5 * e6, 1.0 + e2, 0.5 * e4], 

21 [0.5 * e5, 0.5 * e4, 1.0 + e3]]) 

22 

23 

24def voigt_6_to_full_3x3_stress(stress_vector): 

25 """ 

26 Form a 3x3 stress matrix from a 6 component vector in Voigt notation 

27 """ 

28 s1, s2, s3, s4, s5, s6 = np.transpose(stress_vector) 

29 return np.transpose([[s1, s6, s5], 

30 [s6, s2, s4], 

31 [s5, s4, s3]]) 

32 

33 

34def full_3x3_to_voigt_6_strain(strain_matrix): 

35 """ 

36 Form a 6 component strain vector in Voigt notation from a 3x3 matrix 

37 """ 

38 strain_matrix = np.asarray(strain_matrix) 

39 return np.transpose([strain_matrix[..., 0, 0] - 1.0, 

40 strain_matrix[..., 1, 1] - 1.0, 

41 strain_matrix[..., 2, 2] - 1.0, 

42 strain_matrix[..., 1, 2] + strain_matrix[..., 2, 1], 

43 strain_matrix[..., 0, 2] + strain_matrix[..., 2, 0], 

44 strain_matrix[..., 0, 1] + strain_matrix[..., 1, 0]]) 

45 

46 

47def full_3x3_to_voigt_6_stress(stress_matrix): 

48 """ 

49 Form a 6 component stress vector in Voigt notation from a 3x3 matrix 

50 """ 

51 stress_matrix = np.asarray(stress_matrix) 

52 return np.transpose([stress_matrix[..., 0, 0], 

53 stress_matrix[..., 1, 1], 

54 stress_matrix[..., 2, 2], 

55 (stress_matrix[..., 1, 2] + 

56 stress_matrix[..., 1, 2]) / 2, 

57 (stress_matrix[..., 0, 2] + 

58 stress_matrix[..., 0, 2]) / 2, 

59 (stress_matrix[..., 0, 1] + 

60 stress_matrix[..., 0, 1]) / 2])