New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reformulation of basicFlowFunctions #725
Comments
The same test for Old: Old:
New:
|
Note, inlining does not seem to work in dymola 2017. |
Old:
New:
|
I found another formulation that's a bit slower, but it is C2 continuous:
this one takes 0.36 seconds in the test (instead of 0.255), but it's C2 continuous and for such an important function I think it makes sense to use it instead of the current C1 continuous implementation. If you agree then I'll re-implement the derivative functions and |
I think that's fine. Maybe |
For future reference: Based on this timer the C2 implementation is actually faster than edit: for |
Similar to #723
IBPSA.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp
can be reformulated frominto
In a (best case) example model this yields a significant speedup. Consider the example:
which evaluates the function only in the regularisation region. I simulated this using
The old formulation leads to:
The new formulations leads to:
the cpu times seem to be self-inconsistent but they do show a clear advantage of the new formulation. Re-adding the
else if
construct does not affect computation time so the gains in computation time seem to be entirely related to the formulation of theelse
branch.When changing the else branch from
dp*m_flow_turbulent/dp_turbulent/4*(5-(dp/dp_turbulent)^2)
todp*m_flow_turbulent^5/m_flow_turbulent^4/dp_turbulent/4*(5-(dp/dp_turbulent)^2)
computation time rises by more than a factor of 10.
(m_flow_turbulent/k)^2
is a lot faster than(m_flow_turbulent/k)*(m_flow_turbulent/k)
.Adding and eliminating
Modelica.SIunits.PressureDifference dp_div = dp/dp_turbulent "Help variable for computational efficiency";
Leads to
CPU-time for integration : 0.255 seconds
Replacing
/4
by*0.25
does not have a noticeable effect.I'm not sure what's going on, but I suggest to go with this new formulation:
The text was updated successfully, but these errors were encountered: