Skip to content

Instantly share code, notes, and snippets.

View tcmoore3's full-sized avatar

Tim Moore tcmoore3

  • University of Michigan
  • Ann Arbor
View GitHub Profile
from signac_dashboard import Dashboard
from signac_dashboard.modules import StatepointList, ImageViewer, VideoViewer
from signac_dashboard.modules import Notes
class PlotDashboard(Dashboard):
def job_sorter(self, job):
return [job.sp.pressure, job.sp.kT]
def job_title(self, job):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# how to wrap a single coordinate
x_wrapped = (x - box.mins[0]) % box.lenghts[0] + box.mins[0]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def rotacf(x, y, funlen, dstart=2):
"""Calculate the autocorrelation of a function
Params
------
forces : np.ndarray, shape=(n,)
The force timeseries acting on a molecules
timestep : float
Simulation timestep in fs
funlen : int
The desired length of the correlation function
system = hoomd.deprecated.init.create_random_polymers(
box=hoomd.data.boxdim(L=60),
polymers=[polymer1],
separation=dict(A=0.25, B=0.25), seed=52)
charges = {'A': -1, 'B': 1}
for p in system.particles:
p.charge = charges[p.type]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tcmoore3
tcmoore3 / optimize.py
Created May 22, 2017 20:51
curve fitting
# import curve fit
from scipy.optimize import curve_fit
# this is the function you want to fit to
def gauss(r, *p):
A, sigma, r0 = p
return A / (sigma * (np.pi/2)**0.5) * np.exp(-2*(r - r0)**2/sigma**2)
# p0 = initial guesstes
p0 = (np.amax(hist), (bins[-1]-bins[0])/2, bins[np.argmax(hist)])
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from numpy import pi
import mbuild as mb
cer2 = mb.load('cer2.pdb')
grid = mb.pattern.Grid2DPattern(50, 50)
leaflet, system = mb.Compound(), mb.Compound()
repeat_spacing = 6 # repeat spacing in nm
leaflet = grid.apply(cer2) # put lipids on gird points
leaflet = mb.Compound(leaflet)
for layer_num in range(4): # add 4 leaflets to the system