Skip to content

Instantly share code, notes, and snippets.

View janash's full-sized avatar

Jessica A. Nash janash

View GitHub Profile
@janash
janash / .travis.yml
Created July 31, 2018 04:33
.travis.yml for msf bootcamp
language: python
# turn off sudo
sudo: false
# python versions to be tested
matrix:
include:
- python: 2.7
- python: 3.5
# .readthedocs.yml
version: 2
build:
image: latest
python:
version: 3.7
install:
"""
molecule.py
A python package for the MolSSI Software Summer School.
Contains a molecule class
"""
import numpy as np
def calculate_distance(rA, rB):
# .readthedocs.yml
version: 2
build:
image: latest
python:
version: 3.6
install:
@janash
janash / calculate_molecular_mass.py
Last active June 8, 2020 13:17
molecular mass function - homework for best practices workshop
def calculate_molecular_mass(symbols):
"""Calculate the mass of a molecule.
Parameters
----------
symbols : list
A list of elements.
Returns
-------
@janash
janash / calculate_center_of_mass.py
Created November 6, 2019 18:31
center of mass function - homework for best practices workshop
def calculate_center_of_mass(symbols, coordinates):
"""Calculate the center of mass of a molecule.
The center of mass is weighted by each atom's weight.
Parameters
----------
symbols : list
A list of elements for the molecule
coordinates : np.ndarray
import numpy as np
for atom1 in atoms:
for atom2 in atoms:
a1 = atoms.index(atom1)
a2 = atoms.index(atom2)
coor1 = coordinates[a1]
coor2 = coordinates[a2]
distance = np.sqrt(np.sum((coor1-coor2)**2))
if 0 < distance <= 1.5:
def read_xyz(filepath):
"""
Reads coordinates from an xyz file.
Parameters
----------
filepath : str
The path to the xyz file to be processed.
Returns
def rdf(values, max_value, bin_size,num_particles, box_length):
"""
Calculate the radial distribution function for a set of particles.
Parameters
----------
values : list
A list of particle particle distances.
max_value : float
The maximum value to consider for the calculation.
def rdf(values, n_bins, max_value, num_particles, box_length):
"""
Compute the RDF for a set of values
Parameters
-----------
values : np.ndarray
The distance values to compute the RDF for.
n_bins : int