r47 - 08 Nov 2013 - 17:29:10 - AlexFionaYou are here: TWiki >  PtPhysics Web > WebHome

Welcome Part Time Physics Students

This site has been created to promote collaboration around the Part time Physics course held at UCL. We already use a mail group but wanted a richer level of sharing. Please feel free to post content and fill in and extend the site where you see fit.

The menus and options on the left have been created but have been left unedited for now, please feel free to extend and share these links.

Conways Game Of Life

Simple yet impactful GOL.

Hartree Fock - Self Consistent Field Approximation

Simple Hartree Fock SCF implementation

Simple Cross Search

Simple cross location in a matrix

simple

Drop Wizard Services

Here are my first Drop Wizard services. Plan to point some D3 viz against these service.

Apache Hive, Cloudera and Spark with Tableau

Great article showing how to extend the examples with a Tableau connection.

Disruptive Analytics

See my link below to my first blog post on the topic of disruptive analytics. This forms the starting point in looking at how basic statistics coupled with compute can give companies and everyday folks advantages.

Laguerre Polynomials

Have been meaning to plot these for ages.

  • [http://en.wikipedia.org/wiki/Laguerre_polynomials][Wikipedia Link]]

# Name : Alex Baker
# Title : Laguerre Gaussian Polynomials
# Description : Using Rodrigues Formula we generate the Laguerre Polynomials for a range of values of n.

# Ln(x) = e^x/n! . dn/dxn(e^-x x^n)

# how do we differentiate in python, we can perhaps do this numerically?

# n, 1.2.3....(n-1)n

from sympy import *

def factorial(n):
     return reduce(lambda a,b:a * b, [x for x in range(1,n+1)])

p = Plot(visible=False)

x = Symbol('x')
for i,n in enumerate(range(1,5)):
   print n, simplify((exp(1)**x)/factorial(n)*diff((exp(1)**-x)*x**n,x,n))
   p[i] = simplify((exp(1)**x)/factorial(n)*diff((exp(1)**-x)*x**n,x,n))

p.saveimage('plot.png', format='png')

1 1 - x
2 1 - 2*x + x**2/2
3 1 - 3*x + 3*x**2/2 - x**3/6
4 1 - 4*x + 3*x**2 - 2*x**3/3 + x**4/24

A* Rubik Solver

Finally gotten around to putting the astar solver ontop of my rubics cube model, first look it seem that a random shuffle() of 2 moves is fairly easy to solve. The heuristic is very basic, need to include something to evaluate whether the faces are closer or not to the goal cube. However it does seem to at least work. also need a way to check the paths against the cached nodes from shuffle.

OK
bakera@bilbo:~/workspace/mycube/src$ python solver.py 
['UI', 'DI']

   visited [0009/0037]
   path size 3

goal cube
[[ 0.  0.  0.  2.  2.  2.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  2.  2.  2.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  2.  2.  2.  0.  0.  0.  0.  0.  0.]
 [ 4.  4.  4.  1.  1.  1.  5.  5.  5.  6.  6.  6.]
 [ 4.  4.  4.  1.  1.  1.  5.  5.  5.  6.  6.  6.]
 [ 4.  4.  4.  1.  1.  1.  5.  5.  5.  6.  6.  6.]
 [ 0.  0.  0.  3.  3.  3.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  3.  3.  3.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  3.  3.  3.  0.  0.  0.  0.  0.  0.]]

step  0 :
[[ 0.  0.  0.  4.  4.  4.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  2.  2.  2.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  5.  5.  5.  0.  0.  0.  0.  0.  0.]
 [ 3.  4.  2.  1.  1.  1.  3.  5.  2.  6.  6.  6.]
 [ 3.  4.  2.  1.  1.  1.  3.  5.  2.  6.  6.  6.]
 [ 3.  4.  2.  1.  1.  1.  3.  5.  2.  6.  6.  6.]
 [ 0.  0.  0.  4.  4.  4.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  3.  3.  3.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  5.  5.  5.  0.  0.  0.  0.  0.  0.]]

step  1 :
[[ 0.  0.  0.  2.  2.  2.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  2.  2.  2.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  5.  5.  5.  0.  0.  0.  0.  0.  0.]
 [ 4.  4.  2.  1.  1.  1.  3.  5.  5.  6.  6.  6.]
 [ 4.  4.  2.  1.  1.  1.  3.  5.  5.  6.  6.  6.]
 [ 4.  4.  2.  1.  1.  1.  3.  5.  5.  6.  6.  6.]
 [ 0.  0.  0.  4.  4.  4.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  3.  3.  3.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  3.  3.  3.  0.  0.  0.  0.  0.  0.]]

step  2 :
[[ 0.  0.  0.  2.  2.  2.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  2.  2.  2.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  2.  2.  2.  0.  0.  0.  0.  0.  0.]
 [ 4.  4.  4.  1.  1.  1.  5.  5.  5.  6.  6.  6.]
 [ 4.  4.  4.  1.  1.  1.  5.  5.  5.  6.  6.  6.]
 [ 4.  4.  4.  1.  1.  1.  5.  5.  5.  6.  6.  6.]
 [ 0.  0.  0.  3.  3.  3.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  3.  3.  3.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  3.  3.  3.  0.  0.  0.  0.  0.  0.]]

None
.
----------------------------------------------------------------------
Ran 1 test in 0.533s



Scipy Central

Interesting snippets website of interesting scipy things.

Quantum Particles

Solving the time independent Schrodinger equation in two dimensions, normalising the wavefunction expression gives us the equation below.

\Psi (x,y) = \frac{2}{a} sin ( \frac{n_{x} \pi x}{a} ) sin ( \frac{n_{y} \pi y}{a} )

We can generate the plots below using mayavi from enthought using the script below.

# Create the data.
from numpy import pi, sin, cos, mgrid
dx, dy= 3/250.0, 3/250.0
[x,y] = mgrid[0:dx*250:dx,0:dy*250:dy]

z = (2.0/3.0)*sin(2*pi*x/3.0)*sin(pi*y)

# if we square the wave function we obtain the probability density function
# the most likely location to locate the particle 

#z = z0*z0

# View it.
from enthought.mayavi.mlab import *
#s = mlab.mesh(x, y, z)
surf(x,y,z)

show()

eignphasesum2.gif eignphasesum2.gif eignphasesum2.gif

Degenerate Wave Function

As usual the square of the wavefunction is a probability density, telling us where we are most likely to find the particle.

eignphasesum2.gif eignphasesum2.gif eignphasesum2.gif

Close Coupling Expansion

Something slightly more demanding to test equation rendering.

\Psi^{N+1}_{k} = A \sum\limits_{i}^{n} \sum\limits_{j}^{n_{c}} a_{ijk} \Phi_{i}^{N} \left ( x_{1} ... x_{N} \right ) u_{ij} \left(x_{N+1} \right) + \sum\limits_{i}^{m} b_{ik} \chi_{i}^{N+1} \left( x_{1} ... x_{N+1} \right)

Fire Cracker

Must stop getting hold of these problems, they are interesting and keep the coding skills sharp but what a time suck. This one has eaten few hours of thinking time, especially on how to model the system and perform the integral. Think that the fragment object could do with an abstraction for the dynamics of the problem perhaps a custom decorator that implements the model.

* Fire Cracker

Multiprocess Example

Example below on how to split and merge calc using processes on shared memory.


"""
example multiprocess
"""

import numpy as np
import multiprocessing
import ctypes

import random
import os

_ctypes_to_numpy = {
    ctypes.c_char : np.int8,
    ctypes.c_wchar : np.int16,
    ctypes.c_byte : np.int8,
    ctypes.c_ubyte : np.uint8,
    ctypes.c_short : np.int16,
    ctypes.c_ushort : np.uint16,
    ctypes.c_int : np.int32,
    ctypes.c_uint : np.int32,
    ctypes.c_long : np.int32,
    ctypes.c_ulong : np.int32,
    ctypes.c_float : np.float32,
    ctypes.c_double : np.float64
}

_numpy_to_ctypes = dict((value, key) for key, value in
                                _ctypes_to_numpy.iteritems())

def shmem_as_ndarray(data, dtype=float):
    """ Given a multiprocessing.Array object, as created by
    ndarray_to_shmem, returns an ndarray view on the data.
    """
    dtype = np.dtype(dtype)
    size = data._wrapper.get_size()/dtype.itemsize
    arr = np.frombuffer(buffer=data, dtype=dtype, count=size)
    return arr


def ndarray_to_shmem(arr):
    """ Converts a numpy.ndarray to a multiprocessing.Array object.
    
        The memory is copied, and the array is flattened.
    """
    arr = arr.reshape((-1, ))
    data = multiprocessing.RawArray(_numpy_to_ctypes[arr.dtype.type], 
                                        arr.size)
    ctypes.memmove(data, arr.data[:], len(arr.data))
    return data

################################################################################
# A class to carry around the relevant information
################################################################################

class SharedMemArray(object):
    """ Wrapper around multiprocessing.Array to share an array accross
        processes.
    """

    def __init__(self, arr):
        """ Initialize a shared array from a numpy array.

            The data is copied.
        """
        self.data = ndarray_to_shmem(arr)
        self.dtype = arr.dtype
        self.shape = arr.shape

    def __array__(self):
        """ Implement the array protocole.
        """
        arr = shmem_as_ndarray(self.data, dtype=self.dtype)
        arr.shape = self.shape
        return arr
 
    def asarray(self):
        return self.__array__()

import time

def number_of_processors(): 
       ''' number of virtual processors on the computer ''' 
       # Windows 
       if os.name == 'nt': 
          return int(os.getenv('NUMBER_OF_PROCESSORS')) 
       else: 
      raise RuntimeError, 'unknown platform' 

def getsplit(a, nprocesses):
    return np.vstack([a for a in __citerate(a, nprocesses)])

def __citerate(a, nprocesses):
   count = len(a)/nprocesses
   print count
   for i,s in enumerate(range(0,nprocesses)):
      #print i, s, [x for x in range(count*s, count*s+count,1)]
      yield np.array([x for x in range(count*s, count*s+count,1)])
      #print i,s,a[i:i+1]
      #yield a[i:i+1]

def test_sharing_array():
    """ Check that a SharedMemArray shared between processes is indeed
        modified in place.
    """    
    a = np.array([random.randint(1,x) for x in range(1,10001)]).ravel().reshape((100,100))       
    arr = SharedMemArray(a)    
    
    r = np.zeros((a.shape[0], 1), dtype=np.float64)         
    rrr = SharedMemArray(r)    
    
    nprocesses = number_of_processors()    
    __split__ = getsplit(a, nprocesses)
        
    s = np.zeros((__split__.shape[0], 1), dtype=np.float64)         
    srr = SharedMemArray(s)    
    
    #print __split__
    
    #print len([i for i in range(0, a.shape[1],1)])        
    print 'start', arr.asarray()
    #pool = [multiprocessing.Process(target=g, args=(arr,rrr,__split__[i])) for i in range(0, a.shape[1],1)]    
    pool = [multiprocessing.Process(target=g, args=(arr,rrr,__split__[i], srr,i)) for i in range(0, nprocesses,1)]    
    for p in pool:    
   print 'start', p
   p.start() 
    for p in pool:    
   print 'join', p    
   p.join() 
    print 'result', rrr.asarray().ravel()
    print 'status', srr.asarray()
    
    if srr.asarray().sum() < 0:
   print 'error', srr.asarray()[srr.asarray()<0]
    
    #np.testing.assert_equal(-b, a)

def g(arr,r,i,s,k):   
   #print arr,r,i,s,k
   try:
      a = arr.asarray()      
      _r = r.asarray()         
      _s = s.asarray()         
      #time.sleep(10)
      for x in i:
         _r[x] = a[x].sum()    # simple sum here across each row
      #print _r[i], _r
      _s[k] = 1
      #1/0
   except:
      _s[k] = -1

# Our worker function    
def f(arr,r,i):   
   a = arr.asarray()      
   _r = r.asarray()         
   #time.sleep(4) # simulate a calculation
   _r[i] = a[i].sum()    # simple sum here across each row
   #print _r[i], _r

if __name__ == '__main__':
    test_sharing_array()

Simple Maven Example


# simple maven commands
# http://maven.apache.org/guides/getting-started/index.html#How_do_I_make_my_first_Maven_project

mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DgroupId=com.mycompany.app \
  -DartifactId=my-app

mvn eclipse:eclipse
mvn clean
mvn compile
mvn test
mvn package
mvn clean compile assembly:single
# include in local .m2/repository
mvn install



Pyramid Series

Simple script to generate the series.

import itertools as it

'''

bakera@bilbo:~/haldon/pyramid$ python reduced.py
1
11
21
1211
111221
312211
13112221
1113213211
31131211131221
13211311123113112211
11131221133112132113212221
bakera@bilbo:~/haldon/pyramid$ 

'''

# levels
depth = 10
start = '1'
print start
for n in range(0,depth,1):
        start = ''.join(["%s%s" % (str(x),str(y)) for (x,y) in [(len(list(b)), a) for a, b in (list(g) for g in it.groupby(start))]])
        print start

Simple Stack

Quantum Link

Interesting link for quantum that discusses more advanced topics in bit sized chunks.

Ant And Grain

Interesting problem involving an ant, some grain and a 5 by 5 grid, oh and a histogram.

B Tree

Stepping back to basics to make sure that we understand the simple cases for DFS and BFS tree navigation code systems, this is a very simple set of examples for those who are not familiar with how to use these trees.

KDTree

Thought that this warrented a posting, have been thinking about how to use these lately and think that any query can potentially fit into this structure.

The need for speed

Iterators and yield in python provide a powerful way to manage large datasets.

Site Support

Depending on how much of this site still looks interesting or relevant in about 6 months will dictate whether I keep the link going, please do let me know if you think that it is worth maintaining this site otherwise it is likely that this site may come down soon. Please either post onto the site or you can email me on baker dot alexander at gmail dot com.

Summer Time Blues

Well for most the last batch of exams are over and we can perhaps allow ourselves a rest for a day or two, for me finding the time to complete labs and hand in tutorials was hard enough but to then make further time to revise and bring the whole thing together for an exam brings some unique challenges.

Would it then be a bit weird to suggest that I enjoyed some of the revision? is this possible? the e & m revision and solid state revision sessions were perhaps not enjoyable but satifying in that the whole subject can be brought together. One thing that I did much more of this year than other years was to actually read the book, especially the solid state Kittel book, to the extent that I think that this might be the pivitol text of the course, or perhaps the only one that I actually read and understood. I think that Kittel brings much of physics as a whole together from across quantum, crystallography wave and vectors and it works and makes sense. I recommend that you spend some time, about a week should do it to read this book and relate it back to the course notes.

pivitol course text

Whilst the engine is still running it makes sense for me to layout some ideas and thinking for the summer, I have been collecting a list of things that I wanted to look at over the last year and put them onto the wiki link below, some of these go back a year or more but time has not been in my favour over the last year and many of what I deem to be more interesting things I have had to either skim over or not look at at all.

Summer Reading List

Brownian Motion of Stock

Brownian Motion of a stock, have included a histogram of the final set of draws. This final histogram allows us to figure out the distribution, mean , std of the stock over a certain time horizon.

brownian motion

'''
N_sim: number of simulations
T: horizon
dt: step length in years
sigma: volatility per year
mu: drift terms (moving average or long-term mean for stock returns)
S0: initial stock price
'''

from numpy.random import standard_normal
from numpy import array, zeros, sqrt, shape
from pylab import *

S0 = 10.222

T =1
dt =0.0002
sigma = 0.4
mu = 1
N_Sim = 10

Steps=round(T/dt); #Steps in years
S = zeros([N_Sim, Steps], dtype=float)
x = range(0, int(Steps), 1)

for j in range(0, N_Sim, 1):
        S[j,0]= S0
        for i in x[:-1]:
                S[j,i+1]=S[j,i]+S[j,i]*(mu-0.5*pow(sigma,2))*dt+sigma*S[j,i]*sqrt(dt)*standard_normal();
        plot(x, S[j])

title('Simulations %d Steps %d Sigma %.6f Mu %.6f S0 %.6f' % (int(N_Sim), int(Steps), sigma, mu, S0))
xlabel('steps')
ylabel('stock price')
show()

Energy Density Distribution of a Black Body

The energy density distribution of a black-body spectrum, most of the energy is contributed by photons 3k_{b}T

black body

from pylab import *
from scipy import e
x = arange(0, 15, 0.001)
print x
energy_spectrum_distribution = (pow(x,3)/pow(e,x)-1)
title('The energy density distribution')
plot(x,energy_spectrum_distribution)
show()

Finite Difference Method

Interesting tutorial on FDTD methodology.

Pylab to Mayavi porting

Having used Pylab and matplotlib for some time it seems that support for 3d plotting has stopped in version 90.1 forward should use the mayavi libraries. This is a considerable porting effort and need to be approached carefully not to break any existing code.

  • Mayavi
  • Example Scripts
  • Enthought Install
  • Python Exe's

    Sympy Documentation

    Have install the wonderful sympy for those interested in a free CAS tool.

    Newton Raphson

    Had almost forgotten about, until it popped up on a problem sheet for Thermo, the Newton Raphson method for solving roots of equations. Simple Python example using Scipy below:

    # Name : Alexander Baker
    # Date : 2nd December 2008
    # Description : based on Newton Raphson method of root finding, based on 
    #   x_{n+1} = x_{n} - f(x_{n})/df(x_{n})/dx
    # http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.newton.html#scipy.optimize.newton
    # http://pathfinder.scar.utoronto.ca/~dyer/csca57/book_P/node35.html
    
    import scipy.optimize
    from scipy import optimize
    
    def q(x):
        return (3.0-x)*scipy.exp(x) - 3.0
        
    def qprime(x):
        return (2.0-x)*scipy.exp(x)    
    
    print scipy.optimize.newton(q, 5, qprime, maxiter=500)
    
    

    2008 Time Table - Link

    Welcome back for another year of evening lectures at UCL, why does the summer never feel long enough? you are just getting into it and bang back into lectures? well here are the links.

    Interesting Quantum Mechanics Resource

    Interesting links to some base, intermediate and advanced physics topics.

    Gamma

    Starting to think about whether the maths content on the course for years three and four are sufficient? Researching more and more MSc material it is clear that whilst the BSc takes us up to a level for Quantum mechincal maths, PDE's Linear algebra, there is little in the way to support future subjects like QFT? perhaps the idea is that you study these on a need to know basis later on.

    The B8 course or now Math6202 given by Gavin Esler seems to take provide a spring board for these topics.

    momentum

    Here is some great python that was used to generate the image above.

    from cmath import *
    
    g = 7
    lanczos_coef = [ \
         0.99999999999980993,
       676.5203681218851,
     -1259.1392167224028,
       771.32342877765313,
      -176.61502916214059,
        12.507343278686905,
        -0.13857109526572012,
         9.9843695780195716e-6,
         1.5056327351493116e-7]
    
    def gamma(z):
        z = complex(z)
        if z.real < 0.5:
            return pi / (sin(pi*z)*gamma(1-z))
        else:
            z -= 1
            x = lanczos_coef[0]
            for i in range(1, g+2):
                x += lanczos_coef[i]/(z+i)
            t = z + g + 0.5
            return sqrt(2*pi) * t**(z+0.5) * exp(-t) * x
    
    from pylab import *
            
    
    y = []
    x = arange(-4.5, 4.5, 0.1)
    
    for point in x:
       y.append(gamma(point))
          
    plot(x, y, 'r-')
    axis([-5, 5, -20, 25])
    title('gamma plot using lanczos approximation')
    grid(True)
    savefig('gamma.png')
    
    
    
    

    Position, Momentum and Fourier Transforms?

    Why are position and momentum the fourier transform of one another? why when we take the fourier transform of a particle in position space do we result with the particle description in momentum space? The maths answer (for those familiar with Dirac notation) is given below.

    momentum

    However what about the real physics behind this?

    Using the De Broylie relationship a particle's momentum is proportional to its angular or frequency, wave number K. This if we describe a particle as a sum of its momentum states just like in a simple histogram, where the buckets are the groupings of discrete momenta then this is analagous to performing the same histogram (frequency decomposition or fourier transform what ever you want to call it) across a sum of frequency components, where the buckets are associated with separate frequency domains. Does this mean therefore that a momentum decomposition is analagous to a fourier transform in the position space? well yes, since the frequency of each component is related to the wavelength (c = f * lambda) then the buckets in the frequency domain are proportional to the position domain in some way. So in summary the fourier transform of the position domain provides an analagous way to describe a particle in the momentum space.

    How to wrap a python script to run as a windows service.

    Use this example to wrap your scripts as windows services.

    New Python Library for profiling - pycallgraph

    Found this great new library that can generate plots like below with just a few simple extra lines in your python algorithm.

    example

    A while back I got interested in how the google search engine managed to scale it's search so well, I thought that I would investigate this by writing a simple version that would allow me to understand the mathematics behind the search. Having subsequently spent a chunk of time studying quantum mechanics I thought that it would be interesting to join the dots on some of the similarities and differences.

    Much time in quantum mechanics is spent solving problems wo find eigenvalues and eigen vectors. The quantum wave function for a system having collapsed seemly randomly into one of these we can then take measurements to qualify our preductions. Google when you search are doing something very similar, they too are locating eigenvectors in an n dimensional state space, google then uses the eigenvectors (remember the magnitude of the vector) to reank these vectors. These are then returned to you as search results.

    Finishing Exams

    Congratulations to all 3/4th students whom today have completed final exams. A special well done to Max, Andrew and Dominic who have completed the course. Well done and good luck for the future in what ever study you guy's go into next. For the rest of us, a long wait to see whether our efforts where enough followed by another 12 months, with the delights of solid state to look forward to. smile

    Exciting Scipy Extension

    Interesting library that is under development for clustering.

    * Scipy Cluster

    Quantum Computing Language

    Found these rather interesting links, whilst thinking about better ways to encapsulate some operators in python for spin seems that someone has already generated a potential solution in C++.

    Pauli Spin Matricies

    Lots of things about spin worried me, least of all the way that the model for intrinsic spin is matrix based. Also the fact that intrisinc spin happens to couple and act like angular momentum? why? How do we know that they are exactly the same? where does this intrinsic spin originate from? To this end I start to play around with spin operators and thought that I could try and understand the tensor operator. The funny thing that looks like a circle with a cross in the middle. I started with systems of single fermions and then grew to system with multiple fermions and more complex spin operators.

    I was not happy that the spin operators seemed to effect the combined spin states in ways that for say the ladder spin operators where easy to understand but for the S_{z} operators and more complex not so easy.

    Since intrinic spin can be modelled using matricies, I asked myself was it not possible to prove these operator results this using some basic matricies from first principles? well the answer is yes, it can be proved and it all fits really nicely together.

    I learnt so many things along the way here, chiefly that to couple the spin from more than one fermiion you need to find the tensor product (kron() function in python and matlab I presume) of the system of particles then apply the matrix operator to this combined state matrix. The result as show below for S_{z} operator on a two fermion spin up system results in a matrix that can be resolved (not sure what the anti process is of a tensor) into it's base states.

    example 1
    =========
    s_{z} |+1/2, +1/2> = frac{hbar}{2} ( sigma_{1z} tensor 1_{2} + 1_{1} tensor sigma_{2z} ) |+1/2, +1/2>
    [[ 1.]
     [ 0.]
     [ 0.]
     [ 0.]]
    
    

    I have included the code listing that generated this output below. Some of the more complicated structres for S^{2} are not listed here, however if you are interested I can make these available.

    More complex operators

    Using the same approach and defining spin ladder operatos in terms of the spin pauli spin matricies, it was possible to extend this model to prove some other helpful identities. The example below is based on another scipt that has a more complex spin operator. My next steps are to figure out a way to express the resultant tensor matrix as the underlying spin state combinations.

    bakera@treebeard:~/inglethorpe/pauli$ python p.py
    >>> wavefunction - |+1/2, -1/2>
    [[0]
     [1]
     [0]
     [0]]
    >>> operator - s_{1-}. S_{2+} |+1/2, -1/2>
    [[ 1.]
     [ 0.]
     [ 0.]
     [ 0.]]
    
    

    Spherical Harmonics & Other Special Orthogonal Functions

    Sometime I hate starting something, or getting interested in something, it just means that I can't put it down. Take these two examples, after some questions on spherical harmonics last week with Quantum mechanics I started thinking about plotting and wondering how to plot these in 3d without relying on power plotting functions in matlab or alike.

    The first of these links shows some basic attempts to plot the first few spherical harmonics and I was pleased with the results. The meshgrid() function that is common to both matlab and python abstracts some of the hard work although there is an outer() that does the opposite of the inner() function for vectors. One thing that took a bit to get was that the plot() functions take x,y and z co-ordinates however the spherical harmonics are easiest to generate in spherical polar coordinates. Thus transformation was required.

    Plotting a sphere in 3d is easy in spc however after thinking about it for a bit I realised that the spherical harmonics are just a modulation of the radial value for each coordinate since there is no depenence on the theta and phi. This took me longer to realise that it should have, still got there in the end.

    The next step was to leverage the special orthogonal functions that exist in the scipy.special.orthogonal package to avoid hard coding the functions (e.g. cos^2 theta -1). The second script makes use of these functions in two dimensions. Still need to merge these two scripts together. Like I said it is annoying when something gets your attention and you just keep tweeking and playing.

    y_2_0

    Portico Link

    See the link below for the UCL Student Portico website.

    Book Review - Experimental Methods: An Introduction to the Analysis and Presentation of Data

    Third year labs have been more enjoyable relative to seond year labs, I have put this down to a number of things 1) getting a poor mark last year so really wanting to do better 2) approached the problem of labs as a problem to solve 3) dedicated some real time and effort into finding a way to make analysis interesting.

    My starting point in kick starting my lab work and more specifically the write up process was purchasing the book below. Have taken some time to review how I used this book together with some of the other aspects of my approach that I felt had been more succesful.

    Examinations Timetable Yr III 2008.

    Please see below the examination timetable for year III ptphysics course. Looks like the 5 exams are nicely spread out with Quantum nicely embedded in the middle. This is so much better than last year. Quote Andrew, 'will give us a fighting chance'.

    • PHAS3224: Nuclear and Particle Physics29/Apr/200810:002 hr 30 min26EXAMJBR
    • PHAS3775: Principles and Practice of Electronics30/Apr/200810:002 hr 30 min4EXAMTV3
    • PHAS3226: Quantum Mechanics12/May/200810:002 hr 30 min30EXAMPCT
    • PHAS2224: Atomic and Molecular Physics19/May/200814:302 hr 30 min20EXAMTC2
    • PHAS2427: Environmental Physics22/May/200810:002 hr 30 min47EXAMCON

    Interesting Paper

    Found this article interesting and a good example of how quantum theory is applied today.

    UCL Phyics Past Papers

    It is getting to that time again, if like me you are wondering how to get hold of past papers, here is the answer, click on the link below. Sadly I do not have worked solutions for them all :-). Would be a great resource to build.

    2246 Single Pdf - Mathematics Notes

    Found this condenses version of the 2246 notes in one pdf that I have found useful for the quantum mechanics course, especially a refresher on eigen vectors and normalised vectors. 2246 Notes

    Advanced Quantum Mechanics - Day Time Lecture Notes

    See the link below for the complete set of day time notes from UCL level 3 Quantum Mechanics day time lectures. Also includes some useful solutions and advice on exam preparation.

    Day Time Zip

    Lectures Fox

    Thanks to Eric, great link to all sorts of interesting lectures, both video and audio in some cases, great resource.

    lecturefox

    Physics & Astronomy Past Papers (all years, all subjects)

    At great expense and at the request of Piers, I have made available the following directory for these who are interested in getting access to the Physics past papers (but can't be bothered to get access). Please treat this link with care, otherwise it might be removed. Enjoy!

    Is physics complex or just plain complicated? - Spring Term 2007

    Welcome back to all those who are are currently in the 3rd or 4th year of the Part Time BSc at UCL. Hope that you have all had a good break following a rather hectic autumn term and are looking forward to starting the new spring term. Talking to Piers before Christmas it was interesting to discover that someone else reflected some similar thoughts, that each term seems to get tougher than the last, this has been a pattern repeating we felt for at least the last four terms. Could it be that this term, the subjects find a zenith both in terms of the complexity the whole set of modules and in how complicated each individual subject becomes?

    Good luck for the new term.

    Interesting Link

    Terms Dates 2007 to 2008

    • First Term: Monday 24 September 2007 - Friday 14 December 2007 (12 weeks)
    • Second Term: Monday 7 January 2008 - Wednesday 19 March 208 (11 weeks)
    • Third Term: Monday 21 April 2008 - Friday 6 June 2008 (7 weeks)

    2007 to 2008 (Year Three) - Modules

    • 2427 - ICUC009U? - Environmental Physics
    • 2224 - ICUC008U? - Atomic and Molecular Physics
    • 3226 - ICUC016U? - Quantum Mechanics
    • 3224 - ICUC014U? - Nuclear and Particle Physics
    • 3775 - ICUC020U? - Principles and Practice of Electronics

    2007 to 2008 (Year Three) Practical Courses

    Students in the third year take the 0.5 unit 3770, Practical (Laboratory) Skills III.

    Offical Web Site

    http://www.ucl.ac.uk/phys/part-time/PTPhysics/Welcome.html

    Second Year Students

    Please register first using the link on top left and side then edit away, if you get stuck then please email the group email link, am not going to post here for fear of spammers getting access (or candace?).

    What is this for?

    This site is aimed at creating a place where we can share and promote physics thinking based around resources and problems that we have come across as part of the course. Using the power of Twiki to quickly share and build a resource for future years of students that study Physics at UCL and other Universities.

    Feel free to post something in here?

    -- AlexFiona - 17 Dec 2006

    New link to Great Python Tutorial

    http://www.alexfb.com/python1.pdf

    Web TWiki Site Map

    Use to...

    Main Home of Main web Search Main web Recent changes in the Main web Get notified of changes to the Main web Welcome to TWiki... Users, Groups, Offices - tour this expandable virtual workspace. ...get a first-hand feel for TWiki possibilities.
    TWiki Home of TWiki web Search TWiki web Recent changes in the TWiki web Get notified of changes to the TWiki web Welcome, Registration, and other StartingPoints; TWiki history & Wiki style; All the docs... ...discover TWiki details, and how to start your own site.
    Centella Home of Centella web Search Centella web Recent changes in the Centella web Get notified of changes to the Centella web ...collaborate on
    FamilyBaker Home of <span class=FamilyBaker? web" width="16" height="16" border="0"> Search <span class=FamilyBaker? web" width="16" height="16" border="0"> Recent changes in the <span class=FamilyBaker? web" width="16" height="16" border="0"> Get notified of changes to the <span class=FamilyBaker? web" width="16" height="16" border="0"> ... collaborate on family baker ... ...collaborate on
    PtPhysics Home of <span class=PtPhysics? web" width="16" height="16" border="0"> Search <span class=PtPhysics? web" width="16" height="16" border="0"> Recent changes in the <span class=PtPhysics? web" width="16" height="16" border="0"> Get notified of changes to the <span class=PtPhysics? web" width="16" height="16" border="0"> collaborate site for Part Time Physics students at UCL ...collaborate on physics
    RMatrix Home of RMatrix web Search RMatrix web Recent changes in the RMatrix web Get notified of changes to the RMatrix web ...collaborate on r-matrix techniques
    Sandbox Home of Sandbox web Search Sandbox web Recent changes in the Sandbox web Get notified of changes to the Sandbox web Sandbox test area with all features enabled. ...experiment in an unrestricted hands-on web.
    Support Home of Support web Search Support web Recent changes in the Support web Get notified of changes to the Support web Twiki relating to applications and support questions ...collaborate on
    Ubuntu Home of Ubuntu web Search Ubuntu web Recent changes in the Ubuntu web Get notified of changes to the Ubuntu web ...collaborate on ubuntu
    You can use color coding by web for identification and reference. This table is updated automatically based on WebPreferences settings of the individual webs. Contact webmaster@alexfb.com if you need a separate collaboration web for your team. See also AdminTools.
    Legend of icons:  

    Home of web = Go to the home of the web
    Search web = Search the web

      Recent changes in the web = See recent changes in the web
    Get notified of changes to the web = Subscribe to get notified of changes by e-mail

    TWiki.TWiki Web:

    Notes:

    • You are currently in the PtPhysics web. The color code for this web is this background, so you know where you are.
    • If you are not familiar with the TWiki collaboration platform, please visit WelcomeGuest first.

    This site has been created to promote collaboration around the Part time Physics course held at UCL. We already use a mail group but wanted a richer level of sharing. Please feel free to post content and fill in and extend the site where you see fit.

    The menus and options on the left have been created but have been left unedited for now, please feel free to extend and share these links.

    New link to Great Python Tutorial

    http://www.alexfb.com/python1.pdf

    Terms Dates 2007 to 2008

    • First Term: Monday 24 September 2007 - Friday 14 December 2007 (12 weeks)
    • Second Term: Monday 7 January 2008 - Wednesday 19 March 208 (11 weeks)
    • Third Term: Monday 21 April 2008 - Friday 6 June 2008 (7 weeks)

    2007 to 2008 (Year Three) - Modules

    • 2427 - ICUC009U? - Environmental Physics
    • 2224 - ICUC008U? - Atomic and Molecular Physics
    • 3226 - ICUC016U? - Quantum Mechanics
    • 3224 - ICUC014U? - Nuclear and Particle Physics
    • 3775 - ICUC020U? - Principles and Practice of Electronics

    2007 to 2008 (Year Three) Practical Courses

    Students in the third year take the 0.5 unit 3770, Practical (Laboratory) Skills III.

    Offical Web Site

    http://www.ucl.ac.uk/phys/part-time/PTPhysics/Welcome.html

    Second Year Students

    Please register first using the link on top left and side then edit away, if you get stuck then please email the group email link, am not going to post here for fear of spammers getting access (or candace?).

    What is this for?

    This site is aimed at creating a place where we can share and promote physics thinking based around resources and problems that we have come across as part of the course. Using the power of Twiki to quickly share and build a resource for future years of students that study Physics at UCL and other Universities.

    Feel free to p

    Topic attachments
    I Attachment Action Size Date Who Comment
    elsepng snapshot.png manage 61.7 K 16 Jul 2011 - 21:34 AlexFiona  
    elsepng snapshot0.png manage 26.5 K 16 Jul 2011 - 21:28 AlexFiona a = 3 nx = 2, ny = 3
    elsepng snapshot2.png manage 55.8 K 16 Jul 2011 - 21:30 AlexFiona  
    elsepng snapshot3.png manage 78.8 K 16 Jul 2011 - 21:31 AlexFiona  
    elsepng snapshot4.png manage 60.4 K 16 Jul 2011 - 21:31 AlexFiona  
    elsepng snapshot5.png manage 70.3 K 16 Jul 2011 - 21:40 AlexFiona  
    Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r47 < r46 < r45 < r44 < r43 | More topic actions
     
    Home
    Copyright © 1999-2014 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
    Ideas, requests, problems regarding TWiki? Send feedback