Lab12b - # Calculate number of ways to arrange q1 quanta in...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
from __future__ import division from visual.factorial import * from visual.graph import * log1graph = gcurve(color=color.red) log2graph = gcurve(color=color.cyan) loggraph = gcurve(color=color.yellow) Ntotal = 500 # total number of oscillators N1 = 300 # number of oscillators in object 1 N2 = Ntotal-N1 # number of oscillators in object 2 qtotal = 100 # quanta of energy shared among all the oscillators q1 = 0 # start with no energy in object 1 while q1 <= qtotal: q2 = qtotal-q1 # number of quanta of energy in object 2
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: # Calculate number of ways to arrange q1 quanta in object 1: ways1 =combin(q1+N1-1,q1) # Calculate number of ways to arrange q2 quanta in object 2: ways2 =combin(q2+N2-1,q2) # Plot number of ways to arrange energy in the two objects: # Now plot the logarithms ("log" in Python is natural logarithm): log1graph.plot( pos=(q1,log(ways1)) ) log2graph.plot( pos=(q1,log(ways2)) ) loggraph.plot( pos=(q1,log(ways1*ways2)) ) q1 = q1+1...
View Full Document

This note was uploaded on 01/28/2012 for the course PY 205M taught by Professor Brown during the Spring '08 term at N.C. State.

Ask a homework question - tutors are online