Sale!

ECSE597/ECSE472 Assignment 1 to 4 Solutions

Original price was: $90.00.Current price is: $80.00.

Download Details:

  • Name: Assignment1-2vxs8o.zip
  • Type: zip
  • Size: 1.70 MB

  • Name: Assignment3-4xwahw.zip
  • Type: zip
  • Size: 1.57 MB

  • Name: Assignment4.zip
  • Type: zip
  • Size: 740.72 KB

Category:

Description

5/5 - (1 vote)

ECSE597/ECSE472
Assignment #1

Question 1. Add the stamps for the following elements in functions named makeGmatrix.m,
makeCmatrix.m, and makeBvect.m
a. Resistor (already Implemented)
b. Capacitor
c. Inductor
d. Voltage Source (already Implemented for DC voltage sources)
e. Current Source
f. Voltage Controlled Voltage Source
g. Voltage Controlled Current Source
h. Current Controlled Current Source
i. Mutual Inductor
j. Ideal opamp

Question 2. Write a frequency analysis function named fsolve.m.
Run all test bench functions provided to test your simulator.
Deliverables:
1. Submit all your code in a zip file.
2. Submit a PDF file containing your results for all testbench functions.

 

ECSE 597
Assignment #3

 

Question I: Backward Euler (5marks)

Write a function called BE_method.m with the following header:
function [tpoins,y]= BE_method(tEnd,h, outNode)
% This function uses BACKWARD EULER method to compute the transient reponse
% of the circuit.
%Inputs: 1. tEnd: The simulation starts at time = 0s and ends at time =
% tEND s.
% 2. h: length of step size.

% 3. outNode: is the node for which the transient is required.
%Output: 1. tpoints are the time points. 2. y: is the transient response at output
node.
Your function should use Backward Euler with a constant step size to compute the transient
response of a linear circuit.

1. Test your function by running the provided Testbench_q1.m file. This file simulates the
netlists Circuit_chebychev_filter_TD.m (it has time domain sources) and
Circuit_chebychev_filter_freq.m (it has frequency domain sources) in the frequency
domain using your fsolve.m function which you developed in past assignments. In your
submission, include the codefor the new function BE_method.m as well as the output plot
of the testbench function.
2. Explain the relation between the two plots in the output figure.

Question II Trapezoidal Rule(5marks)

Write a function Trapezoidal_method.m with the following header:
function [tpoints,y]= Trapezoidal_method(tEnd,h, outNode)
% This function uses Trapezoidal method to compute the transient reponse
% of the circuit.
%Inputs: 1. tEnd: The simulation starts at time = 0s and ends at
% time = tEND s.
% 2. h: length of step size.

% 3. outNode: is the node for which the transient is required.
%Output: 1. tpoints are the time points. 2.y: is the transient response at output
Node.
Your function should use Trapezoidal Rule with a constant step size to compute the transient
response of a linear circuit.
1. Test your function by running the provided Testbench_q2.m file. This script alsoruns your
code from Question 1 and compares BE to TR. In your submission, provide the codefor the
function you wrote as well as the plot from the test bench.
2. By examining the plot, what can you deduce about the BE and TR methods?

Question III Forward Euler(5marks)

Write a function FE_method.m with the following header:
function [tpoints,y]= FE_method(tEnd,h, outNode)
% This function uses FORWARD EULER method to compute the transient reponse
% of the circuit.
%Inputs: 1. tEnd: The simulation starts at time = 0s and ends at
% time = tEND s.
% 2. h: length of step size.

% 3. outNode: is the node for which the transient is required.
%Output: 1. tpoints are the time points. 2.y: is the transient response at outNode.
Your function should use the Forward Euler method with a constant step size to compute the
transient response of a linear circuit. You may assume that the C matrix of your MNA is
invertible for the purposes of this assignment.
To test your code, run the provided test bench script Testbench_q3.m which simulates the circuit
in the provided netlist Q3BEcircuit.m.

1. Examine and comment on your observations from the output files.
2. It can be shown that, when the C matrix is invertible, the poles of the circuit are the
eigenvalues of the matrix −ðķ
−1𝐚 (note the negative sign). Determine the stability
condition of the Forward euler method for this circuit and experimentally verify your
results by running simulations (note the eig function in matlab computes the
eigenvalues of a matrix).

Question IV Sensitivity using Perturbation method (3marks)

Write a function named sens_perturbation_method.m to compute the sensitivity of output voltage
with respect to all the resistive and capacitive elements in the circuit using perturbance method
(alternatively called difference method). Choose an appropriate value of the perturbance. Your
function must compute the absolute and relative sensitivity of output with respect to all
parameters at all frequency points.

The function stub is provided below.
function [D,S] = sens_perturbation_method(fpoints,eleNames,outNode)
% This function uses DIFFERENCE method to compute the sensitivity of the
% output node with respect to all the parameters.
%Inputs: 1. fpoints: contains the frequency points at which the sensitivity is
% is required.

% 2. eleNames: is a cell array contains the names of the elements.
% 3. outNode: is the node for which the sensitivity is required.
%Output: 1.D: is a matrix. It should contain the ABSOLUTE sensitivity of the
% outNode at all fpoints for all elements.
% One way to fill store senstivity in D is to add sensitivity of
% a given element in one column of D for all fpoints.

% In this case if there are F number of frequency points and
% P number of elements in eleNames, then the size of matrix D
% will be FxP.
% 2. S: is matrix. It should contain the RELATIVE sensitivity of
% outNode for all the elements in eleNames. It can be filled
% similar to matrix D.
Note: You do not have to adhere to the function stub provided above. You have the freedom to
modify the function as per your preference.

Question V Sensitivity using the Differentiation method (3marks)

Write a function named sens_differentiation_methood.m. Your function should compute the sensitivity of
output voltage for all the resistors and capacitors in the circuit using differentiation method. Your function
must compute the absolute and relative sensitivity of output with respect to all parameters at all frequency
points. The function stub is provided below.
function [D,S] = sens_differentiation_method(fpoints,eleNames,outNode)
% This function uses the DIFFERENTIATION method to compute the sensitivity of the
% output node with respect to all the parameters.

%Inputs: 1. fpoints: contains the frequency points at which the sensitivity is
% is required.
% 2. eleNames: is a cell array contains the names of the elements.
% 3. outNode: is the node for which the sensitivity is required.
%Output: 1.D: is a matrix. It should contain the ABSOLUTE sensitivity of the
% outNode at all fpoints for all elements.

% One way to fill store senstivity in D is to add sensitivity of
% a given element in one column of D for all fpoints.
% In this case if there are F number of frequency points and
% P number of elements in eleNames, then the size of matrix D
% will be F x P.

% 2. S: is matrix. It should contain the RELATIVE sensitivity of
% outNode for all the elements in eleNames. It can be filled
% similar to matrix D.
Note: You do not have to adhere to the function stub provided above. You have the freedom to
modify the function as per your preference.

Question VI Sensitivity using the Adjoint method (3 marks)

Write a function sens_adjoint_methood.m to compute the sensitivity of output voltage for all the resistors
and capacitors in the circuit using the adjoint method. Your function should evaluate the absolute and
relative sensitivity of output with respect to all parameters at all frequency points. The function stub is
provided below.

function [D,S] = sens_adjoint_method(fpoints,eleNames,outNode)
% This function uses the ADJOINT method to compute the sensitivity of the
% output node with respect to all the parameters.
%Inputs: 1. fpoints: contains the frequency points at which the sensitivity is
% is required.

% 2. eleNames: is a cell array contains the names of the elements.
% 3. outNode: is the node for which the sensitivity is required.
%Output: 1.D: is a matrix. It should contain the ABSOLUTE sensitivity of the
% outNode at all fpoints for all elements.

% One way to fill store sensitivity in D is to add sensitivity of
% a given element in one column of D for all fpoints.
% In this case if there are F number of frequency points and
% P number of elements in eleNames, then the size of matrix D
% will be F x P.

% 2. S: is matrix. It should contain the RELATIVE sensitivity of
% outNode for all the elements in eleNames. It can be filled
% similar to matrix D.
Note: You do not have to adhere to the function stub provided above. You have the freedom to
modify the function as per your preference.

Question VII (6 marks)

Test the functions written in Questions IV, V and VI by running (or modifying it according to
your requirements) the code provided in Testbench_q7.m.
This code calls the netlist of a low-pass filter from the file sallenkey_lp.m.

Provide the plots of absolute and relative sensitivity obtained for R1 and C1.
For each element, plot the adjoint method, differentiation method and perturbation method
results on the same graph.

 

Assignment 4

Question I (5marks)

Implement the function named nl_BE_method.m for computing the transient response of nonlinear
circuits using the Backward Euler method. The stub for this function is provided below. Please feel free to
modify the function in accordance with your preferences.
function [tpoints, X]= nl_BE_method(tEnd,h, outNode)
% This function uses BACKWARD EULER method to compute the transient reponse
% of a NONLINEAR circuit.

%Inputs: 1. tEnd: The simulation starts at time = 0s and ends at time =
% tEND s.
% 2. h: length of step size.
% 3. outNode: is the node for which the transient is required.
%Output: 1. tpoints: list of time points.
% 2. X: is the transient response at output node.
%
%Note: The function stub provided above is just an example. You can modify the
% in function in any fashion.
%—————————————————————
For this function you will need the functions makeFvect.m and make_nlJacobian.m you created in
Assignment 2.

Figure 1: Half-wave rectifier.
Deliverables: After implementing the function, test your method using the circuit shown in Figure 1.
Figure 1 shows a half-wave rectifier connected to a 60Hz sinusoidal source with 1Volt amplitude.
The netlist of this file is provided in the script Half_wave_rectifier_TR.m.

Run the script TestBench_q1.m
to test your code. Make sure you make necessary changes in the testbench script to accommodate the
changes (if any) you made in the BE function.
Please provide the plots of the voltages at all the three nodes of the above circuit.

Question II (15 Marks)

Implement the functions described in above to solve the Harmonic Balance equation described as
ð‘ŪĖ…ð‘ŋĖ… + 𝑠 Ė…ð‘Šð‘ŋĖ… + ð‘­Ė…(ð‘ŋĖ…) = ð‘ĐĖ…(𝑠)
where 𝑠 = 2𝜋 ∗ 𝑓𝑟𝑒𝑞ð‘Ē𝑒𝑛𝑐ð‘Ķ.
To handle the Harmonic Balance elements, we are providing you with following functions:
a) makeHB_Gmat.m this function creates the matrix ð‘ŪĖ… using the matrix ð‘Ū. This function is already
implemented for you. The stub for this function is provided below,
function Gbar = makeHB_Gmat(H)

% This function uses the MNA matrix, G, to compute the HB matrix Gbar.
% First, this function builds the matrix G and then it builds Gbar.
% So please make sure your method makeGmatrix.m works well or use the
% makeGmatrix method provided to you along with this assignment.
% input: H is the number of harmonics.

% Number of Fourier coefficients can be computed as, Nh = 2*H+1;
% output: Gbar is the Harmonic balance matrix of size (n*Nh x n*Nh).
b) makeHB_Cmat.m this function creates the matrix ð‘ŠĖ… using the matrix 𝑊. This function is already
implemented for you.
function Cbar = makeHB_Cmat(H)

% This function uses MNA matrix, C, to compute the HB matrix Cbar.
% First, this function builds the matrix C and then it builds Cbar.
% Therefore please make sure your method makeCmatrix.m works well or use the
% makeCmatrix method provided to you along with this assignment.
% Inputs: H is the number of harmonics.

% Number of Fourier coefficients can be computed as, Nh = 2*H+1;
% Output: Cbar is the Harmonic balance matrix of size (n*Nh x n*Nh).
c) The addition of Harmonic Balance voltage sources is already done for you in the functions,
makeGmatrix.m and makeBvect.m.

You need to implement the following functions using the provided framework. The stubs for the
functions below are provided to you,
a) make_Gamma.m this function creates the Direct Fourier Transform (DFT) matrix. It takes the
number of harmonics, H, as input and provides the DFT matrix as a output.
b) HB_fvect.m is the function that adds the Harmonic Balance based nonlinear stamp to the
vector ð‘­Ė…(ð‘ŋĖ…). This function takes the vector of Fourier coefficients of nodal voltages, ð‘ŋĖ…, as input
and then returns the ð‘­Ė…(ð‘ŋĖ…).

c) HB_nljacobian.m is the function that creates/updates the Harmonic Balance Jacobian, ðœ•ð‘­Ė…(ð‘ŋĖ…)
𝜕ð‘ŋĖ…
, for
the nonlinear elements. This function also takes ð‘ŋĖ… (i.e., the vector of Fourier coefficients of
nodal voltages) as input.
d) HBsolve.m this function solves the Harmonic Balance system of equations using NewtonRaphson Method. This method requires initial guess, and the number of Harmonics as input and
returns a vector of nodal Fourier coefficients as output.

Deliverables: You will test your Harmonic Balance method using the circuit provided in Figure 1. The
script Half_wave_rectifier_HB.m contains the Harmonic Balance netlist for the circuit in Figure 1. After
implementing the required functions, run the file TestBench_q2.m to simulate the circuit.
1. Simulate the above circuit and then plot the time-domain steady state response for the circuit at
nodes 1, 2, and 3.

2. To verify your simulation, compare it with the nonlinear transient response you implemented
above.
3. Include the code above in your PDF file submission for the assignment.