This section of the course is about Simulation, when you get done with this section you should be able to understand when to use a computer simulation, you should be able to explain what a physically based object oriented simulation is, and you'll be able to create and run a simulation. So, why simulate? The reason is that even a simple circuit like the one shown here with a pump and a pressure relief valve, and a directional valve and a cylinder can get complex. So, for example, what happens in the 10 milliseconds after that valve changes position. And what's the time course of that cylinder expanding against the load? And so very quickly you run out of the ability to use, write the equations by hand, and use those to solve some of the detailed properties of the food power system or if you look at this example, which is the Toro lawn mower that you've seen. Here the, you're interested in the performance of the entire system, so for example, what happens to the pressure in the system when you're mowing with the mower decks moving, and then at the same time you reach a hill. So now you're putting more power into the drive wheels, and then at the same time you turn the mowing machine, so now fluid is going into the steering mechanism as well. So, what happens to the speed of your mowing deck cutters as you add these additional loads to the machine? So it's possible to simulate this entire system with a, computer based simulation program and then we can look at things like, well, how much total fluid runs through the system, which will help you to, for example, size the reservoir. So where the types of simulating, simulation programs the we are, going to be, you'll be introduced to are called object-oriented, physical system simulation, so let me explain what that means. Traditionally this is a spring-mass damper system that I'm sure that you worked on as in one of your undergraduate engineering courses, so it's a, force acting on a mass and then there's a spring and a damper, attached to ground. So the way that you tackle that, was that you wrote the traditionally wrote the equations for the system, so you looked at the force balance on the mass and then looked at, the constrictor of laws for the spring and the damper and then you pieced all these together, then if you're going to simulate the system you took that second order differential equation, split it up into a set of first order differential equations. And then put that into your, simulation engine, MathWorks or SimuLink, or pick your favorite simulation engine, in order to get the, to get the output. So it's up to you to, to, determine how the system interconnects, go into the equations and then how to manipulate those equations to get them to a set of first order to differential equations. So a physically based simulation, is based on the physics of the system and the, the simulation objects rather than being first rule of equations are the actual objects themselves. So for example, in a object based simulation you'd pull down a block that represented the mass, and then internally when a mass would be constitute loft which is at as you apply our force to the mass it accelerates. And then you pull down an object that's a spring, and it's internally got its constitute of law which is that the displacement of the spring is proportionately positioned, and then in the simulation you interconnect these two elements to say one end of the spring is connected to the mass. So you do that for the whole system, and when you run the simulation internally, that physical system simulation makes use of the interconnection laws, and the constitutive laws, in order to in, internally bring that into a set of equations, that can be, that can be stimulated. So it's very powerful, because it's almost rather than you having to do the work, then the system does the work for you, It's particularly useful when you have nonlinear systems, so for example, a nonlinear spring, where force is not proportional to displacement. And it's really useful for the power systems, where for example, as you're, fluid pressure drops it can entrain bubbles as a cavitate, so that can be simulated or, as your, flow across a valve, Is a nonlinear property of the pressure drop across the valve, so these physical system simulations are great for fluid power. So here are some of the commercial systems that are out there, this is by no means a, a complete list, but this represents some of the ones that you might, you might come across in your workplace, Dymola, uses Modelica modeling language which is a, increasingly popular open source language, and so Dymola is built on top of that and has a pretty extensive set of fluid power, components in its libraries or AMESim, again, used quite often in industry out there. An example of a Multi-domain where you can simulate mechanics, fluid power, electrical, all in one simulation. Now example, Automation Studio, still another one is, is FluidSIM and still another one is, SimHydraulics. Now, SimHydraulics is the simulation system that you will be using in this course it's a product of MathWorks and we are really grateful to MathWorks for enabling every student who is signed up for this course to get a time limited version that they can download for free onto their own computers. MathLinks, Mathworks, MatLab, and, and Simulink, and Simscape, and SimHydraulics to allow all of you to simulate fluid power systems. So just a little bit about SimHydraulics is the simulation package that we'll be using, it's SimHydraulics, which is part of the, kind of the Matlab family of products, sits on top of Simscape, and Simscape is the physically oriented modeller that Matlab provides, and Simscape in turn sits on top of Simulink which is a signal based simulation package. Which in turn sits on top of the underlying algorithms in, in Matlab, and so it's important to understand that because, for example, some of the documentation that you'll be reading, is about Simscape, which describes some of it, basics of physical modeling, some of the documentation about Simhydraulics. And then, how you operate the whole package is very similar to how you operate the Simulink, which some of you might be familiar with. So, there's a foundational library of components that are in Simscape, and then, Simscape also includes a modeling language so you can build your own components and then Simscape has add-on libraries. So, for example, there's a mechanical library, a drive train library, electronics, and then SimHydraulics that we'll be using. So what I'm going to show you is how to build a fluid power model that looks like this in SimHydraulics just to get you going, so this'll be a pump, actually going to use a source of constant pressure there'll be a pressure relief valve, there'll be a two-way valve, solenoid valve that's actuated back and forth a one-way cylinder that operates on a mass with some damping and a spring. So let's go ahead and take a look at how you'd build that model up in some hydraulics, and along the way I'll be describing some of the basics about SimHydraulics operates so that you can on your own, feel confident that you have the ability to build up your own models and run them in some hydraulics. Okay, I got MatLab open, and in the resources you can a describe how you download the MatLab and how you open it up and you'll get this initial screen. So first I'm going to go to the Simulink library, In the Simulink library you'll see, all, all the different blocks that you can pull into your simulation I'm going to go down to Simscape, and then under Simhydraulics I'll open up. So Simscape is a physical system modeller, under the foundation library in Simscape, you can see that there is some basic hydraulic components. So for example, there is a constant area hydraulic orifice, and then down here is a translational hydromechanical transmission, so this is basically a ideal cylinder, and so, and a hydraulic reference, so some of the elements you will be building your model with will be in the simscape foundation library, but generally you will be using the models that are in the sim hydraulics library. So for example there's, here's couple different kinds of accumulators and then there's a number of different kinds of, cylinders. So let's just take a look at one of these systems, let's go back up and take a look at the gas-charge accumulator which is a device that used to smooth out the ripples in a food par system kind of like a capacitor. So, if you click on any block then it gives you a little bit of a, information about the block so it says precharge gas chamber and so on, and then it gives you parameters that you can set and then very useful is the help. So, if you click on the help you'll get quite a lengthy description of the element, and what's terrific is that they include the equations for the element. So, as you'll see coming up when we, talk about accumulators, they're govern by idea gas laws and compression of ideal gases and so I'm not going into details, but this equation basically describes the relationship between the volume of fluid in the accumulator and the pressures in the accumulator. Using ideal gas properties and polytropic properties and one over k, where k is the ratio of specific heat, so all this is essentially the, the basic properties of expanding and, and, contracting gasses that govern the behavior of the accumulator. So one of, one of the things that's useful about this is that you can go in yourself and look at each one of the elements, and determine whether or not they have the sufficient complexity or details that you need for your simulation, and then of course advanced simulators you can write your own custom components to build on top of these. All right so let's see what it takes to build up a model, so to start a new model you go under the new tab and you look down into simulink and you click on simulink model. And then the first thing you might want to do is to save it so, I've started a folder of my models under my documents mat lab, but you can put them wherever you like so, there will do. Give it a name and Save it, and I'm going to pull my library back up. [COUGH] So let's take a look under hydraulic cylinders, so to put an element in your model you take the elements, we'll take a single acting hydraulic cylinder and you drag it onto the model. [COUGH] And then let's also take, the double acting hydraulic cylinder. So what you can do on this is when you double-click, it's got parameters, so here, for example, you can put in the piston area and the piston stroke or for the Double acting one where there's a rod you can put in the cap side and the rod side. And let's just take a look at this, this element, so there are things that are called, conserving ports and things that are called physical system ports. So this single acting cylinder has three power conserving ports. So this is where, power comes into or out of the element. So one of the things that Cylinder does is mechanical power, so it's got two mechanical power ports at the end, one of which is connected to the outside of the cylinder In one of which is connected to the rod. So for example, in the simulation you connect the one that's connected to the outside onto a mechanical ground, and then you connect the one that's on the rod side to whatever load that you're driving. And by connecting those two conserving ports, it says that those two elements, this one and the one you connected to, are going to be moving at the same velocity. And then here's a hydraulic conserving port, so this goes into the cylinder and by connecting this to, say, a pump it's going to say that the flow of fluid through the line that it's coming from into this is going to be the same flow of fluid so they are power conserving ports. And then also on some of the elements you have connections that are denoted by triangles that are called physical signal ports and there uh,for example, this one indicates the position of the rod. So down on our double-acting cylinder now you've got a four, there isn't a physical signal port, you've got eight fluid power or hydraulic conserving port one on the cap side of the cylinder one on the rod side and then again two mechanical ones. Okay now let's go ahead and build up the model that I showed you previously, and this is actually the example that's into some hydraulics documentation and a link to that example is in the resources for the section of the course, or if you looked at the last slide where I showed you a schematic of the system we're going to build It's also got the link to the, documentation that. Goes you can go through, in detail and step by step, and build up the model, so I'm just going to do a few of the steps to show you generally how these things work. So the first thing that we need to do is to put a valve in the model, well, actually the first thing we need to do is to start a new model, so we'll start a new Simulink model, and again I'm going to save it and I'm going to call this one simple Hydraulic systems and I'll save it in my model. Okay, then I pull up the library, and the first thing that I'm going to put on the block is a three-way directional valve. So, if you go in the sim hydraulics library and then you go under valves, and then you go under directional valves, you'll see the three-way directional valve block. So let's pull that out and put it into the model, the next thing I am going to put into the model is a cylinder, going to put in a, single acting hydraulic cylinder. So let's go into cylinders and find the single acting hydraulic cylinder. So we'll drag that into the model, and then we're going to, put in a two position valve actuation block because we have to have something to turn that model, that valve on and off, so let's go back into the direction valves and if we look down. If we look under Valve Actuators we'll find the two position valve actuator, drag that into the model, okay now let's pull in a source of hydraulic pressure, which is, we're going to use to drive the system. So here's our hydraulic pressure source, drag that into the system. Now it's time to connect these things together, so the output of the valve is going to go to the input of the cylinder, to connect elements together you click on a port and while holding the mouse down, you drag over and go to the port that it's going to be connected to. And that hydrologic pressure source gets connected to the input of the directional valve, and then the valve actuator gets connected to the signal input of the directional valve. Now notice that we've used the two different kinds of ports here, so the one where I connected the pressure source to the three directional valve is a conserving port because it represents fluid flow between the pressure source and the valve. [INAUDIBLE], the one with the triangle is a physical signal port, because it represents the signal coming in to the directional valve that's going to make that valve flip back and forth between its two directions. Once you've got everything on and connected, it's easy to move components around, so if you click and drag and you'll notice that the connections go along with it. And then you can take the connection wire itself and move that around, so it's important to have your diagram look as neat and uncluttered as you can. And then the other thing you can do is you can, you can click on the name and edit it to be whatever you like. So you can just change it to be hydraulic pressure. So here what I've done is built up the complete model, I'll let you go through all the detailed steps and you can just go through that step by step tutorial that is part of the sim hydraulics documentation. So you can see the full model again, here's our pressure source, here's that valve. Here's the valve actuator here's the cylinder, added in a mass that it's acting on and a damper and a spring. And then this MTR is a mechanical translational, reference, so this represents the mechanical ground so you can see the case of the cylinder is grounded, one end of the spring is grounded, the damper is grounded. Then we've got, driving the actuator, we have a sine wave signal. And this sine wave came out of the simulink package, so you need a converter block to convert from simulink blocks into Simscape or physical system blocks, so that's what this converter is, simulink to physical system converter, that makes this sine wave block compatible with the by the actuator block. Then we have to be want to be able to see the output of the system, so we added in a couple scopes. So we can look at the output plots and again, those are signalling blocks, so we need a physical system to simulate a converter putting in in this case it shows us the valve position uh,We've got another channel that shows us the input signal for the sine wave, and then we have another scope that comes from, this is the rod position, goes from the converter into our other scope. Then we also put in a hydraulic reference, which is the hydraulic tank, and then one of the things you have to put in is this hydraulic fluid element, It can be connected any one of the fluid lines and it specifies a particular fluid that you're going to use. Okay, once the model's all built and connected, then the next step is to adjust the parameters, so one of the parameters that you want to adjust is the simulation solver. If you go under simulation, and then model configuration parameters, It gives you dialog box, and one of the things you want to do for full power system is change that solver to the ODE 23 T which is down here. And then the other thing that's useful is the stop timer, the simulation, we're going to change this keep it at 10 seconds but if you want a shorter or a longer simulation this is where you change the simulation time. Then the other block the other parameter here that we're going to change is the max step size from automatic, we're going to change it to .two and these are our recommended settings for most fluid power systems. Now another thing you are going to to set is the hydraulic fluid, so if you double click on the fluid block and we're going to to pick Skydraw five, which is a particular brand of commonly used oil for hydraulic systems or a quick... Okay and you'll notice when you change the fluid type, then the amount of trapped air and the system temperature and a few other things change along, along with it. Then the last one I'll change is on the single acting hydraulic cylinder, so open that up and we change the piston area to be 0.002 meters squared. So you can go ahead and follow along on the tutorial document and adjust all the other parameters, most of the blocks need to be opened up and their parameters set, so for example you can set the spring constant and a few things about the, a few things about the, hydraulic pressure source and the size of the sign wave, and so on. Once all the parameters are set, it's time to run the simulation, so the green box at the top, which is the run box click on that, it will compile and depending on the speed of your computer or the complexity of the simulation, It might take a little bit of time to run the simulation. If there's any errors that pop up you'll want to pay attention to them the warnings you don't have to pay attention to. So to see what's going on, you click on the scope output, so let's just take a look at the valve and we'll do a auto-set of the axes. So here's the valve input signal, which is a sine wave, and then each time the sine wave gets bigger than the, switching level for the valve actuator the valve actuator send a command to switch the the actual valve. So, here's the valve in one position, the valve switches to the other position, switches to the fro, back to the first position. So that tells you what's going on to the input of the system, so based on we have this, this cylinder either flow going into the cylinder or flow coming out of the cylinder so let's take a look at that route position as it is pushed against the mass spring in the in the damper so open up this second scope, and make this part a little bit bigger and then you can autoscale it so you can see. So here's where the valve switched and now fluid is going into the piston, the piston is, pushing against the mass, and here's the trace of the mass, moving and then the switch is the other way and it switches back down because of the spring is pushing it back, and then the battle switch is in it goes up again. So notice on the output that the mask goes up to about .two meters in excursion. So lets change some of the parameters and see how they impact the simulation. So lets we'll double click on that mass, and change it from 4.5 kilograms to 45 kilograms. And we'll change the properties of the damper, from 250 Newton meter per second, to oh let's put in, 5,000, make it a much, much higher damper and run the same simulation and now let's take a look at the output. Now, because the mass is bigger and is pushing against a much bigger damping load now, the mass only goes to .16. You can also see that the dynamics are changed so for example, when it switches, it takes much longer for it to reach its initial position. So that's gives you a little bit of sense of how easy it is to set up simulations with parameters that are specific to your system, and also it enables you to play what if games in order to determine the properties of the components that you need in the design. I hope that gives you enough of a start that you feel confident to, go off and run SimHydraulics on your own, and I highly recommend that you know, right now you go ahead and, and run through that example on your own. Setup the simulation, get it to run try changing so of the parameters, and it'll give you a little bit of a better feel for how this simulation program works, because we will be using the simulation program throughout the remainder of the course. Another thing we'd like you to do is in the resources section for this part of the course, there's pointed to a number of key background documents that go into more depth about how this particular simulation packets SimHydraulics run, so I hope you're able to read those because it'll just give you a, a little bit of sense of what's going on as you put together your simulations. And then finally, to really gain an appreciation and a level of confidence with implementing and running simulations, we do ask you that you go through all the exercises for the section, which are a, sequence of simulation based exercises that are designed to build up your capacity to do simulations.