Skip to content

Commit

Permalink
Updated setup file to compile ublocklu with boost and updated example…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
adocherty committed Sep 17, 2009
1 parent 8fc12d2 commit 1b77ec6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Polymode/Material.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def convertwavelength(self, x, wlunits='um'):

return wl

def plot(self,wlrange=None, points=100):
def plot(self,wlrange=None, points=100, showdata=False):
'''
Plot the material refractive index
* wrange is the wavelength range
Expand Down
37 changes: 31 additions & 6 deletions Polymode/mathlink/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,39 @@
print "Numpy doesn't support Cython!"

def configuration(parent_package='', top_path=None):
from numpy.distutils.system_info import get_info, NotFoundError

config = Configuration('mathlink', parent_package, top_path)
config.add_library('famos',sources=[join('amos','*f'), join('amos','mach','*f')])
#config.add_extension('amos', sources=['amos.cpp'], depends=['amos.h'], libraries=['famos', 'g2c'])
config.add_extension('bessel_ratios', sources=['bessel_ratios.cpp'], depends=['bessel_function_ratios.h'], libraries=['famos', 'gfortran'])

#C++ tridiagonal block solver
#config.add_extension('ublocklu', sources=['ublas_block_lu/ublocklu.cpp','ublas_block_lu/numimport.cpp'], libraries=[])

#Compile the amos library
config.add_library('famos',
sources=[join('amos','*f'),
join('amos','mach','*f')]
)

config.add_extension('bessel_ratios',
sources=['bessel_ratios.cpp'],
depends=['bessel_function_ratios.h'],
libraries=['famos', 'gfortran']
)

#Get blas/lapack resources from numpy
lapack_opt = get_info('lapack_opt')

if not lapack_opt:
raise NotFoundError,'no lapack/blas resources found'

atlas_version = ([v[3:-3] for k,v in lapack_opt.get('define_macros',[]) \
if k=='ATLAS_INFO']+[None])[0]

#C++ tridiagonal block solver
ublock_sources = ['ublas_block_lu/ublocklu.cpp','ublas_block_lu/numimport.cpp']
config.add_extension('ublocklu',
sources=ublock_sources,
include_dirs=['ublas_block_lu'],
libraries=['atlas','lapack_atlas','boost_python-mt'],
extra_info = lapack_opt
)

return config

Expand Down
17 changes: 12 additions & 5 deletions examples/ex4_extra_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
Material.find_materials('ag')

#Use supplied data from internal material databases
ag_sopra = Material.Sopra('Ag')
ag_fs = Material.FreeSnell('ag')

for mat in [ag_sopra, ag_fs]:
#Compare refractive index of some plastics
pmma = Material.PMMA()
pc = Material.Polycarbonate()
ps = Material.Polystyrene()
zeo = Material.Zeonex()

#Plot the dispersion of the different materials
#This will give some errors as we are extrapolating
#outside the valid region of wavelengths
for mat in [pmma, pc, ps, zeo]:
print mat
mat.plot([0.4,1.0], showdata=True)
Plotter.title("The refractive index of silver from different sources")
mat.plot([0.4,1.2], showdata=True)
Plotter.title("The refractive index of different optical polymers")
Plotter.show()

#Example of a new material using Sellmeier coefficients
Expand All @@ -36,4 +44,3 @@ def strange_index(self, wavelength):
#Example of a new material using interpolation of a Sopra formatted file
#nm_sopra = Material.SopraFile( open('test.nk', 'r') )


4 changes: 2 additions & 2 deletions examples/ex6_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

#Plot the point distribution
subplot(221)
scatter(x1,y1, 2)
scatter(x1.ravel(), y1.ravel(), 2)
axis('tight')

subplot(222)
scatter(x2,y2, 2)
scatter(x2.ravel(), y2.ravel(), 2)
axis('tight')

#Example function
Expand Down

0 comments on commit 1b77ec6

Please sign in to comment.