Exemplo n.º 1
0
def test_elements_to_atomicnums(els, zs):

    Zs = loaders.elements_to_atomicnums(els)

    assert np.allclose(Zs, zs)
Exemplo n.º 2
0
def elements_to_idxs(elements, amap):
    anums = loaders.elements_to_atomicnums(list(elements))

    return [amap[anum] for anum in anums]
Exemplo n.º 3
0
                elements = selection.elements[mask]
                coordinates = selection.positions[mask]
            else:
                # Store indices of selection for later use
                # Needed to insert gradient as b-factors
                sel_idxs = selection.ix

                elements = selection.elements
                coordinates = selection.positions

            # Get species for selection
            # Apply mapping from elements to atomic number
            # Apply chemical mapping (if any)
            # Apply mapping from atomic numbers to indices
            anums = loaders.elements_to_atomicnums(elements)
            if cmap is not None:
                loaders.chemap([anums], cmap)  # Only one system
            species = loaders.anum_to_idx(anums, amap)

            G = np.zeros(len(system.atoms))

            if args.visualization.lower() == "gradient":

                gradt = gradient(
                    torch.from_numpy(species),
                    torch.from_numpy(coordinates),
                    float(label),
                    model,
                    AEVC,
                    nn.MSELoss(),