It is a simple idea that I want to solve the same equations in a finite volume when the variable x of the next volume is calculated smaller than 0. Due to the characteristic of the modeling language, it is really difficult for me to do the cycle. I hope someone can help me with this. Thank you!

```
model Model
parameter Real L = 10;
parameter Real r = 5;
parameter Integer N = 20;
Real x(N)(each start = 0);
equation
if noEvent(x(1) >= 0 and x(1) < L) then
der(x(1)) = r;
else
der(x(1)) = 0;
end if;
for i in 2:N loop
if noEvent(x(i - 1) >= L and x(i) >= 0 and x(i) < L) then
der(x(i)) = r - 1 * time;
elseif noEvent(x(i) < 0) then
der(x(i - 1)) = r - x(i - 1);
else
der(x(i)) = 0;
end if;
end for;
end model;
```

The code simply cannot dose when the time> 8s. And the Mworks show the message:

```
...
Error: Failed to solve linear system at Time = 7.99999989157494
Error: Failed to solve linear system at Time = 7.99999989157489
Error: Failed to solve linear system at Time = 7.99999989157489
```