6 01 Fall Semester 2007 Assignment 7 Issued Tuesday Oct 16 1 MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6 01 Introduction to EECS I Fall Semester 2007 Assignment 7 Issued Tuesday Oct 16 To do this week in Tuesday software lab 1 Start writing code and test cases for the numbered questions in the software lab Paste all your 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 Thursday 1 Read the lecture notes 2 Complete the Tuesday software lab Questions 1 14 to hand in Thursday in lab 3 Read through the entire description of Thursday s lab in Thursday lab 1 Answer the numbered questions Questions 15 29 in the circuit lab and demonstrate them to your LA 2 Do the nanoquiz it will be based on the material in the lecture notes and the on line tutor problems due on Thursday before the start of lecture next Tuesday 1 Do the lab writeup providing written answers including code and test cases for Questions 15 29 in this handout 6 01 Fall Semester 2007 Assignment 7 Issued Tuesday Oct 16 On Athena machines make sure you do athrun 6 01 update so that you can get the Desktop 6 01 lab7 directory which has the files mentioned in this handout You need the file resolveConstraints py example py circuit py circuit2 py for the 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 course Web site on the Calendar page Be sure you have numpy installed 2 6 01 Fall Semester 2007 Assignment 7 Issued Tuesday Oct 16 3 The constraints view of circuits In this software lab you will learn about resistor networks as constraint systems then build a tool that makes it easy to solve for the voltages in a circuit layout Tuesday Software Lab Circuit Constraints You will be downloading and using resolveConstraints py which contains programs for creating lists of constraints and their associated variables and then once the list of constraints and variables has been generated determining values for the variables so that the constraints are satisfied In particular a user must first create an instance of the class ConstraintSet Then the user invokes 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 the instance The instance s method getConstraintEvaluationFunction returns a function that evaluates how well a supplied set of numerical values for all the instance s variables satisfies all the instance 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 satisfied These constraint satisfying values of the variables can be printed by calling ConstraintSet s method display There are two arguments to the function addConstraint The first argument is a constraint evaluation procedure that takes a list of numerical values for the particular constraint s variables and 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 The second argument to addConstraint is a list of strings that are labels for the variables used in the constraint The order of these variable labels is important The order of the labels should match the 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 constraints 5 v 2 y 3 0 and 3 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 satisfying values 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 0 def 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 0 Second create an instance of ConstraintSet and add the two constraints being careful to provide variable labels in the same order as used in the constraint procedures 6 01 Fall Semester 2007 Assignment 7 Issued Tuesday Oct 16 4 linSys 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 for generating the variables and constraints for a circuit In class we discussed the nodal approach for accomplishing this task The steps in the nodal approach were 1 Label all the circuit node voltages and element currents noting direction and select a reference ground node 2 For each element write constitutive equations that relate the element s currents to the voltages at the element s terminals 3 For each circuit node except the reference node write a conservation law also known in circuit analysis as Kirchoff s current law KCL That is insist that the sum of currents entering 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 functions which return constraint procedures associated with a circuit s constitutive equations and conservation laws In the file circuitConstraints py you will find functions for generating procedures that implement circuit related constraints Consider two of these procedure generating procedures resistor and vsrc These two functions return procedures that implement the constraints associated with the the constitutive relations of a resistor and a voltage source respectively To better understand the resistor function recall that if a current i1 2 is flowing from n1 to n2 through an R ohm resistor then vn1 vn2 and i1 2 must satisfy the constraint vn1 vn2 Ri1 2 0 Note that the way we have defined the constraint if vn1 vn2 then i1 2 0 and current is flowing from n1 to n2 If vn1 vn2 then i1 2 0 and even though i1 2 is still defined as the current flowing from n1 to n2 the physical current is really flowing from n2 to
View Full Document