The purpose of this exercise is to

  1. Download library of external functions necessary for your simulator
  2. Modify and add your function
  3. Execute test runs of your simulator

STEP 1 Download the function library: Exercise4.zip.


STEP 2a In the previous exercise, you built and tested the functions mentioned in the list below. Today you will integrate these functions with the rest of the simulator library. Make the following changes:

  • dLoad.m - remove the residues corresponding to derivatives of states from other modules.
  • dNetwork - simply change the name of the function to loadflow.m

STEP 2b For the Load module, create a Jacobian function jLoad.m. The inputs to this function are the same as for dLoad. The outputs are Jx and Jd, which represent the Jacobian of the residues with respect to the state and the state derivative, respectively.

The first line of you function file should be:

function [Jx,Jd] = jLoad(t,x,d,z,p)


STEP 2c Add the following finite state automata models to the library folder (please make sure the names are in exact agreement).

  • T_sensor
  • T_switch
  • T_timer
  • T_6sup
  • C_sensor
  • C_switch
  • C_timer
  • C_6sup

STEP 3a The library function NetworkSimRun.m executes a single deterministic run. The function has two inputs: tF (the simulation final time) and Dat (a three dimensional vector of perturbed parameter values), where Dat = [X2, Ps, Tm].

Download the file SampleDat.mat containing an array of data points and test the simulator, e.g., run [t,x,d,te,z,e,p] = NetworkSimRun(5,DatMat(:,3));


STEP 3b Compare your outputs with the graphs below.

[t,x,d,te,z,e,p] = NetworkSimRun(5,DatMat(:,1));

Exercise4 SampleRun1.jpg

[t,x,d,te,z,e,p] = NetworkSimRun(5,DatMat(:,2));

Exercise4 SampleRun2.jpg

[t,x,d,te,z,e,p] = NetworkSimRun(5,DatMat(:,3));

Exercise4 SampleRun3.jpg