Integrated T+D Powerflow
Example file: docs/examples/api/example_app_pp_gld_pf.py
With the Python API in GridLAB-D™, integration with other Python-based power system simulation tools is now possible. This example code (example_app_pp_gld_pf.py)shows how to create an integrated bulk power system and distribution system powerflow model. In this case, we just couple a single GridLAB-D™ model to a single bus in pandapower bus, replacing the fixed load at that bus with a scaled-up version of the load as simulated by GridLAB-D™.
Users have a few parameters they can set at the top of the file:
-
step_size- The simulation step size in seconds of the integrated powerflow. This is value is only used by GridLAB-D™ as the powerflow in pandapower is time agnostic. -
microstep_max- The number of iteration micro-steps to take at each simulation time step. Minimum value is one. -
plotting_tool- Choose between "matplotlib" and "plotly" to select which tool is used to plot the collected data.
To integrate the powerflow between GridLAB-D™ and pandapower, we define the variables being exchanged between the two models in such a way so as to cause a circular dependency. In this case, we send the solution of the unbalanced GridLAB-D™ powerflow, expressed as the positive sequence load (real and reactive power) at the head of the distribution model (in the "substation" object) to pandapower as the load at the specified bus. This load value is scaled such to generally match the nominal load pandapower is expecting at that bus. Similarly, the nodal complex voltage found with pandapower's AC powerflow is used to define the substation's object's voltage on three phases. The substation object voltage is a boundary condition GridLAB-D™ and will impact the solution of the powerflow, including the total distribution system load. The distribution system load as expressed in pandapower as the load on specified bus influences that system's poweflow solution and will change the voltage at the node where the GridLAB-D™ is coupled.
Generally, with the data exchanges between the two models only taking once at each time step, the two models will have slightly different opinions on what the load and voltage at the point of coupling are. That is, without extra effort, the models may or may not be converged very well. To solve this problem, this example implements "micro-stepping" to allow GridLAB-D™, which can't resimulate a given time, and pandapower to reach a more consistent (converged) state. Micro-stepping simply advances GridLAB-D™ small simulation times (one second time steps), using the latest voltage from pandapower to effectively resolve the model. The assumption is that nothing in the model will meaningful change in one second and thus taking a modest number of one-second steps will not meaningfully change the model state. For this example, we consider that last state of the micro-stepping to have taken place when the micro-stepping began. For powerflow purposes, pandapower has no sense of time and thus can re-iterate its powerflow solution as needed.
Lastly, both visualization of the voltage and load are captured at each simulation time step and plotted after the simulation finishes. The presented data shows what we would expect when solving powerflows: as the load increases, the voltage decreases and vice versa.
