When OpenVAF compresses derivatives shared in a common subgraph it
may in some cases find nested subgraphs. For example if a voltage is
calculated with Vab = Vay + Vyx + Vxb to save an unknown OpenVAF will
perform two subgraph optimizations (one for each addition).
Previously OpenVAF would only emit the derivatives for the last
subgraph in this case as the chain rule was applied in the incorrect
order. This would cause catastrophic convergence failures for some
models like MEXTRAM.
This commit reverses the order in which chain rules are applied.
However, this meant that higher order derivative chain rules were not
emitted properly as the lower order derivative needs to be emitted
first (which was pushed to the chain rule list first). Therefore, the
order in which derivatives where pushed to the chain rule list was
also reversed.
A unit case that covers this case (and the subgraph optimization in
general) was added to ensure this doesn't regress in the future.
When OpenVAF compresses derivatives shared in a common subgraph it may in some cases find nested subgraphs. For example if a voltage is calculated with
Vab = Vay + Vyx + Vxb
to save an unknown OpenVAF will perform two subgraph optimizations (one for each addition).Previously OpenVAF would only emit the derivatives for the last subgraph in this case as the chain rule was applied in the incorrect order. This would cause catastrophic convergence failures for some models like MEXTRAM.
This commit reverses the order in which chain rules are applied. However, this meant that higher order derivative chain rules were not emitted properly as the lower order derivative needs to be emitted first (which was pushed to the chain rule list first). Therefore, the order in which derivatives where pushed to the chain rule list was also reversed.
A unit case that covers this case (and the subgraph optimization in general) was added to ensure this doesn't regress in the future.