CURENT / andes

Python toolbox / library for power system transient dynamics simulation with symbolic modeling and numerical analysis 🔥
https://ltb.curent.org
Other
208 stars 108 forks source link

Fixed Teye #485

Closed zaidmahmood closed 9 months ago

zaidmahmood commented 9 months ago

Fixed an issue where mass matrix was not being updated in set() call.

cuihantao commented 9 months ago

Github is now showing my code review. Pasting it here:

                    uid_int = state.a[uid].item()
                    self.system.TDS.Teye[uid_int, uid_int] = instance.v[uid]

This will fail when uid is an array of more than one element. In that case, uid_int will be a list of multiple elements. Teye[uid_int, uid_int] will be a copy of the square sparse matrix, which cannot be assigned a list (instance.v[uid]).

I guess what you will need is a list comprehension or a for loop. @zaidmahmood

cuihantao commented 9 months ago

The new change does not account for an np.ndarray type of input. Also, the program should fail explicitly if the input does not match any of the conditions, i.e., in addition to if-elif, we need an else.

cuihantao commented 9 months ago

I added new tests for the change. The test failed due to another unrelated issue. Please take a look at the file changes.