Example #1
0
    def Evaluate(self, mechTest, stretchBound):
        # Evaluate
        # print('W = ', self._W)
        # print('dW = ', self._dW)
        l = self.DefineFunctionsInStretches(mechTest)
        # print('W(uniaxial) = ', self._W)
        # print('dW(uniaxial) = ', self._dW)

        self.stretches = np.linspace(stretchBound[0], stretchBound[1], s)

        self.W_v, self.dW_v, self.H_v, self.sigma_v = Evaluate.Functions(l, self.stretches, self._W, self._dW, self._H, self._sigma)
        value = Evaluate.SinglePoint(self._W, l, 5.0)

        P, dWoffset = [], 0.
        P, dWoffset = Postulates.verify(l, self.stretches, self._W, self._dW, self._H, self._sigma)
        print(P)
        print(dWoffset)

        return self.stretches, self.W_v, self.dW_v, self.H_v, self.sigma_v, P, dWoffset
    def Evaluate(self, mechTest, stretchBound):
        ''' All '''
        self._W = self.W
        self._dW = self.dW
        self._H = self.H
        self._sigma = self.sigma

        l, l_l1, l_l2, l_l3 = MechanicalTests.Uniaxial()
        self.Substitute(self.mu, self._muC)
        self.Substitute(self.alpha, self._alphaC)
        self.Substitute(self.l1, l_l1)
        self.Substitute(self.l2, l_l2)
        self.Substitute(self.l3, l_l3)

        self.stretches = np.linspace(stretchBound[0], stretchBound[1], s)
        self.W_v, self.dW_v, self.H_v, self.sigma_v = Evaluate.Functions(l, self.stretches, self._W, self._dW, self._H, self._sigma)

        ''' Compression '''
        self._W = self.W
        self._dW = self.dW
        self._H = self.H
        self._sigma = self.sigma

        l, l_l1, l_l2, l_l3 = MechanicalTests.Uniaxial()
        self.Substitute(self.mu, self._muC)
        self.Substitute(self.alpha, self._alphaC)
        self.Substitute(self.l1, l_l1)
        self.Substitute(self.l2, l_l2)
        self.Substitute(self.l3, l_l3)

        stretchesC = np.linspace(stretchBound[0], 1.0, s/2)
        # W_vC, dW_vC, H_vC, sigma_vC = Evaluate.Functions(l, stretchesC, self._W, self._dW, self._H, self._sigma)
        f_W = lambdify(l, self._W, "numpy")
        W_vC = f_W(stretchesC)
        # print("stretchesC",stretchesC.shape)
        # print("W_vC",W_vC.shape)

        ''' Tension '''
        self._W = self.W
        self._dW = self.dW
        self._H = self.H
        self._sigma = self.sigma

        l, l_l1, l_l2, l_l3 = MechanicalTests.Uniaxial()
        self.Substitute(self.mu, self._muT)
        self.Substitute(self.alpha, self._alphaT)
        self.Substitute(self.l1, l_l1)
        self.Substitute(self.l2, l_l2)
        self.Substitute(self.l3, l_l3)

        stretchesT = np.linspace(1.0, stretchBound[1], s / 2)
        # W_vT, dW_vT, H_vT, sigma_vT = Evaluate.Functions(l, stretchesT, self._W, self._dW, self._H, self._sigma)
        f_W = lambdify(l, self._W, "numpy")
        W_vT = f_W(stretchesT)
        # print("stretchesT",stretchesT.shape)
        # print("W_vT",W_vT.shape)

        # TODO Postulates (CORRECT since these is a combined tension compression test)
        P, dWoffset = Postulates.verify(l, self.stretches, self._W, self._dW, self._H, self._sigma)

        ''' Join tests (W and stretches for now) '''
        self.stretches = np.append(stretchesC, stretchesT)
        self.W_v = np.append(W_vC, W_vT)
        # print("stretches", self.stretches.shape)
        # print("W_v", self.W_v.shape)

        return self.stretches, self.W_v, self.dW_v, self.H_v, self.sigma_v, P, dWoffset
Example #3
0
def verify(l, _lambdas, _W, _dW, _H, _sigma):
    ''' postulates '''
    P1 = False
    P2 = False
    P3 = False
    P4 = False
    P5 = False
    P6 = False
    ''' Resting state '''
    print('Postulates @ Resting state:')
    # W is zero
    v = Evaluate.SinglePoint(_W, l, 1.0)
    print(v)
    if round(v, 4) == 0.0:
        P1 = True
    print('     W(1)={:.20f} is zero [{}]'.format(v, P1))

    # dW is zero
    v0 = Evaluate.SinglePoint(_dW[0], l, 1.0)
    v1 = Evaluate.SinglePoint(_dW[1], l, 1.0)
    v2 = Evaluate.SinglePoint(_dW[2], l, 1.0)
    dWoffset = -v0
    print(v0)
    print(v1)
    print(v2)
    if round(v0, 4) == 0.0 and round(v1, 4) == 0.0 and round(v2, 4) == 0.0:
        P2 = True
    print('     dW(1)=[{:.4f},{:.4f},{:.4f}] is zero [{}]'.format(
        v0, v1, v2, P2))

    # diag(H) > 0
    v0 = Evaluate.SinglePoint(_H[0, 0], l, 1.0)
    v1 = Evaluate.SinglePoint(_H[1, 1], l, 1.0)
    v2 = Evaluate.SinglePoint(_H[2, 2], l, 1.0)
    if v0 > 0.0 and v1 > 0.0 and v2 > 0.0:
        P3 = True
    print('     diag(H)=[{:.4f},{:.4f},{:.4f}] is > 0 [{}]'.format(
        v0, v1, v2, P3))

    # det(H) > 0
    H1 = np.zeros((3, 3))
    for i in range(3):
        for j in range(3):
            H1[i, j] = Evaluate.SinglePoint(_H[i, j], l, 1.0)
    v = np.linalg.det(H1)
    if v > 0.0:
        P4 = True
    print('     det(H)={:.4f} is > 0 [{}]'.format(v, P4))
    ''' Deforming state '''
    print('Postulates @ Deforming state:')
    # W is non-negative
    W_v, dW_v, H_v, sigma_v = Evaluate.Functions(l, _lambdas, _W, _dW, _H,
                                                 _sigma)
    P5 = not any(v < 0 for v in W_v)
    print('     W is non-negative [{}]'.format(P5))

    # dW is monotonicly increasing
    P6 = monotonic_increasing(dW_v[0])
    print('     dW is monotonic increasing [{}]'.format(P6))
    # print(_dW[0])
    # axis = plt.subplot(121)
    # plt.plot(_lambdas, W_v)
    # axis.set_xlim([0, 5])
    # axis.set_ylim([0, 4e7])
    # axis = plt.subplot(122)
    # plt.plot(_lambdas, dW_v[0]-dWoffset)
    # axis.set_xlim([-5, 5])
    # axis.set_ylim([-2e7, 2e7])
    # plt.show()
    # print(_lambdas)
    # print(W_v)
    # print(dW_v[0])
    # input('break')

    P = np.asarray([P1, P2, P3, P4, P5, P6])
    return P, dWoffset