DOC PREVIEW
DREXEL PHYS 113 - rec7

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

PHYSICS 113 – Recitation Assignment 7NameRecitation Assignment # 7Nov. 8, 2006You may complete this in class. However, if you are unable to do so, it is expected that youcomplete this for recitation next time.Where a box appears, call over Travis to check over your progress. When the sheet is complete,you will hand it in. Also, you are expected to email your final programs to Travis.For today’s assignment, we’ll do a little i/o (input and output for the uninitiated). There are twocommands that you’ll need:The first is the “input” command, which allows the user to enter data.m1=input("What is the mass of the first block? (in kg)")This is very useful if you want to be able to set the initial conditions in your code “by hand.”The second is the “print” statement, which allows the code to print out numbers to the terminal(NOT the display window).print "T1=",T1In this case, we’re printing out a text string “T1=”, and printing the variable called T1.Assignment: Thermal EquilibriumIn class, we discussed how to solve for thermal equilibrium between two solids if we know the initialmasses, temperatures, and specific heats of each of them. Sometimes, though, it is helpful to havea computer to solve problems for you. This should not be a substitute for doing simple problemswith Pen and Paper. We will simply use a new numerical method, called relaxation to computethe equilibrium temperature of two solids.This code is deceptively simple. Mine is only 25 lines long. Still, you’ll need to keep on your toes.1. Put the normal header in the code, ask the user to enter the following quantities: 1) Mass ofthe first block (in kg), 2) Temperature of the first block (in c), 3) Specific Heat of the firstblock (in J/kg/K)?, 4),5), and 6) should be the same but for the second block.2.2 In order to add a graphical component, set up a scene with the following commands:scene.range=(2,T1+T2,2)scene.autoscale=0Then create two “boxes” called block1 and block2. The lengths and widths of both shouldbe 1, and the heights should be the same as the temperature. If you can figure out how todo it, make the bottom of the boxes level with one another. The boxes should be differentcolors, and sitting right next to each other.3. Now comes the loop part. Create a loop which says:while (abs(T1-T2) > 0.1):This is very different than what you normally do when you write a “while” loop. Normally,we’re imagining a movie wherein each step represents a frame of the movie. Here, each steprepresents an “iteration” – a ste p closer to reaching the correct solution.Set rate(2), and at each timestep, alter the temperature of the two blocks. How?Well, the cooler one should be raised in temperature, the hotter one should be lowered. Ihave found the following relations useful:δT1=(T2− T1)20δT2=(T1− T2)20These are NOT the actual changes in temperature, only a first guess. Note, though, that ifthe temperatures were already the same, that the changes would be zero. This is preciselythe relation we want.How much heat would be transferred in the cases of these temperature differences?δQ1= C1m1δT1δQ2= C2m2δT2Now, here’s the important part – energy is preserved, and thus the total heat flowing intoblock 1 is just:Q1= (δQ1− δQ2)And the negative of that for block 2.The change in temperature for this “iteration” is simply:∆T1=Q1m1C1and similarly for block 2. Us e this to update your estimate of the temperature of each block.4. It is a pain to keep typing in all 6 values. So try the following. Create a file (call it “prog7.in”for example), with 1 number on each line, e ach corresponding to the input. Then when yourun the program, you can simply type:python prog7.py < prog7.inThis is an example of an input stream, and makes things MUCH easier.5.2 At each step in the integration, update the images of the blocks so that the heights representthe current tem perature. When they reach equilibrium, they should be the sam e height.6. After the completion of the loop, print out the temperature of each block.7.2 Do problem 5.8 in your textbook using your


View Full Document

DREXEL PHYS 113 - rec7

Download rec7
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view rec7 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view rec7 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?