def calculate_jacobian(self):
     """Compute the value for the Jacobian when the deformation gradient is updated,
     and confirm that it has a positive value.
     """
     jacobian = numpy.linalg.det(self.deformation_gradient)
     tests.deformation_gradient_physical(jacobian=jacobian)
     return jacobian
def homework1_part1():
    """Curvilinear Kinematics: Uniaxial deformation of a cylinder"""
    # Position at which to evaluate
    radius = 10
    angle = math.pi / 4

    # Constants
    lambda1 = 2
    lambda2 = 3

    # Lab frame
    lab_vector1 = numpy.array([math.cos(angle), math.sin(angle), 0])
    lab_vector2 = numpy.array([-math.sin(angle), math.cos(angle), 0])
    lab_vector3 = numpy.array([0, 0, 1])
    lab_frame = configurations.Basis(vector1=lab_vector1,
                             vector2=lab_vector2,
                             vector3=lab_vector3,
                             type=constants.LAB)

    # Reference configuration
    reference_vector1_covariant = numpy.array(lab_vector1)
    reference_vector2_covariant = numpy.array(radius * lab_vector2)
    reference_vector3_covariant = numpy.array(lab_vector3)
    reference_configuration_covariant = configurations.Basis(vector1=reference_vector1_covariant,
                                                     vector2=reference_vector2_covariant,
                                                     vector3=reference_vector3_covariant,
                                                     type=constants.COVARIANT)
    reference_vector1_contravariant = numpy.array(lab_vector1)
    reference_vector2_contravariant = numpy.array(1 / radius * lab_vector2)
    reference_vector3_contravariant = numpy.array(lab_vector3)
    reference_configuration_contravariant = configurations.Basis(vector1=reference_vector1_contravariant,
                                                         vector2=reference_vector2_contravariant,
                                                         vector3=reference_vector3_contravariant,
                                                         type=constants.CONTRAVARIANT)
    reference_configuration = configurations.ReferenceConfiguration(covariant_basis=reference_configuration_covariant,
                                                            contravariant_basis=reference_configuration_contravariant)
    # Deformed configuration
    deformed_vector1_covariant = numpy.array(lambda1 * lab_vector1)
    deformed_vector2_covariant = numpy.array(lambda1 * radius * lab_vector2)
    deformed_vector3_covariant = numpy.array(lambda2 * lab_vector3)
    deformed_configuration_covariant = configurations.Basis(vector1=deformed_vector1_covariant,
                                                    vector2=deformed_vector2_covariant,
                                                    vector3=deformed_vector3_covariant,
                                                    type=constants.COVARIANT)
    deformed_vector1_contravariant = numpy.array(1 / lambda1 * lab_vector1)
    deformed_vector2_contravariant = numpy.array(1 / (lambda1 * radius) * lab_vector2)
    deformed_vector3_contravariant = numpy.array(1 / lambda2 * lab_vector3)
    deformed_configuration_contravariant = configurations.Basis(vector1=deformed_vector1_contravariant,
                                                        vector2=deformed_vector2_contravariant,
                                                        vector3=deformed_vector3_contravariant,
                                                        type=constants.CONTRAVARIANT)
    deformed_configuration = configurations.DeformedConfiguration(covariant_basis=deformed_configuration_covariant,
                                                          contravariant_basis=deformed_configuration_contravariant)

    # Compute deformation gradient and other kinematic quantities
    deformation_gradient_matrix = kinematics.deformation_gradient(deformed_configuration_covariant,
                                                                  reference_configuration_contravariant)
    tests.deformation_gradient_physical(numpy.linalg.det(deformation_gradient_matrix))
    right_cauchy_green_deformation = kinematics.right_cauchy_green_deformation_tensor(
        deformation_gradient_matrix)
    left_cauchy_green_deformation = kinematics.left_cauchy_green_deformation_tensor(
        deformation_gradient_matrix)
    green_lagrange_strain = kinematics.green_lagrange_strain(right_cauchy_green_deformation)