def send_forces(self) -> np.ndarray: """Send the nuclear forces through MDI Returns ------- forces : np.ndarray Forces on the nuclei """ # Ensure that the molecule currently passes validation if not self.molecule_validated: raise Exception( "MDI attempting to compute gradients on an unvalidated molecule" ) input = qcel.models.AtomicInput(molecule=self.molecule, driver="gradient", model=self.model, keywords=self.keywords) self.compute_return = compute(input_data=input, program=self.program, raise_error=self.raise_error, local_options=self.local_options) forces = self.compute_return.return_result MDI_Send(forces, len(forces), MDI_DOUBLE, self.comm) return forces
def send_energy(self): """ Send the total energy through MDI :returns: *energy* Energy of the system """ self.run_scf() MDI_Send(self.energy, 1, MDI_DOUBLE, self.comm) return self.energy
def send_dimensions(self): """ Send the dimensionality of the system through MDI :returns: *dimensions* Dimensionality of the system """ dimensions = [1, 1, 1] MDI_Send(dimensions, 3, MDI_INT, self.comm) return dimensions
def send_total_charge(self): """ Send the total system charge through MDI :returns: *charge* Total charge of the system """ charge = self.molecule.molecular_charge() MDI_Send(charge, 1, MDI_DOUBLE, self.comm) return charge
def send_multiplicity(self): """ Send the electronic multiplicity through MDI :returns: *multiplicity* Multiplicity of the system """ multiplicity = self.molecule.multiplicity() MDI_Send(multiplicity, 1, MDI_INT, self.comm) return multiplicity
def send_elements(self): """ Send the atomic number of each nucleus through MDI :returns: *elements* Element of each atom """ natom = self.molecule.natom() elements = [self.molecule.true_atomic_number(iatom) for iatom in range(natom)] MDI_Send(elements, natom, MDI_INT, self.comm) return elements
def send_forces(self): """ Send the nuclear forces through MDI :returns: *forces* Atomic forces """ force_matrix = psi4.driver.gradient(self.scf_method, **self.kwargs) forces = force_matrix.np.ravel() MDI_Send(forces, len(forces), MDI_DOUBLE, self.comm) return forces
def send_charges(self): """ Send the nuclear charges through MDI :returns: *charges* Atomic charges """ natom = self.molecule.natom() charges = [self.molecule.charge(iatom) for iatom in range(natom)] MDI_Send(charges, natom, MDI_DOUBLE, self.comm) return charges
def send_masses(self): """ Send the nuclear masses through MDI :returns: *masses* Atomic masses """ natom = self.molecule.natom() molecule_dict = self.molecule.to_dict() masses = molecule_dict['mass'] MDI_Send(masses, natom, MDI_DOUBLE, self.comm) return masses
def send_total_charge(self) -> float: """Send the total system charge through MDI Returns ------- charge : float Total charge of the system """ charge = self.molecule.molecular_charge MDI_Send(charge, 1, MDI_DOUBLE, self.comm) return charge
def send_natoms(self) -> int: """Send the number of atoms through MDI Returns ------- natom : int Number of atoms """ natom = len(self.molecule.geometry) MDI_Send(natom, 1, MDI_INT, self.comm) return natom
def send_node(self) -> str: """Send the name of the current node through MDI Returns ------- node : str Name of the current node """ node = self.current_node MDI_Send(node, MDI_COMMAND_LENGTH, MDI_CHAR, self.comm) return node
def send_multiplicity(self) -> int: """Send the electronic multiplicity through MDI Returns ------- multiplicity : int Multiplicity of the system """ multiplicity = self.molecule.molecular_multiplicity MDI_Send(multiplicity, 1, MDI_INT, self.comm) return multiplicity
def send_ncommands(self) -> int: """ Send the number of supported MDI commands through MDI Returns ------- ncommands : int Number of supported commands """ ncommands = len(self.commands) MDI_Send(ncommands, 1, MDI_INT, self.comm) return ncommands
def send_masses(self) -> np.ndarray: """Send the nuclear masses through MDI Returns ------- masses : np.ndarray Atomic masses """ natom = len(self.molecule.geometry) masses = self.molecule.masses MDI_Send(masses, natom, MDI_DOUBLE, self.comm) return masses
def send_coords(self) -> np.ndarray: """Send the nuclear coordinates through MDI Returns ------- coords : np.ndarray Nuclear coordinates """ natom = len(self.molecule.geometry) coords = np.reshape(self.molecule.geometry, (3 * natom)) MDI_Send(coords, 3 * natom, MDI_DOUBLE, self.comm) return coords
def send_elements(self): """Send the atomic number of each nucleus through MDI Returns ------- elements : :obj:`list` of :obj:`int` Element of each atom """ natom = len(self.molecule.geometry) elements = [ qcel.periodictable.to_atomic_number(self.molecule.symbols[iatom]) for iatom in range(natom) ] MDI_Send(elements, natom, MDI_INT, self.comm) return elements
def send_energy(self) -> float: """Send the total energy through MDI Returns ------- energy : float Energy of the system """ # Ensure that the molecule currently passes validation if not self.molecule_validated: raise Exception( "MDI attempting to compute energy on an unvalidated molecule") self.run_energy() energy = self.compute_return.return_result MDI_Send(energy, 1, MDI_DOUBLE, self.comm) return energy
def send_commands(self) -> str: """ Send the supported MDI commands through MDI Returns ------- command_string : str String containing the name of each supported command """ command_string = "".join( [f"{c:{MDI_COMMAND_LENGTH}}" for c in self.commands.keys()]) # confirm that command_string is the correct length if len(command_string) != len(self.commands) * MDI_COMMAND_LENGTH: raise Exception( "Programming error: MDI command_string is incorrect length") MDI_Send(command_string, len(command_string), MDI_CHAR, self.comm) return command_string
def send_natoms(self): """ Send the number of atoms through MDI """ natom = self.molecule.natom() MDI_Send(natom, 1, MDI_INT, self.comm) return natom
def send_coords(self): """ Send the nuclear coordinates through MDI """ coords = self.molecule.geometry().np.ravel() MDI_Send(coords, len(coords), MDI_DOUBLE, self.comm) return coords