当前位置: 首页>>代码示例>>Python>>正文


Python pymatgen.Molecule方法代码示例

本文整理汇总了Python中pymatgen.Molecule方法的典型用法代码示例。如果您正苦于以下问题:Python pymatgen.Molecule方法的具体用法?Python pymatgen.Molecule怎么用?Python pymatgen.Molecule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymatgen的用法示例。


在下文中一共展示了pymatgen.Molecule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_bond_feature

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def create_bond_feature(self, mol, bid: int, eid: int):
        """
        Create information for a bond for a pair of atoms that are not actually bonded

        Args:
            mol (pybel.Molecule): Molecule being featurized
            bid (int): Index of atom beginning of the bond
            eid (int): Index of atom at the end of the bond
        """
        a1 = mol.OBMol.GetAtom(bid + 1)
        a2 = mol.OBMol.GetAtom(eid + 1)
        same_ring = mol.OBMol.AreInSameRing(a1, a2)
        return {"a_idx": bid,
                "b_idx": eid,
                "bond_type": 0,
                "same_ring": True if same_ring else False,
                "spatial_distance": a1.GetDistance(a2)} 
开发者ID:materialsvirtuallab,项目名称:megnet,代码行数:19,代码来源:molecule.py

示例2: _get_chiral_centers

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def _get_chiral_centers(self, mol):
        """
        Use RDKit to find the chiral centers with CIP(R/S) label

        This provides the absolute stereochemistry.  The chiral label obtained
        from pybabel and rdkit.mol.getchiraltag is relative positions of the bonds as provided

        Args:
            mol (Molecule): Molecule to asses
        Return:
            (dict): Keys are the atom index and values are the CIP label
        """
        mol_rdk = self._get_rdk_mol(mol, 'smiles')
        if mol_rdk is None:
            # Conversion to RDKit has failed
            return {}
        else:
            chiral_cc = Chem.FindMolChiralCenters(mol_rdk)
            return dict(chiral_cc) 
开发者ID:materialsvirtuallab,项目名称:megnet,代码行数:21,代码来源:molecule.py

示例3: get_pymatgen_molecule

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def get_pymatgen_molecule(self):
        """Create a Molecule instance of the pymatgen library

        .. warning:: The `pymatgen library <http://pymatgen.org>`_ is imported
            locally in this function and will raise
            an ``ImportError`` exception, if it is not installed.

        Args:
            None

        Returns:
            :class:`pymatgen.core.structure.Molecule`:
        """
        from pymatgen import Molecule
        return Molecule(self['atom'].values,
                        self.loc[:, ['x', 'y', 'z']].values) 
开发者ID:mcocdawc,项目名称:chemcoord,代码行数:18,代码来源:_cartesian_class_io.py

示例4: mol_Oh

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def mol_Oh(central, ligand, scale):
    """ 
    Return a perfect octahedra as a mg.Molecule object.

    Args:
        central: (string) Name of the central atom
        ligand: (string) Name of ligand atoms
        scale: (float) length of central-ligand distance

    Returns
        mg.Molecule object
    """
    species = [mg.Element(central)] + 6 * [mg.Element(ligand)]
    template = [[ 0., 0., 0.],
                [ 1., 0., 0.],
                [-1., 0., 0.],
                [ 0., 1., 0.],
                [ 0.,-1., 0.],
                [ 0., 0., 1.],
                [ 0., 0.,-1.]]
    coords = [[scale * xi for xi in coord] for coord in template]
    return mg.Molecule(species, coords) 
开发者ID:gVallverdu,项目名称:myScripts,代码行数:24,代码来源:distorsion.py

示例5: paramVector

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def paramVector(mol, radius = 10.):
    """ 
    Build the vector representing the site in the parameters' space.

    Args:
        * mol : mg.Molecule object of the central atom plus the ligand atoms.
              : The first atom must be the central atom
        * radius : cut off distance for neighbors of the central atoms

    Returns:
        * a numpy array. The n first distances are the central to all ligand
        distances sorted from the smallest to the largest. The m following
        distances are all ligand - ligand distances sorted from the smallest to
        the largest.
    """
    # distances central atom to ligand
    d_central = [di for n, di in mol.get_neighbors(mol[0], radius)]
    # all distances
    dm = mol.distance_matrix
    d_all = [di for line in np.triu(dm) for di in line if di > 0.]
    return np.array(sorted(d_central) + sorted(d_all)) 
开发者ID:gVallverdu,项目名称:myScripts,代码行数:23,代码来源:distorsion.py

示例6: parse_symmetry

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def parse_symmetry(pos):
    mol = Molecule(['C']*len(pos), pos)
    try:
        symbol = PointGroupAnalyzer(mol, tolerance=0.1).sch_symbol
    except:
        symbol = 'N/A'
    return symbol 
开发者ID:qzhu2017,项目名称:PyXtal,代码行数:9,代码来源:01-compare_optalg.py

示例7: get_ase_mol

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def get_ase_mol(molname):
    """convert ase molecule to pymatgen style"""
    ase_mol = molecule(molname)
    pos = ase_mol.get_positions()
    symbols = ase_mol.get_chemical_symbols()
    return(Molecule(symbols, pos)) 
开发者ID:qzhu2017,项目名称:PyXtal,代码行数:8,代码来源:from_ase_molecule.py

示例8: get_nn_info

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def get_nn_info(self, molecule: Molecule, n: int) -> List[Dict]:
        site = molecule[n]
        siw = []
        for i, s in enumerate(molecule):
            if i != n:
                siw.append({'site': s,
                            'image': None,
                            'weight': site.distance(s),
                            'site_index': i})
        return siw 
开发者ID:materialsvirtuallab,项目名称:megnet,代码行数:12,代码来源:local_env.py

示例9: setUpClass

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def setUpClass(cls):
        cls.structure = Structure.from_file(os.path.join(MODULE_DIR, 'cifs', 'BaTiO3_mp-2998_computed.cif'))
        cls.molecule = Molecule(['C', 'O', 'O'], [[0, 0, 0], [-1, 0, 0], [1, 0, 0]])
        cls.mall = MinimumDistanceNNAll(4)
        cls.aapair = AllAtomPairs() 
开发者ID:materialsvirtuallab,项目名称:megnet,代码行数:7,代码来源:test_local_env.py

示例10: test_simple_molecule_graph

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def test_simple_molecule_graph(self):
        mol = Molecule(['C', 'H', 'O'], [[0, 0, 0], [1, 0, 0], [2, 0, 0]])
        graph = SimpleMolGraph().convert(mol)
        self.assertListEqual(to_list(graph['atom']), [6, 1, 8])
        self.assertTrue(np.allclose(graph['bond'], [1, 2, 1, 1, 2, 1]))
        self.assertListEqual(to_list(graph['index1']), [0, 0, 1, 1, 2, 2])
        self.assertListEqual(to_list(graph['index2']), [1, 2, 0, 2, 0, 1]) 
开发者ID:materialsvirtuallab,项目名称:megnet,代码行数:9,代码来源:test_molecule.py

示例11: mol_from_pymatgen

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def mol_from_pymatgen(mol: Molecule):
    """
    Args:
        mol(Molecule)
    """
    mol = pybel.Molecule(BabelMolAdaptor(mol).openbabel_mol)
    mol.make3D()
    return mol 
开发者ID:materialsvirtuallab,项目名称:megnet,代码行数:10,代码来源:molecule.py

示例12: get_graphs_within_cutoff

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def get_graphs_within_cutoff(structure: StructureOrMolecule,
                             cutoff: float = 5.0,
                             numerical_tol: float = 1e-8) \
        -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
    """
    Get graph representations from structure within cutoff
    Args:
        structure (pymatgen Structure or molecule)
        cutoff (float): cutoff radius
        numerical_tol (float): numerical tolerance

    Returns:
        center_indices, neighbor_indices, images, distances
    """
    if isinstance(structure, Structure):
        lattice_matrix = np.ascontiguousarray(
            np.array(structure.lattice.matrix), dtype=float)
        pbc = np.array([1, 1, 1], dtype=int)
    elif isinstance(structure, Molecule):
        lattice_matrix = np.array(
            [[1000.0, 0., 0.],
             [0., 1000., 0.],
             [0., 0., 1000.]], dtype=float)
        pbc = np.array([0, 0, 0], dtype=int)
    else:
        raise ValueError('structure type not supported')
    r = float(cutoff)
    cart_coords = np.ascontiguousarray(
        np.array(structure.cart_coords), dtype=float)
    center_indices, neighbor_indices, images, distances = \
        find_points_in_spheres(cart_coords, cart_coords, r=r, pbc=pbc,
                               lattice=lattice_matrix, tol=numerical_tol)
    center_indices = center_indices.astype(DataType.np_int)
    neighbor_indices = neighbor_indices.astype(DataType.np_int)
    images = images.astype(DataType.np_int)
    distances = distances.astype(DataType.np_float)
    exclude_self = (center_indices != neighbor_indices) | (distances > numerical_tol)
    return center_indices[exclude_self], neighbor_indices[exclude_self], \
        images[exclude_self], distances[exclude_self] 
开发者ID:materialsvirtuallab,项目名称:megnet,代码行数:41,代码来源:data.py

示例13: setUpClass

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def setUpClass(cls):
        cls.molecule = Molecule(['C', 'O', 'O'], [[0, 0, 0], [-1, 0, 0], [1, 0, 0]])
        cls.model = MEGNetModel.from_file(os.path.join(
            CWD, '../../../mvl_models/mp-2019.4.1/formation_energy.hdf5')) 
开发者ID:materialsvirtuallab,项目名称:megnet,代码行数:6,代码来源:test_molecule_util.py

示例14: test_get_pmg_mol_from_smiles

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def test_get_pmg_mol_from_smiles(self):
        mol = get_pmg_mol_from_smiles('C')
        self.assertTrue(isinstance(mol, Molecule)) 
开发者ID:materialsvirtuallab,项目名称:megnet,代码行数:5,代码来源:test_molecule_util.py

示例15: from_pymatgen_molecule

# 需要导入模块: import pymatgen [as 别名]
# 或者: from pymatgen import Molecule [as 别名]
def from_pymatgen_molecule(cls, molecule):
        """Create an instance of the own class from a pymatgen molecule

        Args:
            molecule (:class:`pymatgen.core.structure.Molecule`):

        Returns:
            Cartesian:
        """
        new = cls(atoms=[el.value for el in molecule.species],
                  coords=molecule.cart_coords)
        return new._to_numeric() 
开发者ID:mcocdawc,项目名称:chemcoord,代码行数:14,代码来源:_cartesian_class_io.py


注:本文中的pymatgen.Molecule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。