def trace(vector):
    """np.trace() only work for square matrices. To get the trace of 
    stress/strain vectors, this function must be applied.

    Parameters
    ----------
    vector: numpy.ndarray
        the stress/strain vector.

    Returns
    -------
    trace: 
        the sum of diagonal components of the stress/strain matrix.

    """
    return float(vector[0, 0] + vector[1, 0] + vector[2, 0])