Skip to content

Commit 9420949

Browse files
evaluateResidual() uses updateChildren()
1 parent 617a300 commit 9420949

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

src/Model/PhasorDynamics/SystemModel.hpp

+4-29
Original file line numberDiff line numberDiff line change
@@ -263,42 +263,17 @@ namespace GridKit
263263
*/
264264
int evaluateResidual()
265265
{
266-
// Update variables
267-
IdxT varOffset = 0;
268-
IdxT optOffset = 0;
266+
// No need to notify children yet, since we're about to
267+
// evaluate them
268+
updateChildren<false>();
269+
269270
for (const auto& bus : buses_)
270271
{
271-
for (IdxT j = 0; j < bus->size(); ++j)
272-
{
273-
bus->y()[j] = y_[varOffset + j];
274-
bus->yp()[j] = yp_[varOffset + j];
275-
}
276-
varOffset += bus->size();
277-
278-
for (IdxT j = 0; j < bus->sizeParams(); ++j)
279-
{
280-
bus->param()[j] = param_[optOffset + j];
281-
}
282-
optOffset += bus->sizeParams();
283-
284272
bus->evaluateResidual();
285273
}
286274

287275
for (const auto& component : components_)
288276
{
289-
for (IdxT j = 0; j < component->size(); ++j)
290-
{
291-
component->y()[j] = y_[varOffset + j];
292-
component->yp()[j] = yp_[varOffset + j];
293-
}
294-
varOffset += component->size();
295-
296-
for (IdxT j = 0; j < component->sizeParams(); ++j)
297-
{
298-
component->param()[j] = param_[optOffset + j];
299-
}
300-
optOffset += component->sizeParams();
301-
302277
component->evaluateResidual();
303278
}
304279

0 commit comments

Comments
 (0)