Lab 12 VPython

Lab 12 VPython - q1 = 0 # start with no energy in object 1...

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 * g = gdisplay(title='Temperature vs. # of quanta', xtitle = 'q1', ytitle = 'T') T1graph = gcurve(color=color.red) T2graph = gcurve(color=color.cyan) 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 k = 1.4e-23 hbar = 1.05e-34 ks = 16*4 # aluminum; factor of 4 comes from 2 springs per oscillator, each 1/2 as long m = 4.484e-26 # figure this out: 1 mole of Al has a mass of 27 grams deltaE1 = hbar*sqrt(ks/m) # figure this out: energy of one quantum (in joules) deltaE2 = -hbar*sqrt(ks/m) # note that when energy is added to object 1, it is subtracted from 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: q1 = 0 # start with no energy in object 1 while q1 < qtotal: # For each delta_S you need two values of S # so use q1, and (q1+1)=q1a (and appropriate values of q2, q2a) # Calculate ways to arrange energy as in previous program: q2 = qtotal-q1 q1a = q1+1 q2a = qtotal-q1a ways1 = combin(q1+N1-1,q1) ways2 = combin(q2+N2-1,q2) ways1a = combin(q1a+N1-1,q1a) ways2a = combin(q2a+N2-1,q2a) ways = ways1*ways2 waysa = ways1a*ways2a S1 = k*log(ways1) S1a = k*log(ways1a) S2 = k*log(ways2) S2a = k*log(ways2a) deltaS1 = S1a-S1 deltaS2 = S2a-S2 T1 = deltaE1/deltaS1 # note that (1/T) = (deltaS/deltaE) T2 = deltaE2/deltaS2 T1graph.plot(pos=(q1,T1)) T2graph.plot(pos=(q1,T2)) q1 = q1+1...
View Full Document

Ask a homework question - tutors are online