{"id":50,"date":"2017-10-16T19:13:31","date_gmt":"2017-10-16T19:13:31","guid":{"rendered":"https:\/\/cyflexdoc.wpengine.com\/?p=50"},"modified":"2018-03-24T11:08:02","modified_gmt":"2018-03-24T11:08:02","slug":"cyflex-math-and-the-temperature-gotcha","status":"publish","type":"post","link":"https:\/\/cyflex.com\/index.php\/cyflex-math-and-the-temperature-gotcha\/","title":{"rendered":"CyFlex Math and the temperature \u201cGOTCHA\u201d"},"content":{"rendered":"<p>Units Independence in CyFlex computations:<\/p>\n<p>CyFlex supports \u201cunits-independence\u201d. Internally, applications such as \u201ccompvar\u201d, mass flow rate, etc. perform computations using SI (metric) base units. Inputs and outputs to these programs involve a units conversion process so that the inputs and outputs can be in other units. A simple example of this is the computation of horsepower from engine speed and torque. The speed may be in \u201crpm\u201d, the torque in \u201clb-ft\u201d and the desired result to be in \u201chp\u201d. The internal process is as follows.<\/p>\n<p>1. Convert the speed input value from \u201crpm\u201d to \u201cradians\/sec\u201d<br \/>\n2. Convert the torque input value from \u201clb-ft\u201d to \u201cnewton-meters\u201d<br \/>\n3. Multiply speed by torque, producing a power value in \u201cwatts\u201d<br \/>\n4. Convert the power from \u201cwatts\u201d to \u201chp\u201d<br \/>\n5. Store the power in \u201chp\u201d in the output variable<br \/>\nIn a CyFlex computed expression, this is simply &#8220;eng_spd * eng_torque&#8221; and it doesn&#8217;t matter if eng_spd and eng_torque are in English or Metric units. The result will still be computed properly. Likewise, the output target could be &#8220;hp&#8221; or &#8220;kw&#8221; and the appropriate conversion from &#8220;watts&#8221; will be performed.<\/p>\n<p>See Section 7 of the &#8220;CyFlex Variables, Units, Computed Expressions&#8221; user manual for details of the rules for writing computed expressions.<\/p>\n<p>The Temperature \u201cGOTCHA\u201d:<\/p>\n<p>The description above also describes how conversion takes place for temperature values, but the normal Celsius and Fahrenheit units have a characteristic that is different from other units. They have an offset (bias). Units of pressure, speed, torque, etc., do not have an offset, so 0[psi] = 0[kpa] = 0[in_hg] = 0[in_h20] and so on. However,<\/p>\n<p>0[deg_c] = 273.15[K] (Kelvin is the SI base units)<\/p>\n<p>0[deg_f] = 255.372[K]<\/p>\n<p>So, now take an example of a simple addition expression:<\/p>\n<p>\u201c100[deg_f] + 1[deg_f]\u201d<\/p>\n<p>You expect the result to be 101[deg_f], but here is how the math works:<\/p>\n<p>100[deg_f] converts to 310.928[K]<\/p>\n<p>1[deg_f] converts to 255.928[K]<\/p>\n<p>Summing these values yields a result of 566.855[K]<\/p>\n<p>Converting the result to \u201cdeg_f\u201d yields 560.67[deg_f] ????<\/p>\n<p>What if we just try to subtract 1[deg_f] \u201c100[deg_f] &#8211; 1[deg_f]\u201d<\/p>\n<p>The subtraction (310.92 \u2013 255.928] yields 55[K] which converts to -360.67[deg_f] ???<\/p>\n<p>That demonstrates the problem. But what is the solution. CyFlex has some special temperature units referred to as \u201ctemperature differential\u201d units, \u201cdt_f\u201d, \u201cdt_c\u201d, \u201cdt_k\u201d, and \u201cdt_r\u201d. These units have the bias removed from the units conversion factors.<\/p>\n<p>So, the 100+1 math works as follows when the differential units are specified:<\/p>\n<p>\u201c100[deg_f] + 1[dt_f]\u201d<\/p>\n<p>100[deg_f] converts to 310.928[K]<\/p>\n<p>1[dt_f] converts to 0.5555[K]<\/p>\n<p>Summing these values yields a result of 311.483[K]<\/p>\n<p>Converting the result to \u201cdeg_f\u201d yields 101[deg_f] (ta da!)<\/p>\n<p>Likewise, for subtraction.<\/p>\n<p>Testing expressions from the command line:<\/p>\n<p>You can experiment with any computed expression using the \u201cget_comp\u201d application. Type \u201cuse get_comp\u201d for help.<\/p>\n<p>get_comp \u201cexpression\u201d [u=units]<\/p>\n<p>If u=units are not included, the result is always reported in base SI units. Example:<\/p>\n<p>get_comp \u201c100[deg_f] + 1[dt_f]\u201d<br \/>\n311.48<\/p>\n<p>get_comp \u201c100[deg_f] + 1[dt_f]\u201d u=deg_f<br \/>\n101.00[f]<\/p>\n<p>This units-independence feature is why numeric values in CyFlex expressions include units of measure.<br \/>\nOther benefits of units-independence are that it allows a measurement in one set of units to be displayed, logged, or monitored in different units.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Units Independence in CyFlex computations: CyFlex supports \u201cunits-independence\u201d. Internally, applications such as \u201ccompvar\u201d, mass flow rate, etc. perform computations using SI (metric) base units. Inputs and outputs to these programs involve a units conversion process so that the inputs and outputs can be in other units. A simple example of this is the computation of [&hellip;]<\/p>\n","protected":false},"author":47,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-50","post","type-post","status-publish","format-standard","hentry","category-did-you-know"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/cyflex.com\/index.php\/wp-json\/wp\/v2\/posts\/50","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cyflex.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cyflex.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cyflex.com\/index.php\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/cyflex.com\/index.php\/wp-json\/wp\/v2\/comments?post=50"}],"version-history":[{"count":0,"href":"https:\/\/cyflex.com\/index.php\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"wp:attachment":[{"href":"https:\/\/cyflex.com\/index.php\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cyflex.com\/index.php\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cyflex.com\/index.php\/wp-json\/wp\/v2\/tags?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}