Opened 7 years ago
Closed 7 years ago
#4862 closed defect (fixed)
The NF does not evaluate expressions with Integer indeces
Reported by: | Francesco Casella | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description
Please check the ScalableTestSuite.Power.ConceptualPowerSystem.Verification.TwoGeneratorsStepLoad model. It currently fails during C code compilation.
Flattening the model with the NF leads to equations such as
generator[2].T_s[2] = (generator[2].T_s[2 - 1] + generator[2].NTU / 4.0 * generator[2].T_source) / (1.0 + generator[2].NTU / 4.0);
and
if 1 == 1 then P_diss[1,1] = 0.0; P_ex[1,1] = 0.0; else P_diss[1,1] = P_d * (generator[1].omega - generator[1].omega); P_ex[1,1] = P_f / /*Real*/(abs(1 - 1)) * sin(generator[1].theta - generator[1].theta); end if;
In the first case, the indeces of the array elements should be evaluated to literal constants (as with the old FE).
In the second case, the condition should be evaluated and only the first branch should be included in the flat code.
Change History (4)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
This does not seem to be the current error. Instead it is that scalar*array and array*scalar is translated to scalar*scalar. Note also that the old FE does not have scalar*array (it swaps the arguments to only implement one operator).
comment:4 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
After PR #2350, the model now simulates
Something similar happens in Modelica.Blocks.Examples.PID_Controller. The flattened code contains the follwing lines
instead of