Exemplo n.º 1
0
def get_symmetry_le(electronic_structure,
                    data_rasci,
                    fragment_atoms=(0),
                    tol=0.1,
                    group='D2h'):
    # This only works for singlets on close shell calculations

    types = classify_diabatic_states_of_fragment(
        data_rasci['diabatization']['diabatic_states'],
        fragment_atoms,
        tol=0.1)
    functions_range = get_basis_functions_ranges_by_atoms(
        electronic_structure['basis'], atoms_range=fragment_atoms)
    coordinates_frag = np.array(
        electronic_structure['structure'].get_coordinates())[fragment_atoms]
    labels_frag = electronic_structure['structure'].get_symbols(
    )[fragment_atoms]

    inertia_moments, inertia_axis = get_inertia(
        Structure(coordinates=coordinates_frag, symbols=labels_frag))
    center_frag, normal_frag = get_plane(coordinates_frag)

    # print(np.array(inertia_axis))
    # print(inertia_moments)
    # print(inertia_axis[0])
    # print(inertia_axis[1])
    # print(inertia_axis[2])

    if 'LE' in types:
        indices = [i for i, x in enumerate(types) if x == "LE"]
        symmetry_labels = []
        for index in indices:
            print('\nLE state found at diabat {}!'.format(index + 1))

            coefficients = electronic_structure['nato_coefficients_multi'][
                index + 1]
            occupation = electronic_structure['nato_occupancies_multi'][index +
                                                                        1]
            overlap_matrix = np.array(electronic_structure['overlap'])

            functions_indices = _indices_from_ranges(functions_range)
            overlap_matrix = np.array([
                ovm[functions_indices]
                for ovm in overlap_matrix[functions_indices]
            ])

            c_alpha = np.array(coefficients['alpha'])
            oc_alpha = np.array(occupation['alpha'])

            orbitals = []
            alpha = 0
            beta = 0

            coefficients_new = {'alpha': [], 'beta': []}
            for i, (va, o) in enumerate(zip(c_alpha, oc_alpha)):
                va_frag = va[functions_indices]
                frag_dot = np.dot(va_frag, np.dot(overlap_matrix, va_frag))

                if np.abs(frag_dot - 0.5) > tol:
                    if frag_dot > 0.5:
                        orbitals.append((i, np.round(o)))

                        orbital = np.zeros(len(c_alpha))
                        for j, val in zip(functions_indices, va_frag):
                            orbital[j] = val / np.sqrt(frag_dot)

                        if np.abs(o - 1) < tol and o < 2 - tol:
                            if alpha == beta:
                                alpha += 1
                                coefficients_new['alpha'].append(list(orbital))
                            else:
                                beta += 1
                                coefficients_new['beta'].append(list(orbital))
                    else:
                        pass

            if alpha == beta:
                multiplicity = 1
            else:
                multiplicity = 3

            n_electrons = alpha + beta

            try:
                # This only works for singlets
                molsym = get_wf_symmetry(electronic_structure['structure'],
                                         electronic_structure['basis'],
                                         coefficients_new,
                                         center=center_frag,
                                         orientation=inertia_axis[0],
                                         orientation2=inertia_axis[1],
                                         group=group)

                #molsym.print_alpha_mo_IRD()
                #molsym.print_beta_mo_IRD()
                molsym.print_wf_mo_IRD()
                symmetry_labels.append(molsym.IRLab[np.argmax(molsym.wf_IRd)])
            except:
                pass

        return symmetry_labels

    return None
Exemplo n.º 2
0
# get orbital type
orbital_types = get_orbital_classification(electronic_structure,
                                           center=[0.0, 0.0, 0.0],
                                           orientation=[0.0, 0.0, 1.0])

# print results
print('  {:5} {:5} {:5}'.format('num', 'type', 'overlap'))
for i, ot in enumerate(orbital_types):
    print('{:5}:  {:5} {:5.3f}'.format(i + 1, ot[0], ot[1]))

# print(molecule.alpha_electrons, molecule.beta_electrons)

print('\nAdiabatic states\n--------------------')
print_excited_states(parsed_data['excited_states'], include_conf_rasci=True)

inertia_moments, inertia_axis = get_inertia(electronic_structure['structure'])

#print(im)
#print(ivec[0])
#print(ivec[1])
#print(ivec[2])

print('\nInertia\n----------')
print(inertia_moments)
print(np.array(inertia_axis))

print(electronic_structure['structure'])
symmetry_measures = get_state_symmetry(electronic_structure,
                                       parsed_data['excited_states'],
                                       center=[0, 0, 0],
                                       orientation=inertia_axis[0],