Beispiel #1
0
def _overlap_AB_f90(atomlist1, atomlist2, valorbs1, valorbs2, SKT):
    """
    This function calls an external Fortran function that computes the matrix elements.
    Since hashes and tuples cannot be used easily in Fortran, the arguments are brought
    into a form that can be fed into the Fortran function.
    """
    atom_type_dic, spline_deg, tab_filled_SH0, tab_filled_D, \
        (S_knots, S_coefs, H_knots, H_coefs, D_knots, D_coefs) = \
                            combine_slako_tables_f90(SKT)

    # number of atoms
    Nat1 = len(atomlist1)
    Nat2 = len(atomlist2)
    # orbitals
    atom_indeces1, atom_types1, ls1, ms1 = atomlist2orbitals(
        atomlist1, valorbs1, atom_type_dic)
    atom_indeces2, atom_types2, ls2, ms2 = atomlist2orbitals(
        atomlist2, valorbs2, atom_type_dic)
    assert atom_indeces1 == atom_indeces2, "atomlist1 and atomlist2 should contain the same atoms in the same order!"
    # count valence orbitals
    Norb1 = len(ls1)
    Norb2 = len(ls2)
    # distances and direction
    pos1 = XYZ.atomlist2vector(atomlist1)
    pos1 = np.reshape(
        pos1, (Nat1, 3)).transpose()  # pos(:,i) is the 3d position of atom i
    pos2 = XYZ.atomlist2vector(atomlist2)
    pos2 = np.reshape(pos2, (Nat2, 3)).transpose()
    r, x, y, z = slako.slako.directional_cosines(pos1, pos2)
    # call Fortran function
    S = slako.slako.overlap12(atom_indeces1, atom_types1, ls1, ms1,
                              atom_indeces2, atom_types2, ls2, ms2, r, x, y, z,
                              spline_deg, tab_filled_SH0, S_knots, S_coefs)
    return S
def _DipoleMatrix_f90(atomlist1, atomlist2, valorbs, SKT, Mproximity, S):
    """
    This function calls an external Fortran function that computes the matrix elements.
    Since hashes and tuples cannot be used easily in Fortran, the arguments are brought
    into a form that can be fed into the Fortran function.
    """
    atom_type_dic, spline_deg, tab_filled_SH0, tab_filled_D, \
        (S_knots, S_coefs, H_knots, H_coefs, D_knots, D_coefs) = \
                            combine_slako_tables_f90(SKT)

    # number of atoms
    Nat1 = len(atomlist1)
    Nat2 = len(atomlist2)
    # orbitals
    atom_indeces1,atom_types1,ls1,ms1 = atomlist2orbitals(atomlist1, valorbs, atom_type_dic)
    atom_indeces2,atom_types2,ls2,ms2 = atomlist2orbitals(atomlist2, valorbs, atom_type_dic)
    assert atom_indeces1 == atom_indeces2, "atomlist1 and atomlist2 should contain the same atoms in the same order!"
    # count valence orbitals
    Norb1 = len(ls1)
    Norb2 = len(ls2)
    # distances and direction
    pos1 = XYZ.atomlist2vector(atomlist1)
    pos1 = np.reshape(pos1,(Nat1,3)).transpose()  # pos(:,i) is the 3d position of atom i
    pos2 = XYZ.atomlist2vector(atomlist2)
    pos2 = np.reshape(pos2,(Nat2,3)).transpose()
    r,x,y,z = slako.slako.directional_cosines(pos1,pos2)

    Dipole = slako.slako.dipolematrix(atom_indeces1,atom_types1,ls1,ms1,
                              atom_indeces2,atom_types2,ls2,ms2,
                              r,x,y,z,pos1,
                              Mproximity,
                              S,
                              spline_deg, tab_filled_D,
                              D_knots, D_coefs)
    # In fortran the faster indeces come first, roll axes D(xyz,mu,nu) -> D(mu,nu,xyz)
    Dipole = np.rollaxis(Dipole,0,3)
    return Dipole