Skip to content

Commit

Permalink
made pip installable
Browse files Browse the repository at this point in the history
  • Loading branch information
Shellywell123 committed Nov 17, 2020
1 parent 74fcad8 commit 256ae6b
Show file tree
Hide file tree
Showing 108 changed files with 1,707 additions and 0 deletions.
Binary file added PyCrystallography/Images/BCC_lattice.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/BCC_unit_cell.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/FCC_lattice.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/FCC_unit_cell.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/NaCl_lattice.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/NaCl_unit_cell.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/SP_Diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/biprismid10.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/biprismid3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/biprismid4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/biprismid5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/bipyramid10.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/bipyramid3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/bipyramid4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/bipyramid5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/cube.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/cube_reflection.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/cube_reflection_diag.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/cuboid_x.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/cuboid_y.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/cuboid_z.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/diamond_lattice.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/diamond_unit_cell.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PyCrystallography/Images/face_normals_cube.gif
Binary file added PyCrystallography/Images/face_normals_prism.gif
Binary file added PyCrystallography/Images/frames/01_36.png
Binary file added PyCrystallography/Images/frames/02_36.png
Binary file added PyCrystallography/Images/frames/03_36.png
Binary file added PyCrystallography/Images/frames/04_36.png
Binary file added PyCrystallography/Images/frames/05_36.png
Binary file added PyCrystallography/Images/frames/06_36.png
Binary file added PyCrystallography/Images/frames/07_36.png
Binary file added PyCrystallography/Images/frames/08_36.png
Binary file added PyCrystallography/Images/frames/09_36.png
Binary file added PyCrystallography/Images/frames/10_36.png
Binary file added PyCrystallography/Images/frames/11_36.png
Binary file added PyCrystallography/Images/frames/12_36.png
Binary file added PyCrystallography/Images/frames/13_36.png
Binary file added PyCrystallography/Images/frames/14_36.png
Binary file added PyCrystallography/Images/frames/15_36.png
Binary file added PyCrystallography/Images/frames/16_36.png
Binary file added PyCrystallography/Images/frames/17_36.png
Binary file added PyCrystallography/Images/frames/18_36.png
Binary file added PyCrystallography/Images/frames/19_36.png
Binary file added PyCrystallography/Images/frames/20_36.png
Binary file added PyCrystallography/Images/frames/21_36.png
Binary file added PyCrystallography/Images/frames/22_36.png
Binary file added PyCrystallography/Images/frames/23_36.png
Binary file added PyCrystallography/Images/frames/24_36.png
Binary file added PyCrystallography/Images/frames/25_36.png
Binary file added PyCrystallography/Images/frames/26_36.png
Binary file added PyCrystallography/Images/frames/27_36.png
Binary file added PyCrystallography/Images/frames/28_36.png
Binary file added PyCrystallography/Images/frames/29_36.png
Binary file added PyCrystallography/Images/frames/30_36.png
Binary file added PyCrystallography/Images/frames/31_36.png
Binary file added PyCrystallography/Images/frames/32_36.png
Binary file added PyCrystallography/Images/frames/33_36.png
Binary file added PyCrystallography/Images/frames/34_36.png
Binary file added PyCrystallography/Images/frames/35_36.png
Binary file added PyCrystallography/Images/frames/36_36.png
Binary file added PyCrystallography/Images/inversion.gif
Binary file added PyCrystallography/Images/miller_001.gif
Binary file added PyCrystallography/Images/miller_010.gif
Binary file added PyCrystallography/Images/miller_011.gif
Binary file added PyCrystallography/Images/miller_100.gif
Binary file added PyCrystallography/Images/miller_101.gif
Binary file added PyCrystallography/Images/miller_110.gif
Binary file added PyCrystallography/Images/miller_111.gif
Binary file added PyCrystallography/Images/penrose_tiling_star.gif
Binary file added PyCrystallography/Images/penrose_tiling_sun.gif
Binary file added PyCrystallography/Images/prism10.gif
Binary file added PyCrystallography/Images/prism3.gif
Binary file added PyCrystallography/Images/prism4.gif
Binary file added PyCrystallography/Images/prism5.gif
Binary file added PyCrystallography/Images/pyramid10.gif
Binary file added PyCrystallography/Images/pyramid3.gif
Binary file added PyCrystallography/Images/pyramid4.gif
Binary file added PyCrystallography/Images/pyramid5.gif
Binary file added PyCrystallography/Images/reflection.gif
Binary file added PyCrystallography/Images/rhombus_lattice.gif
Binary file added PyCrystallography/Images/rotation.gif
Binary file added PyCrystallography/Images/square_lattice.gif
Binary file added PyCrystallography/Images/tetrakis.gif
413 changes: 413 additions & 0 deletions PyCrystallography/PyAnimate.py

Large diffs are not rendered by default.

538 changes: 538 additions & 0 deletions PyCrystallography/PyCrystallography.py

Large diffs are not rendered by default.

420 changes: 420 additions & 0 deletions PyCrystallography/PyPacking.py

Large diffs are not rendered by default.

281 changes: 281 additions & 0 deletions PyCrystallography/PyShapes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
import numpy as np
from PyCrystallography import plot_axis,make_atom,make_bond,plot_bonds,plot_atoms

def normal_points(ax,faces,r):
"""
"""

sphere_points = []

for face in faces:

points_sum = np.array([0,0,0])

for vert in face:
points_sum = points_sum + vert

face_centre = points_sum/len(face)


vert1 = face[0]
vert2 = face[1]
vert3 = face[2]

vec1 = [vert2[0]-vert1[0],vert2[1]-vert1[1],vert2[2]-vert1[2]]
vec2 = [vert3[0]-vert1[0],vert3[1]-vert1[1],vert3[2]-vert1[2]]

normal = np.cross(vec1,vec2)
# print(normal)

# generate projected point on a sphere of radius r
normal = face_centre+normal

# scale to be on sphere
current_r = np.sqrt(normal[0]**2 + normal[1]**2 + normal[2]**2)

normal = normal * r/current_r

current_r = np.sqrt(normal[0]**2 + normal[1]**2 + normal[2]**2)
# print(current_r)

if normal[2] > 0:
COL ='blue'
elif normal[2] == 0:
COL ='green'
else:
COL='r'

sphere_points.append(normal)
ax.plot([face_centre[0],normal[0]],[face_centre[1],normal[1]],[face_centre[2],normal[2]],linewidth=3,c='k')
ax.scatter(normal[0],normal[1],normal[2],linewidth=3,c=COL)

return sphere_points

def plot_face(ax,verts,alpha=0.5,color='C0'):
"""
"""

x_list = []
y_list = []
z_list = []

for vert in verts:
x_list.append(vert[0])
y_list.append(vert[1])
z_list.append(vert[2])

verts = [list(zip(x_list,y_list,z_list))]

from mpl_toolkits.mplot3d.art3d import Poly3DCollection
ax.add_collection3d(Poly3DCollection(verts,linewidths=1,edgecolor='k',alpha=alpha,color=color))

def cuboid(ax,h,w,d,alpha=0.5,show_axis=True):
"""
"""
if show_axis == True:
plot_axis(ax,max_lim=1.5*max(h,w,d))
faces = []

#+w
side_verts1 = [h/2,w/2,-d/2],[-h/2,w/2,-d/2],[-h/2,w/2,d/2],[h/2,w/2,d/2]
faces.append(side_verts1)

#-w
side_verts2 = [h/2,-w/2,d/2],[-h/2,-w/2,d/2],[-h/2,-w/2,-d/2],[h/2,-w/2,-d/2]

faces.append(side_verts2)

#+h
side_verts3 = [h/2,w/2,d/2],[h/2,-w/2,d/2],[h/2,-w/2,-d/2],[h/2,w/2,-d/2]
faces.append(side_verts3)

#-h
side_verts4 = [-h/2,w/2,-d/2],[-h/2,-w/2,-d/2],[-h/2,-w/2,d/2],[-h/2,w/2,d/2]
faces.append(side_verts4)

#+d
top_verts = [h/2,w/2,d/2],[-h/2,w/2,d/2],[-h/2,-w/2,d/2],[h/2,-w/2,d/2]
faces.append(top_verts)

#-d
bottom_verts = [h/2,-w/2,-d/2],[-h/2,-w/2,-d/2],[-h/2,w/2,-d/2],[h/2,w/2,-d/2]

faces.append(bottom_verts)

for face in faces:
plot_face(ax,face,alpha=alpha)

return faces


def prism(ax,h_z,r_xy,num_of_side):
"""
will plot a prism of given height, width and depth in x,y, and z
"""
h = h_z
r = r_xy

plot_axis(ax,max_lim=1.5*max(h_z,r_xy))

faces = []

top_verts = []
bottom_verts = []

for n in range(0,num_of_side):
theta = (2*n/num_of_side)*np.pi + np.pi/4
theta_next = (2*(n+1)/num_of_side)*np.pi+ np.pi/4

x = (r)*np.cos(theta)
y = (r)*np.sin(theta)

x_next = (r)*np.cos(theta_next)
y_next = (r)*np.sin(theta_next)

side_verts = [x,y,-h/2],[x_next,y_next,-h/2],[x_next,y_next,h/2],[x,y,h/2]
faces.append(side_verts)

top_verts.append([x,y,h/2])
bottom_verts.append([x,y,-h/2])

faces.append(top_verts)
faces.append(bottom_verts[::-1])

for face in faces:
plot_face(ax,face)

return faces

def tetrakis(ax,r,dr):
"""
will plot a tetrakis
"""
faces = []

top_verts = []
bottom_verts = []

plot_axis(ax,max_lim=1.1*(r+2*dr))
for n in range(0,4):
theta = (2*n/4)*np.pi + np.pi/4
theta_next = (2*(n+1)/4)*np.pi+ np.pi/4
theta_mid = (2*(n+0.5)/4)*np.pi+ np.pi/4

x = (r)*np.cos(theta)
y = (r)*np.sin(theta)

x_mid = (r+dr)*np.cos(theta_mid)
y_mid = (r+dr)*np.sin(theta_mid)
z_mid = 0

x_next = (r)*np.cos(theta_next)
y_next = (r)*np.sin(theta_next)

h = 2*r*np.sin(np.pi/4)

side_verts_top = [0,0,h/2+dr],[x,y,h/2],[x_next,y_next,h/2]
faces.append(side_verts_top)

side_verts_mid_up = [x_mid,y_mid,z_mid],[x_next,y_next,h/2],[x,y,h/2]

faces.append(side_verts_mid_up)

side_verts_mid_left = [x_mid,y_mid,z_mid],[x,y,h/2],[x,y,-h/2]
faces.append(side_verts_mid_left)

side_verts_mid_right = [x_next,y_next,-h/2],[x_next,y_next,h/2],[x_mid,y_mid,z_mid]
faces.append(side_verts_mid_right)

side_verts_mid_down = [x,y,-h/2],[x_next,y_next,-h/2],[x_mid,y_mid,z_mid]
faces.append(side_verts_mid_down)

side_verts_bottom = [x_next,y_next,-h/2],[x,y,-h/2],[0,0,-h/2-dr]
faces.append(side_verts_bottom)

for face in faces:
plot_face(ax,face)

return faces

def pyramid(ax,h,r,num_of_side):
"""
will plot a pyramid with num of sides -1
"""
faces = []
bottom_verts = []
plot_axis(ax,max_lim=1.1*h)

for n in range(0,num_of_side):
theta = (2*n/num_of_side)*np.pi
theta_next = (2*(n+1)/num_of_side)*np.pi
x = r*np.cos(theta)
y = r*np.sin(theta)

x_next = r*np.cos(theta_next)
y_next = r*np.sin(theta_next)

side_verts = [0,0,h/2],[x,y,-h/2],[x_next,y_next,-h/2]
faces.append(side_verts)
bottom_verts.append([x,y,-h/2])

faces.append(bottom_verts[::-1])

for face in faces:
plot_face(ax,face)

return faces

def bipyramid(ax,h,r,num_of_side):
"""
will plot a bipyramid with number of sides /2
"""
faces = []
plot_axis(ax,max_lim=1.1*max(h,r))
for n in range(0,num_of_side):
theta = (2*n/num_of_side)*np.pi
theta_next = (2*(n+1)/num_of_side)*np.pi
x = r*np.cos(theta)
y = r*np.sin(theta)

x_next = r*np.cos(theta_next)
y_next = r*np.sin(theta_next)

side_verts_top = [0,0,h/2],[x,y,0],[x_next,y_next,0]
faces.append(side_verts_top)

side_verts_bottom = [x_next,y_next,0],[x,y,0],[0,0,-h/2]
faces.append(side_verts_bottom)

for face in faces:
plot_face(ax,face)

return faces

def biprismid(ax,h,dh,r,num_of_side):
"""
will plot a bi-prism-id with number of sides /2
"""
faces = []
plot_axis(ax,max_lim=1.1*max(h,r))
for n in range(0,num_of_side):
theta = (2*n/num_of_side)*np.pi
theta_next = (2*(n+1)/num_of_side)*np.pi
x = r*np.cos(theta)
y = r*np.sin(theta)

x_next = r*np.cos(theta_next)
y_next = r*np.sin(theta_next)

side_verts_top = [0,0,h/2+dh],[x,y,h/2],[x_next,y_next,h/2]
faces.append(side_verts_top)

side_verts_mid = [x,y,-h/2],[x_next,y_next,-h/2],[x_next,y_next,h/2],[x,y,h/2]
faces.append(side_verts_mid)

side_verts_bottom = [x_next,y_next,-h/2],[x,y,-h/2],[0,0,-h/2-dh]
faces.append(side_verts_bottom)

for face in faces:
plot_face(ax,face)

return faces
Empty file added PyCrystallography/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions PyCrystallography/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from PyShapes import *
from PyCrystallography import *

fig = plt.figure(0,figsize=[8,8])
ax = fig.add_subplot(111,projection='3d')
#faces = cuboid(ax,2,2,2)
#reflection(ax,2,2,2)
faces=pyramid(ax,2,2,3)
# faces=biprismid(ax,3,1,0.5,5)
points=normal_points(ax,faces,5)
# print(points)

# ns,es,ss=Stereographic_projection(points,3,'test')
# #print(ns,ss)
# identify_fold_symmetry(ns,es,ss)
plt.show()
7 changes: 7 additions & 0 deletions PyCrystallography/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import matplotlib.pyplot as plt
fig = plt.figure(0,figsize=[8,8])
azim = 30
ax = fig.add_subplot(111,projection='3d',azim=azim,elev=30)
from PyCrystallography import reflection
reflection(ax,1,1,1)
plt.show()
27 changes: 27 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from setuptools import setup, find_packages

# with open("README.md", "r") as f:
# README = f.read()

setup(
name='PyCrystallography',
version='0.1.1',
description='Python 3 package being written to illustrate crystallography',
long_description='Python 3 package being written to illustrate crystallography', # fix readme import
long_description_content_type='text/markdown',
author='Shellywell123',
url='https://github.com/Shellywell123/PyCrystallography',
packages=find_packages(),
install_requires=[
'matplotlib>=3.3.2',
'numpy>=1.19.2',
'imageio>=2.9.0'
],
python_requires='>=3.6',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
],
zip_safe=False
)

0 comments on commit 256ae6b

Please sign in to comment.