{"id":6706,"date":"2017-08-17T17:13:15","date_gmt":"2017-08-17T22:13:15","guid":{"rendered":"https:\/\/blogs.mathworks.com\/simulink\/?p=6706"},"modified":"2017-08-17T17:13:15","modified_gmt":"2017-08-17T22:13:15","slug":"creating-your-own-check-valve-for-the-simscape-gas-domain","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2017\/08\/17\/creating-your-own-check-valve-for-the-simscape-gas-domain\/","title":{"rendered":"Creating Your Own Check Valve for the Simscape Gas domain"},"content":{"rendered":"<p>Some time ago, I wrote a blog post about how to <a href=\"https:\/\/blogs.mathworks.com\/simulink\/2015\/05\/26\/creating-custom-valve-in-simscape\">implement a custom valve for the Simscape Hydraulic domain<\/a>. Today I am happy to welcome guest bloggers <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3725083-erin-mcgarrity\">Erin McGarrity<\/a> and <a href=\"https:\/\/au.mathworks.com\/matlabcentral\/profile\/authors\/6699185-ruth-anne-marchant\">Ruth-Anne Marchant<\/a> who will describe how to implement a similar check valve, but for the Simscape Gas domain.<\/p>\n<p><strong>The Problem<\/strong><\/p>\n<p>Check valves are a pretty common element in pneumatic circuits, but the <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ug\/modeling-gas-systems.html\">Simscape Gas library<\/a> does not currently have one (We are working on that, it will come soon). How would you create such a valve using the base components?<\/p>\n<p>Let's begin by putting together a test harness model for our check valve. In the following model, we have two <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ref\/reservoirg.html\">Reservoir<\/a> blocks connected by pipes and a pressure source on the left side. Without a check valve, the flow would go back-and-forth based on the signal from the Sine Wave block.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2017Q3\/testBench.png\" alt=\"Check Valve test harness\" \/><\/p>\n<p>With the Check Valve, we want to allow flow in only one direction, so the response, as seen in the <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ug\/using-the-simscape-results-explorer.html\">Simscape Results Explorer<\/a>, would look like the following:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2017Q3\/desiredFlowRate.png\" alt=\"Check Valve response\" \/><\/p>\n<p><strong>Custom Check Valve Subsystem<\/strong><\/p>\n<p>Let's see what we have inside the Check Valve Subsystem. In this subsystem, we first use a <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ref\/pressuretemperaturesensorg.html\">Pressure & Temperature Sensor (G)<\/a> block to measures the pressure drop across the Valve between ports A and B. We pass this pressure to a <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ref\/pslookuptable1d.html\">PS Lookup Table (1D)<\/a> block, which then generates the opening area of a <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ref\/variablelocalrestrictiong.html\">Variable Local Restriction (G)<\/a> block.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2017Q3\/customCheckValve.png\" alt=\"Check Valve subsystem\" \/><\/p>\n<p><strong>Valve Parameterization<\/strong><\/p>\n<p>To parameterize the Lookup Table, we need to define the opening area as a function of the pressure difference across the valve. For this example, let's say we want our check valve to have a cracking pressure of 10kPa, and a maximum opening pressure of 40 kPa, at which the maximum opening would be 5 mm^2. This would look like:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2017Q3\/pressureAreaCurve.png\" alt=\"Pressure Area relationship\" \/><\/p>\n<p>Based on that information, we can parameterize the orifice:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2017Q3\/psValve.png\" alt=\"Valve Parameters\" \/><\/p>\n<p>and the Lookup Table:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2017Q3\/psLUT.png\" alt=\"Lookup Table Parameters\" \/><\/p>\n<p><strong>Valve Dynamics<\/strong><\/p>\n<p>Finally, we insert a first order delay to prevent the valve from \u201cteleporting\u201d from position to position as the pressure changes. Looking inside the <tt>OpeningDelay<\/tt> Subsystem we see how to accomplish this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2017Q3\/openingDelay.png\" alt=\"Opening Delay\" \/><\/p>\n<p>In this Subsystem, there is a <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ref\/psgain.html\">PS Gain<\/a> block which is labeled \u201cTime Constant.\u201d The value in this block sets the amount of delay the system imposes by its inverse, for example specifying a value of 10 results in a delay of 0.1 second.<\/p>\n<p>Running the simulation and looking at the <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ref\/sscexplore.html\">Simscape Results Explorer<\/a> will show results as displayed above.<\/p>\n<p>Increasing the Gain in the PS Gain block in the OpeningDelay subsystem to 1 makes the valve slower to respond (1 second) and produces the following:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2017Q3\/valveWithDelay.png\" alt=\"Opening Delay longer\" \/><\/p>\n<p>As can be seen from the plot, there is a small leakage backward as the valve closes. This could represent a valve with a weak spring or resistance to closure.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>This blog post describes one way to implement a check valve for the Simscape Gas library. There could be many others, depending on your coding preferences, and the level of accuracy your application needs.<\/p>\n<p>For example, we could have implemented a similar check valve using the Simscape language. We could also have modeled the mechanical part of the valve using blocks from the Simscape mechanical domain, like masses, springs and dampers.<\/p>\n<p>Let us know in the comments below if you would like us to write more about other possible ways to implement valves in Simscape.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2017Q3\/valveWithDelay.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>Some time ago, I wrote a blog post about how to implement a custom valve for the Simscape Hydraulic domain. Today I am happy to welcome guest bloggers Erin McGarrity and Ruth-Anne Marchant who will... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2017\/08\/17\/creating-your-own-check-valve-for-the-simscape-gas-domain\/\">read more >><\/a><\/p>\n","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[39],"tags":[502,105,428],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/6706"}],"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=6706"}],"version-history":[{"count":11,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/6706\/revisions"}],"predecessor-version":[{"id":6718,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/6706\/revisions\/6718"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=6706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=6706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=6706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}