Beispiel #1
0
    def __init__(self,
                 cutoff: float,
                 l_max: int = 8,
                 n_max: int = 8,
                 atom_sigma: float = 0.5,
                 feature_batch: str = 'pandas_concat',
                 **kwargs):
        """

        Args:
            cutoff (float): Cutoff radius.
            l_max (int): The band limit of spherical harmonics basis function.
                Default to 8.
            n_max (int): The number of radial basis function. Default to 8.
            atom_sigma (float): The width of gaussian atomic density. Default to 0.5.
            feature_batch (str): way to batch together a list of features
            **kwargs: keyword args to specify memory, verbose, and n_jobs
        """
        from maml.apps.pes import GAPotential
        self.operator = GAPotential()
        self.cutoff = cutoff
        self.l_max = l_max
        self.n_max = n_max
        self.atom_sigma = atom_sigma
        super().__init__(feature_batch=feature_batch, **kwargs)
Beispiel #2
0
def fit_gap(atoms: List[Atoms],
            energies: List[float],
            forces: Optional[np.ndarray] = None,
            **kwargs) -> Potential:
    """Fit a GAP potential using MAL and return a ready-to-use QUIPPy object
    
    Args:
        atoms: List of molecules to use for training
        energies: List of energies for each structure
        forces: If available, forces acting on each atom
        output_dir: Directory in which to store potential
        kwargs: Passed to the :meth:`GAPotential.train` method
    Returns:
        ase Potential object instantiated with a model fit to the data
    """

    # Convert all of the structures to periodic
    atoms = [make_periodic(a.copy()) for a in atoms]

    # Conver them to PyMatgen objects
    conv = AseAtomsAdaptor()
    strcs = [conv.get_structure(a) for a in atoms]

    # Fit using maml
    gap = GAPotential()
    gap.train(strcs, energies, forces, **kwargs)

    # Save to disk and return the QUIPy object
    gap.write_param()
    return Potential(param_filename="gap.xml")
Beispiel #3
0
 def setUp(self):
     self.potential = GAPotential(name="test")
     self.test_pool = test_datapool
     self.test_structures = []
     self.test_energies = []
     self.test_forces = []
     self.test_stresses = []
     for d in self.test_pool:
         self.test_structures.append(d["structure"])
         self.test_energies.append(d["outputs"]["energy"])
         self.test_forces.append(d["outputs"]["forces"])
         self.test_stresses.append(d["outputs"]["virial_stress"])
     self.test_struct = d["structure"]
Beispiel #4
0
 def setUp(self):
     self.potential = GAPotential(name='test')
     self.test_pool = test_datapool
     self.test_structures = []
     self.test_energies = []
     self.test_forces = []
     self.test_stresses = []
     for d in self.test_pool:
         self.test_structures.append(d['structure'])
         self.test_energies.append(d['outputs']['energy'])
         self.test_forces.append(d['outputs']['forces'])
         self.test_stresses.append(d['outputs']['virial_stress'])
     self.test_struct = d['structure']