예제 #1
0
def strain_from_stretch(u, kappa):
    """Convert the 3x3 stretch tensor to a strain tensor using the
    Seth-Hill parameter kappa and return a 9x1 array"""
    mat, orig_shape = matrix_rep(u)
    if abs(kappa) > 1e-12:
        mat = 1. / kappa * (la.powm(mat, kappa) - np.eye(3))
    else:
        mat = la.logm(mat)
    return array_rep(mat, orig_shape)
예제 #2
0
def logm(A):
    """Compute the matrix logarithm of a 3x3 matrix"""
    mat, orig_shape = matrix_rep(A)
    mat2 = la.logm(mat)
    return array_rep(mat2, orig_shape)
예제 #3
0
def test_logm_expm_consistency():
    A = random_symmetric_positive_definite_matrix()
    A = A.reshape(3, 3)
    B = la.logm(A)
    assert np.allclose(la.expm(B), A)
예제 #4
0
def test_logm():
    """Compute the matrix logarithm of a 3x3 matrix"""
    x, y, z = 1., 2., 3.
    A = np.array([[x, 0, 0], [0, y, 0], [0, 0, z]])
    log_A = np.array([[np.log(x), 0, 0], [0, np.log(y), 0], [0, 0, np.log(z)]])
    assert np.allclose(log_A, la.logm(A))
예제 #5
0
def update_deformation(farg, darg, dt, kappa):
    """Update the deformation gradient and strain

    Parameters
    ----------
    farg : ndarray
        The deformation gradient
    darg : ndarray
        The symmetric part of the velocity gradient
    dt : float
        The time increment
    kappa : int or real
        The Seth-Hill parameter

    Returns
    -------
    f : ndarray
        The updated deformation gradient
    e : ndarray
        The updated strain

    Notes
    -----
    From the value of the Seth-Hill parameter kappa, current strain E,
    deformation gradient F, and symmetric part of the velocit gradient d,
    update the strain and deformation gradient.
    Deformation gradient is given by

                 dFdt = L*F                                             (1)

    where F and L are the deformation and velocity gradients, respectively.
    The solution to (1) is

                 F = F0*exp(Lt)

    Solving incrementally,

                 Fc = Fp*exp(Lp*dt)

    where the c and p refer to the current and previous values, respectively.

    With the updated F, Fc, known, the updated stretch is found by

                 U = (trans(Fc)*Fc)**(1/2)

    Then, the updated strain is found by

                 E = 1/kappa * (U**kappa - I)

    where kappa is the Seth-Hill strain parameter.
    """
    f0 = farg.reshape((3, 3))
    d = matrix_rep(darg, 0)
    ff = np.dot(la.expm(d * dt), f0)
    u = la.sqrtm(np.dot(ff.T, ff))
    if kappa == 0:
        eps = la.logm(u)
    else:
        eps = 1.0 / kappa * (la.powm(u, kappa) - np.eye(3, 3))

    if la.det(ff) <= 0.0:
        raise Exception("negative jacobian encountered")

    f = np.reshape(ff, (9,))
    e = array_rep(eps, (6,))

    return f, e