Opened 17 years ago

Closed 11 years ago

#129 closed defect (fixed)

Using alias substitution BLT(and tearing?) in initial equations

Reported by: Francesco Casella Owned by: Francesco Casella
Priority: critical Milestone:
Component: Backend Version:
Keywords: Cc: Francesco Casella, Adrian Pop, Lennart Ochel

Description


Change History (3)

comment:1 by Francesco Casella, 17 years ago

Currently, the list of initial equations residual in the initial_residual() .cpp function is generated from the flattened model by packing together equations and initial equations as they are.

Applying alias substitution could substantially reduce the size of the problem for the least-squares solver. BLT transformation could also help break the initialization problem into smaller problems (even though the structure of initialization problems often shows one large block and several much smaller blocks in the BLT).

Consider this small example:

model Example

Real x(start = 3, fixed = false);
Real y;
Real z;
Real w;

equation

der(x) = -x - y - z +1;
y = x;
z = x;
w = 2*x;

initial equation

der(x) = 0;

end Example;

Currently, there are 5 non-dummy residuals in the .cpp code

localData->initialResiduals[i++] = ($w - (2.0 * $x));
localData->initialResiduals[i++] = ($derivative$x - (1.0 + (-3.0 * $x)));
localData->initialResiduals[i++] = ($y - $x);
localData->initialResiduals[i++] = ($z - $x);
localData->initialResiduals[i++] = $derivative$x;

After alias substitution and BLT partitioning, you'd get two much smaller problems to solve in sequence: first

localData->initialResiduals[i++] = $derivative$x;
localData->initialResiduals[i++] = ($derivative$x - (1.0 + (-3.0 * $x)));

and then

localData->initialResiduals[i++] = ($w - (2.0 * $x));

If alias substitution is applied, it will become very important to manage the start values correctly. In this case, when an alias is selected for x, y, z, it is important to make sure that the start attribute of x (which was set at a higher level) has a precedence over the default start attributes of y and z. We've already discussed this issue a lot with Dynasim (it is very important for the initialization of fluid systems), so I could help with it.

Finally, it won't be bad to also have some (possibly limited) tearing capabilities as well, in order to ease the job of the least squares solver.

comment:2 by Lennart Ochel, 12 years ago

Cc: Lennart Ochel added
Component: Backend

comment:3 by Lennart Ochel, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.