Skip to content

Instantly share code, notes, and snippets.

View wiederm's full-sized avatar

Marcus Wieder wiederm

View GitHub Profile
@wiederm
wiederm / torchforce.py
Last active April 27, 2024 17:40
Define a PyTorch force, add it to a openmm system object and use it for simulation. Most parts are taken directly from openmm-ml but simplified.
from openmm.app import (
StateDataReporter,
DCDReporter,
CharmmPsfFile,
Simulation,
CharmmCrdFile,
)
from openmm import (
unit,
VerletIntegrator,
@wiederm
wiederm / simulation.py
Last active April 9, 2024 07:32
Anna's waterbox
from openmm.app import (
StateDataReporter,
DCDReporter,
CharmmPsfFile,
CharmmParameterSet,
Simulation,
PDBFile,
)
from openmm import (
unit,
@wiederm
wiederm / build_waterbox.py
Created June 23, 2022 17:01
Build an openmm system from a SMILES string
# imports
import openmm as mm
from openmm.app import Simulation
from openff.evaluator.protocols import coordinates
from openff.evaluator.utils import packmol
from openff.toolkit.typing.engines.smirnoff import ForceField
from openff.units import unit
from openff.toolkit.topology import Molecule, Topology
from openmmml import MLPotential
import torchani
import torch
import timeit
def setup():
energy = model((species, coordinates)).energies
@wiederm
wiederm / memory_profiling.py
Created May 29, 2020 13:19
memory_profiling.py
import torchani
from memory_profiler import profile
import torch
@profile
def setup():
nr_of_methans = 10
nr_of_frames = 100
device = 'cpu'
model = torchani.models.ANI1ccx(periodic_table_index=True).to(device)
@wiederm
wiederm / reweighting.py
Last active March 5, 2020 16:33
BAR & FEP forward, reverse & Non-equ work values for MM to ANI in vacuum
import torchani
import torch
model = torchani.models.ANI1ccx()
import neutromeratio
import numpy as np
import mdtraj as md
import nglview
from tqdm import tqdm
import pickle
@wiederm
wiederm / atom2svg.py
Created February 13, 2020 23:11 — forked from biochem-fan/atom2svg.py
atom2svg
# atom2svg.py by @biochem_fan
# VERSION: 200213
# License: GPLv2 or later (ask me if this is inconvenient for you)
#
# LIMITATIONS:
# - This supports only a single chain. If you have more chains, shift residue IDs and merge chains.
#
# TODO:
# - Residue numbers (how to pack??)
@wiederm
wiederm / waterbox_pbc_testing.py
Last active August 28, 2019 19:28
waterbox_pbc_testing
from openmmtools.testsystems import WaterBox
import matplotlib.pyplot as plt
from simtk import unit
import numpy as np
import torchani
import torch
import time
# openmm units
distance_unit = unit.nanometer
from openmmtools.testsystems import DHFRExplicit
from openmmtools.testsystems import WaterBox
import matplotlib.pyplot as plt
from simtk import unit
import numpy as np
import torchani
import torch
import time
from simtk import unit
from openmmtools.constants import kB
from simtk import unit
import numpy as np
from tqdm import tqdm
from IPython.core.display import display, HTML
from IPython.display import SVG
from rdkit.Chem.Draw import IPythonConsole
import mdtraj as md
#from utils import *
import nglview