The following files are modified. Replace the old ones in the hand-out package gives you the final solution to Assignment 1.
The simulation result of algebraTest_CausalBlockDiagram_mdl.py (with time_max=0) is shown in Figure 1.
Another test is run, with time_max=50, as shown in Figure 2.
The solver detects dependency loops and highlights them (by calling the HighLight function of the graph objects). It runs loopTest_CausalBlockDiagram_mdl.py and gives the output shown in Figure 3.
In addition, such an exception is thrown and dumped to the console:
Exception in thread Thread-1: Traceback (most recent call last): File "/home/thomas/tools/lib/python2.3/threading.py", line 436, in __bootstrap self.run() File "/home/thomas/tools/lib/python2.3/threading.py", line 416, in run self.__target(*self.__args, **self.__kwargs) File "CausalBlockDiagram/SIM_startResume.py", line 105, in initSimul raise NotImplementedError, "algebraic loop detected" NotImplementedError: algebraic loop detected
The solver recognizes delay blocks. Model delayTest_CausalBlockDiagram_mdl.py runs correctly (Figure 4).
All the (previous and current) values of the connections are stored in their signal lists. Please read the commented SIM_startResume.py file to get more insight. block_tmp_value is completely removed. block_out_value is used only to retrieve the values of constant blocks (whose pre-defined block_out_value attribute is given by the designer).
All the blocks are considered, except Integrator, Derivative, Time and FileIO. If any one of them is encountered in a model, an exception is raised and the simulation stops.
The circle is defined by equations:
This can be rewritten as:
, we can
substitute the above equations as:
The graphical model is depicted in Figure 5.
The termination condition is the completion of a full circle. This is tested with 2 test blocks: the upper one returns 2 if is larger than 0; the lower one returns 8 if is larger than 0 (that is, ). This two test results are added. Only when both conditions are satisfied (the plot crosses the last point) will the final result be (subtracted by 9.5) larger than 0. Simulation stops at that time.
Figures 6, 7 and 8 shows the simulation result.