{"action":"created","issue":{"url":"https://api.github.com/repos/tbeu/Modelica/issues/322","repository_url":"https://api.github.com/repos/tbeu/Modelica","labels_url":"https://api.github.com/repos/tbeu/Modelica/issues/322/labels{/name}","comments_url":"https://api.github.com/repos/tbeu/Modelica/issues/322/comments","events_url":"https://api.github.com/repos/tbeu/Modelica/issues/322/events","html_url":"https://github.com/tbeu/Modelica/issues/322","id":196582221,"number":322,"title":"Conservation of energy in Modelica_Fluid (kinetic term)","user":{"login":"modelica-trac-importer","id":22202507,"avatar_url":"https://avatars.githubusercontent.com/u/22202507?v=3","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"labels":[{"id":503777660,"url":"https://api.github.com/repos/tbeu/Modelica/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":503785333,"url":"https://api.github.com/repos/tbeu/Modelica/labels/P:%20high","name":"P: high","color":"ff6666","default":false}],"state":"open","locked":false,"assignee":{"login":"beutlich","id":14896695,"avatar_url":"https://avatars.githubusercontent.com/u/14896695?v=3","gravatar_id":"","url":"https://api.github.com/users/beutlich","html_url":"https://github.com/beutlich","followers_url":"https://api.github.com/users/beutlich/followers","following_url":"https://api.github.com/users/beutlich/following{/other_user}","gists_url":"https://api.github.com/users/beutlich/gists{/gist_id}","starred_url":"https://api.github.com/users/beutlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beutlich/subscriptions","organizations_url":"https://api.github.com/users/beutlich/orgs","repos_url":"https://api.github.com/users/beutlich/repos","events_url":"https://api.github.com/users/beutlich/events{/privacy}","received_events_url":"https://api.github.com/users/beutlich/received_events","type":"User","site_admin":false},"assignees":[{"login":"beutlich","id":14896695,"avatar_url":"https://avatars.githubusercontent.com/u/14896695?v=3","gravatar_id":"","url":"https://api.github.com/users/beutlich","html_url":"https://github.com/beutlich","followers_url":"https://api.github.com/users/beutlich/followers","following_url":"https://api.github.com/users/beutlich/following{/other_user}","gists_url":"https://api.github.com/users/beutlich/gists{/gist_id}","starred_url":"https://api.github.com/users/beutlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beutlich/subscriptions","organizations_url":"https://api.github.com/users/beutlich/orgs","repos_url":"https://api.github.com/users/beutlich/repos","events_url":"https://api.github.com/users/beutlich/events{/privacy}","received_events_url":"https://api.github.com/users/beutlich/received_events","type":"User","site_admin":false}],"milestone":null,"comments":7,"created_at":"2016-12-20T04:11:17Z","updated_at":"2016-12-20T04:12:57Z","closed_at":null,"body":"**Reported by fcasella on 23 Jan 2009 00:23 UTC**\nA few general considerations about the energy balance equations in Modelica_Fluid\n\nThe energy balance equation for 1D systems includes a term\n\nd/dx(m_flow*(e + p/rho + u<sup>2</sup>/2 + gz))\n\nwhich accounts for internal energy, pressure energy, kinetic energy, and potential energy. Let's consider for simplicity the equations of components with no storage and no heat or work added from the outside (i.e. PartialTwoPortTransport): the balance equation is then\n\nd/dx(m_flow*(h + u<sup>2</sup>/2 + gz)) = 0\n\nand m_flow is uniform from inlet to outlet (due to the mass balance equation). The equation can thus be integrated from port_a to port_b, giving\n\nh_a + u_a<sup>2</sup>/2 + gz_a = h_b + u_b<sup>2</sup>/2 + gz_b\n\nIn many applications where there is significant heat transfer, the mechanical terms gz and u<sup>2</sup>/2 are negligible, compared to the changes in h due to heat transfer, so the equation is approximated as\n\nh_a = h_b\n\nwhich then becomes\n\n```\nport_a.h_outflow = inStream(port_b.h_outflow);\nport_b.h_outflow = inStream(port_a.h_outflow);\n```\nHowever, there are cases where this terms might be significant (e.g. nozzles, vertical pipes), so it is interesting to check whether it would be possible to consider them in Modelica_Fluid without too much overhead.\n\nThe gravity term is no big deal, as it gives a constant contribution. Furthermore, if z_a-z_b = 0, it is easy to get rid of it by symbolic manipulation. So, we agreed to write these equations in PartialTwoPortTransport:\n\n```\nport_a.h_outflow = inStream(port_b.h_outflow) + g*(z_b-z_a); \nport_b.h_outflow = inStream(port_a.h_outflow) + g*(z_a-z_b);\n```\nThe kinetic term is much more problematic, as it depends on the velocity, and thus on density, mass flow rate, and cross section at the port. The cross section might not be available in many cases (and usually not relevant either). Furthermore, the dependence on the mass flow rate would break the nice property of propagation of inStream enthalpy in series-connected flow models, by introducing nonlinear implicit equations for the stream enthalpy involving the mass flow rates. Finally, computing the velocity at both ports requires to always compute the port density, which might be not needed otherwise.  Therefore, writing:\n\n```\nport_a.h_outflow = inStream(port_b.h_outflow) + g*(z_b-z_a) +\n                   (u_b^2-u_a^2)/2;\nport_b.h_outflow = inStream(port_a.h_outflow) + g*(z_a-z_b) +\n                   (u_a^2-u_b^2)/2;\n```\nmight not be convenient.\n\nOne possible solution is to define h_outflow on the ports as the so-called _total enthalpy_, or _stagnation enthalpy_, i.e. h + u<sup>2</sup>/2. In this way, the equations\n\n```\nport_a.h_outflow = inStream(port_b.h_outflow) + g*(z_b-z_a);\nport_b.h_outflow = inStream(port_a.h_outflow) + g*(z_a-z_b);\n```\nare exact, and (total) enthalpy is propagated through chains of flow components without generating implicit nonlinear equations involving the mass flow rate.\n\nFor all the applications where u<sup>2</sup>/2 is negligible, one could use h_outflow directly to compute the thermodynamic properties of the fluid, thus ignoring the small difference between enthalpy and total enthalpy. In those special cases where the velocity is significant (e.g. a nozzle), it is possible to write\n\n```\nh_total = inStream(port.h_outflow);\nstate = Medium.setState_ph(port.p, h_total - u^2/2);\n```\nOf course this additional term could be made optional, so the additional numerical complication due to more coupled nonlinear algebraic equations is only included when necessary.\n\nThe advantage of this solution is that, while allowing exact results, the added complication is local to those few components where the velocity is relevant. Furthermore, the energy balance is always correct, while the approximation would just involve the computation of the thermodynamic state corresponding to a certain enthalpy.\n\nThe changes to the existing library are minor: a change to the description of the connector variables, and a few changes on those components which might have a significant variation of velocity between inlet and outlet.\n\n----\n\nMigrated from https://trac.modelica.org/Modelica/ticket/322"},"comment":{"url":"https://api.github.com/repos/tbeu/Modelica/issues/comments/268150114","html_url":"https://github.com/tbeu/Modelica/issues/322#issuecomment-268150114","issue_url":"https://api.github.com/repos/tbeu/Modelica/issues/322","id":268150114,"user":{"login":"modelica-trac-importer","id":22202507,"avatar_url":"https://avatars.githubusercontent.com/u/22202507?v=3","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"created_at":"2016-12-20T04:12:57Z","updated_at":"2016-12-20T04:12:57Z","body":"**Comment by &#x65;&#x72;ic&#46;thomas&#x40;das&#x73;ault-aviat&#105;o&#110;&#x2e;&#x63;&#x6f;m on 26 Jan 2009 09:12 UTC**\nComment about taking into account kinetic energy (fluid mean velocity) into Modelica_Fluid :\n\"> For about two months, I try to  to develop ECS model from \n> Modelica_Fluid ... and will be interested further to model shock waves ....\n> I don't know what is the opinion of Michael Sielemann, who also \n> developp a ECS lib, but I consider that Modelica_Fluid is difficult to \n> use for such modeling (even if it has very good properties to model \n> many other fluid domains.) In ECS, we always have to distinguish \n> static and total properties.\n> Sometimes it would be interesting to have one of them (in the \n> connector), and sometimes the other ones.\n> I don't say that Modelica_Fluid is not usable for ECS, but to use it \n> model developpers must make several important assumptions, especially \n> on the signification of the enthalpy in the connectors, depending of \n> needs in the models.\n>  \n> For example, to switch from a definition the another one and obtain \n> suitable properties, I created the following model\n>  \n> replaceable model ECSDyn0\n>   \"ECS Dyn Base properties (total properties : p, T, m_flow => Ps, Ts,\n> Mach) of a medium\"\n>   import SI = Modelica.SIunits;\n>   import CF = DasECSlib.Utilities.CommonFunctions;\n>  \n>   InputAbsolutePressure p \"Total absolute pressure of medium\";\n>   InputTemperature T \"Total enthalpy of medium\";\n>   InputVelocity V \"Velocity of medium\";\n>   SI.Pressure ps(start=1e5) \"Static pressure of medium\";\n>   SI.Pressure pss(start=1e5) \"Static sound pressure of medium\";\n>   SI.Temperature Ts(start=300) \"Static temperature of medium\";\n>   SI.Density ds \"Static density of medium\";\n>   Real Mach \"Mach number\";\n>  \n>   // Local connector definition, used for equation balancing check\n>   connector InputAbsolutePressure = input Modelica.SIunits.AbsolutePressure\n>     \"Total pressure as input signal connector\";\n>   connector InputTemperature = input Modelica.SIunits.Temperature\n>     \"Total specific enthalpy as input signal connector\";\n>   connector InputVelocity = input Modelica.SIunits.Velocity\n>     \"Velocity as input signal connector\";\n>  \n> protected\n>   constant Real r = 287;\n>   constant Real gamma = 1.405;\n>   parameter SI.SpecificHeatCapacityAtConstantPressure cp = \n> r*gamma/(gamma-1);\n>   parameter Real kp = gamma/(gamma-1); //3.5\n>  \n> equation\n>  \n>   //Hypothesis : Perfect gas (GP) ou semi-perfect (SP)\n>   p = ps*(1+V<sup>2/(2*cp*Ts))</sup>kp;   //GP\n>   p = pss*((gamma+1)/2)^kp;      //GP\n>   T = Ts*(1+V^2/(2*cp*Ts));                        //GP\n>   ds = ps/(r*Ts);                                  //GP and SP\n>   Mach = V/sqrt(gamma*r*Ts);                       //GP and SP\n>  \n>   //Source : [R01] : \"Thermodynamique et Energétique, Tome 1 De \n> l'énergie à l'exergie\",\n>   //PPUR, Lucien Borel-Daniel Favrat => p 151 et 161\n>  \n> end ECSDyn0;\n>  \n> Is'nt it complex, and not really rigourus ? Therefore, if these \n> properties (total and static) could be available more easily in \n> Modelica_Fluid, I would be very interested.\n>  \n> Best regards,\n>  \n> Eric Thomas\n> DA\"\n\nIn addition, it would be intersesting that XRG which make FluidDissipation lib give their opinion.\nPractices in DA:\n- When we use pressure-drops handbooks, like I.E Idel'cik, we use total pressure and temperature, which can be reduced to static ones at low Mach number (<<0.3)\n\n-About tests of compressible fluids in ECS systems:\n - It is quite impossible to measure a static temperature in a fluid network\n - Most of the time, we can measure total and static pressure (but often when only one can be measured, we prefer measuring total pressure)\n\nBest regards,\n\nErid Thomas\nDA\n\n "}}
{"actor":{"display_login":"modelica-trac-importer"}}