{"action":"opened","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":197510952,"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":[],"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":0,"created_at":"2016-12-25T18:28:08Z","updated_at":"2016-12-25T18:28:08Z","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"}}
{"actor":{"display_login":"modelica-trac-importer"}}