 What is PsyCOS? It's a bit different from PsyLab. PsyCOS is an editor, simulator and co-generator for hybrid dynamical systems. That means general dynamical systems where we put together dynamical systems that have continuous time dynamics, discrete time dynamics, you have events. So very general type of models can be constructed and simulated in PsyCOS. Now the goal is mostly industrial usage. As you know, Similink is mostly used in industry, also in teaching and research of course, but the main usage is in industry. And it is also the same thing for PsyCOS. I mean we hope that it becomes the same thing for PsyCOS. It has been distributed along the same free open source license. So once you download PsyLab you have PsyCOS. You can use it right away. Now this is just to give you an idea of what to expect when you run PsyCOS. It's not a programming language where you type the instructions. You just construct models by connecting blocks that you go into different palettes. You pick them up, you connect them together. Of course if you're familiar with Similink there is no surprise. In PsyCOS it's the same thing. This is one of the first models we developed, actually it was for Renault. It's a model for a car engine and a controller. They wanted to validate the controller. Actually we also developed the controller. It was later patented by Renault. And as you see it this way it looks very simple, but in fact I should say that the editor is hierarchical. So in the motor block you actually have more than 100 inside other blocks. And for the controller as well you have 100 or 150 blocks. So using the hierarchy it's possible to make abstraction of the models and make them look simple at different levels and to concentrate the difficulties where the difficulties really are and not make huge uncomprehensible models. As I said before PsyCOS is used for model construction. It's a block diagram editor. And there are a number of basic blocks available in different palettes. Mostly elementary blocks which are used in the construction of general purpose diagrams. But there are also some custom blocks, especially for control for signal processing. And there are many new blocks available in toolboxes for PsyCOS which can be downloaded from the PsyCOS website. Now having PsyCOS in PsyLab is extremely important. That was one of the reasons Similink was very successful compared to say other programs such as system built which had considerable advance over Similink at the time it was called Similab. That was because Similink lived within MATLAB. And the same thing is true for PsyCOS living within PsyLab is very important because we can use PsyLab functionalities in conjunction with PsyCOS simulations to solve many problems. For example model calibration and validation. You want to do simulation to compare with real data to find maybe the optimal parameters that correspond to your model. And in order to do that you have to run many, many simulations and adjust the parameters following certain algorithm. Now in PsyLab you can run PsyCOS simulations in batch mode, change parameters, run them again and this way do model calibration very easily. Model reduction identification once you have constructed your model is usually too complex especially if you have a black diagram editor like PsyCOS. It's very easy to put together hundreds of blocks and you end up with a huge model. You want to reduce the model. You have constructed or identified. Again you can use PsyLab functions to do that within the same environment. You don't have to use a different software to do so. Filter design and controller of course specialized toolboxes in PsyLab are available for filter design controller synthesis. And very often when you have a model in PsyCOS you want to test a controller for you. And how do you construct the controller? You just call the corresponding functions in PsyLab available in specialized toolboxes. You have it right away. You can do the simulation. You can change the parameters instead of changing the parameters of a filter by changing the ABCD matrices if you are familiar with the filters. You can just change the color frequency, the order very easily. Now what is it based on? First of all it's based on an open and documented formalism. Okay so from the beginning we started PsyCOS by not writing a program that does simulation continuous time and then adding what's necessary to make it also do discrete time and then think about how to make them work together. From the beginning we thought of formalism which was inspired by synchronous languages and in particular an extension to continuous time dynamics to model hybrid systems. And it is based on this formalism that PsyCOS was developed. Okay having this development in this way we end up with an efficient simulation tool and the code generation is very natural and it's close to optimal from the beginning. And this is the formalism and the way it's really programmed of course there is the hybrid part, the part that takes care of the interchange between continuous time and discrete time. There's a discrete time simulator but the continuous time simulator, it's not us that have developed it. It is based on a well-known routines, LSODAR and DASKR, which is the new version of Dassault and these routines are interface within PsyLab and so PsyCOS and are used by the simulator. However they have been slightly modified for the needs of PsyCOS. Some of the modification actually has been also incorporated in the official versions of this software. Now what are the tools? Of course simulink from Matworks which is almost a world standard today. It's a toolbox of Matlab. I mean you can have it when you have Matlab but you don't necessarily have it. You have to buy it separately. System build, a very good software initially developed by Wind Rivers as part of the Matrix X package. The only weak point and that was the reason as I mentioned before it probably lost to simulink was the environment which was not comparable to Matlab. Now system build was bought by Matworks and then there was a decision of the Department of Justice and finally it was sold to a national instrument. Another interesting product is Dimolite. It is based on an open language Modellica. The product is available from Dynasim and Dynasim was recently bought by Dassault Systems so it has become a much bigger company now and I think Modellica has an interesting future. There are other of course more specialized tools for simulation specialized for electrical systems such as Spice but here I'm just talking about general purpose simulation tools. Now what are the advantages of using PsyCos? Of course it's free software. There are no licensing fees and a generated code can be freely distributed. It is open source, easy to adapt to specific needs and because of that there are many outside contributions today to PsyCos and when I say adapted to specific needs there are a number of examples. One of them is Electricity of France for example that has taken PsyCos and has developed a tool around it. It's very similar of course to PsyCos but they have added features specific to their needs. This is easily done with open source software. It is more difficult of course with closed software. There is a clear and documented formalism that makes it much easier to construct custom blocks when you know exactly how the compiler works and how the simulator works when you want to construct a new block. It helps you a lot and it also allows you to do code simulation with other tools because there are no secrets behind the way it works. Now the components of course as I mentioned before there is the editor. There is a black diagram editor written in PsyLab. The whole code is written in PsyLab. It uses PsyLab graphics, GUI. That puts some limitations of course on the editor. It may not look very professional, very nice but it is very easy to customize because it's very easy to program in PsyLab, debug PsyLab. The compiler is written in PsyLab and C, mostly in C. The simulator is written in C and Fortran is just the numerical solvers are still in Fortran but the simulator is written in C. There are a number of black libraries. We call them pallets available in PsyCos. Each block actually has two functions associated with it. One which is the interfacing function. What happens when I click on the block? How does it look like? And a simulation function which is in general written in C. That's different from simulink where everything is written in one function. I mean for those who will assist, who will be present this afternoon at the hands-on lab session, we will see how to write new blocks and use existing blocks and so on. We have also put in a Modellica compiler. Again, I don't have the time to explain exactly what Modellica is for. Those who are familiar with Modellica, they will see that it is very important to have a Modellica compiler. I will give an example later. There is a C code generator. Now the current status, the documentation, there is a wide range of documentations available on our website, PsyCos.org, examples, online help and so on. There is my book which gives the details about PsyLab PsyCos, mostly PsyCos. And if you want to write new blocks and so on, I have a copy here if you want to consult. The underlying formalism, as I said before, is well adapted to current needs, is published. We have done minor extensions to the formalism to allow the integration of Modellica. And the formalism today allows, in most cases, to use PsyCos instead of Simulink. So you can take Simulink, a Simulink diagram and do the same thing in PsyCos. There is no automatic translator today. This is something that it can be considered. It could be a project maybe done here. But the formalism allows it. So there is sufficiently powerful to do that. Except for state flow. We don't have for the moment the equivalent of state flow. The compiler is a reliable code. We rewrote the compiler in 2004. It's fairly efficient. Well, the simulator is also well tested now. And the recent extensions have been added for the usage of Modellica. And the C code generator, you can generate C code for single processor. If you have continuous time components in your model, then instead of using a variable step solver used in PsyCos, we use fixed step solvers which are embedded within the generated code. You can do specific code generation for real-time Linux. That's a contribution of Roberto Bucher. And we can also generate syntax code. Syndex is an Inria product for multi-processor environments. Okay. I know many of you probably are used to Windows look and feel. When you copy or select, you want to do control C, control V, and so on. Okay. I'm not a fan of that stuff. I find it much easier to use the X-Windows style. But there have been many, many demands to add this feature in PsyCos. So the next release, it will also have Windows look and feel. So you can do the usual selection copying facilities that are available in the Windows. We're going to have better-looking dialog boxes. And we're going to have more functionalities. For example, today when you have a PsyCos diagram, you can only have one diagram active at the time. And you don't have the possibility of working with SyLab at the same time. Some of these features will be added to the new editor. And of course, the robustness is going to be improved. But another important feature which is not available today, but will be available tomorrow in a generic sense of the word, is general data types. Today, all the only type of data exchange that's possible between blocks is the vector of double precision numbers, float vectors. Now, this is good for most modeling and simulation applications, but when you want to generate code, especially for processors that don't have floating point capabilities, you would like to have different data types, integers of 8 bits, 16 bits, signed, unsigned, and so on. So this will be added. But also data types of more general nature, for example, matrices. And with matrices, it is possible, for example, to write the Riccati equation in common filter using blocks, because it involves matrix products and matrix inversions, and so on. So this already exists in beta version, but it is not in the 4.1 version, which we are going to use for the hands-on lab this afternoon. It's going to be in the future, at least. And the Modellica language will be fully, as fully as possible, integrated in the INSICOS. We are also working on hardware in the loop applications, and we want to be able to use hardware in the loop for validating controllers, and for that, we're going to add more IO devices. And the debugging facilities, we shall see that, but you will see that we need more debugging facilities. And the documentation, well, it's never complete, it's never perfect, it's something that we're going to work on. And finally, that's probably an important point. We have added facilities for importing signaling diagrams, but there is no automatic translator today. Now, this is a typical psychos diagram again. This was an application which was developed for inter-technique. Inter-technique is a French company that makes many things, but in particular, oxygen masks for pilots. And the problem they had was that they had an oxygen mask, they wanted to change the design, reduce the size, and make it lighter, and they had a vibration problem in the mask, and they wanted to have a model to find out what the problem was. So we built the model in psychos, and we showed them, and they were actually quite happy with it, because they found out what the problem was. However, when the technicians looked at the diagrams, they weren't really happy with it, because they said, well, we have mechanical diagrams, and they don't look anything like your psychos diagram. We like to see a pipe here, we like to see a nozzle here, we like to see a pressure chamber, and here you have mathematical equations. And the reason is that psychos is oriented, just like signaling, that means you have blocks with inputs and outputs. But when you have a pipe, well, what is the pipe? The pressure is the input, the flow is the input, but it depends. Just as an electrical circuit, I mean, an electrical circuit, you can, of course, model it using oriented blocks, but you have to change the nature of your diagram. It doesn't correspond to the original electrical diagram, which the electrical engineer is familiar with. And so you have to do some work to make the implicit diagram into an explicit diagram. Okay, that's why we used Modellica to add implicit blocks into psychos. And here is an example. You have here an electrical circuit. Okay, it looks very much like an electrical circuit. Okay, there is no notion of input port, output port. For example, the resistor here has two ports. Okay, the left one is not an input, the right one is an input. You just have currents and voltages. And you have the resistor here simply says, okay, the difference between the voltages are related to the current flowing through these ports. And the current one is the negative of the other, because the sum of the currents must be zero and so on. And this is mixed with standard blocks. In this case, it's just a visualization block. So in the psychos environment, we can now combine implicit blocks and explicit blocks. Now what I'm going to do, because for those who are interested, we have the possibility to see all these features this afternoon. Just quickly show you maybe how the window looks like and how we can just run the simulation because I'm running out of time. Okay, that's a typical psychos diagram. It's a very small diagram, but it is used. It is a model in a neurobiological model. I don't know exactly what the physics behind this is. It was done by somebody in our laboratory that works on these problems. But the idea is that you have a dynamical system, you have a dynamical system which is excited by events which are randomly distributed in time and they have random values. So here I have a pulse generator. It generates events or activations. You should think of the red links as activations. So you explicitly say this block here generates random events and these random events excite some dynamical system with nonlinear dynamics. Okay, if I look inside now, I open the super block. This is called a super block. I use another editor and in this editor, you see random number generators and event delay. That's a block that generates an event. When it receives an event with certain delay and the delay is variable because it is related to the random number generator here. Actually, the Poisson process that is generated. Here you have mathematical expressions. Okay, so in this case, I have a mathematical expression written essentially in Sylab syntax or mathematical syntax if you like and it is compiled. So this model can be simulated. I simply go to the simulate button and run it. So here I have the events randomly in space in time and that's the result of the dynamic simulation. So very quickly, you can see the result and construct the model using all these blocks that are existing blocks. I could have opened the palette, say the sources and I could copy an element from here to here and so on. Okay, so it's very easy to construct. So this is a particular block, this buffer. It's written C. You have the possibility of programming directly in C your block, the dynamics of your block. That's a very nice feature because you don't find what you're looking for in the palettes. You take this special block and you write exactly what you want the block to do in C language. And what happens when you run the simulation? Well, you compile actually what happens. It went too fast. The C program generates a C file. It is compiled and it is linked incrementally with Sylab. Serge mentioned that we can do incremental linking and you can see the result here, link done. Okay, so that's, I don't want to get into detail what the program does, but this is a buffer simulated in C language. And then there we have an FFT that computes the FFT over a sliding window. Okay, that's the diagram with a PID controller. Actually, there is a P and a D. And these blocks are simply a TK widget that allows you to adjust the value of the P and D gains. So I run it quickly. You will see exactly what's useful. That's the input, which is a step. Oh, no, it's this backward step. And this is the output, which is, well, depending on what you want to do, it's probably not satisfactory because the P gain is zero and the D gain is zero. Now I can change the value of P gain and play with it in order to find maybe an optimal okay, controller parameter. If you go out of bound, then it becomes unstable and it doesn't simulate. So you have to be careful when you play, especially with the D value. Here I have a Sylab program that calls the simulator and runs it in batch mode. Psycho simulate is the Sylab function that runs a simulation in Sycos. So this program runs many, many times a simulation to find an optimum controller. Now as you can see, there are different simulation runs here. At every run, the parameter is changed. And at the end, we just visualize the cost function associated with each parameter. And we see it here on a 3D plot. Of course, we could have used optimization function to optimize it and so on.