Physical Modeling Tutorial, Part 1: Introduction to Simscape

in this video we are going to introduce the concept of plant modeling with sim scape and the physical network approach specifically we will talk about what sim scape is modeling differences between Simulink and sim scape building and simulating a model in sim scape and some general guidelines when it comes to sim scape modeling this training will be applicable for both the combustion engine and electric teams although the basic sim scape concepts are explored with a battery model as an example they can be extended and applied to many other domains such as mechanical hydraulic or thermal modeling we would like to acknowledge and thank the Virginia Tech Formula Student team for providing us with data about their vehicle motors engines and batteries for us to use in this training the first question to answer is what is sim scape sim scape extends Simulink with libraries for modeling and simulating multi-domain physical systems let’s switch to MATLAB and see how sim scape and Simulink are related in that lab we can open the Simulink library browser by typing SL library browser at the MATLAB command prompt scroll down to find the sim scape library it contains models of foundation elements for various physical domains for example electrical hydraulic mechanical and more in addition to this math works offers a suite of physical modeling products built on top of sim scape for specialized modeling of multi-domain physical systems for example sim scape driveline can be used to model longitudinal dynamics of vehicles and sim scape multi body can be used to model 3d systems with sim scape you create your model using the physical network method where deriving the system level equations is not required let’s take an example of an RLC circuit here I will open two models in order to compare the two methods the model on the left is built using Simulink and the model on the right uses sim scape the Simulink model builds the derived equation using integrators and other math operators it also has signal lines that carry numerical values in a unique direction designated by the arrow head the sim scape model however uses building blocks like resistor and inductor to build a physical system there is no necessity to derive the equations for the system you can also see that the lines don’t have arrow heads these are not the same as Simulink signals instead these are physical connections where the energy flow is bi-directional let’s go back to the present we just saw the sim scape library and how it extends simulate sim scape is built on top of MATLAB and Simulink there are other specialized add-ons such as sim scape multi-body and sim scape drive line for specific domains that are in turn built on top of sim scape sim scape also possesses other capabilities that we will talk about later in this training such as units data logging and custom block building physical systems can be modeled in Simulink using a sigma based input-output method this method is flexible but requires deriving and implementing equations at the system level as shown on the left with sim scape you create your model using the physical network method we’re deriving the system level equations is not required this makes your models easier to create understand and maintain in sim scheme the model itself is built using physical blocks and looks more like the diagrams shown at right we saw the difference between Simulink and sim scape in terms of the connections using an RLC circuit as an example we have unidirectional signal lines in Simulink and bi-directional physical connections in sim scape these examples and others discussed in this video series are available for download from the training main page finally note that the approach to creating signal based Simulink models and network based sim scape models remains the same no matter the type of system we are trying to model be it mechanical thermal hydraulic or other now let’s look at another example here we’ll take a physical system model of Sims game and simulate it we’re going to take the equivalent circuit of a battery as our example you can approximate a simple model of a battery as an ideal voltage source connected with a series resistor and an RC parallel bridge the electrical schematic of the RC circuit is shown here let’s model this circuit and simulate it to measure the current flowing through it to start we’ll switch to MATLAB we can create a new Simulink model through the Simulink start page accessible from the MATLAB toolbar choose blank model we can open the Simulink library browser through the command line as before or by clicking the icon on the tool strip now we’ll drag the blocks we need to the model open up the electrical elements library found under sim scape foundation library first we’ll grab a resistor we can add this to the model by left clicking holding and dragging it from the library to our model this will represent our series resistance to add a second resistor we can repeat the same procedure or we can simply right-click on the existing resistor and drag it to create a copy we will add a capacitor also from the electrical elements library next we need a voltage source this can be found in the electrical sources library we will choose DC voltage source left click and drag to add it to our model finally we also need an electrical reference this can be found under the electrical elements library this represents the ground terminal for the circuit most portions of physical networks representing a physical domain will include a domain-specific reference block this establishes a reference level for physical quantities such as voltage or velocity for example a DC motor which contains electrical and mechanical domains must include at least one electrical ground and one mechanical reference block in this case we only need one electrical ground now we need to create the connections first let’s maximize this so that we can see all of our components you can zoom in or out using the scroll wheel or by pressing spacebar you can cause the components to fill your screen to create a connection simply click on one port and drag the signal line to the next port you can also control click on a block and click the next block to automatically create connection let’s also connect the positive end of the DC voltage source to the series resistor now we need to connect this resistor to the RC parallel bridge the same procedure applies and a branch will automatically be created if you’d like to make a branch from an existing signal you could control click on that signal and a new branch will appear let’s connect this to the negative end of our voltage source we’ll also need to connect the electrical reference block to define the ground we will choose the negative terminal of the DC voltage block although the dynamic should be the same regardless of which point we choose in a mechanical system however the precision of the reference is physically important and represents anything rigidly attached to the frame note that as you connect these blocks together the physical connections will be colored blue this represents a connection in the domaine to view a legend of all domain colors select display sim scape Legend this shows all of the colors for the available domains in sim scape in the same menu you can also disable the coloring of physical connections by unchecking the domain Styles option I won’t do this now though many sim scape blocks can be configured by double-clicking them and editing their dialogues in this way you can change the parameters for each component in a physical network double-click the DC voltage source and change its constant voltage to 4.2 volts note here that this value has associated units sim Escape supports units based on different quantities like voltage and current from the electrical domain and velocity and force in the mechanical domain many units are available for these quantities let’s switch back to MATLAB for a bit to see this execute the command PM underscore get units to get a list of all the units the sim scape supports let’s go back to the model now and finish setting our parameters we’ll double click the resistor to set its parameters in the same way let’s give it a value of 0.01 ohm we will set this resistor to resistance of point zero zero five ohm let’s set the capacitor block capacitance to 5000 ferret note that the capacitor and resistor blocks had another tab called variables this can be used to set initial conditions for variables such as the initial capacitor voltage this is covered in the sim scape fundamentals video we can also make block values appear directly on the model by setting appropriate block annotations for example let’s choose this resistor right click on it and choose properties open the block annotation tab there are several properties we can show on this let’s scroll all the way down and choose the resistance R and its units we can customize the display in the window at right after clicking ok now we can see the value without having to double click on the block we can also change the value and the change little register in the model now we’d like to observe the current flowing through the circuit for this we are going to use a simulant scope current and other physical quantities in sim scape models can be measured using sensors and can be passed through the model using Simulink signals first let’s add a sensor block to the model the current sensor can be found in the electrical sensors library let’s make some room here in our window we can zoom out with the scroll wheel or we can click the wheel and drag to pan drag this to the model just like in a physical signal we have to put the current sensor in series note that the current path is shown in blue indicating that it is a physical electrical signal and that the output of the sensor has a triangular connection this indicates that it is a physical signal as well and carries units a physical signal cannot be connected directly to simulate blocks since Simulink signals are numerical thus we need a physical signal to Simulink converter block a convenient way to add blocks to a model if you know their name is to click in the Simulink editor and begin typing the name of the block here we have added the physical signal to simulant converter block there is of course a semi link to physical signal converter block both of these can be found in the sim scape utilities library let’s connect the sensed signal to the converter block this acts as an interface between the physical domain and Simulink since sim scape supports units we can specify any units or conversions before we convert to the Simulink domain this is done by double clicking on the block the default unit here is 1 this means that the unit is not specified let’s specify ampere now we can visualize this signal using the Simulink scope which is located in the Simulink syncs library one final step remains before we simulate the model all sim scape models require a solver configuration block this can be found in the sim scape utilities library drag the block to the model and connect it anywhere in the circuit it does not matter where this is used to define solver settings for each physical network and tells Simulink what options to use to solve this particular physical metal work note that a sim scape model you have more than one network hence more than one solve our configuration block in our case we only have one network next when simulating a sim scape model certain Simulink solvers are recommended let’s open up the solver parameters in the configuration parameters window by clicking the gear icon or hitting control e on your keyboard the recommended solvers for sim scape models are OD e 1 5s o 2 e 2 3 t & 4 fixed step simulations OD e 1 4 x we will use o 2 e 1 5s here models created with sim scape blocks are solved differently for models created using Simulink blocks even if the underlying equations are identical this is one of the reasons the recommended solvers are different for the two approaches more information about this can be found the documentation set the stop time to a hundred seconds this specifies the amount of simulation time for which the model will run click OK to return to the Simulink editor you can also change the stop time directly in the tool bar here simulate the model by hitting the Run button and double-click the scope to open it hit the auto scale button to bring the waveform into view if it is not already congratulations you have just created and simulated your first physical system in sim scape sim scape models can contain many different physical domains let us take an example here I have blocks with varying domains however you can only connect physical ports if the blocks are of the same physical domain for example on the Left we have two blocks from the electrical domain these can be connected sim scape will not permit you to directly connect physical ports that are of different domains here we have a hydraulic reference and a mechanical translational damper these cannot be connected note that you can create multi domain models in sim scape this will be discussed in the sim scape fundamentals video let’s go back to the presentation and recap what we’ve just done we built the equivalent circuit of a battery by dragging and dropping resistors a capacitor and a reference block from the electrical elements library we also added a DC voltage source for the electrical sources library and a solver configuration block from the utilities library we then set parameters for the blocks by double-clicking and editing the parameters for each one of them at this point the model of our physical system was built to interface between Simulink and Sims game we can use Simulink to physical signal and physical signal to simulate converters since we are measuring current we are using a current sensor and placing it in series with the circuit there are also other sensors available based on what quantities we want to measure we were then ready to simulate the model we talked about solvers and how Sims gate models are simulated differently when compared to simulate models the recommended solvers for sim scape models are OD e 1 v s o 2 e 2 3 t and OD e 1 4×4 fixed step simulations or local solvers we saw that we can change the simulation lengths directly in the Simulink editor and used a Simulink scope block to visualize our signal we also talked about essential Sims gate blocks every physical network in a sim scape model should have a solver configuration block these are used to set the solver parameters per network that a sim scape model may have more than one physical network and hence more than one solve our configuration block most simple cattles also have domain specific reference blocks to provide a reference level for the various physical quantities in the system finally we talked about multiple domains and sim scape and how we can interconnect only blocks from the same domain a sim scape model could be multi domain and we will talk about this in the next video on sim scape fundamentals in summary we talked about what sip scape is the difference is between Simulink and sim scape building and simulating a sim scape model and guidelines for sim scape modeling this concludes the video

8 thoughts on “Physical Modeling Tutorial, Part 1: Introduction to Simscape

  1. i am looking for single phase synchronous generator simulink. For the sampling of the condition motoring of synchronous generator. please help me.

Leave a Reply

Your email address will not be published. Required fields are marked *