Created
May 11, 2020 21:34
-
-
Save rmatsum836/08f31a7554d13ae7f1ddb9d552b6be5f to your computer and use it in GitHub Desktop.
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 mdtraj as md | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scattering.scattering import structure_factor | |
# Load trajectory with MDTraj | |
trj = md.load('sample.trr', top='sample.gro') | |
il = trj.topology.select('resid 0') | |
trj_il = trj.atom_slice(il) | |
L = trj.unitcell_lengths[0][0] | |
low_lim = (2 * np.pi) / (L / 2) | |
fig, ax = plt.subplots() | |
# Calculate structure factor | |
Q, S = structure_factor(trj, Q_range=(low_lim, 200)) | |
ax.plot(Q, S, label=f'{i} chunk size') | |
plt.legend() | |
plt.ylim((0, 4)) | |
plt.xlim((low_lim, 200)) | |
plt.savefig('structure_factor.pdf') | |
np.savetxt('emim_sq.txt', | |
np.transpose(np.vstack([Q, S])), | |
header='# Q \tS (1/nm)') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment