This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"path/filepath" | |
"regexp" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lineplot(x, y, length=None, width=1, connection_style="--", ax=None, **kwargs): | |
if ax is None: | |
ax = plt.gca() | |
if length is None: | |
length = length or (max(x) - min(x)) / len(x) * 0.8 | |
x, y = np.array(x), np.array(y) | |
xmin, xmax = x - length / 2, x + length / 2 | |
lines = ax.hlines(y=y, xmin=xmin, xmax=xmax, **kwargs) | |
for i in range(len(x) - 1): | |
xs, ys = [xmax[i], xmin[i + 1]], [y[i], y[i + 1]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Calculate mean square displacement (MSD) of a given element in a trajectory. | |
Use jax_md to handle PBC. | |
""" | |
from typing import List | |
import jax | |
import jax.numpy as jnp | |
import numpy as np | |
from ase import Atoms | |
from jax_md import space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
from pathlib import Path | |
import ase.io | |
import subprocess as sp | |
import numpy as np | |
from ase.calculators.singlepoint import SinglePointCalculator | |
import re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from numba import njit | |
from typing import Any, Callable, Sequence, TypeVar | |
Point_T = TypeVar("T") | |
Metric = Callable[[np.ndarray, np.ndarray], float] | |
@njit | |
def euclidean_distance(x: np.ndarray, y: np.ndarray) -> float: | |
dR = x - y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy as np | |
from ase import Atoms | |
class CubeData: | |
def __init__( | |
self, | |
atoms: Atoms, | |
origin:np.ndarray, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ase.build | |
import ase.data | |
import ase.geometry | |
import numpy as np | |
from ase import Atoms | |
def compute_radius(atoms: Atoms): | |
"""Compute the radius of an atom, assuming sphere.""" | |
positions = atoms.get_positions() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from ase import units | |
from numba import njit | |
@njit(fastmath=True) | |
def log_fermi(positions, radius, temperature, beta): | |
eps = 1e-9 # small number to avoid instability | |
dists = np.sqrt(np.sum(positions * positions, axis=1)) | |
exp_term = np.exp(beta * (dists - radius)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Tuple | |
import torch | |
Tensor = torch.Tensor | |
def find_alignment_kabsch(P: Tensor, Q: Tensor) -> Tuple[Tensor, Tensor]: | |
"""Find alignment using Kabsch algorithm between two sets of points P and Q. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from collections.abc import Sequence | |
import ase.io | |
import ase.neighborlist | |
import numpy as np | |
import torch | |
import ase.data | |
from torch_geometric.data import Data | |
from torch_geometric.nn import radius_graph |
NewerOlder