def find_all_path(start_node, end_node, dist):
    try:
        global __obj_data__
        global __shortest_path__
        global __total_paths__
        global __number_of_paths_to_print__
        ret_value = -1
        # if __number_of_paths_to_print__ <= 0:
        #     return -1

        if __obj_data__ is None:
            __obj_data__ = get_obj_data()
        temp_index = __obj_data__.node_name_list.index(start_node)
        __obj_data__.node_list[temp_index].is_blocked = True
        # __obj_data__.node_list[temp_index].dist = dist
        __obj_data__.graph_stack.append(__obj_data__.node_list[temp_index])
        if start_node == end_node:
            if __shortest_path__[1] == -1 or __shortest_path__[1] > dist:
                __shortest_path__[1] = dist
            __shortest_path__[3] += 1
            __number_of_paths_to_print__ -= 1
            __total_paths__ += 1
            return 2
        if dist == 0:
            __shortest_path__[0] = temp_index
        temps = __obj_data__.graph[temp_index]
        all_indexes = [idx for idx, x in enumerate(temps) if x == 1]
        for item in all_indexes:
            if not __obj_data__.node_list[item].is_blocked:
                temp_dist = find_distance(__obj_data__.node_list[temp_index],
                                         __obj_data__.node_list[item])
                dist += temp_dist
                __obj_data__.node_list[item].dist = temp_dist
                ret_value = find_all_path(__obj_data__.node_name_list[item],
                                         end_node, dist)
                if ret_value == 2 and __number_of_paths_to_print__ >= 0:
                    print("\nPath " + str(__total_paths__))
                    print_stack_paths(
                        __obj_data__.graph_stack,
                        __obj_data__.node_name_list[__shortest_path__[0]]
                    )
                    print(__obj_data__.node_name_list[__shortest_path__[0]] +
                          " ------ Overall -----> " +
                          __obj_data__.node_name_list[item] + " : " + str(dist))
                    if __shortest_path__[2] == 0 or \
                       __shortest_path__[1] < __shortest_path__[2]:
                        __shortest_path__[2] = __shortest_path__[1]
                if ret_value == 2:
                    __obj_data__.node_list[item].is_blocked = False
                    __obj_data__.graph_stack.pop()
                dist -= temp_dist
        __obj_data__.node_list[temp_index].is_blocked = False
        __obj_data__.graph_stack.pop()
        return -1
    except Exception as e:
        raise Exception("Something went wrong. " + str(e))
Exemplo n.º 2
0
def calculate_current_and_total_and_distance(index, parent_index):
    dist = 0
    try:
        global __obj_data__
        current_node = __obj_data__.node_list[index]
        dist = __obj_data__.node_list[parent_index].curr_dist + \
               find_distance(__obj_data__.node_list[parent_index],
                             current_node) + \
               current_node.estimate
    except Exception as e:
        raise Exception("Something went wrong. " + str(e))
    return dist
Exemplo n.º 3
0
def calculate_straight_line_distance(end_node):
    try:
        global __obj_data__
        end_node_details = None
        for each_node in __obj_data__.node_list:
            if each_node.name == end_node:
                end_node_details = each_node
                break
        for each_node in __obj_data__.node_list:
            each_node.estimate = find_distance(each_node, end_node_details)
    except Exception as e:
        raise Exception("Something went wrong. " + str(e))
Exemplo n.º 4
0
NE = 0  #this is the total no of electron

for i in range(len(ATOM_SYMBOL)):
    k = no_of_e(ATOM_SYMBOL[i])
    NE += k

print('Total no of electron is ' + str(NE))

#calculate the nuclear repulsion energy
E_nuc = 0.0
for i in range(NATOM):
    for j in range(0, i):
        Z_a = no_of_e(ATOM_SYMBOL[i])
        Z_b = no_of_e(ATOM_SYMBOL[j])
        R_ab = find_distance(GEOM[i], GEOM[j])
        print(R_ab)
        E_nuc += (Z_a * Z_b) / R_ab
print('Nuclear repulsion energy ' + str(E_nuc) + ' a.u.')

#basis set dimension
nbasis = 7
#Read one electron integrals
# Reads s
S = file_read_1e('s.dat', nbasis)

# read V
V = file_read_1e('v.dat', nbasis)

#read T
T = file_read_1e('t.dat', nbasis)