{"id":5098,"date":"2016-03-22T11:48:37","date_gmt":"2016-03-22T16:48:37","guid":{"rendered":"https:\/\/blogs.mathworks.com\/simulink\/?p=5098"},"modified":"2018-11-11T21:35:26","modified_gmt":"2018-11-12T02:35:26","slug":"coolprop-to-the-rescue","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2016\/03\/22\/coolprop-to-the-rescue\/","title":{"rendered":"CoolProp to the Rescue"},"content":{"rendered":"<p><em>This week, I am happy to welcome guest blogger <a href=\"https:\/\/ww2.mathworks.cn\/en\/services\/consulting\/meet-our-team\/tom-egel.html\">Tom Egel<\/a> from <a href=\"https:\/\/www.mathworks.com\/services\/consulting\/\">MathWorks Consulting Services<\/a>.<\/em><\/p>\r\n\r\n<p><strong>CoolProp to the Rescue<\/strong><\/p>\r\n\r\n<p>Do you use the Simscape <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/thermal-liquid-models.html\">Thermal Liquid domain<\/a>?  If so, then you should know about <a href=\"http:\/\/www.coolprop.org\/\">CoolProp<\/a>.<\/p>\r\n\r\n<p>Specifying fluid properties is an important part of creating an accurate simulation model. The industry standard <a href=\"http:\/\/www.nist.gov\/srd\/nist23.cfm\">REFPROP database from NIST<\/a> contains many fluid properties.  There is a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/38339-engine-cooling-model-in-simscape\">demo on MATLAB Central<\/a> showing how it can be used to parametrize a Simscape model.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2016Q1\/ssc_engine_cooling_system_01.png\" alt=\"Engine Cooling demo\" \/><\/p>\r\n\r\n\r\n<p>Obviously, not all fluids in the universe are present in the REFPROP database. One notable omission is common antifreeze, also known as <a href=\"https:\/\/en.wikipedia.org\/wiki\/Ethylene_glycol\">Ethylene Glycol<\/a> (or the more environmentally friendly <a href=\"https:\/\/en.wikipedia.org\/wiki\/Propylene_glycol\">Propylene Glycol<\/a>).<\/p>\r\n\r\n<p>This is where CoolProp comes in...<\/p>\r\n\r\n<p>CoolProp is an open source fluid property database very similar to REFPROP, and it provides <a href=\"http:\/\/www.coolprop.org\/coolprop\/wrappers\/MATLAB\/index.html#matlab\">wrappers so it can be called from MATLAB<\/a>.<\/p>\r\n\r\n<p>To get started, go to their <a href=\"https:\/\/sourceforge.net\/projects\/coolprop\/files\/CoolProp\/nightly\/MATLAB\/\">sourgeforge project page<\/a> and download those four files: +CoolProp.7z, CoolPropsetup.m, SwigRef.m, and the wrapper MEX-file for your operating system.<\/p>\r\n\r\n<p>With that on your path, you can obtain properties, for example the density, of a Propylene Glycol (PG) mixture using code like:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2016Q1\/propyleneDensity.png\" alt=\"Obtaining the density of Propylene Glycol\" \/><\/p>\r\n\r\n<p>The main function call <tt>CoolProp.PropsSI<\/tt> can only operate on scalar quantities (single temperature and pressure values), so the next step is to wrap the calls to <tt>CoolProp.PropsSI<\/tt> in for loops to create the 2D tables needed for the Simscape Thermal Liquid domain.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2016Q1\/prop2D.png\" alt=\"Obtaining the density of Propylene Glycol\" \/><\/p>\r\n\r\n<p>We can then call this function for the range of pressures and temperature of interest, and obtain the different properties needed by the Thermal Liquid domain.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2016Q1\/allPropyleProps.png\" alt=\"Obtaining the density of Propylene Glycol\" \/><\/p>\r\n\r\n<p>And use the output in the Thermal Liquid Settings block:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2016Q1\/configBlock.png\" alt=\"Thermal Liquid Settings\" \/><\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Do you simulate exotic fluids with the Simscape Thermal Liquid domain? How do you get you fluid properties data? Let us know by leaving a <a href=\"https:\/\/blogs.mathworks.com\/simulink\/?p=5098&#comment\">comment here<\/a><\/p>\r\n\r\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2016Q1\/configBlock.png\" onError=\"this.style.display ='none';\" \/><\/div><p>This week, I am happy to welcome guest blogger Tom Egel from MathWorks Consulting Services.\r\n\r\nCoolProp to the Rescue\r\n\r\nDo you use the Simscape Thermal Liquid domain?  If so, then you should know... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2016\/03\/22\/coolprop-to-the-rescue\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[39],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/5098"}],"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=5098"}],"version-history":[{"count":10,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/5098\/revisions"}],"predecessor-version":[{"id":8312,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/5098\/revisions\/8312"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=5098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=5098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=5098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}