Skip to content
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

[WIP] European Merging Function tutorial in pypowsybl #418

Open
obrix opened this issue Jun 7, 2022 · 4 comments
Open

[WIP] European Merging Function tutorial in pypowsybl #418

obrix opened this issue Jun 7, 2022 · 4 comments
Assignees

Comments

@obrix
Copy link
Member

obrix commented Jun 7, 2022

European Merging Function tutorial in pypowsybl

  • Do you want to request a feature or report a bug?

A feature : To expose what is necessary to be able to run the EMF tutorial from powsybl-tutotial in pypowsybl.

  • What is the current behavior?

All necessary API are not exposed in pypowsybl, the following elements are missing :

  • BalanceComputation API
  • BalanceAdjustmentsParameters
  • BalanceComputationArea creation with net positions
  • Exporting a merged cgmes network in xml ?
  • What is the expected behavior?

All necessary API should be exposed to be able to execute the same process as in powsybl-tutorial with a more user friendly approach.

Design

BalanceComputationParameters

The implementation can rely on loadflow.Parameters and add the neccesary members :

class BalanceComputationParameters:
def __init__(self, loadflowparameters: LoadFlow.Parameters, threshold: float, maxNumberIterations: int)

BalanceComputation

In a similar way than LoadFlow class, we can have a BalanceComputation object with a run method that will take a list of BalanceComputionAreas, a merged network, and a BalanceComputationParameters and return a BalanceComputionResult object

class BalanceComputation:
def run(self, network: Network, computationAreas: List[BalanceComputationAreas], parameters: BalanceComputationParameters) -> BalanceComputationResult

BalanceComputationArea

Add a method to BalanceComputation object that will create the list of computation areas in a similar way than what is done in igmPreprocessing and prepareFictitiousArea methods in the tutorial
Need as a parameter : MergedNetwork, List of CGMESControlAreas, Dict of NetPositions (controlAreaId -> floats). This should return a list of objects wrapping a java handle (BalanceComputationArea).

class BalanceComputation:
def build_computation_areas(self, network : Network, cgmesControlAreas : list[CGMESControlAreas], netPositions :dict[String, float]) -> list[BalanceComputationArea]

In the java tutorial CGMESControlAreas are retrieved from each individual networks unmerged. To do something similar here we can add a function to the the Network class the wrap the following Java code :

CgmesControlArea controlArea = network.getExtension(CgmesControlAreas.class).getCgmesControlAreas().iterator().next();

The CgmesControlArea can be retrieved and stored on python side as a java handle directly, or in a simple object wrapping the handle.

Net positions

In the tutorial net positions seem to be retrieved from a DataExchanges object that is built from an xml files. I am not sure we need to provide a way to retrieve the net positions from a similar file here. We can simply let the user load its net positions himself ?

BalanceComputationResult

Add a simple object to store the status, iteration count, and maybe the map of areas to scaling factors as a dict ?

Merged network serialization to xml cgmes

Just add a new member function to the network class to do this ?

Process overview in pypowsybl

  • Load each network
  • Retrieve CGMESControlAreas for each network and store them
  • Merge all the networks into one
  • Create the balance computation areas using BalanceComputation.build_computation_areas , the cgmes control areas and user provided net positions.
  • Execute the balance computation using BalanceComputation.run and retrieve the balance computation result
  • Serialize the merged network ?
@obrix
Copy link
Member Author

obrix commented Jun 8, 2022

Hello @geofjamg @annetill , this is a first draft for the support of EMF in pypowsybl. Feel free to comment, I will begin to work on it as some design choices have already been discussed with @geofjamg .

@obrix obrix self-assigned this Jun 8, 2022
@annetill
Copy link
Member

annetill commented Jun 9, 2022

Thanks for this first draft!
It looks good but I have about how to build a BalanceComputationArea. I don't know if we want to expose the object CGMESControlAreas that is build from an extension of the network (that contains indeed two lists: the terminals and the boundaries that delimit the area). The only very interesting think is the energy identification code that is needed to retrieve the target net position from PEVF file.
For me, the most interesting things are:

  • The NetworkArea that gives a list of internal buses and the net position ;
  • The Scalable that describes how the balance will be done: on loads, on generators and with which coefficient.
    Note that in the tutorial we create a fictitious area that represents "the rest of the synchronous area" that is not among the valid networks. This fictitious area is scale through dangling line scalable.

@obrix
Copy link
Member Author

obrix commented Jun 9, 2022

@annetill Yes, as I began to work on a prototype I asked myself the same thing about CGMESControlAreas and I am not sure what is best.
In the tutorial CGMESControlAreas are built from each network pre merge. The issue here is that as discussed with @geofjamg we plan to use Network.merge in the python API which is a destructive merge, I think I thus have to create and store those areas in some way before actually doing the merge operation. I have to make some tests to check what is best from an API point of view.

Concerning the PEVF file, do we need to provide something for the user to load it ? (ie something similar to the DataExchanges object in the tutorial ?) Or can we simply let him handle it on its own ? I don't know the PEVF format.

Concerning NetworkArea and Scalable do you mean it would be a good idea to expose them in python ? My idea was simply to create them on the fly on java side in the call to build_computation_areas because they are necessary for BalanceComputationArea building, but the python user would simply retrieve handles to java BalanceComputationArea objects and not NetworkArea/Scalable.

@Haigutus
Copy link

Any updates on this?

On PEVF/CGMA files, I would recommend not to handle that part, rather take input of dict {"area_id/HVDC_id": value}

Example implementation to convert IEC schedules to json -> https://github.com/Baltic-RCC/EMF/blob/286fb31bd68289d7dc4a622b95b891d36825d54d/emf/common/converters/iec_schedule_to_ndjson.py#L27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants