homework7-tgodara

# Homework7-tgodara - ECE 1574 Homework Set#7 Tanuj Godara 905279307 LAB EXERCISE In good C style write a program which by a Monte Carlo technique

This preview shows pages 1–3. Sign up to view the full content.

ECE 1574 Homework Set #7 Tanuj Godara 905279307 LAB EXERCISE In good C++ style, write a program which by a Monte Carlo technique estimates the reliability of the electrical circuit represented schematically below. ------2 ohms---- ----3 ohms----- | | | | | | | | --- ---- ---- | | | | | | | | | | | | | ------4 ohms---- -----6 ohms---- | | | 100 volts 10 - 20 ohms | | | | ___ ___ - - In the circuit, there are a 100-volt DC source, a 2-ohm resistor in parallel with a 4-ohm resistor, and then a 3-ohm resistor in parallel with a 6-ohm resistor. The circuit is terminated in a load whose value varies randomly between 10 and 20 ohms. REQUIREMENTS 1. Using a flat logarithmic distribution values for the load [that is, a distribution in which any value in the domain from ln(10 ohms) to ln(20 ohms) is equally likely], let your program solve the circuit 100,000 times, counting the number of times the voltage across the load falls below 77.5 volts. (You may use one or more C++ vectors or arrays in your code if you wish, but this is not required.) 2. Implement operations by function calls wherever reasonable to do so. For instance, implement the parallel combination of 2 and 4 ohms by a function call. 3. Let your program calculate the average across the 100,000 trials of (a) the total power delivered by the source and (b) the power disspated by each resistor, including the load. 4. Let your program output three numbers on separate lines: first, the number of times the voltage across the load falls below 77.5 volts; second, the average power delivered by the source over the 100,000 trials; and, third, the average power dissipated by each resistors over the 100,000 trials.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Seed the computer’s random-number generator with the integer 569. QUESTIONS 1. Submit complete source code and output for the lab exercise given above. #include <iostream> #include <cmath> #include <vector> #include <cstdlib> using namespace std; double parallelcomb( double r1, double r2) { double paratot; paratot = (1/r1) + (1/r2); paratot = 1/paratot; return paratot; } double genrand() { return double (rand())/RAND_MAX; } void main() { srand(569); double volt, res1, res2, res3, res4, genres, vdrop1, vdrop2, totres; double count = 0;
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/14/2010 for the course COMM 2064 taught by Professor Jimkuypers during the Spring '08 term at Virginia Tech.

### Page1 / 8

Homework7-tgodara - ECE 1574 Homework Set#7 Tanuj Godara 905279307 LAB EXERCISE In good C style write a program which by a Monte Carlo technique

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online