{"id":3668,"date":"2014-05-22T09:27:27","date_gmt":"2014-05-22T14:27:27","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=3668"},"modified":"2014-05-22T09:27:27","modified_gmt":"2014-05-22T14:27:27","slug":"flexible-bodies-in-simmechanics","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2014\/05\/22\/flexible-bodies-in-simmechanics\/","title":{"rendered":"Flexible Bodies in SimMechanics"},"content":{"rendered":"<!--introduction-->\r\n<p>This week we see how to create flexible bodies in <a href=\"https:\/\/www.mathworks.com\/products\/simmechanics\/\">SimMechanics<\/a>. For that, we will use techniques seen in previous posts like <a href=\"https:\/\/blogs.mathworks.com\/seth\/2010\/01\/21\/building-models-with-matlab-code\">Building Models with MATLAB Code<\/a> and <a href=\"https:\/\/blogs.mathworks.com\/seth\/2008\/08\/21\/mask-initialization-and-self-modifying-blocks\">Self-Modifying Subsystems<\/a>.<\/p>\r\n<!--\/introduction-->\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/FlexibleBeam.png\" alt=\"Flexible Beam\" \/><\/p>\r\n\r\n<p><strong>The Lumped Parameter Approach<\/strong><\/p>\r\n\r\n<p>Using a lumped parameter approach, we can approximate a flexible body using a series of rigid bodies connected by springs and dampers. The material properties and the cross section of the flexible body determines the spring stiffness and damping coefficients.\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/lumped.png\" alt=\"Lumped Flexible Beam\" \/><\/p>\r\n\r\n<p><strong>The Fundamental Element<\/strong><\/p>\r\n\r\n<p>To begin, in SimMechanics, we create one element to be duplicated as many times as needed and store it in a library. For a beam bending about one axis, our fundamental element looks like:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/oneElement.png\" alt=\"One Element\" \/><\/p>\r\n\r\n<p><strong>Assembling the Beam<\/strong><\/p>\r\n\r\n<p>Now that we have one element, we can create a subsystem that will assemble as many elements as desired. Here is what the final result looks like:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/FlexibleBeamBlock.gif\" alt=\"Self-Modifying Flexible Beam\" \/><\/p>\r\n\r\n\r\nTo implement this block, we follow the <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/create-dynamic-masked-subsystems.html\">self-modifying subsystem<\/a> workflow suggested by Seth in a <a href=\"https:\/\/blogs.mathworks.com\/seth\/2008\/08\/21\/mask-initialization-and-self-modifying-blocks\">previous post<\/a>. In the Mask Initialization tab of the subsystem, we define a function that deletes the content of the subsystem and redraws it when needed.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/MaskInit.png\" alt=\"Mask Initialization\" \/><\/p>\r\n\r\n<p>To delete the content, we use <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/delete_line.html\"><tt>delete_line<\/tt><\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/delete_block.html\"><tt>delete_block<\/tt><\/a>.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/deleteContent.png\" alt=\"Deleting the beam\" \/><\/p>\r\n\r\n<p>To redraw the subsystem, we use <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/add_block.html\"><tt>add_block<\/tt><\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/add_line.html\"><tt>add_line<\/tt><\/a>.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/redrawContent.png\" alt=\"Drawing the beam\" \/><\/p>\r\n\r\n\r\n\r\n<p><strong>The Result<\/strong><\/p>\r\n\r\n<p>Flexible bodies open a  lot of possibilities. One of them is <a href=\"http:\/\/en.wikipedia.org\/wiki\/Vibration\">vibration analysis<\/a>. With a beam composed of 25 elements, I have been able to observe the first three <a href=\"http:\/\/en.wikipedia.org\/wiki\/Normal_mode\">normal modes<\/a> of the beam:<\/p>\r\n\r\n<p>First mode<br>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/mode1.gif\" alt=\"Mode 1\" \/><\/p>\r\n<p>Second Mode<br>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/mode2.gif\" alt=\"Mode 2\" \/><\/p>\r\n<p>Third mode<br>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/Mode3.gif\" alt=\"Mode 3\" \/><\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Here are a few tips if you want to dig deeper in this area:<\/p>\r\n\r\n<ul>\r\n\t<li>For a more advanced example of building SimMechanics components programmatically, I recommend looking at <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/45410-simscape-multibody-model-from-matlab-code\">SimMechanics Model from MATLAB Code<\/a> from my colleague <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/156229\">Pravesh Sanghvi<\/a>.<\/li>\r\n\r\n\t<li>For more details on how to convert the physical properties of your beam like the Young\u2019s elastic modulus and the cross-section moment of inertia, I recommend going through this article: <a href=\"https:\/\/www.mathworks.com\/company\/newsletters\/articles\/modeling-flexible-bodies-in-simmechanics-and-simulink.html\">Modeling Flexible Bodies in SimMechanics and Simulink<\/a>.<\/li>\r\n\r\n\t<li>To configure a SimMechanics block programmatically, I recommend using <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/get_param.html#btqy0m7-2\"><tt>get_param(blk,'DialogParameters')<\/tt><\/a> to obtain the list of dialog parameters for this block.<\/li>\r\n\r\n\t<li><a href=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/Flexible Bodies.zip\">Click here to download my flexible beam example<\/a>.<\/li>\r\n<\/ul>\r\n\r\n<p>Try modeling flexible bodies in SimMechanics and let us know what you think by leaving a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=3668&#comment\">comment here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/Mode3.gif\" onError=\"this.style.display ='none';\" \/><\/div><!--introduction-->\r\n<p>This week we see how to create flexible bodies in <a href=\"https:\/\/www.mathworks.com\/products\/simmechanics\/\">SimMechanics<\/a>. For that, we will use techniques seen in previous posts like <a href=\"https:\/\/blogs.mathworks.com\/seth\/2010\/01\/21\/building-models-with-matlab-code\">Building Models with MATLAB Code<\/a> and <a href=\"https:\/\/blogs.mathworks.com\/seth\/2008\/08\/21\/mask-initialization-and-self-modifying-blocks\">Self-Modifying Subsystems<\/a>.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2014\/05\/22\/flexible-bodies-in-simmechanics\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,47,39],"tags":[384,79],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/3668"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=3668"}],"version-history":[{"count":28,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/3668\/revisions"}],"predecessor-version":[{"id":3711,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/3668\/revisions\/3711"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=3668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=3668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=3668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}