Exemplo n.º 1
0
    def recv_multiplicity(self, multiplicity=None):
        """ Receive the electronic multiplicity through MDI

        Arguments:
            multiplicity: New multiplicity of the system. If None, receive through MDI.
        """
        if multiplicity is None:
            multiplicity = MDI_Recv(1, MDI_INT, self.comm)
        self.molecule.set_multiplicity(multiplicity)
Exemplo n.º 2
0
    def recv_total_charge(self, charge=None):
        """ Receive the total system charge through MDI

        Arguments:
            charge: New charge of the system. If None, receive through MDI.
        """
        if charge is None:
            charge = MDI_Recv(1, MDI_DOUBLE, self.comm)
        self.molecule.set_molecular_charge(int(round(charge)))
Exemplo n.º 3
0
    def recv_lattice(self, lattice=None):
        """ Receive the charges of a set of lattice point charges through MDI

        Arguments:
            lattice: New charges of the lattice of point charges. If None, receive through MDI.
        """
        if lattice is None:
            self.lattice = MDI_Recv(self.nlattice, MDI_DOUBLE, self.comm)
        else:
            self.lattice = lattice
        self.set_lattice_field()
Exemplo n.º 4
0
    def recv_coords(self, coords=None):
        """ Receive a set of nuclear coordinates through MDI and assign them to the atoms in the current molecule

        Arguments:
            coords: New nuclear coordinates. If None, receive through MDI.
        """
        natom = self.molecule.natom()
        if coords is None:
            coords = MDI_Recv(3 * natom, MDI_DOUBLE, self.comm)
        matrix = psi4.core.Matrix.from_array(np.array(coords).reshape(-1, 3))
        self.molecule.set_geometry(matrix)
Exemplo n.º 5
0
    def recv_clattice(self, clattice=None):
        """ Receive the coordinates of a set of lattice point charges through MDI

        Arguments:
            clattice: New coordinates of the lattice of point charges. If None, receive through MDI.
        """
        if clattice is None:
            self.clattice = MDI_Recv(3 * self.nlattice, MDI_DOUBLE, self.comm)
        else:
            self.clattice = clattice
        self.set_lattice_field()
Exemplo n.º 6
0
    def recv_masses(self, masses: Optional[List[float]] = None) -> None:
        """Receive a set of nuclear masses through MDI and assign them to the atoms in the current molecule

        Parameters
        ----------
        masses : :obj:`list` of :obj:`float`, optional
            New nuclear masses. If None, receive through MDI.
        """
        natom = len(self.molecule.geometry)
        if masses is None:
            masses = MDI_Recv(natom, MDI_DOUBLE, self.comm)
        self.update_molecule("masses", masses)
Exemplo n.º 7
0
    def recv_nlattice(self, nlattice=None):
        """ Receive the number of lattice point charges through MDI

        Arguments:
            nlattice: New number of point charges. If None, receive through MDI.
        """
        if nlattice is None:
            self.nlattice = MDI_Recv(1, MDI_INT, self.comm)
        else:
            self.nlattice = nlattice
        self.clattice = [0.0 for ilat in range(3 * self.nlattice)]
        self.lattice = [0.0 for ilat in range(self.nlattice)]
        self.set_lattice_field()
Exemplo n.º 8
0
    def recv_multiplicity(self, multiplicity: Optional[int] = None) -> None:
        """Receive the electronic multiplicity through MDI

        Parameters
        ----------
        multiplicity : int, optional
            New multiplicity of the system. If None, receive through MDI.
        """
        if multiplicity is None:
            multiplicity = MDI_Recv(1, MDI_INT, self.comm)
        self.multiplicity = multiplicity

        # Allow a validation error here, because a future >TOTCHARGE command might resolve it
        try:
            self.update_molecule("molecular_multiplicity", self.multiplicity)
        except qcel.exceptions.ValidationError:
            pass
Exemplo n.º 9
0
    def recv_total_charge(self, charge: Optional[float] = None) -> None:
        """Receive the total system charge through MDI

        Parameters
        ----------
        charge : float, optional
            New charge of the system. If None, receive through MDI.
        """
        if charge is None:
            charge = MDI_Recv(1, MDI_DOUBLE, self.comm)
        self.total_charge = charge

        # Allow a validation error here, because a future >ELEC_MULT command might resolve it
        try:
            self.update_molecule("molecular_charge", self.total_charge)
        except qcel.exceptions.ValidationError:
            pass
Exemplo n.º 10
0
    def recv_elements(self, elements: Optional[List[int]] = None):
        """Receive a set of atomic numbers through MDI and assign them to the atoms in the current molecule

        Parameters
        ----------
        elements : :obj:`list` of :obj:`int`, optional
            New element numbers. If None, receive through MDI.
        """
        natom = len(self.molecule.geometry)
        if elements is None:
            elements = MDI_Recv(natom, MDI_INT, self.comm)

        for iatom in range(natom):
            self.molecule.symbols[iatom] = qcel.periodictable.to_symbol(
                elements[iatom])

        return elements
Exemplo n.º 11
0
    def recv_coords(self, coords: Optional[np.ndarray] = None) -> None:
        """ Receive a set of nuclear coordinates through MDI and assign them to the atoms in the current molecule

        Parameters
        ----------
        coords : np.ndarray, optional
            New nuclear coordinates. If None, receive through MDI.
        """
        natom = len(self.molecule.geometry)
        if coords is None:
            coords = MDI_Recv(3 * natom, MDI_DOUBLE_NUMPY, self.comm)
        new_geometry = np.reshape(coords, (-1, 3))
        self.molecule = qcel.models.Molecule(**{
            **self.molecule.dict(),
            **{
                "geometry": new_geometry
            }
        })
Exemplo n.º 12
0
    def recv_masses(self, masses=None):
        """ Receive a set of nuclear masses through MDI and assign them to the atoms in the current molecule

        Arguments:
            masses: New nuclear masses. If None, receive through MDI.
        """
        natom = self.molecule.natom()
        if masses is None:
            masses = MDI_Recv(natom, MDI_DOUBLE, self.comm)

        # Assign the mass of all atoms, taking care to avoid ghost atoms
        jatom = 0
        for iatom in range(natom):
            while self.molecule.fZ(jatom) == 0 and jatom < self.molecule.nallatom():
                jatom = jatom + 1
                if jatom >= self.molecule.nallatom():
                    raise Exception('Unexpected number of ghost atoms when receiving masses')
            self.molecule.set_mass(iatom, masses[jatom])
            jatom = jatom + 1