Skip to content

Instantly share code, notes, and snippets.

View craabreu's full-sized avatar

Charlles Abreu craabreu

View GitHub Profile
@craabreu
craabreu / csvr.py
Last active June 10, 2023 18:01
Canonical Sampling through Velocity Rescaling in OpenMM
from typing import Union
import numpy as np
import openmm
from openmm import unit
class CSVRIntegrator(openmm.CustomIntegrator):
"""
@craabreu
craabreu / combination.py
Created November 1, 2023 12:22
Efficient, parallelization-friendly combination generator
import typing as t
import math
def combination(n: int, k: int, m: int) -> t.Generator[int, None, None]:
"""
Return the m-th combination (in lexicographic order) of the n integers from 0 to
n-1, taken k at a time.
"""
a, b, x = n, k + 1, math.comb(n, k)