Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 138 additions & 2 deletions examples/network_comparator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,13 @@
"outputs": [],
"source": [
"networks = [n1, n2, n3, n4]\n",
"profiles = [n.get_default_nad_profile() for n in networks]\n",
"for i, p in enumerate(profiles, start=1):\n",
"profiles = []\n",
"for i, n in enumerate(networks, start=1):\n",
" p = n.get_default_nad_profile()\n",
" p.branch_labels.at['TWT', 'middle'] = f'TWT - network{i}'\n",
" p.branch_labels.at['HVDC1', 'middle'] = f'HVDC1 - network{i}'\n",
" p.branch_labels.at['HVDC2', 'middle'] = f'HVDC2 - network{i}'\n",
" profiles.append(pp.network.NadProfile(branch_labels=p.branch_labels, vl_descriptions=p.vl_descriptions))\n",
"\n",
"ppj.network_comparator(networks, profiles, display_buttons=False)"
]
Expand Down Expand Up @@ -359,6 +361,140 @@
"networks = [n1, n2]\n",
"ppj.network_comparator(networks=networks, profiles=create_nad_style_profiles_for_contingencies(contingencies_json, networks))"
]
},
{
"cell_type": "markdown",
"id": "8a2146b2-5085-401b-a184-54bb99682913",
"metadata": {},
"source": [
"## Profiles: displays uncertainties for generators and loads with the comparator, in VL boxes"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "51f73ea0-5ea5-4320-8a47-8d5122c92bc1",
"metadata": {},
"outputs": [],
"source": [
"n1 = pp.network.create_four_substations_node_breaker_network()\n",
"n2 = pp.network.create_four_substations_node_breaker_network()\n",
"networks = [n1, n2]\n",
"\n",
"uncertainties1_json = \"\"\"\n",
"{\n",
" \"uncertainInjections\": [\n",
" {\"id\": \"GH1\", \"absolute\": [0, 100]},\n",
" {\"id\": \"GH2\", \"relative\": [-14.2, 14.2]},\n",
" {\"id\": \"GH3\", \"relative\": [-10.0, 10.0]},\n",
" {\"id\": \"GTH2\", \"relative\": [-12.0, 12.0]},\n",
" {\"id\": \"LD1\", \"relative\": [-15.0, 15.0]},\n",
" {\"id\": \"LD2\", \"absolute\": [0, 80.0]},\n",
" {\"id\": \"LD3\", \"relative\": [-18.0, 18.0]}\n",
" ]\n",
"}\n",
"\"\"\"\n",
"uncertainties2_json = \"\"\"\n",
"{\n",
" \"uncertainInjections\": [\n",
" {\"id\": \"GH1\", \"absolute\": [0, 100]},\n",
" {\"id\": \"GH3\", \"relative\": [-15.0, 15.0]},\n",
" {\"id\": \"GTH2\", \"relative\": [-12.5, 12.5]},\n",
" {\"id\": \"LD1\", \"relative\": [-16.0, 16.0]},\n",
" {\"id\": \"LD2\", \"absolute\": [10, 80.0]},\n",
" {\"id\": \"LD3\", \"relative\": [-20.0, 20.0]}\n",
" ]\n",
"}\n",
"\"\"\"\n",
"uncertainties_json = [uncertainties1_json, uncertainties2_json]\n",
"\n",
"\n",
"profiles = [n.get_default_nad_profile() for n in networks]\n",
"new_profiles = []\n",
"for i, profile in enumerate(profiles, start=0):\n",
" injections_uncertainties = ppj.parse_uncertain_injections(json.loads(uncertainties_json[i]))\n",
" injection_details_df=ppj.build_vl_descriptions_df(networks[i], injections_uncertainties)\n",
" new_profiles.append(pp.network.NadProfile(branch_labels=profile.branch_labels,\n",
" vl_descriptions=injection_details_df, bus_descriptions=profile.bus_descriptions))\n",
"\n",
"ppj.network_comparator(networks, new_profiles)"
]
},
{
"cell_type": "markdown",
"id": "f26e4e73-73b9-43fb-9a5e-8ada958d74cb",
"metadata": {},
"source": [
"## Profiles: displays Contribution of Generators to Secondary Frequency Control (in percentage)"
]
},
{
"cell_type": "markdown",
"id": "2db293c8-69ec-4ad1-b540-1a0e15253703",
"metadata": {},
"source": [
"### in addition to the uncertainties data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a39a634d-f9df-4da7-96d0-90de0600bc9b",
"metadata": {},
"outputs": [],
"source": [
"sfcc1_json = \"\"\"\n",
"{\n",
" \"GH1\": 17,\n",
" \"GH3\": 36,\n",
" \"GTH2\": 40\n",
"}\n",
"\"\"\"\n",
"sfcc2_json = \"\"\"\n",
"{\n",
" \"GH1\": 50,\n",
" \"GH3\": 25,\n",
" \"GTH2\": 45\n",
"\n",
"}\n",
"\"\"\"\n",
"\n",
"sfcc_json = [sfcc1_json, sfcc2_json]\n",
"\n",
"profiles = [n.get_default_nad_profile() for n in networks]\n",
"new_profiles = []\n",
"for i, profile in enumerate(profiles, start=0):\n",
" injection_details_df=ppj.build_vl_descriptions_df(networks[i], injections_uncertainties, secondary_control=json.loads(sfcc_json[i]))\n",
" new_profiles.append(pp.network.NadProfile(branch_labels=profile.branch_labels,\n",
" vl_descriptions=injection_details_df, bus_descriptions=profile.bus_descriptions))\n",
"\n",
"ppj.network_comparator(networks, new_profiles)"
]
},
{
"cell_type": "markdown",
"id": "c94978c4-8cb1-4450-9561-89fe66333b34",
"metadata": {},
"source": [
"### just the contribution percentages"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aeea6072-74b5-451a-88de-24f3ecb661ba",
"metadata": {},
"outputs": [],
"source": [
"profiles = [n.get_default_nad_profile() for n in networks]\n",
"new_profiles = []\n",
"for i, profile in enumerate(profiles, start=0):\n",
" injection_details_df=ppj.build_vl_descriptions_df(networks[i], secondary_control=json.loads(sfcc_json[i]))\n",
" new_profiles.append(pp.network.NadProfile(branch_labels=profile.branch_labels,\n",
" vl_descriptions=injection_details_df, bus_descriptions=profile.bus_descriptions))\n",
"\n",
"ppj.network_comparator(networks, new_profiles)"
]
}
],
"metadata": {
Expand Down
69 changes: 68 additions & 1 deletion js/comparatorwidget.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,71 @@

#action-buttons-bars button.button-active {
border: 2px solid orange;
}
}

.inj-bar-row {
display: flex;
align-items: center;
gap: 6px;
line-height: 1;
text-align: left;
}

.inj-bar-row .inj-bar-svg {
flex: 0 0 auto;
overflow: visible;
}

.inj-bar-row.gen .inj-bar-range {
fill: #e5e7eb;
stroke: #9ca3af;
stroke-width: 0.5;
}

.inj-bar-row .inj-bar-band {
fill: #93c5fd;
opacity: 0.85;
}

.inj-bar-row.load .inj-bar-band {
fill: #fca5a5;
}

.inj-bar-row .inj-bar-marker {
stroke: #111827;
stroke-width: 1.5;
}

.inj-bar-row .inj-bar-label {
color: #111827;
font-size: 9px;
white-space: nowrap;
}

.inj-bar-row .inj-bar-num {
fill: #111827;
font-size: 6px;
font-family: inherit;
dominant-baseline: middle;
}

.inj-bar-row .inj-bar-num-p {
font-size: 8px;
font-weight: 600;
}

.inj-bar-row .inj-bar-num-ext {
font-size: 6px;
fill: #4b5563;
}

.inj-bar-row .inj-bar-marker-sfcc {
stroke: #f97316;
stroke-width: 1.5;
}

.inj-bar-row .inj-bar-num-sfcc {
fill: #f97316;
font-size: 7px;
font-weight: 600;
}
Loading