# Causal Block Diagram Assignment

## The assignment

Implement the missing functions of the simulator (atom3/Formalisms/CausalBlockDiagram/ST_CBD/ST_Simulator.py) to accomplish the following requirements:

1. [10%] The construction of the dependency graph;
2. [10%] Given an algebraic loop, detection of whether it is linear;
3. [10%] Given a linear algebraic loop, construct input for a linear solver; the format of the input should be:
```///////////////////////////////////////////////////////////////////////////
// Input for the solver is of the form: [M1, M2], where
//
//      [[ C11, C12, C13 ],
// M1 =  [ C21, C22, C23 ],
//       [ C31, C32, C33 ]]
//
// M2 =  [ C1,  C2,  C3 ]
//
// represents the following linear equation system:
// {
//   C11*x + C12*y + C13*z = C1
//   C21*z + C22*y + C23*z = C2
//   C31*z + C32*y + C33*z = C3
// }
// where x, y, and x are signals (block outputs) inside a strong component.
///////////////////////////////////////////////////////////////////////////
```
4. [10%] For each of the blocks, write the computation they need to perform. You need to implement all algebraic blocks as well as the delay block.

[50% -- 5% per item] Test all aspects of your simulator:

1. Simple algebraic models without loop, one for each algebraic block;
2. A non-trivial algebraic model without loop to test sorting;
3. An algebraic model with a non-linear loop;
4. An algebraic model with a linear loop ;
5. An algebraic model with at least two linear loops, and computation in between;
6. A simple Delay block model;
7. A Derivative model using delay block. Test using simple linear input (so you can compare with the analytical solution).
8. An Integrator model using delay block. Test using simple constant input (so you can compare with the analytical solution).
9. A Circle Test model using Integrators on the one hand and Derivative blocks on the other hand.
10. Plot error (wrt. analytical solution) for both solutions (Integrators and Derivatives) as a function of stepsize.