Skip to content
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

avoid warning "Variable array index in equation can result in slow simulation time" in PressureIndependent damper #1513

Closed
mwetter opened this issue Aug 11, 2021 · 0 comments · Fixed by #1514
Assignees

Comments

@mwetter
Copy link
Contributor

mwetter commented Aug 11, 2021

With OCT, the model IBPSA.Fluid.Actuators.Dampers.PressureIndependent triggers during translation the warning

Variable array index in equation can result in slow simulation time

This is during parameter evaluation, and can be avoided with the change

 initial equation
   (kSupSpl, idx_sorted) = Modelica.Math.Vectors.sort(kSupSpl_raw, ascending=true);
-  ySupSpl = ySupSpl_raw[idx_sorted];
-  invSplDer = IBPSA.Utilities.Math.Functions.splineDerivatives(x=kSupSpl, y=ySupSpl);
+  // The sum below is a trick to avoid in OPTIMICA the warning
+  // Variable array index in equation can result in slow simulation time if we were to use
+  // ySupSpl = ySupSpl_raw[idx_sorted];
+  for i in 1:sizeSupSpl loop
+    ySupSpl[i] = sum((if k == idx_sorted[i] then ySupSpl_raw[k] else 0) for k in 1:sizeSupSpl);
+  end for;
+  invSplDer = IBPSA.Utilities.Math.Functions.splineDerivatives(x=kSupSpl_raw, y=ySupSpl_raw);
 equation
@mwetter mwetter self-assigned this Aug 11, 2021
mwetter added a commit that referenced this issue Aug 11, 2021
This change also reorders constant declarations
mwetter added a commit that referenced this issue Aug 12, 2021
Reformulated initial equation section for #1513
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant