report代做 | 代写Network | network | bash代做 | mining | shell | oop作业 | project | assignment作业 | lab – 13 | Circuit Solver

13 | Circuit Solver

math代写 | report代做 | 代写Network | network | bash代做 | mining | shell | oop作业 | project | assignment作业 | lab – 该题目是一个常规的Network的练习题目代写, 是比较典型的report/Network/network/bash/mining/shell/oop等代写方向, 这个项目是lab代写的代写题目

lab代写 代写lab


  • Show understanding of l oop invariants
  • Show understanding of calculating the rough (Big O) worst-case complexity of your code.

13.1 Motivation

Looking at the applications of numerical methods in an engineering context, using computers to solve large linear systems link in lab 11 can be used for:

  • Steady-State Analysis of Chemical Reactors
  • Statics Solutions of Large Structures
  • Current and Voltage Prediction of Electrical Circuits
  • Spring-Mass Modeling of Structural Dynamics

And more! While as aerospace engineers you are most likely interested in the structural statics and dynamics solutions, here we present an exercise in resistor network solutions as the governing dynamics are simpler providing a chance to focus on the code rather then the problem domain, but this code is easily adapted to other (potentially more relevant) domains.

13.1.1 Circuit Representation

We will use a CSV format for representing the circuit to be solved. Consider first the circuit in Figure 13.1. It is a resistor network to be solved, and your program should be able to read the corresponding csv form of this circuit.

Figure 13.1: A resistor circuit to be solved.
The CSV representing the circuit in Figure 13.1 is shown as follow.

Type | Node 1 | Node 2 | Value

V,6,1, R,1,2, R,2,3, R,3,4, R,4,5, R,2,5, R,5,6,

Your program should compute all current values for the given circuit..
Figure 13.2: Assumed current.

The output of your circuit solver is also a CSV file, in which all current values should be listed. An example of the output of your solver for the above circuit would be:

Type | Node 1 | Node 2 | Value

V,6,1, I,1,2,6. I,2,3,-1. I,4,3,-1. I,5,4,-1. I,5,2,-4. I,6,5,-6.

Not that the direction matters and current is assumed to flow from node 1 to node 2 so for current flowing against that direction it should be negative, as shown above.

We explain shortly how to compute the current values in Figure 13.2. A common problem in electrical engineering involves deter mining the currents and voltages at various locations in resistor circuits. These problems are solved using Kirchhoffs current and voltage rules. The current (or point) rule states that the algebraic sum of all currents entering a node must be zero, or

i= 0 where all current entering the node is considered positive in sign. The current rule is an application of the principle of conservation of charge. The voltage (or loop) rule specifies that the algebraic sum of the potential differences (that is, voltage changes) in any loop must equal zero. For a resistor circuit, this is expressed as

(iR) = 0 whereis the emf (electromotive force) of the voltage sources,iis the current at a given resistor and R is the resistance of the same resistors on the loop. Kirchhoffs voltage rule is an expression of the conservation of energy.

Given the assumptions in Figure 13.2, Kirchhoffs current rule is applied at each node to yield

i 12 +i 52 +i 32 = 0 i 65 i 52 i 54 = 0 i 43 i 32 = 0 i 54 i 43 = 0 Application of the voltage rule to each of the two loops gives i 54 R 54 i 43 R 43 i 32 R 32 +i 52 R 52 = 0 i 65 R 65 i 52 R 52 i 12 R 12 200 = 0 or, substituting the resistances from Figure 13.1 and bringing constants to the right-hand side,

15 i 54 5 i 43 10 i 32 + 10i 52 = 0 20 i 65 10 i 52 5 i 12 200 = 0 Therefore, the problem amounts to solving the following set of six equations with six unknown currents: 1 1 1 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0 1 1 0 10 10 0 15 5 5 10 0 20 0 0

i 12
i 32
i 65
i 54
i 43

Although impractical to solve by hand, this system is easily handled using an elimination method. Proceeding in this manner, the solution is

i 12 = 6. 1538 , i 52 = 4. 6154 ,i 32 = 1. 5385
i 65 = 6. 1538 , i 54 = 1. 5385 ,i 43 = 1. 5385

13.2 Project

The assignment is to produce a project that takes in a CSV file defining a resistor network and outputs a CSV file detailing the currents in that network. Several simplifications will be in-place as detailed in this section.

13.2.1 Solving

You may use any numerical method of solving the linear system you choose. Compute all answers with double precision. In your report, detail the weaknesses of the method you choose (sources or error, time complexity, etc.)

In a realistic setting, you would be required to identify the loops of the circuit yourself. However, since this problem is both well studied and yet difficult to properly implement your input file will be annotated with the loops labeled to assist in creation of the voltage law equations.

Also, assume only one voltage source (i.e. there will be 2 nodes with a “V” label and they can be assumed to be the 2 terminals of a battery or power-supply for purposes of solving the circuit.) See the above worked example for how this is applied in practice.

13.2.2 Input

A CSV file defining 2 voltage nodes and a number of resistors with values indicating resis- tance and the listed order indicating the “positive” direction of current flow through that edge. Therefore current flowing against that direction is “negative” like in the worked ex- ample.

Also a number of rows indicating the loops for the voltage law will be included at the end of the file. As an example, the two loops from the above problem would be indicated by:

L,2,3,4, L,1,2,5,

Where the end is assumed connected to the beginning node.

13.2.3 Output

The output should be a near copy of the input with the types changed from resistance (in the form “R”) to current with 4 decimal places (in the form “I” with a value of the form “X.XXXX”) and preservation of the loop rows optional. This output should be saved to a file as directed in the grading section.

13.2.4 Grading

The auto-grader will generate a CSV file that matches the requirements of this lab and run the binary in the top level of the lab repository calledkirchhoff_solvewith the path to the file as the only command-line argument.

This file can either be a C program that does all the work, or a shell 代做 script代写”> bash script that does any required pre-processing, building of the C program and output formatting if desired. The bash-script methods allows you to harness the powerful shell tools used in the first few labs to reduce the amount of string parsing needed in your C code.

Note: Even if you program the entire exercise in C, thekirchhoff_solvescript should be present to build (if necessary) and run your program. The auto grade will execute ./kirchhoff_solve ./path/to/input.dotin your lab directory regardless of your chosen approach.Please verify this with a TA if you are unclear.

After running, the auto-grader will check the lab repository for a file calledans.csvthat replaces the resistance values in the input file with the current values computed by your code.

13.2.5 Turning it all in

When complete, submit the assignment by committing your develop branch, pushing it to GitHub and opening a Pull Request on the site. Make sure to include your report and any required files along with thekirchhoff_solvescript.