Unformatted text preview:

6.01, Fall Semester, 2007—Assignment 7, Issued: Tuesday, Oct. 16 1MASSACHVSETTS INSTITVTE OF TECHNOLOGYDepartment of Electrical Engineering and Computer Science6.01—Introduction to EECS IFall Semester, 2007Assignment 7, Issued: Tuesday, Oct. 16To do this week...in Tuesday software lab1. Start writing code and test cases for the numbered questions in the software lab. Paste allyour code, including your test cases, into the box provided in the “Software Lab” (Part 7.1)problem on the on-line tutor. This will not be graded....before the start of lab on Thursday1. Read the lecture notes.2. Complete the Tuesday software lab (Questions 1-14) to hand i n Thursday in lab.3. Read through the entire description of Thursday’s lab....in Thursday lab1. Answer the numbered questions (Questions 15-29) in the circuit lab and demonstrate themto your LA.2. Do the nanoquiz; it will be based on the material in the lecture notes and the on-line tutorproblems due on Thursday....before the start of lecture next Tuesday1. Do the lab writeup, providing written answers (including code and test cases) for Questions15-29 in this handout.6.01, Fall Semester, 2007—Assignment 7, Issued: Tuesday, Oct. 16 2On Athena machines make sure you do:athrun 6.01 updateso that you can get the Desktop/6.01/lab7 directory which has the files mentioned in thishandout.• You need the file resolveConstraints.py, example.py, circuit.py, circuit2.py forthe software lab.• You need the files circuitConstraints.py, circuitt.py, circuit2t.py, circuitLine.py,circuitG.py, genGrid.py, genKcl.py for the circuit lab.During software lab, if you are using your own laptop, download the files from the courseWeb site (on the Calendar page). Be sure you have numpy installed.6.01, Fall Semester, 2007—Assignment 7, Issued: Tuesday, Oct. 16 3The constraints view of circuitsIn this software lab you will learn about resistor networks as constraint systems, then build a toolthat makes it easy to solve for the voltages in a circuit layout.Tuesday Software Lab: Circuit ConstraintsYou will be downloading and using resolveConstraints.py, which contains programs for creatinglists of constraints and their associated variables, and then once the list of constraints and variableshas been generated, determining values for the variables so that the constraints are satisfied. Inparticular, a user must first create an instance of the class ConstraintSet. Then the user in-vokes ConstraintSet’s method addConstraint multiple times, once for each of the constraints.The method addConstraint appends a constraint and the constraint’s associated variables to theinstance. The instance’s method getConstraintEvaluationFunction returns a function that eval-uates how well a supplied set of numerical values for all the instance’s variables satisfies all theinstance’s constraints. By calling the function resolveConstraints with this evaluation function,numerical values are determined for the all the instance variables so that all the constraints are sat-isfied. These constraint-satisfying values of the variables can be printed by calling ConstraintSet’smethod display.There are two arguments to the function addConstraint. The first argument is a constraintevaluation procedure that takes a list of numerical values for the particular constraint’s variablesand returns a floating point number that indicates how far the constraint is from being satisfied.The constraint evaluation procedure should return zero if the constraint is exactly satisfied. Thesecond argument to addConstraint is a list of strings that are labels for the variables used in theconstraint. The order of these variable labels is important. The order of the labels should matchthe order of numerical values in the list used by the constraint evaluation procedure.As an example, consider the problem of finding values for x and y which satisfy the two constraints5 ∗ v − 2 ∗ y − 3 = 0and3 ∗ v + 4 ∗ y − 33 = 0.Of course, v = 3 and y = 6 satisfy the above two constraints.To use the constraint class and the function resolveConstraints to find the constraint-satisfyingvalues of v and y, first define the two constraint evaluation procedures:def firstEqn():# Enforces 5*v - 2*y - 3 = 0, assumes the input is [v,y]return lambda x : 5.0*x[0] - 2.0*x[1] - 3.0def secondEqn():# Enforces 3*v + 4*y - 33 = 0, assumes the input is [y,v]return lambda x : 3.0*x[1] + 4.0*x[0] - 33.0Second, create an instance of ConstraintSet and add the two constraints, being careful to providevariable labels in the same order as used in the constraint procedures:6.01, Fall Semester, 2007—Assignment 7, Issued: Tuesday, Oct. 16 4linSys = ConstraintSet()linSys.addConstraint(firstEqn(),[’v’, ’y’])linSys.addConstraint(secondEqn(),[’y’, ’v’])Finally, call resolveConstraints and display the solution:solution = resolveConstraints(linSys.getConstraintEvaluationFunction())linSys.display(solution)In order to use resolveConstraints for circuit problems, one needs an organized approach forgenerating the variables and constraints for a circuit. In class we discussed the nodal approach foraccomplishing this task. The steps in the nodal approach were1. Label all the circuit node voltages and element currents (noting direction), and select areference (ground) node.2. For each element, write constitutive equations that relate the element’s currents to the volt-ages at the element’s terminals.3. For each circuit node, except the reference node, write a conservation law, also known incircuit analysis as Kirchoff’s current law (KCL). That is, insist that the sum of currentsentering a node should be equal to the sum of currents leaving a node.In order to use the constraint resolver to solve circuit problems, it is helpful to have functionswhich return constraint procedures associated with a circuit’s constitutive equations and conser-vation laws. In the file circuitConstraints.py, you will find functions for generating proceduresthat implement circuit related constraints. Consider two of these procedure generating procedures:resistor and vsrc. These two functions return procedures that implement the constraints asso-ciated with the the constitutive relations of a resistor and a voltage source, respectively. To betterunderstand the resistor function, recall that if a current i1,2is flowing from n1to n2through anR-ohm resistor, then vn1, vn2and i1,2must satisfy the constraintvn1− vn2− Ri1,2= 0 .Note that


View Full Document

MIT 6 01 - Assignment - 6.01

Documents in this Course
Week 1

Week 1

3 pages

Op-Amps

Op-Amps

8 pages

Op-Amps

Op-Amps

6 pages

Syllabus

Syllabus

14 pages

Planning

Planning

14 pages

Load more
Download Assignment - 6.01
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 Assignment - 6.01 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 Assignment - 6.01 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?