#4920 closed defect (fixed)
The NF does not expand the arguments of the product() function to scalars
Reported by: | casella | Owned by: | perost |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description
Please check Modelica.Electrical.PowerConverters.Examples.ACDC.RectifierBridge2Pulse.HalfControlledBridge2Pulse.err.
When flattening with the old FE, this equation is obtained:
rootMeanSquareVoltage.product.y = rootMeanSquareVoltage.product.u[1] * rootMeanSquareVoltage.product.u[2];
while the NF gives
rootMeanSquareVoltage.product.y = product(rootMeanSquareVoltage.product.u);
which eventually the code generation chain cannot handle.
Change History (3)
comment:1 Changed 6 years ago by sjoelund.se
comment:2 Changed 6 years ago by sjoelund.se
I thought to fix the old FE by translating into a reduction expression by calling vector() to flatten the array (https://github.com/OpenModelica/OMCompiler/pull/2403). But it only works if at most 1 dimension is >1. sum and product work in almost the same way, but only sum is handled (mostly) correctly (in Static, Ceval, Simplify). If we had an operator to reshape a multi-dim array into a vector that was handled properly everywhere (including efficient code generation for iterators), that would be great.
comment:3 Changed 6 years ago by perost
- Resolution set to fixed
- Status changed from new to closed
Fixed in 30b0d61 by adding code generation for product. The runtime functionality was actually already implemented, I guess someone had just forgot to add a case for product in the code generator.
I believe the old FE also hides other problems by pretending it can always expand product. For example the following just expands the product to 1.0:
That error should be fixed along with the code generation. product(v for v in r) works fine in the old FE, but the new FE still converts this to product(array(...)) which is not supported in code generation.