Skip to content
Snippets Groups Projects
material_test.py 2.70 KiB
import math
from python_matrix_operations import *
import ctypes
import os
import sys
#---------------------------------------------------------------

#To indicate phases return either : 1 / 2 / 3

#--- define indicator function
def indicatorFunction(x):
    theta=0.25
    factor=1
    if (x[0] <-0.5+theta and x[2]<-0.5+theta):
        return 1    #Phase1
    elif (x[1]<-0.5+theta and x[2]>0.5-theta):
        return 2    #Phase2
    else :
        return 0    #Phase3


########### Options for material phases: #################################
#     1. "isotropic"     2. "orthotropic"      3. "transversely_isotropic"   4. "general_anisotropic"
#########################################################################
## Notation - Parameter input :
# isotropic (Lame parameters) : [mu , lambda]
#         orthotropic         : [E1,E2,E3,G12,G23,G31,nu12,nu13,nu23]
# transversely_isotropic      : [E1,E2,G12,nu12,nu23]
# general_anisotropic         : full compliance matrix C
######################################################################

# --- Number of material phases
Phases=3


#--- Define different material phases:

#- PHASE 1
phase1_type="isotropic"
materialParameters_phase1 = [80, 80]

# phase1_type="orthotropic"
# materialParameters_phase1 = [11.2e3,630,1190,700,230,960,0.63 ,0.49,0.37]    # walnut parameters (values for compliance matrix)
# # materialParameters_phase1 = [10.7e3,430,710,620,23,500, 0.51 ,0.38,0.31]   # Norway spruce parameters (values for compliance matrix)

#- PHASE 2
# phase2_type="transversely_isotropic"
# materialParameters_phase2 = [11.2e3,1190,960,0.63 ,0.37]

phase2_type="isotropic"
materialParameters_phase2 = [80, 80]

#- PHASE 3
phase3_type="isotropic"
materialParameters_phase3 = [60, 25]

#--- for general anisotopic material the compliance matrix is required:
# phase3_type="general_anisotropic"
# materialParameters_phase3 = np.array([[1.0,     0.0,     0.0,   0.0 ,         0.0,   0.0],
#                                       [0.0,     1.0,     0.0,   0.0 ,         0.0,   0.0],
#                                       [0.0,     0.0,     1.0,   0.0 ,         0.0,   0.0],
#                                       [0.0,     0.0,     0.0,   math.sqrt(2), 0.0,   0.0],
#                                       [0.0,     0.0,     0.0,   0.0 ,         1.0,   0.0],
#                                       [0.0,     0.0,     0.0,   0.0 ,         0.0,   1.0]])


#--- define prestrain function for each phase
# (also works with non-constant values)
def prestrain_phase1(x):
    return [[1, 0, 0], [0,1,0], [0,0,1]]

def prestrain_phase2(x):
    return [[1, 0, 0], [0,1,0], [0,0,1]]

def prestrain_phase3(x):
    return [[0, 0, 0], [0,0,0], [0,0,0]]
    # return [[x[0],0 ,0 ], [0,0,x[1]], [0,0,x[2]]]