Beispiel #1
0
 def test_normalize_adjacency_matrix(self):
     adj = np.array([
         [2., 1., 0.],
         [1., 10., 5.],
         [0., 5., 100.],
     ])
     nadj = pre.normalize_adjacency_matrix(adj)
     d_inv_sqrt = np.array([
         [3.**-.5, 0., 0.],
         [0., 16.**-.5, 0.],
         [0., 0., 105.**-.5],
     ])
     np.testing.assert_almost_equal(
         d_inv_sqrt @ adj @ d_inv_sqrt, nadj.toarray())
Beispiel #2
0
def conversion_function(fem_data, data_directory):
    adj = fem_data.calculate_adjacency_matrix_element()
    nadj = prepost.normalize_adjacency_matrix(adj)
    x_grad, y_grad, z_grad = \
        fem_data.calculate_spatial_gradient_adjacency_matrices('elemental')
    x_grad_2, y_grad_2, z_grad_2 = \
        fem_data.calculate_spatial_gradient_adjacency_matrices(
            'elemental', n_hop=2)
    global_modulus = np.mean(
        fem_data.elemental_data.get_attribute_data('modulus'), keepdims=True)

    tensor_stress = fem_data.convert_array2symmetric_matrix(
        fem_data.elemental_data.get_attribute_data('ElementalSTRESS'),
        from_engineering=False)[:, :, :, None]
    tensor_strain = fem_data.convert_array2symmetric_matrix(
        fem_data.elemental_data.get_attribute_data('ElementalSTRAIN'),
        from_engineering=True)[:, :, :, None]
    tensor_gauss_strain1 = fem_data.convert_array2symmetric_matrix(
        fem_data.elemental_data.get_attribute_data('GaussSTRAIN1'),
        from_engineering=True)[:, :, :, None]
    tensor_gauss_strain2 = fem_data.convert_array2symmetric_matrix(
        fem_data.elemental_data.get_attribute_data('GaussSTRAIN2'),
        from_engineering=True)[:, :, :, None]
    tensor_gauss_strain3 = fem_data.convert_array2symmetric_matrix(
        fem_data.elemental_data.get_attribute_data('GaussSTRAIN3'),
        from_engineering=True)[:, :, :, None]
    tensor_gauss_strain4 = fem_data.convert_array2symmetric_matrix(
        fem_data.elemental_data.get_attribute_data('GaussSTRAIN4'),
        from_engineering=True)[:, :, :, None]
    return {
        'adj': adj,
        'nadj': nadj,
        'global_modulus': global_modulus,
        'x_grad': x_grad,
        'y_grad': y_grad,
        'z_grad': z_grad,
        'x_grad_2': x_grad_2,
        'y_grad_2': y_grad_2,
        'z_grad_2': z_grad_2,
        'tensor_stress': tensor_stress,
        'tensor_strain': tensor_strain,
        'tensor_gauss_strain1': tensor_gauss_strain1,
        'tensor_gauss_strain2': tensor_gauss_strain2,
        'tensor_gauss_strain3': tensor_gauss_strain3,
        'tensor_gauss_strain4': tensor_gauss_strain4,
    }
Beispiel #3
0
def conversion_function_rotation_thermal_stress(fem_data, raw_directory=None):
    adj = fem_data.calculate_adjacency_matrix_node()
    nadj = prepost.normalize_adjacency_matrix(adj)
    nodal_grad_x, nodal_grad_y, nodal_grad_z = \
        fem_data.calculate_spatial_gradient_adjacency_matrices(
            'nodal', n_hop=2)
    nodal_hess_xx = nodal_grad_x.dot(nodal_grad_x).tocoo()
    nodal_hess_xy = nodal_grad_x.dot(nodal_grad_y).tocoo()
    nodal_hess_xz = nodal_grad_x.dot(nodal_grad_z).tocoo()
    nodal_hess_yx = nodal_grad_y.dot(nodal_grad_x).tocoo()
    nodal_hess_yy = nodal_grad_y.dot(nodal_grad_y).tocoo()
    nodal_hess_yz = nodal_grad_y.dot(nodal_grad_z).tocoo()
    nodal_hess_zx = nodal_grad_z.dot(nodal_grad_x).tocoo()
    nodal_hess_zy = nodal_grad_z.dot(nodal_grad_y).tocoo()
    nodal_hess_zz = nodal_grad_z.dot(nodal_grad_z).tocoo()

    frame_adjs = fem_data.calculate_frame_tensor_adjs(mode='nodal', n_hop=2)
    nodal_frame_xx = frame_adjs[0][0]
    nodal_frame_xy = frame_adjs[0][1]
    nodal_frame_xz = frame_adjs[0][2]
    nodal_frame_yx = frame_adjs[1][0]
    nodal_frame_yy = frame_adjs[1][1]
    nodal_frame_yz = frame_adjs[1][2]
    nodal_frame_zx = frame_adjs[2][0]
    nodal_frame_zy = frame_adjs[2][1]
    nodal_frame_zz = frame_adjs[2][2]

    filter_ = fem_data.filter_first_order_nodes()

    node = fem_data.nodes.data[filter_]
    nodal_mean_volume = fem_data.convert_elemental2nodal(
        fem_data.calculate_element_volumes(), mode='mean')
    nodal_concentrated_volume = fem_data.convert_elemental2nodal(
        fem_data.calculate_element_volumes(), mode='effective')
    initial_temperature = fem_data.nodal_data.get_attribute_data(
        'INITIAL_TEMPERATURE')[filter_]
    cnt_temperature = fem_data.nodal_data.get_attribute_data(
        'CNT_TEMPERATURE')[filter_]

    elemental_lte_array = fem_data.elemental_data.get_attribute_data(
        'linear_thermal_expansion_coefficient_full')
    nodal_lte_array = fem_data.convert_elemental2nodal(elemental_lte_array,
                                                       mode='mean')
    global_lte_array = np.mean(elemental_lte_array, axis=0, keepdims=True)

    elemental_lte_mat = fem_data.convert_array2symmetric_matrix(
        elemental_lte_array, from_engineering=True)
    nodal_lte_mat = fem_data.convert_array2symmetric_matrix(
        nodal_lte_array, from_engineering=True)
    global_lte_mat = np.mean(elemental_lte_mat, axis=0, keepdims=True)

    elemental_strain_array = fem_data.elemental_data.get_attribute_data(
        'ElementalSTRAIN')
    nodal_strain_array = fem_data.nodal_data.get_attribute_data(
        'NodalSTRAIN')[filter_]
    elemental_strain_mat = fem_data.convert_array2symmetric_matrix(
        elemental_strain_array, from_engineering=True)
    nodal_strain_mat = fem_data.convert_array2symmetric_matrix(
        nodal_strain_array, from_engineering=True)

    dict_data = {
        'nadj': nadj,
        'nodal_grad_x': nodal_grad_x,
        'nodal_grad_y': nodal_grad_y,
        'nodal_grad_z': nodal_grad_z,
        'nodal_hess_xx': nodal_hess_xx,
        'nodal_hess_xy': nodal_hess_xy,
        'nodal_hess_xz': nodal_hess_xz,
        'nodal_hess_yx': nodal_hess_yx,
        'nodal_hess_yy': nodal_hess_yy,
        'nodal_hess_yz': nodal_hess_yz,
        'nodal_hess_zx': nodal_hess_zx,
        'nodal_hess_zy': nodal_hess_zy,
        'nodal_hess_zz': nodal_hess_zz,
        'nodal_frame_xx': nodal_frame_xx,
        'nodal_frame_xy': nodal_frame_xy,
        'nodal_frame_xz': nodal_frame_xz,
        'nodal_frame_yx': nodal_frame_yx,
        'nodal_frame_yy': nodal_frame_yy,
        'nodal_frame_yz': nodal_frame_yz,
        'nodal_frame_zx': nodal_frame_zx,
        'nodal_frame_zy': nodal_frame_zy,
        'nodal_frame_zz': nodal_frame_zz,
        'node': node,
        'nodal_strain_array': nodal_strain_array,
        'elemental_strain_array': elemental_strain_array,
        'nodal_strain_mat': nodal_strain_mat[..., None],
        'elemental_strain_mat': elemental_strain_mat[..., None],
        'nodal_mean_volume': nodal_mean_volume,
        'nodal_concentrated_volume': nodal_concentrated_volume,
        'initial_temperature': initial_temperature,
        'cnt_temperature': cnt_temperature,
        'elemental_lte_array': elemental_lte_array,
        'nodal_lte_array': nodal_lte_array,
        'global_lte_array': global_lte_array,
        'elemental_lte_mat': elemental_lte_mat[..., None],
        'nodal_lte_mat': nodal_lte_mat[..., None],
        'global_lte_mat': global_lte_mat[..., None],
    }
    return dict_data
Beispiel #4
0
 def conversion_function(fem_data, raw_directory=None):
     adj = fem_data.calculate_adjacency_matrix_element()
     nadj = prepost.normalize_adjacency_matrix(adj)
     return {'adj': adj, 'nadj': nadj}