Skip to content

ghallsimpsons/characteristic-matrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Characteristic Matrix Solver for Dialectric Media This package provides methods for finding analytic solutions for electromagnetic waves in planar dialectric and birefringent media.

Before using this package, make sure to run the test suite to ensure the current build is functioning properly. You can run the tests from the command line with python tests.py. If you plan on including this package in your own project, you can include the tests module in your own tests. When imported in another module, the tests will silently succeed, but will still complain (loudly) if anything is awry.

##Dependencies The core modules currently depend upon NumPy and have only been tested in Python 2.7. The included examples also depend upon SciPy, matplotlib, and ParallelPython.

#Contents Design
Examples
Classes
Unit Types
Parallel Calculations

#Design This package is broken into two main modules. The [c_matrix](#c_matrix) module contains the classes related to dielectric interfaces. The [vector_types](#vector_types) module provides representations of various vectors that are useful for polarization sensitive simulations.

In general, an interface matrix is formed by stacking one or more dielectric (birefringent) layers together. This matrix then acts on a polarization vector (via multiplication) to produce an output polarization after passing through the interface.

#Examples

##Anti-Reflection Coating

from c_matrix import Layer, Interface
from examples import graph
layer1=Layer(2, .00035)
layer2=Layer(4, .00025)
layer3=Layer(7, .00018)
layer4=Layer(9.6, .006)
iface=Interface(layer1,layer2,layer3,layer4,layer3,layer2,layer1)
graph(iface)

##3-Layer Achromatic Half Wave Plate

from c_matrix import Layer, Interface
from examples import graph, rot_sweep
ar=Layer(3.23, "0.34mm")
hwp=Layer(eps=9.36, eps2=11.56, thickness="3.6mm")
ahwp=Interface(ar,hwp,hwp("58deg"),hwp,ar)
graph(ahwp)
rot_sweep(ahwp)
#Classes ##c_matrix ###Layer The Layer class represents a single dielectric/birefringent layer. ######Arguments Although the Layer class can be instantiated with one or no arguments, this is strongly discouraged. Layers can be initialized with the following properties:
`eps`: The relative permittivity along the ordinary axis of the layer.
`thickness (strongly encouraged)`: The thickness of the layer in [Distance Units](#distanceunits). While the thickness will defaut to a sane value (1/4 wavelength at 124GHz) if not specified, it is strongly encouraged that you specify the thickness to avoid unexpected behavior.
`eps2 (optional)`: The relative permittivity along the extraordinary axis of the layer. If unspecified, the layer will have only a single index.
`angle (optional)`: The angle, in [Angle Units](#angleunits), at which to rotate the ordinary axis of the layer relative to the x-axis.
######Public Methods
`__call__(angle)`: Because it is undesirable to create multiple identical layers differing only by the orientation axis, a rotated copy of a layer can be created simple by calling the layer with the angle at which you would like to rotate. This method does not modify the existing layer, unless of course you set the existing layer equal to the rotated representation.

###Interface The Interface class represents a stack of coincident Layers. ######Arguments layers: An Interface is initialized by passing in an arbitrary number or Layer objects. The Interface is generated with the Layers in the order by which they are passed, but a single layer can be passed multiple times, e.g. Interface(cracker, chocolate, marshmallow, cracker) ######Public Methods build(frequency): The optical properties of an interface in general depend upon the frequency of the incoming light. You must therefore construct the operator at a given frequency before acting it on an incoming light vector by calling the build method.
__mul__(vect): The primary usage of an Interface is by acting it on a light vector by multiplication. As with all well-behaved multiplication operators, this returns the new polarization vector, but does not modify the original incoming vector.
__call__(angle): See Layer._call_

##vector_types The vector_types module provides a few conventient vector representations of (partially) polarized light. ###PolarizationVector Essentially represents a sine wave with a phase offset. PolarizationVectors form a complete algebra (addition and scalar multiplication). ######Arguments Either:
`amplitude`: Unitless amplitude of electric field.
`phase`: Phase angle in [Angle Units](#angleunits)
OR:
`phasor`: Complex number represention the amplitude and phase of the vector. ######Properties `power`: The square of the electric field.
`amp`: The amplitude of the electric field.
`phase`: The absolute phase of the electric field.
###PolarizationTwoVector Represents an arbitrary normal-incidence plane wave. PolarizationTwoVectors can be added together to generate composite waves. ######Arguments `vector_x`: A [PolarizationVector](#polarizationvector) representing the x component of field.
`vector_y`: A [PolarizationVector](#polarizationvector) representing the y component of field.
######Properties `I`: The intensity of the field.
`Q`: The Q polarized intensity of the field.
`U`: The U polarized intensity of the field.
`V`: The circularly polarized intensity of the field.
`stokes`: The [StokesVector](#stokesvector) representation of the field.
######Public Methods `rot(angle)`: Returns the vector rotated by the given angle, specified in [Angle Units](#angleunits)
###StokesVector The Stokes representation of a normal-incidence plane wave. ######Arguments Either:
`I`: The intensity of the field.
`Q`: The Q polarized intensity of the field.
`U`: The U polarized intensity of the field.
`V`: The circularly polarized intensity of the field.
`Phase (optional)`: The absolute phase of the [StokesVector](#stokesvector), in [Angle Units](#angleunits).
The phase offset is relative to the x component if the x component is non-zero, or the y component otherwise. It is zero by default.
OR:
`vector_x`: A [PolarizationVector](#polarizationvector) representing the x component of field.
`vector_y`: A [PolarizationVector](#polarizationvector) representing the y component of field.
######Properties `I`: The intensity of the field.
`Q`: The Q polarized intensity of the field.
`U`: The U polarized intensity of the field.
`V`: The circularly polarized intensity of the field.
`cartesian`: The [PolarizationTwoVector](#polarizationtwovector) corresponding to the [StokesVector](#stokesvector)
`phase`: The phase offset in radians relative to the x component if the x component is non-zero, or the y component otherwise.
######Public Methods `rot(angle)`: Returns a [StokesVector](#stokesvector) rotated by the angle given in [Angle Units](#angleunits)
#Unit Types ##Angle Units Any angle can either be specified as an int/float in radians, or in degrees by passing a string, e.g. "90 deg". ##Frequency Units Any frequency can either be specified as an int/float (optionally in scientific notation, e.g. 120E9) in Hz, or in higher frequencies by passing a string, e.g. "120 GHz". ##Distance Units Any distance can either be specified as an int/float (optionally in scientific notation, e.g. 10E-6) in meters, or in smaller unity by passing a string, e.g. "30um". ##Parallel Calculations This package is modular enough that it should be easy to integrate it with your favorite multiprocessing or parallel computing library. However, an easy to use (hopefully) general purpose function is included with this package in the `mp` module. There are some examples of its usage in the examples module. Currently, the `mp` module will only do local multiprocessing, though it can be trivially extended to clusters. The function that provides this capability is `mpexec`. It allows you to execute a function across a finite range for a single parameter. Suppose you have a function `f` which takes 3 arguments, `a`, `b` and `c`. To sweep across values of `b` in range(3) for fixed `a` and `c`, you would call the your function with `mpexec(f, "b", range(3), a="1", c="4")`. The return value is an array of your function return values, indexed by your parameter range. `mpexec` also takes optional keyword arguments `modules` and `globals`. For a description of these arguments, see the arguments of [Server.submit](http://www.parallelpython.com/content/view/15/30/).

#Acknowledgements These modules were written with the help of Aritoki Suzuki and Charles Hill at UC Berkeley. The mathematics draws extensively from Chapter 3 of Tomotake Matsumura's A Cosmic Microwave Background Radiation Polarimeter Using Superconducting Magnetic Bearings

About

Methods for finding analytic solutions for waves in dialectric media.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages