From 610199f3684e949d2edaae8038991f73c36814c5 Mon Sep 17 00:00:00 2001 From: Pavel Dmitriev Date: Thu, 10 Mar 2016 18:19:50 +0800 Subject: [PATCH] cleaned up for setup.py --- PyATMM/__init__.py | 6 +++++ PyATMM/main.py | 55 -------------------------------------------- PyATMM/util.py | 28 ---------------------- examples/__init__.py | 0 setup.py | 54 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 83 deletions(-) delete mode 100644 PyATMM/main.py delete mode 100644 PyATMM/util.py delete mode 100644 examples/__init__.py create mode 100644 setup.py diff --git a/PyATMM/__init__.py b/PyATMM/__init__.py index e69de29..cacbb7f 100644 --- a/PyATMM/__init__.py +++ b/PyATMM/__init__.py @@ -0,0 +1,6 @@ +""" +Python implementation of the generalized TMM +""" + +__author__ = "Pavel Dmitriev" +__version__ = "1.0.0-a0" \ No newline at end of file diff --git a/PyATMM/main.py b/PyATMM/main.py deleted file mode 100644 index ce96eff..0000000 --- a/PyATMM/main.py +++ /dev/null @@ -1,55 +0,0 @@ -__author__ = 'Pavel Dmitriev' - -import numpy as np -import matplotlib.pyplot as plt -from transferMatrix import * - -#kx = 0.01 -ky = 0.02 - -e0_1 = 1.02 -e0_2 = 1.01 -e0_3 = 1 - -e1 = 2.02 -e2 = 2.01 -e3 = 2 - -# theta=np.pi*3/5 -# phi=np.pi/4 -# psi=np.pi*7/4 -theta = 0 -phi = 0 -psi = 0 - -w = 1 -d = 50 - - -ran = np.linspace(0.01, w, 100) - -ss = [] -sp = [] -ps = [] -pp = [] -sum = [] -for kx in ran: - D0 = build_anisotropic_layer_matrix(e1=e0_1, e2=e0_2, e3=e0_3, theta=theta, phi=phi, psi=psi, w=w, kx=kx, ky=ky, d=d) - D = build_anisotropic_layer_matrix(e1=e1, e2=e2, e3=e3, theta=theta, phi=phi, psi=psi, w=w, kx=kx, ky=ky, d=d) - print("Matrix:", np.dot(np.linalg.inv(D0), D)) - r_ss, r_sp, r_ps, r_pp, t_ss, t_sp, t_ps, t_pp = solve_transfer_matrix(np.dot(np.linalg.inv(D0), D)) - ss.append(np.abs(r_ss**2)) - sp.append(np.abs(r_sp**2)) - ps.append(np.abs(r_ps**2)) - pp.append(np.abs(r_pp**2)) - sum.append(np.abs(r_ss**2) + np.abs(r_sp**2) + np.abs(r_ps**2) + np.abs(r_pp**2) - + np.abs(t_ss**2) + np.abs(t_sp**2) + np.abs(t_ps**2) + np.abs(t_pp**2)) - - -plt.plot(ran, ss) -plt.plot(ran, sp) -plt.plot(ran, ps) -plt.plot(ran, sp) -#plt.plot(ran, sum) -plt.legend(['ss', 'sp', 'ps', 'pp'], loc='best') -plt.show(block=True) \ No newline at end of file diff --git a/PyATMM/util.py b/PyATMM/util.py deleted file mode 100644 index 5ac3ef2..0000000 --- a/PyATMM/util.py +++ /dev/null @@ -1,28 +0,0 @@ -import numpy - - -def solve_quartic(a, b, c, d, e): - - p = (8.*a*c - 3.*b**2) / (8.*a**2) - q = (b**3 - 4.*a*b*c + 8.*a**2*d) / (8.*a**3) - - D0 = c**2 - 3*b*d + 12*a*e - D1 = 2*c**3 - 9*b*c*d + 27*b**2*e + 27*a*d**2 - 72*a*d**2 - 72*a*c*e - D = (1./27.)*(4*D0**3 - D1**2) - - if D != 0 and D0 == 0: - Q = numpy.power((D1 + numpy.sign(D1)*numpy.sqrt(D1**2 - 4*D0**3))/2., 1./3.) - else: - Q = numpy.power((D1 + numpy.sqrt(D1**2 - 4*D0**3))/2., 1./3.) - - S = (1./2.) * numpy.sqrt(-(2./3.)*p + (1./(3.*a))*(Q + D0/Q)) - if S == 0: - Q = -Q - S = (1/2) * numpy.sqrt(-(2/3)*p + (1/(3*a))*(Q + D0/Q)) - - x1 = -b/(4.*a) + S + (1./2.)*numpy.sqrt(-4.*S**2 - 2*p + q/S) - x2 = -b/(4.*a) + S - (1./2.)*numpy.sqrt(-4.*S**2 - 2*p + q/S) - x3 = -b/(4.*a) + S + (1./2.)*numpy.sqrt(-4.*S**2 - 2*p - q/S) - x4 = -b/(4.*a) + S - (1./2.)*numpy.sqrt(-4.*S**2 - 2*p - q/S) - - return x1, x2, x3, x4 \ No newline at end of file diff --git a/examples/__init__.py b/examples/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ffd7db1 --- /dev/null +++ b/setup.py @@ -0,0 +1,54 @@ +import PyATMM + +# Always prefer setuptools over distutils +from setuptools import setup, find_packages +# To use a consistent encoding +from codecs import open +from os import path + +here = path.abspath(path.dirname(__file__)) + +# Get the long description from the RpythonEADME file +with open(path.join(here, 'README.md'), encoding='utf-8') as f: + long_description = f.read() + +setup( + name='PyATMM', + + # Versions should comply with PEP440. For a discussion on single-sourcing + # the version across setup.py and the project code, see + # https://packaging.python.org/en/latest/single_source_version.html + version=PyATMM.__version__, + + description='Implementation of the transfer matrix method', + long_description=long_description, + + url='https://github.com/kitchenknif/PyTMM', + + author=PyATMM.__author__, + author_email='pavel.a.dmitriev@gmail.com', + + # license=PyATMM.__license__, + + classifiers=[ + + 'Intended Audience :: Science/Research', + 'Topic :: Scientific/Engineering :: Physics', + + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + ], + keywords='', + + packages=find_packages(exclude=['contrib', 'docs', 'tests']), + + install_requires=['numpy', 'scipy'], + + extras_require={}, + package_data={}, + data_files=[], + entry_points={}, +) \ No newline at end of file