-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the ecological analysis method #86
Labels
Comments
mzy2240
added
enhancement
New feature or request
good first issue
Good for newcomers
labels
Sep 9, 2022
# feed line flow to EFM
for i in range(num_branch):
frombus = branch_df['findex'][i]
tobus = branch_df['tindex'][i]
flow = branch_df.loc[i, f"Line{target}"]
if flow > 0:
EFM[1+frombus+num_gen][1+tobus+num_gen] += abs(flow)
else:
EFM[1+tobus+num_gen][1+frombus+num_gen] += abs(flow)
# feed loss
# this loss aggregates the line loss to from bus
# can be further updated based on your consideration.
# however, the loss is/should be very small, thus it may not induce any change
for i in range(num_branch):
frombus = branch_df['findex'][i]
tobus = branch_df['tindex'][i]
flow = branch_df.loc[i, f"LineLoss{target}"]
# flow=branch_df.LineLossMW[i]
EFM[1+num_gen+frombus][2+num_bus+num_gen] += abs(flow)
frombus = branch_df['findex'][i]
tobus = branch_df['tindex'][i] |
@faoh Good job! Now you could consider vectorizing most of the loops, e.g. for i in range(num_gen):
flow = gen.loc[i, f"Gen{target}"]
EFM[0][i+1] += flow # [row][col] The above code could be easily converted into the following code: EFM[0][1:1+num_gen] = gen[f"Gen{target}"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
e.g.
can be optimized into
When computing the EFM, compute the line flow and the loss induced EFM together
Use loc instead of column + index to access cells for better readiness and performance
The text was updated successfully, but these errors were encountered: