Modeling Drilling Dynamics with Simulink - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 0:00
Loaded: 0%
Stream Type LIVE
Remaining Time 0:00
 
1x
  • Chapters
  • descriptions off, selected
  • subtitles off, selected
      Video length is 22:25

      Modeling Drilling Dynamics with Simulink

      The drilling industry has substantially improved performance based on knowledge from physics-based, statistical, and empirical models of components and systems. However, open-source packages and several commercial software struggle with modeling drilling dynamics. Simulink® has several inbuilt capabilities that enable you to work more efficiently and improve your development of drilling models. Explore how you can:

      • Manage models and data in one place in a collaborative, scalable environment with Simulink Projects
      • Use Simulink to convert MATLAB® scripts to MATLAB functions that simplify the task of building models
      • Create a custom interface with block masking to hide the block content and simplify the user interface to the model
      • Create custom libraries for common drilling dynamics such as drill string, heavyweight drill pipe, drill bit, and mud motor
      • Use the variant subsystem to easily swap out the active implementation and replace with alternate configurations without modifying the model

      Published: 21 Nov 2021

      Hello, my name is Inho Kim, Senior Application Engineer at MathWorks. Today we will discuss about how to make your modeling easy using Simulink, by going through one of representative models in Open Source Drilling Community.

      The details of this model were already presented by Rajat from Exxon in previous session. Please check his presentation, if you didn't have a chance to hear about technical details. That being said, this presentation is more focusing on introducing Simulink functions while modeling dynamic systems, therefore, one who is starting from scratch or combining existing MATLAB code to Simulink version of model.

      Here's our agenda today. We start with introducing Simulink with a simple example. Then we will talk about Simulink projects and version control when you and your colleagues are working on same modeling project. Then MATLAB Function block and Simulink from MATLAB Function with masking those MATLAB Function blocks will be discussed.

      Custom library for frequently used blocks will be briefly touched on using Open Source Drilling Community model. Then variant subsystem, which can help to easily switching subsystems without remodeling, will be discussed. Finally, some useful resources will close this talk.

      There are many ways to assess Simulink. You can click this button in bluesheet or you can type it in in command window, Simulink.

      You will see the start page. There are many templates. Based on what you are doing, there are blocksets and toolboxes. You can select the template you can start. In this case, we'll use the blank model for showing some simple example.

      The library browser contains a lot of blocks you can use, as you can see, sine wave, a step function for the sources. In this simple example, we'll use a sine wave, drag and drop. If you know any block name, you can type it in in the canvas.

      We want to select Integrator. You can see multiple options with starting with "int." Select the integrator, connect this. We want to see the results, which you can use a scope. We want to compare the original signal and then integrate the signal. But then we can click the Run button and see what happened.

      So you are seeing the yellow line is the sine wave. And then the magenta line is where the sine wave was integrated. As you can see, the time is starting from 0 to 10, which we define over here, 10 seconds.

      And then the solver for this calculation is automatically selected as a variable step, solver with certain solver selection. If you're using with the hardware, you can use the fixed-step and specify what is the step size.

      Now, let's look into the model that Exxon engineers developed originally, which is MATLAB script. And then we'll compare that to the Simulink model that we have been working with. So this is the script. It starts with the comment who actually build this code. Then there are some descriptions of sections, parameters, calculation for other calculations, some array calculations, as well as multiple array calculations for using the loop function.

      As you can see, it is all well documented. But this code is quite long. It's over 1,900 lines of code. One can imagine that if somebody wants to modify or adding some section of this code, may take a long time to understand first and then go do it.

      So now let's look into the Simulink model. I open up this project file, well, the model. Then you can see the Simulink canvas. What you are seeing over here there are multiple subsystems.

      And then the subsystems has their own subsystems to break it down, the code. So as you can see, this part, the topdrive side, the ROP, the axial motion, and then RPM for the torsional motion inputs. And then there are drill-string element and then drill-bit element.

      If I go into drill-string element, that can further divide to drill pipe elements and then heavyweight drill pipe elements. I can even go further in drill pipe. There are multiple drill pipes are connected together, especially this one. If I go in over here, it has multiple of MATLAB function blocks that actually calls MATLAB function itself.

      And here we actually did a little bit further work over here. As you can see, if I click it, it actually shows the mask. So which means the user side, if they want to change some parameters for each individual drill pipes, they can simply change those input parameters and numerical information for how many elements are in this simulation and drill pipe, so on and so forth.

      Top of that, if somebody wants to add additional elements, here we have a custom library called Drilling Dynamics. As you can see, these are the elements that we have been using in this model, drill bit side, drill pipe, the mud motor.

      When I opened the Simulink model, I use project file, start the model right away. As you may notice, parameters stored in separate files are automatically popped up in the workspace. And one of the folder, DDLibrary over here, is also activated.

      So let's talk about project here. When you are working on coding with either MATLAB and Simulink, you can save the progress by just saving the file when you are closing MATLAB. In this case though, you may lose the history of changes and your codes you worked on, unless those are written somewhere. Next time when you come back to code, you may need to spend some time where you were.

      Or if you are working on quite complex model, you may have to remember and need to add passes, some folders which may contain subfunctions, libraries, or data every time you start a new MATLAB instance. Project is quite useful tool to avoid those kind of situations and help you track the progress.

      One of the big advantage using the project is actually the Source Control. In this case, I use the git. But you also can use the SVN. When I click the branch, I can actually track down whatever I change it and then comment it. And I can see what was the change.

      In this particular case, let's select this Added variant subsystem for a heavyweight drill pipe, which you can see, there is a blue rectangle showing that this file was changing. If I right click it and it showed the difference, it actually shows the revisions before and after.

      Left hand side is the previous model, then right hand side is the one that committed after saving. It's not on yet. You can actually see in the model side how the model was actually changed from our previous one to next one.

      Let's use a simple example. Say, if you have already working on codes, how you can actually make the project. Click the New and there is a project, and then start the From folder. If you have anything from the code in the git or SVN, you can start from there.

      Let's set up the project. So it will automatically ask what kind of folders you want to add. So you add the folder, data, another folder, subfunctions. If this folder has the subfolders you want to add, you can actually use the add with the subfolders.

      Next, we want to have a parameter for running this model. So we select this parameter. This setup will give you the option that when you open up this project, you automatically open up the parameter file and finish.

      Now we need to use the Source control. Click here and add project. You can either use git or SVN. I will use the git this time, convert it, then open Project. Because we open up the one new project, so let's comment it here, new project. Submit it.

      Then, let's check the branch. So you can see, the first commented ones has the new project. And you can see that plus sign shows that these are the files and folders were added for this project.

      If I make the shortcut for this particular model, it may be much easier to assess this model the next time. If I click it, it will open up the Simulink test model. And then you can just start from there, one button, see the simulation.

      So what if I just change the location of the line and then save it, close it, then use comment, changed location of line, and then submit. Then you can actually see what was changed in the model, so show difference.

      This case, I didn't check the line. So I just click it. They showed the line. And as you can see, the difference before the commented and then after commented, and then the right hand side before the model and then after that.

      Next topic we want to discuss about is MATLAB Function block and Simulink. If you have a function in MATLAB environment, you can actually bring this function into Simulink.

      So let's open the Simulink blank model. The library browser can find out MATLAB on their Simulink and then user-defined functions. Drag and drop, click this, then you will see MATLAB Function structure over here. It will help to type it again, just double click it, use existing function, copy, and then paste it, save it, name it in different ones, custom function.

      We go up, but let's close this. We can see the custom function is generated. Quickly, we can check sine wave as input and then output using scope. If we run this, you can see the 10 times of sine wave and actually compare that using this. So the original signal on the sine wave has amplitude as 1. Then the output is 10.

      If you want to change the parameter, you double click it and go inside over there. Then you can change the values. But there are better ways to do it. So what we can do, copy that name of the parameter, put that as an input of that function. Let's comment it out and use the data manager, change that parameter, because right now it's input, because it's in the input side. We can change that as a parameter.

      If I run this one, Simulink will give me the error, because the information of parameter is not stored. One of the way you can do is you can actually make parameter script and then use that, run it before you run this model using the project. And you will see it.

      But the better way is you can actually make a simple mask of this function. When you try to make the mask, right click it on the mask. You can add the parameter. If you have multiple other parameters, you can use different icons over here. Especially, a container is very useful.

      If you have a different section of the parameter, you can use the tab to segregate that. And the prompt is how it shows in the mask. And then the name is the parameter name of the function.

      So if I change that param, the property of the name is changed. And then this value is kind of initial value. So say, we set a 1. Whenever we click it, the initial value is a 1. So if I run it again, because it's 1, it's overlapped each other.

      You can simply change the parameter. Just click this box and then change it. We run the simulation. You can see, there is a three times of parameter goes into that function.

      Now, let's talk about Custom Library. If you go project, open up the model, and this particular model has a lot of repeated blocks we will use. In this case, if you want to redesign this kind of system, it's better to have your own custom library, so that you can easily assess. If I go library browser, I already added this drilling dynamics library, which contains the blocks that we can actually just drag and drop, and then build the model from it.

      How we can build this library is under the New. You can see the library You can open up a blank library, can actually generate multiple subsystems. But the Custom Library doesn't accept the entire model. It accepts the library block. So it would be helpful for that.

      If I go into the Library folder, what you're seeing is multiple Simulink models. I will take this, go up. You can see these are the subsystem. And then under Subsystem, we can see these blocks.

      And also, you see over here a Locked Library. You can unlock this library and then modify it. But usually it's locked. So these library blocks cannot be modified. After you make this library, you can use this kind of script, so that the library browser can see your custom library.

      Finally, we can discuss about variant subsystem. Sometimes when we model this complex system, and especially in the drilling industry, if you want to just change the configuration and then see the difference, and especially in this case, either we attach the heavy weight drill pipe in the drilling system or not, it's one of the case.

      Under the Modeling, you can actually see a Convert to Variant. And this is what I already did. So if I click this one, you can see the Variant Subsystem. There are choices.

      So if I choose the first one, then they will choose the heavy weight drill pipe element. If I go up, then choose a different one, then it will comment it out the heavy weight drill pipe and then just pass the information to the next element. And even the input and output, input especially, will be selected according to the information that we need to pass.

      Great, let's go back to the slide. We discuss about all these topics in a MATLAB and Simulink environment, Simulink projects, MATLAB function block, and masking, custom library, and variant subsystems. I also attach the MATLAB documentation, so that you can actually find out more information from documentation.

      For the resources, MathWorks offer a self-paced, free learning material. If you're new to the MATLAB or Simulink, you can go through this onramp. There are many more onramps over there. I open it up. There are different types of onramps they are offering. These are all free. So you can actually go through it.

      And we also have a MATLAB training. This is paid service. If you want to learn more about MATLAB and Simulink, you can contact us to find out the better course suits for your project.

      We have an industry team. There are three sales reps and then industry marketing manager. I attach all those emails for them under the emails, so you can actually contact them after this conference. They will connect us, especially application engineers or consulting service, depending on the project. Thank you for listening.

      View more related videos