Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » Mr.Stier98
  • » Profile

Posts

Posts

Feb-10-22 13:21:19
event triggered definition of array elements gives wrong values

the purpose of this model is to provide the indexed elements of the "vector" array the values of the array "tester", which are increasing numbers from 1 to 12.
This shall happen every time the BooleanPulse is true. The arrays are indexed by the Integer "counter", which increases by 1 every boolean pulse.

the model simulates but gives every "vector" element the value 0. also the warning message is "Failed to solve linear system of equations (no. 21) at time 0.000000. Residual norm is 0.5."

model Array_Test_simple
Real vector[12];
Integer counter;
Real tester[12]=1:1:12;
  Modelica.Blocks.Sources.BooleanPulse booleanPulse(period = 0.1)  annotation(
    Placement(visible = true, transformation(origin = {-62, 38}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));

initial algorithm
counter:=1;
algorithm

when booleanPulse.y then
vector[counter]:=tester[counter];
counter:=pre(counter)+1;
end when;

equation

annotation(
    uses(Modelica(version = "4.0.0")));
end Array_Test_simple;

  • Index
  • » Users
  • » Mr.Stier98
  • » Profile
You are here: