API Reference
This section provides detailed API documentation for all WEC-Grid classes and functions, auto-generated from the source code docstrings.
Core Components
Engine
Main orchestrator for WEC-Grid simulations and cross-platform power system analysis.
Coordinates WEC farm integration with PSS®E and PyPSA power system modeling backends. Manages simulation workflows, time synchronization, and visualization for grid studies.
Attributes:
Name | Type | Description |
---|---|---|
case_file |
str | None
|
Path to power system case file (.RAW). |
case_name |
str | None
|
Human-readable case identifier. |
time |
WECGridTime
|
Time coordination and snapshot management. |
psse |
PSSEModeler | None
|
PSS®E simulation interface. |
pypsa |
PyPSAModeler | None
|
PyPSA simulation interface. |
wec_farms |
List[WECFarm]
|
Collection of WEC farms in simulation. |
database |
WECGridDB
|
Database interface for simulation data. |
plot |
WECGridPlot
|
Visualization and plotting interface. |
wecsim |
WECSimRunner
|
WEC-Sim integration for device modeling. |
sbase |
float | None
|
System base power in MVA. |
Example
engine = Engine() engine.case("IEEE_30_bus") engine.load(["psse", "pypsa"]) engine.apply_wec("North Farm", size=5, bus_location=14) engine.simulate(load_curve=True) engine.plot.comparison_suite()
Notes
- PSS®E requires commercial license; PyPSA is open-source
- WEC data from WEC-Sim simulations (requires MATLAB)
- Supports cross-platform validation studies
TODO
- Consider renaming to WECGridEngine for clarity
- need a way to map GridState componet names to modeler component names
Source code in src/wecgrid/engine.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
|
apply_wec(farm_name, size=1, wec_sim_id=1, bus_location=1, connecting_bus=1, scaling_factor=1)
Add a Wave Energy Converter (WEC) farm to the power system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
farm_name
|
str
|
Human-readable WEC farm identifier. |
required |
size
|
int
|
Number of WEC devices in farm. Defaults to 1. |
1
|
wec_sim_id
|
int
|
Database simulation ID for WEC data. Defaults to 1. |
1
|
bus_location
|
int
|
Grid bus for WEC connection. Defaults to 1. |
1
|
connecting_bus
|
int
|
Network topology connection bus. Defaults to 1. |
1
|
scaling_factor
|
int
|
Multiplier applied to WEC power output [unitless]. Defaults to 1. |
1
|
Example
engine.apply_wec("North Coast Farm", size=20, bus_location=14) print(f"Total farms: {len(engine.wec_farms)}") Total farms: 1
Notes
- Farm power scales linearly with device count
- WEC data sourced from database using sim_id
- Generator IDs are auto-assigned sequentially based on farm order
TODO
- Fix PSS®E generator ID limitation (max 9 farms)
- Default connecting_bus should be swing bus
Source code in src/wecgrid/engine.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
case(case_file)
Specify the power system case file for subsequent loading.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
case_file
|
str
|
Path or identifier for a PSS®E RAW case file. Examples:
- Full paths: |
required |
Example
engine.case("IEEE_30_bus") print(engine.case_name) IEEE 30 bus
Notes
This method only stores the file path and a human-friendly name. It does not verify that the file exists or is loadable. Only PSS®E RAW (.RAW) format is supported.
Source code in src/wecgrid/engine.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
generate_load_curves(morning_peak_hour=8.0, evening_peak_hour=18.0, morning_sigma_h=2.0, evening_sigma_h=3.0, amplitude=0.05, min_multiplier=0.5, amp_overrides=None)
Generate realistic time-varying load profiles for power system simulation.
Creates bus-specific load time series with double-peak daily pattern representing typical electrical demand. Scales base case loads with configurable peak timing and variability.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
morning_peak_hour
|
float
|
Morning demand peak time [hours]. Defaults to 8.0. |
8.0
|
evening_peak_hour
|
float
|
Evening demand peak time [hours]. Defaults to 18.0. |
18.0
|
morning_sigma_h
|
float
|
Morning peak width [hours]. Defaults to 2.0. |
2.0
|
evening_sigma_h
|
float
|
Evening peak width [hours]. Defaults to 3.0. |
3.0
|
amplitude
|
float
|
Maximum variation around base load. Defaults to 0.30 (±30%). |
0.05
|
min_multiplier
|
float
|
Minimum load multiplier. Defaults to 0.70. |
0.5
|
amp_overrides
|
Dict[int, float]
|
Per-bus amplitude overrides. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Time-indexed load profiles [MW]. Index: simulation snapshots, Columns: bus numbers, Values: active power demand. |
Raises:
Type | Description |
---|---|
ValueError
|
If no power system modeler loaded. |
Example
Generate standard load curves
profiles = engine.generate_load_curves() print(f"Buses: {list(profiles.columns)}")
Custom peaks for industrial area
custom = engine.generate_load_curves( ... morning_peak_hour=6.0, ... evening_peak_hour=22.0, ... amplitude=0.15 ... )
Notes
- Double-peak pattern: morning and evening demand peaks
- Short simulations (<6h): flat profile to avoid artificial peaks
- PSS®E base loads: system MVA base
- PyPSA base loads: aggregated by bus
TODO
- Add weekly/seasonal variation patterns
Source code in src/wecgrid/engine.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
|
load(software)
Initialize power system simulation backends.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
software
|
List[str]
|
Backends to initialize ("psse", "pypsa"). |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If no case file loaded or invalid software name. |
RuntimeError
|
If initialization fails (missing license, etc.). |
Example
engine.case("IEEE_30_bus") engine.load(["psse", "pypsa"])
Notes
- PSS®E requires commercial license; PyPSA is open-source
- Enables cross-platform validation studies
- Both backends are independent and can simulate separately
TODO
- Add error handling for PSS®E license failures
Source code in src/wecgrid/engine.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
simulate(num_steps=None, load_curve=False)
Execute time-series power system simulation across loaded backends.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_steps
|
int | None
|
Number of simulation time steps. If |
None
|
load_curve
|
bool
|
Enable time-varying load profiles. Defaults to |
False
|
strict_convergence
|
bool
|
Stop simulation on first convergence failure.
Defaults to |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If no power system modelers are loaded. |
Example
engine.simulate(num_steps=144) engine.simulate(load_curve=True) engine.simulate(strict_convergence=True) # Operational mode
Notes
- All backends use identical time snapshots for comparison
- WEC data length constrains maximum simulation length
- Load curves use reduced amplitude (10%) for realism
- Results accessible via
engine.psse.grid
andengine.pypsa.grid
- Strict mode provides traditional power system analysis behavior
TODO
- Address multi-farm data length inconsistencies
- Implement automatic plotting feature
Source code in src/wecgrid/engine.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
|
Database
SQLite database interface for WEC-Grid simulation data management.
Provides database operations for storing WEC simulation results, device configurations, and time series data. Supports both raw SQL queries and pandas DataFrame integration with multi-software backend support.
Database Schema Overview:
Metadata Tables: - grid_simulations: Grid simulation metadata and parameters - wec_simulations: WEC-Sim simulation parameters and wave conditions - wec_integrations: Links WEC farms to grid connection points
PSS®E Results Tables: - psse_bus_results: Bus voltages, power injections [pu on S_base] - psse_generator_results: Generator outputs [pu on S_base] - psse_load_results: Load demands [pu on S_base] - psse_line_results: Line loadings [% of thermal rating]
PyPSA Results Tables
- pypsa_bus_results: Same schema as PSS®E for cross-platform comparison
- pypsa_generator_results: Same schema as PSS®E
- pypsa_load_results: Same schema as PSS®E
- pypsa_line_results: Same schema as PSS®E
WEC Simulation Data
- wec_simulations: Metadata including wave spectrum, class, and conditions
- wec_power_results: High-resolution WEC device power output [Watts]
Key Design Features
- Software-specific tables enable multi-backend comparisons
- All grid power values in per-unit on system S_base (MVA)
- GridState DataFrame schema alignment for direct data mapping
- Optional storage model - persist only when explicitly requested
- JSON configuration file for database path management
- User-guided setup for first-time configuration
- Support for downloaded or cloned database repositories
Database Location
Configured via database_config.json in the same directory as this module. Users can point to downloaded database file, cloned repository, or create new empty database.
Attributes:
Name | Type | Description |
---|---|---|
db_path |
str
|
Path to SQLite database file (from JSON configuration). |
Example
db = WECGridDB(engine) # Uses path from database_config.json
First run will prompt user to configure database path
with db.connection() as conn: ... results = db.query("SELECT * FROM grid_simulations", return_type="df")
Notes
Database path is configured via JSON file on first use. Users are guided through setup process with clear instructions. All database operations are transaction-safe with automatic rollback on errors.
Source code in src/wecgrid/util/database.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 |
|
check_and_initialize()
Check if database exists and has correct schema, initialize if needed.
Validates that all required tables exist with proper structure. Creates database and initializes schema if missing or incomplete.
Returns:
Name | Type | Description |
---|---|---|
bool |
True if database was already valid, False if initialization was needed. |
Source code in src/wecgrid/util/database.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
clean_database()
Delete the current database and reinitialize with fresh schema.
WARNING: This will permanently delete all stored simulation data. Use with caution - all existing data will be lost.
Returns:
Name | Type | Description |
---|---|---|
bool |
True if database was successfully cleaned and reinitialized. |
Notes
Wasn't working if my Jupyter Kernal was still going, need to restart then call
Example: >>> engine.database.clean_database() WARNING: This will delete all data in the database! Database cleaned and reinitialized successfully.
Source code in src/wecgrid/util/database.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 |
|
connection()
Context manager for safe database connections.
Provides transaction safety with automatic commit on success and rollback on exceptions. Connection closed automatically.
Source code in src/wecgrid/util/database.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
get_simulation_info(grid_sim_id=None)
Get grid simulation information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid_sim_id
|
int
|
Specific simulation ID. If None, returns all. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Simulation metadata. |
Source code in src/wecgrid/util/database.py
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 |
|
grid_sims()
Get all grid simulation metadata in a user-friendly format.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Grid simulations with key metadata columns. |
Example
engine.database.grid_sims() grid_sim_id sim_name case_name psse pypsa sbase_mva ... 0 1 Test Run IEEE_14_bus True False 100.0 ...
Source code in src/wecgrid/util/database.py
1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 |
|
initialize_database(db_path=None)
Initialize database schema with WEC-Grid tables and indexes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_path
|
str
|
Path where database should be created. If provided, creates new database at this location and updates the current instance to use it. If None, uses existing database path. |
None
|
Creates all required tables according to the finalized WEC-Grid schema: - Metadata tables for simulation parameters - Software-specific result tables (PSS®E, PyPSA) - WEC time-series data tables - Performance indexes for efficient queries
All existing data is preserved if tables already exist.
Example
Create new database when none is configured
engine.database.initialize_database("/path/to/new_database.db")
Initialize schema on existing configured database
engine.database.initialize_database()
Source code in src/wecgrid/util/database.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
|
pull_sim(grid_sim_id, software=None)
Pull simulation data from database and reconstruct GridState object.
Retrieves all time-series data for a specific simulation and recreates the GridState object with both snapshot data and time-series history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid_sim_id
|
int
|
Grid simulation ID to retrieve. |
required |
software
|
str
|
Software backend to pull data for ("psse" or "pypsa"). If None, automatically detects which software was used based on grid_simulations table flags. |
None
|
Returns:
Name | Type | Description |
---|---|---|
GridState |
Reconstructed GridState object with time-series data. |
Raises:
Type | Description |
---|---|
ValueError
|
If grid_sim_id not found or software not available for this simulation. |
Example
Pull PSS®E simulation data
grid_state = engine.database.pull_sim(grid_sim_id=123, software="psse") print(f"Buses: {len(grid_state.bus)}") print(f"Time series data: {list(grid_state.bus_t.keys())}")
Auto-detect software and pull data
grid_state = engine.database.pull_sim(grid_sim_id=123)
Source code in src/wecgrid/util/database.py
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 |
|
query(sql, params=None, return_type='raw')
Execute SQL query with flexible result formatting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sql
|
str
|
SQL query string. |
required |
params
|
tuple
|
Query parameters for safe substitution. |
None
|
return_type
|
str
|
Format for results - 'raw', 'df', or 'dict'. |
'raw'
|
Returns:
Type | Description |
---|---|
Results in specified format: |
|
|
|
|
|
|
Example
db.query("SELECT * FROM grid_simulations WHERE case_name = ?", ... params=("IEEE_14_bus",), return_type="df")
Source code in src/wecgrid/util/database.py
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
|
save_sim(sim_name, notes=None)
Save simulation data for all available software backends in the engine.
Automatically detects and stores data from all active software backends (PSS®E, PyPSA) and WEC farms present in the engine object.
Always creates a new simulation entry - no duplicate checking. Users can manage simulation names as needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sim_name
|
str
|
User-friendly simulation name. |
required |
notes
|
str
|
Simulation notes. |
None
|
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
grid_sim_id of the created simulation. |
Example
sim_id = engine.database.save_sim( ... sim_name="IEEE 30 test", ... notes="testing the database" ... )
Source code in src/wecgrid/util/database.py
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
|
set_database_path(db_path)
Set database path and reinitialize connection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_path
|
str
|
Path to WEC-GRID database file. |
required |
Example
engine.database.set_database_path("/path/to/wecgrid-database/WEC-GRID.db")
Source code in src/wecgrid/util/database.py
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 |
|
store_gridstate_data(grid_sim_id, timestamp, grid_state, software)
Store GridState data to appropriate software-specific tables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid_sim_id
|
int
|
Grid simulation ID. |
required |
timestamp
|
str
|
ISO datetime string for this snapshot. |
required |
grid_state
|
GridState object with bus, gen, load, line DataFrames. |
required | |
software
|
str
|
Software backend - "PSSE" or "PyPSA". |
required |
Example
db.store_gridstate_data( ... grid_sim_id=123, ... timestamp="2025-08-14T10:05:00", ... grid_state=my_grid_state, ... software="PSSE" ... )
Source code in src/wecgrid/util/database.py
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 |
|
wecsim_runs()
Get all WEC simulation metadata with enhanced wave parameters.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: WEC simulations with parameters and wave conditions including wave spectrum type, wave class, and all simulation parameters. |
Example
engine.database.wecsim_runs() wec_sim_id model_type sim_duration_sec delta_time wave_spectrum wave_class ... 0 1 RM3 600.0 0.1 PM irregular ...
Source code in src/wecgrid/util/database.py
1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 |
|
Time
Centralized time coordination for WEC-Grid simulations.
Coordinates temporal aspects across power system modeling (PSS®E, PyPSA), WEC simulations (WEC-Sim), and visualization components. Manages simulation time windows, sampling intervals, and ensures cross-platform alignment.
Attributes:
Name | Type | Description |
---|---|---|
start_time |
datetime
|
Simulation start timestamp. Defaults to current date at midnight. |
num_steps |
int
|
Number of simulation time steps. Defaults to 288 (24 hours at 5-minute intervals). |
freq |
str
|
Pandas frequency string for time intervals. Defaults to "5min" (5-minute intervals). |
sim_stop |
datetime
|
Calculated simulation end timestamp. Automatically computed from start_time, sim_length, and freq. Updated whenever simulation parameters change. |
Example
Default 24-hour simulation at 5-minute intervals
time_mgr = WECGridTime() print(f"Duration: {time_mgr.num_steps} steps") print(f"Interval: {time_mgr.freq}") Duration: 288 steps Interval: 5T
Custom simulation period
from datetime import datetime time_mgr = WECGridTime( ... start_time=datetime(2023, 6, 15, 0, 0, 0), ... sim_length=144, # 12 hours ... freq="5min" ... ) print(f"Start: {time_mgr.start_time}")
Source code in src/wecgrid/util/time.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
snapshots
property
Generate time snapshots for simulation time series.
Returns:
Type | Description |
---|---|
DatetimeIndex
|
pd.DatetimeIndex: Simulation timestamps from start_time with length sim_length. |
set_end_time(end_time)
Set simulation duration by specifying the desired end time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
end_time
|
datetime
|
Desired simulation end timestamp. Must be later than current start_time. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If end_time is earlier than or equal to start_time. |
Source code in src/wecgrid/util/time.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
update(*, start_time=None, num_steps=None, freq=None)
Update simulation time parameters with automatic recalculation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_time
|
datetime
|
New simulation start timestamp. |
None
|
num_steps
|
int
|
New number of simulation time steps. |
None
|
freq
|
str
|
New pandas frequency string for time intervals. |
None
|
Source code in src/wecgrid/util/time.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
Plot
A focused plotting interface for WEC-GRID simulation visualization.
This class provides methods to plot time-series data for various grid components, create single-line diagrams, and compare results from different modeling backends (PSS®E and PyPSA). Can work with live engine data or standalone GridState objects from database pulls.
Source code in src/wecgrid/util/plot.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 |
|
add_grid(software, grid_state)
Add a GridState object for standalone plotting.
Allows plotting of simulation data without requiring the original modeling software to be installed. Useful for analyzing database-pulled simulations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
software
|
str
|
Software identifier ("psse", "pypsa", etc.) |
required |
grid_state
|
GridState object containing simulation data |
required |
Example
plotter = WECGridPlot() psse_grid = engine.database.pull_sim(grid_sim_id=1, software='psse') plotter.add_grid('psse', psse_grid) plotter.gen(software='psse', parameter='p')
Source code in src/wecgrid/util/plot.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
bus(software='pypsa', parameter='p', bus=None)
Plot a bus parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
software
|
str
|
The modeling software to use ( |
'pypsa'
|
parameter
|
str
|
Bus parameter to plot (e.g., |
'p'
|
bus
|
Optional[List[str]]
|
A list of bus names to plot. If |
None
|
Returns:
Type | Description |
---|---|
tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]: The displayed |
|
figure and axes for further customization. |
Source code in src/wecgrid/util/plot.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
compare_modelers(grid_component, name, parameter)
Compares a parameter for a specific component between PSS®E and PyPSA.
Works with both live engine data and standalone GridState objects added via add_grid().
Parameters:
Name | Type | Description | Default |
---|---|---|---|
grid_component
|
str
|
The type of component ('bus', 'gen', 'load', 'line'). |
required |
name
|
List[str]
|
The name(s) of the component(s) to compare. |
required |
parameter
|
str
|
The parameter to compare. |
required |
Source code in src/wecgrid/util/plot.py
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 |
|
from_database(database, grid_sim_id, software=None)
classmethod
Create a standalone plotter from database simulation data.
Convenience method to create a plotter with GridState data pulled from the database, without requiring the original modeling software.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
database
|
WECGridDB instance |
required | |
grid_sim_id
|
int
|
Grid simulation ID to retrieve |
required |
software
|
str
|
Software backend ("psse" or "pypsa"). If None, auto-detects from database. |
None
|
Returns:
Name | Type | Description |
---|---|---|
WECGridPlot |
Plotter instance with GridState data loaded |
Example
plotter = WECGridPlot.from_database( ... engine.database, grid_sim_id=1, software='psse' ... ) plotter.gen(software='psse', parameter='p')
Source code in src/wecgrid/util/plot.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
gen(software='pypsa', parameter='p', gen=None)
Plot a generator parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
software
|
str
|
The modeling software to use ( |
'pypsa'
|
parameter
|
str
|
Generator parameter to plot (e.g., |
'p'
|
gen
|
Optional[List[str]]
|
A list of generator names to plot. If |
None
|
Returns:
Type | Description |
---|---|
tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]: The displayed |
|
figure and axes for further customization. |
Source code in src/wecgrid/util/plot.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
line(software='pypsa', parameter='line_pct', line=None)
Plot a line parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
software
|
str
|
The modeling software to use ( |
'pypsa'
|
parameter
|
str
|
Line parameter to plot. Defaults to |
'line_pct'
|
line
|
Optional[List[str]]
|
A list of line names to plot. If |
None
|
Returns:
Type | Description |
---|---|
tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]: The displayed |
|
figure and axes for further customization. |
Source code in src/wecgrid/util/plot.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
load(software='pypsa', parameter='p', load=None)
Plot a load parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
software
|
str
|
The modeling software to use ( |
'pypsa'
|
parameter
|
str
|
Load parameter to plot (e.g., |
'p'
|
load
|
Optional[List[str]]
|
A list of load names to plot. If |
None
|
Returns:
Type | Description |
---|---|
tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]: The displayed |
|
figure and axes for further customization. |
Source code in src/wecgrid/util/plot.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
sld(software='pypsa', figsize=(14, 10), title=None, save_path=None)
Generate single-line diagram using GridState data.
Creates a single-line diagram visualization using the standardized GridState component data. Works with both PSS®E and PyPSA backends by using the unified data schema from GridState snapshots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
software
|
str
|
Backend software ("psse" or "pypsa") |
'pypsa'
|
figsize
|
tuple
|
Figure size as (width, height) |
(14, 10)
|
title
|
str
|
Custom title for the diagram |
None
|
save_path
|
str
|
Path to save the figure |
None
|
show
|
bool
|
Whether to display the figure (default: False) |
required |
Returns:
Type | Description |
---|---|
matplotlib.figure.Figure: The generated SLD figure |
Notes
Uses NetworkX for automatic layout calculation since GridState doesn't include geographical bus positions. The diagram includes:
- Buses: Colored rectangles based on type (Slack=red, PV=green, PQ=gray)
- Lines: Black dashed lines connecting buses
- Generators: Circles above buses with generators
- Loads: Downward arrows on buses with loads
Limitations: - No transformer identification (would need additional data) - Layout is algorithmic, not geographical - No shunt devices (not in GridState schema)
Source code in src/wecgrid/util/plot.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
|
wec_analysis(farms=None, software='pypsa')
Creates a 1x3 figure analyzing WEC farm performance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
farms
|
Optional[List[str]]
|
A list of farm names to analyze. If None, all farms are analyzed. |
None
|
software
|
str
|
The modeling software to use. Defaults to 'pypsa'. |
'pypsa'
|
Source code in src/wecgrid/util/plot.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 |
|
Modelers
Power System
Base Classes
Bases: ABC
Abstract base class for power system modeling backends.
Defines standardized interface for PSS®E, PyPSA, and other power system tools in WEC-GRID framework. Provides grid analysis, WEC integration, and time-series simulation capabilities through common API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
engine
|
Any
|
WEC-GRID Engine with case_file, time, and wec_farms attributes. |
required |
Attributes:
Name | Type | Description |
---|---|---|
engine |
Reference to simulation engine. |
|
grid |
GridState
|
Time-series data for buses, generators, lines, loads. |
sbase |
float
|
System base power [MVA]. |
Example
from wecgrid.modelers import PSSEModeler, PyPSAModeler psse_model = PSSEModeler(engine) pypsa_model = PyPSAModeler(engine)
Notes
- Abstract class - use concrete implementations (PSSEModeler, PyPSAModeler)
- Grid state data follows standardized schema for cross-platform comparison
- All abstract methods must be implemented by subclasses
Source code in src/wecgrid/modelers/power_system/base.py
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
|
bus
property
Current bus state with columns: bus, bus_name, type, p, q, v_mag, angle_deg, base.
Returns:
Type | Description |
---|---|
Optional[DataFrame]
|
pd.DataFrame: Bus state data [p.u. on system MVA base] or None if no snapshots. |
bus_t
property
Time-series bus data for all snapshots.
Returns:
Type | Description |
---|---|
Dict[str, DataFrame]
|
Dict[str, pd.DataFrame]: Keys: timestamp strings, Values: bus state DataFrames. |
gen
property
Current generator state with columns: gen, bus, p, q, base, status.
Returns:
Type | Description |
---|---|
Optional[DataFrame]
|
pd.DataFrame: Generator state data [p.u. on generator MVA base] or None if no snapshots. |
gen_t
property
Time-series generator data for all snapshots.
Returns:
Type | Description |
---|---|
Dict[str, DataFrame]
|
Dict[str, pd.DataFrame]: Keys: timestamp strings, Values: generator state DataFrames. |
line
property
Current line state with columns: line, ibus, jbus, line_pct, status.
Returns:
Type | Description |
---|---|
Optional[DataFrame]
|
pd.DataFrame: Line state data [line_pct as % of thermal rating] or None if no snapshots. |
line_t
property
Time-series line data for all snapshots.
Returns:
Type | Description |
---|---|
Dict[str, DataFrame]
|
Dict[str, pd.DataFrame]: Keys: timestamp strings, Values: line state DataFrames. |
load
property
Current load state with columns: load, bus, p, q, base, status.
Returns:
Type | Description |
---|---|
Optional[DataFrame]
|
pd.DataFrame: Load state data [p.u. on system MVA base] or None if no snapshots. |
load_t
property
Time-series load data for all snapshots.
Returns:
Type | Description |
---|---|
Dict[str, DataFrame]
|
Dict[str, pd.DataFrame]: Keys: timestamp strings, Values: load state DataFrames. |
add_wec_farm(farm)
abstractmethod
Add WEC farm to power system model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
farm
|
WECFarm
|
WEC farm with connection details and power characteristics. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if farm added successfully, False otherwise. |
Raises:
Type | Description |
---|---|
ValueError
|
If WEC farm parameters invalid. |
Notes
Implementation should:
- Create new bus for WEC connection
- Add WEC generator with power characteristics
- Create transmission line to existing grid
- Update grid state after modifications
- Solve power flow to validate changes
Example
if modeler.add_wec_farm(wec_farm): ... print("WEC farm added successfully")
Source code in src/wecgrid/modelers/power_system/base.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
|
init_api()
abstractmethod
Initialize backend power system tool and load case file.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if initialization successful, False otherwise. |
Raises:
Type | Description |
---|---|
ImportError
|
If backend tool not found or configured. |
ValueError
|
If case file invalid or cannot be loaded. |
Notes
Implementation should:
- Initialize backend API/environment
- Load case file (.sav, .raw, etc.)
- Set system base MVA (self.sbase)
- Perform initial power flow solution
- Take initial grid state snapshot
Example
if modeler.init_api(): ... print("Backend initialized successfully")
Source code in src/wecgrid/modelers/power_system/base.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
|
simulate(load_curve=None)
abstractmethod
Run time-series simulation with WEC and load updates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
load_curve
|
DataFrame
|
Load values for each bus at each snapshot. Index: snapshots, columns: bus IDs. If None, loads remain constant. |
None
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if simulation completes successfully, False otherwise. |
Raises:
Type | Description |
---|---|
Exception
|
If error updating components or solving power flow. |
Notes
Implementation should:
- Iterate through all time snapshots from engine.time
- Update WEC generator power outputs [MW] from farm data
- Update bus loads [MW] if load_curve provided
- Solve power flow at each time step
- Capture grid state snapshots for analysis
- Handle convergence failures gracefully
Example
Constant loads
modeler.simulate()
Time-varying loads
modeler.simulate(load_curve=load_df)
Source code in src/wecgrid/modelers/power_system/base.py
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
|
solve_powerflow()
abstractmethod
Run power flow solution using backend solver.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if power flow converged, False otherwise. |
Notes
Implementation should:
- Call backend's power flow solver
- Check convergence status
- Handle solver-specific parameters
- Suppress verbose output if needed
Example
if modeler.solve_powerflow(): ... print("Power flow converged")
Source code in src/wecgrid/modelers/power_system/base.py
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
|
take_snapshot(timestamp)
abstractmethod
Capture current grid state at specified timestamp.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timestamp
|
datetime
|
Timestamp for the snapshot. |
required |
Notes
Implementation should:
- Extract bus data: voltages [p.u.], [degrees], power [MW], [MVAr]
- Extract generator data: power outputs [MW], [MVAr], status
- Extract line data: power flows [MW], [MVAr], loading [%]
- Extract load data: power consumption [MW], [MVAr]
- Convert to standardized WEC-GRID schema
- Store in self.grid with timestamp indexing
Example
modeler.take_snapshot(datetime.now())
Source code in src/wecgrid/modelers/power_system/base.py
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |
|
Standardized container for power system snapshot and time-series data.
The GridState class provides a unified data structure for storing power system component states across different simulation backends (PSS®E, PyPSA, etc.). It maintains both current snapshot data and historical time-series data for buses, generators, lines, and loads using standardized DataFrame schemas.
This class enables cross-platform validation and comparison between different power system analysis tools by enforcing consistent data formats and units. All electrical quantities are stored in per-unit values based on system MVA.
Attributes:
Name | Type | Description |
---|---|---|
software |
str
|
Backend software name ("psse", "pypsa", etc.). |
bus |
DataFrame
|
Current bus state with voltage, power injection data. |
gen |
DataFrame
|
Current generator state with power output data. |
line |
DataFrame
|
Current transmission line state with loading data. |
load |
DataFrame
|
Current load state with power consumption data. |
bus_t |
AttrDict
|
Time-series bus data organized by variable name. |
gen_t |
AttrDict
|
Time-series generator data organized by variable name. |
line_t |
AttrDict
|
Time-series line data organized by variable name. |
load_t |
AttrDict
|
Time-series load data organized by variable name. |
Example
grid = GridState()
Update with current snapshot
grid.update("bus", timestamp, bus_dataframe)
Access current state
print(f"Number of buses: {len(grid.bus)}")
Access time-series data
voltage_history = grid.bus_t.v_mag # All bus voltages over time
Notes
- All power values are in per-unit on system base MVA
- Voltage magnitudes are in per-unit, angles in degrees
- Line loading is expressed as percentage of thermal rating
- Component IDs must be consistent across all DataFrames
- Time-series data is automatically maintained when snapshots are updated
DataFrame Schemas
Each component DataFrame follows a standardized schema as documented in the individual update method and property descriptions.
Source code in src/wecgrid/modelers/power_system/base.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
|
update(component, timestamp, df)
Update snapshot and time-series data for a power system component.
This method updates both the current snapshot DataFrame and the historical
time-series data for the specified component type. It expects DataFrames
with standardized WEC-Grid schemas and proper df.attrs['df_type']
attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
component
|
str
|
Component type ("bus", "gen", "line", "load"). |
required |
timestamp
|
Timestamp
|
Timestamp for this snapshot. |
required |
df
|
DataFrame
|
Component data with |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If component is not recognized, |
DataFrame Schemas
Component ID: for the component attribute the ID will be an incrementing ID number starting from 1 in order of bus number
Component Names
for the component_name attribute the name will be the corresponding component label and ID (e.g., "Bus_1", "Gen_1").
Bus DataFrame (df_type="BUS"
)
Column | Description | Type | Units | Base Used |
---|---|---|---|---|
bus | Bus number (unique identifier) | int | — | — |
bus_name | Bus name/label (e.g., "Bus_1", "Bus_2") | str | — | — |
type | Bus type: "Slack", "PV", "PQ" | str | — | — |
p | Net active power injection (Gen − Load) | float | pu | S_base (MVA) |
q | Net reactive power injection (Gen − Load) | float | pu | S_base (MVA) |
v_mag | Voltage magnitude | float | pu | V_base (kV LL) |
angle_deg | Voltage angle | float | degrees | — |
vbase | Bus nominal voltage (line-to-line) | float | kV | — |
Generator DataFrame (df_type="GEN"
)
Column | Description | Type | Units | Base Used |
---|---|---|---|---|
gen | Generator ID | int | — | — |
gen_name | Generator name (e.g., "Gen_1") | str | — | — |
bus | Connected bus number | int | — | — |
p | Active power output | float | pu | S_base (MVA) |
q | Reactive power output | float | pu | S_base (MVA) |
Mbase | Generator nameplate MVA rating | float | MVA | Mbase (machine) |
status | Generator status (1=online, 0=offline) | int | — | — |
Load DataFrame (df_type="LOAD"
)
Column | Description | Type | Units | Base Used |
---|---|---|---|---|
load | Load ID | int | — | — |
load_name | Load name (e.g., "Load_1") | str | — | — |
bus | Connected bus number | int | — | — |
p | Active power demand | float | pu | S_base (MVA) |
q | Reactive power demand | float | pu | S_base (MVA) |
status | Load status (1=connected, 0=offline) | int | — | — |
Line DataFrame (df_type="LINE"
)
Column | Description | Type | Units | Base Used |
---|---|---|---|---|
line | Line ID | int | — | — |
line_name | Line name (e.g., "Line_1_2") | str | — | — |
ibus | From bus number | int | — | — |
jbus | To bus number | int | — | — |
line_pct | Percentage of thermal rating in use | float | % | — |
status | Line status (1=online, 0=offline) | int | — | — |
Base Usage Summary
-
S_base (System Power Base): All
p
andq
values across buses, generators, and loads are in per-unit on the single, case-wide power base (e.g., 100 MVA): -
V_base (Bus Voltage Base): Each bus has a nominal voltage in kV (line-to-line)
-
Mbase (Machine Base): Per-generator nameplate MVA rating used for manufacturer parameters.
Example
Update bus data at current time
bus_df = create_bus_dataframe() # with proper schema bus_df.attrs['df_type'] = 'BUS' grid.update("bus", pd.Timestamp.now(), bus_df)
Access updated data
current_buses = grid.bus voltage_timeseries = grid.bus_t.v_mag
Source code in src/wecgrid/modelers/power_system/base.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
|
Bases: dict
Dictionary that allows attribute-style access to keys.
This utility class enables accessing dictionary values using dot notation (d.key) in addition to the standard bracket notation (d['key']). This is used for convenient access to time-series data collections.
Example
data = AttrDict({'voltage': df1, 'power': df2}) data.voltage # Same as data['voltage'] data.power = df3 # Same as data['power'] = df3
Raises:
Type | Description |
---|---|
AttributeError
|
If the requested attribute/key does not exist. |
Source code in src/wecgrid/modelers/power_system/base.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
PSS/E Modeler
Bases: PowerSystemModeler
PSS®E power system modeling interface.
Provides interface for power system modeling and simulation using Siemens PSS®E software. Implements PSS®E-specific functionality for grid analysis, WEC farm integration, and time-series simulation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
engine
|
Any
|
WEC-GRID simulation engine with case_file, time, and wec_farms attributes. |
required |
Attributes:
Name | Type | Description |
---|---|---|
engine |
Reference to simulation engine. |
|
grid |
GridState
|
Time-series data for all components. |
sbase |
float
|
System base power [MVA] from PSS®E case. |
psspy |
module
|
PSS®E Python API module for direct access. |
Example
psse_model = PSSEModeler(engine) psse_model.init_api() psse_model.solve_powerflow()
Notes
- Requires PSS®E software installation and valid license
- Compatible with PSS®E version 35.3 Python API
- Supports both .sav (saved case) and .raw (raw data) formats
- Automatically captures grid state at each simulation snapshot
TODO
- Add support for newer PSS®E versions
- Implement dynamic simulation capabilities
Source code in src/wecgrid/modelers/power_system/psse.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 |
|
add_wec_farm(farm)
Add a WEC farm to the PSS®E model.
This method adds a WEC farm to the PSS®E model by creating the necessary electrical infrastructure: a new bus for the WEC farm, a generator on that bus, and a transmission line connecting it to the existing grid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
farm
|
WECFarm
|
The WEC farm object containing connection details. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the farm is added successfully, False otherwise. |
Raises:
Type | Description |
---|---|
ValueError
|
If the WEC farm cannot be added due to invalid parameters. |
Notes
The following PSS®E API calls are used:
busdat()
: Get base voltage of connecting bus Returns: Base voltage [kV]bus_data_4()
: Add new WEC bus (PV type)- Base voltage [kV]
plant_data_4()
: Add plant data to WEC busmachine_data_4()
: Add WEC generator to bus- PG: Active power generation [MW]
branch_data_3()
: Add transmission line from WEC bus to grid- R: Resistance [pu]
- X: Reactance [pu]
- RATEA: Rating A [MVA]
TODO: Fix the hardcoded line R, X, and RATEA values
Source code in src/wecgrid/modelers/power_system/psse.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
adjust_reactive_lim()
Remove reactive power limits from all generators.
Adjusts all generators in the PSS®E case to remove reactive power limits by setting QT = +9999 and QB = -9999. This is used to more closely align the modeling behavior between PSS®E and PyPSA.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if successful, False otherwise. |
Notes
The following PSS®E API calls are used:
amachint()
: Get all generator bus numbers Returns: Bus numbers [dimensionless]machine_chng_4()
: Modify generator reactive power limits- Sets QT (Q max) to 9999.0 [MVAr]
- Sets QB (Q min) to -9999.0 [MVAr]
Source code in src/wecgrid/modelers/power_system/psse.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
init_api()
Initialize the PSS®E environment and load the case.
This method sets up the PSS®E Python API, loads the specified case file, and performs initial power flow solution. It also removes reactive power limits on generators and takes an initial snapshot.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if initialization is successful, False otherwise. |
Raises:
Type | Description |
---|---|
ImportError
|
If PSS®E is not found or not configured correctly. |
Notes
The following PSS®E API calls are used for initialization:
psseinit()
: Initialize PSS®E environmentcase()
orread()
: Load case file (.sav or .raw)sysmva()
: Get system MVA base Returns: System base MVA [MVA]fnsl()
: Solve power flowsolved()
: Check solution status Returns: 0 = converged, 1 = not converged [dimensionless]
Source code in src/wecgrid/modelers/power_system/psse.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
simulate(load_curve=None)
Simulate the PSS®E grid over time with WEC farm updates.
Simulates the PSS®E grid over a series of time snapshots, updating WEC farm generator outputs and optionally bus loads at each time step. For each snapshot, the method updates generator power outputs, applies load changes if provided, solves the power flow, and captures the grid state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
load_curve
|
Optional[DataFrame]
|
DataFrame containing load values for each bus at each snapshot. Index should be snapshots, columns should be bus IDs. If None, loads remain constant. |
None
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the simulation completes successfully. |
Raises:
Type | Description |
---|---|
Exception
|
If there is an error setting generator power, setting load data, or solving the power flow at any snapshot. |
Notes
The following PSS®E API calls are used for simulation:
machine_chng_4()
: Update WEC generator active power output- PG: Active power generation [MW]
load_data_6()
: Update bus load values (if load_curve provided)- P: Active power load [MW]
- Q: Reactive power load [MVAr]
fnsl()
: Solve power flow at each time step
Source code in src/wecgrid/modelers/power_system/psse.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
|
snapshot_buses()
Capture current bus state from PSS®E.
Builds a Pandas DataFrame of the current bus state for the loaded PSS®E grid using the PSS®E API. The DataFrame is formatted according to the GridState specification and includes bus voltage, power injection, and load data.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns: bus, bus_name, type, p, q, v_mag, angle_deg, Vbase. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If there is an error retrieving bus snapshot data from PSS®E. |
Notes
The following PSS®E API calls are used to retrieve bus snapshot data:
Bus Information:
- abuschar()
: Bus names ('NAME')
Returns: Bus names [string]
- abusint()
: Bus numbers and types ('NUMBER', 'TYPE')
Returns: Bus numbers, Bus types 3,2,1
- abusreal()
: Bus voltages and base kV ('PU', 'ANGLED', 'BASE')
Returns: Acutal Voltage magnitude [pu], Voltage angle [degrees], Base voltage [kV]
Generator Data:
- amachint()
: Generator bus numbers ('NUMBER')
Returns: Bus numbers [dimensionless]
- amachreal()
: Generator power output ('PGEN', 'QGEN')
Returns: Active power [MW], Reactive power [MVAr]
Load Data:
- aloadint()
: Load bus numbers ('NUMBER')
Returns: Bus numbers [dimensionless]
- aloadcplx()
: Load power consumption ('TOTALACT')
Returns: Complex power [MW + j*MVAr]
Source code in src/wecgrid/modelers/power_system/psse.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
|
snapshot_generators()
Capture current generator state from PSS®E.
Builds a Pandas DataFrame of the current generator state for the loaded PSS®E grid using the PSS®E API. The DataFrame includes generator power output, base MVA, and status information.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns: gen, gen_name, bus, p, q, Mbase, status. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If there is an error retrieving generator data from PSS®E. |
Notes
The following PSS®E API calls are used to retrieve generator data:
amachint()
: Generator bus numbers and status ('NUMBER', 'STATUS') Returns: Bus numbers [dimensionless], Status codes [dimensionless]amachreal()
: Generator power and base MVA ('PGEN', 'QGEN', 'MBASE') Returns: Active power [MW], Reactive power [MVAr], MBase MVA [MVA]
Source code in src/wecgrid/modelers/power_system/psse.py
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 |
|
snapshot_lines()
Capture current transmission line state from PSS®E.
Builds a Pandas DataFrame of the current transmission line state for the loaded PSS®E grid using the PSS®E API. The DataFrame includes line loading percentages and connection information.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns: line, line_name, ibus, jbus, line_pct, status. Line names are formatted as "Line_ibus_jbus_count". |
Raises:
Type | Description |
---|---|
RuntimeError
|
If there is an error retrieving line data from PSS®E. |
Notes
The following PSS®E API calls are used to retrieve line data:
abrnchar()
: Line IDs ('ID') Returns: Line identifiers [string]abrnint()
: Line bus connections and status ('FROMNUMBER', 'TONUMBER', 'STATUS') Returns: From bus [dimensionless], To bus [dimensionless], Status [dimensionless]abrnreal()
: Line loading percentage ('PCTRATE') Returns: Line loading [%] "Percent from bus current of default rating set"
Source code in src/wecgrid/modelers/power_system/psse.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
|
snapshot_loads()
Capture current load state from PSS®E.
Builds a Pandas DataFrame of the current load state for the loaded PSS®E grid using the PSS®E API. The DataFrame includes load power consumption and status information for all buses with loads.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns: load, bus, p, q, base, status. Load names are formatted as "Load_bus_count". |
Raises:
Type | Description |
---|---|
RuntimeError
|
If there is an error retrieving load data from PSS®E. |
Notes
The following PSS®E API calls are used to retrieve load data:
aloadchar()
: Load IDs ('ID') Returns: Load identifiers [string]aloadint()
: Load bus numbers and status ('NUMBER', 'STATUS') Returns: Bus numbers [dimensionless], Status codes [dimensionless]aloadcplx()
: Load power consumption ('TOTALACT') Returns: Complex power consumption [MW + j*MVAr]
Source code in src/wecgrid/modelers/power_system/psse.py
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 |
|
solve_powerflow(log=False)
Run power flow solution and check convergence.
Executes the PSS®E power flow solver using the Newton-Raphson method and verifies that the solution converged successfully.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_details
|
bool
|
If True, return detailed dict. If False, return bool. |
required |
Returns:
Type | Description |
---|---|
bool or dict: Bool for simple convergence check, dict with details for simulation. |
Notes
The following PSS®E API calls are used:
fnsl()
: Full Newton-Raphson power flow solutionsolved()
: Check if power flow solution converged (0 = converged)iterat()
: Get iteration count from last solution attempt
Source code in src/wecgrid/modelers/power_system/psse.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
take_snapshot(timestamp)
Take a snapshot of the current grid state.
Captures the current state of all grid components (buses, generators, lines, and loads) at the specified timestamp and updates the grid state object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timestamp
|
datetime
|
The timestamp for the snapshot. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in src/wecgrid/modelers/power_system/psse.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|
PyPSA Modeler
Bases: PowerSystemModeler
PyPSA power system modeling interface.
Provides interface for power system modeling and simulation using PyPSA (Python for Power System Analysis). Implements PyPSA-specific functionality for grid analysis, WEC farm integration, and time-series simulation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
engine
|
Any
|
WEC-GRID simulation engine with case_file, time, and wec_farms attributes. |
required |
Attributes:
Name | Type | Description |
---|---|---|
engine |
Reference to simulation engine. |
|
grid |
GridState
|
Time-series data for all components. |
network |
Network
|
PyPSA Network object for power system analysis. |
sbase |
float
|
System base power [MVA] from case file. |
parser |
float
|
GRG PSS®E case file parser object for data extraction. |
Example
pypsa_model = PyPSAModeler(engine) pypsa_model.init_api() pypsa_model.simulate()
Notes
- Compatible with PyPSA version 0.21+ for power system analysis
- Uses GRG PSS®E parser for case file import and conversion
- Automatically converts PSS®E impedance values to PyPSA format
- Provides validation against PSS®E results for cross-platform verification
TODO
- Add support for PyPSA native case formats
- Implement dynamic component ratings
Source code in src/wecgrid/modelers/power_system/pypsa.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 |
|
add_wec_farm(farm)
Add a WEC farm to the PyPSA model.
This method adds a WEC farm to the PyPSA model by creating the necessary electrical infrastructure: a new bus for the WEC farm, a generator on that bus, and a transmission line connecting it to the existing grid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
farm
|
WECFarm
|
The WEC farm object containing connection details including bus_location, connecting_bus, and farm identification. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the farm is added successfully, False otherwise. |
Raises:
Type | Description |
---|---|
Exception
|
If the WEC farm cannot be added due to PyPSA errors. |
Notes
The WEC farm addition process includes:
Bus Creation: - Creates new bus at farm.bus_location - Uses same voltage level as connecting bus [kV] - Sets AC carrier type for electrical connection
Line Creation: - Adds transmission line between WEC bus and grid - Uses hardcoded impedance values [Ohm] - Sets thermal rating [MVA]
Generator Creation: - Adds WEC generator with wave energy carrier type - Initial power setpoint of 0.0 [MW] - PV control mode for voltage regulation
TODO
Replace hardcoded line impedance values with calculated values based on farm specifications and connection distance.
Source code in src/wecgrid/modelers/power_system/pypsa.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
import_raw_to_pypsa()
Import PSS®E case file and build PyPSA Network.
Builds a PyPSA Network from a parsed PSS®E RAW case file using the GRG parser. Converts PSS®E data structures and impedance values to PyPSA format, including buses, lines, generators, loads, transformers, and shunt impedances.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if case import is successful, False otherwise. |
Raises:
Type | Description |
---|---|
Exception
|
If case file parsing fails or case is invalid. |
Notes
The import process includes:
Bus Data: - Bus numbers, names, and base voltages [kV] - Voltage magnitude setpoints and limits [pu] - Bus type mapping (PQ, PV, Slack)
Line Data: - Resistance and reactance converted from [pu] to [Ohm] - Conductance and susceptance converted from [pu] to [Siemens] - Thermal ratings [MVA]
Generator Data: - Active and reactive power setpoints [MW], [MVAr] - Power limits and control modes - Generator status and carrier type
Load Data: - Active and reactive power consumption [MW], [MVAr] - Load status and bus assignment
Transformer Data: - Impedance values normalized to transformer base [pu] - Tap ratios and phase shift angles [degrees] - Thermal ratings [MVA]
Shunt Data: - Conductance and susceptance [Siemens] - Status and bus assignment
Source code in src/wecgrid/modelers/power_system/pypsa.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
init_api()
Initialize the PyPSA environment and load the case.
This method sets up the PyPSA network by importing the PSS®E case file, creating the network structure, and performing initial power flow solution. It also takes an initial snapshot of the grid state.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if initialization is successful, False otherwise. |
Raises:
Type | Description |
---|---|
ImportError
|
If PyPSA or GRG dependencies are not found. |
ValueError
|
If case file cannot be parsed or is invalid. |
Notes
The initialization process includes:
- Parsing PSS®E case file using GRG parser
- Creating PyPSA Network with system base MVA [MVA]
- Converting PSS®E impedance values to PyPSA format
- Adding buses with voltage limits [kV] and control types
- Adding lines with impedance [Ohm] and ratings [MVA]
- Adding generators with power limits [MW], [MVAr]
- Adding loads with power consumption [MW], [MVAr]
- Adding transformers and shunt impedances
- Solving initial power flow
Source code in src/wecgrid/modelers/power_system/pypsa.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
simulate(load_curve=None)
Simulate the PyPSA grid over time with WEC farm updates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
load_curve
|
Optional[DataFrame]
|
DataFrame containing load values for each bus at each snapshot. Index should be snapshots, columns should be bus IDs. If None, loads remain constant. |
None
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the simulation completes successfully. |
Source code in src/wecgrid/modelers/power_system/pypsa.py
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 |
|
snapshot_buses()
Capture current bus state from PyPSA.
Builds a Pandas DataFrame of the current bus state for the loaded PyPSA network. The DataFrame is formatted according to the GridState specification and includes bus voltage, power injection, and control data.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns: bus, bus_name, type, p, q, v_mag, angle_deg, Vbase. Index represents individual buses. |
Notes
The following PyPSA network data is used to create bus snapshots:
link - https://pypsa.readthedocs.io/en/stable/user-guide/components.html#bus
Bus Information: - Bus names and numbers "name" (converted from string indices) [dimensionless] - Bus control types "type"(PQ, PV, Slack) [string] - Base voltage levels "v_nom" [kV]
Electrical Quantities: - Active and reactive power injections "p", "q" [MW], [MVAr] → [pu] - Voltage magnitude "v_mag_pu" [pu] of v_nom - Voltage angle "v_ang" [radians] → [degrees]
Time Series Data: - Uses latest snapshot from network.snapshots - Defaults to steady-state values if no time series available
Source code in src/wecgrid/modelers/power_system/pypsa.py
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 |
|
snapshot_generators()
Capture current generator state from PyPSA.
Builds a Pandas DataFrame of the current generator state for the loaded PyPSA network. The DataFrame includes generator power output, base power, and status information.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns: gen, bus, p, q, base, status. Generator names are formatted as "bus_count" (e.g., "1_1", "1_2"). |
Notes
The following PyPSA network data is used to create generator snapshots: link - https://pypsa.readthedocs.io/en/stable/user-guide/components.html#generator
Generator Information: - Generator names and bus assignments [dimensionless] - Active and reactive power output [MW], [MVAr] → [pu] - Generator status and availability [dimensionless]
Time Series Data: - Uses latest snapshot from generators_t for power values - Uses generator 'active' attribute for status if available - Per-bus counter for consistent naming convention
Power Conversion: - All power values converted to per-unit on system base - System base MVA used for normalization [MVA]
Source code in src/wecgrid/modelers/power_system/pypsa.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
|
snapshot_lines()
Capture current transmission line state from PyPSA.
Builds a Pandas DataFrame of the current transmission line state for the loaded PyPSA network. The DataFrame includes line loading percentages and connection information.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns: line, ibus, jbus, line_pct, status. Line names are formatted as "Line_ibus_jbus_count". |
Notes
The following PyPSA network data is used to create line snapshots:
Line Information: - Line bus connections (bus0, bus1) [dimensionless] - Line thermal ratings (s_nom) [MVA] - Line status (assumed active = 1)
Power Flow Data: - Active power flow at both ends [MW] - Reactive power flow at both ends [MVAr] - Apparent power calculated from P and Q [MVA] - Line loading as percentage of thermal rating [%]
Naming Convention: - Lines named as "Line_ibus_jbus_count" for consistency - Per-bus-pair counter for multiple parallel lines - Bus numbers converted from PyPSA string indices
Source code in src/wecgrid/modelers/power_system/pypsa.py
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 |
|
snapshot_loads()
Capture current load state from PyPSA.
Builds a Pandas DataFrame of the current load state for the loaded PyPSA network. The DataFrame includes load power consumption and status information for all buses with loads.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns: load, bus, p, q, base, status. Load names are formatted as "Load_bus_count". |
Notes
The following PyPSA network data is used to create load snapshots:
link - https://pypsa.readthedocs.io/en/stable/user-guide/components.html#load
Load Information: - Load names and bus assignments [dimensionless] - Active and reactive power consumption [MW], [MVAr] → [pu] - Load status from 'active' attribute [dimensionless]
Time Series Data: - Uses latest snapshot from loads_t for power values - Defaults to steady-state values if no time series available - Per-bus counter for consistent naming convention
Power Conversion: - All power values converted to per-unit on system base - System base MVA used for normalization [MVA]
Source code in src/wecgrid/modelers/power_system/pypsa.py
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 |
|
solve_powerflow(log=False)
Run power flow solution and check convergence.
Executes the PyPSA power flow solver with suppressed logging output and verifies that the solution converged successfully for all snapshots.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if power flow converged for all snapshots, False otherwise. |
Notes
The power flow solution process:
- Temporarily suppresses PyPSA logging to reduce output
- Calls
network.pf()
for power flow calculation - Checks convergence status for all snapshots
- Reports any failed snapshots for debugging
Example
if modeler.solve_powerflow(): ... print("Power flow converged successfully") ... else: ... print("Power flow failed to converge")
Source code in src/wecgrid/modelers/power_system/pypsa.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
take_snapshot(timestamp)
Take a snapshot of the current grid state.
Captures the current state of all grid components (buses, generators, lines, and loads) at the specified timestamp and updates the grid state object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timestamp
|
datetime
|
The timestamp for the snapshot. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Note
This method calls individual snapshot methods for each component type and updates the internal grid state with time-series data.
Source code in src/wecgrid/modelers/power_system/pypsa.py
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
|
WEC-Sim Runner
Interface for running WEC-Sim device-level simulations via MATLAB engine.
Simplified runner that manages MATLAB engine, executes WEC-Sim models from their native directories, and stores results in WEC-Grid database.
Attributes:
Name | Type | Description |
---|---|---|
wec_sim_path |
str
|
Path to WEC-Sim MATLAB installation. |
database |
WECGridDB
|
Database interface for simulation data storage. |
matlab_engine |
MatlabEngine
|
Active MATLAB engine. |
Source code in src/wecgrid/modelers/wec_sim/runner.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
|
get_wec_sim_path()
Get the currently configured WEC-Sim path.
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: Absolute path to the WEC-Sim installation or |
Optional[str]
|
if no path has been configured. |
Source code in src/wecgrid/modelers/wec_sim/runner.py
94 95 96 97 98 99 100 101 |
|
set_wec_sim_path(path)
Configure the WEC-Sim MATLAB framework installation path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Filesystem location of the WEC-Sim MATLAB installation. |
required |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the supplied |
Source code in src/wecgrid/modelers/wec_sim/runner.py
80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
show_config()
Display current WEC-Sim configuration.
Prints the currently configured WEC-Sim path along with the location of the configuration file used to persist this setting.
Source code in src/wecgrid/modelers/wec_sim/runner.py
103 104 105 106 107 108 109 110 111 112 |
|
sim_results(df_power, model, wec_sim_id)
Generate visualization plots for WEC-Sim simulation results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df_power
|
DataFrame
|
Power and optional wave elevation time series produced by WEC-Sim. |
required |
model
|
str
|
Name of the WEC-Sim model used for the simulation. |
required |
wec_sim_id
|
int
|
Database identifier for the WEC-Sim run. |
required |
Source code in src/wecgrid/modelers/wec_sim/runner.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
start_matlab()
Initialize MATLAB engine and configure WEC-Sim framework paths.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
|
bool
|
engine was already running or the MATLAB Python API is unavailable. |
Source code in src/wecgrid/modelers/wec_sim/runner.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
stop_matlab()
Shutdown the MATLAB engine and free system resources.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
|
bool
|
running. |
Source code in src/wecgrid/modelers/wec_sim/runner.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
WEC Components
WEC Device
Individual Wave Energy Converter device with time-series power output data.
Represents a single wave energy converter with simulation results, grid connection parameters, and metadata. Contains time-series power output data from WEC-Sim hydrodynamic simulations for realistic renewable generation modeling.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Unique device identifier, typically "{model}{sim_id}". |
dataframe |
DataFrame
|
Primary time-series data for grid integration at 5-minute intervals. Columns: time, p [MW], q [MVAr], base [MVA]. |
dataframe_full |
DataFrame
|
High-resolution simulation data with complete WEC-Sim output including wave elevation and device states. |
base |
float
|
Base power rating [MVA] for per-unit calculations. |
bus_location |
int
|
Power system bus number for grid connection. |
model |
str
|
WEC device model type ("RM3", "LUPA", etc.). |
sim_id |
int
|
Database simulation identifier for traceability. |
Example
power_data = pd.DataFrame({ ... 'p': [2.5, 3.1, 2.8], # MW ... 'q': [0.0, 0.0, 0.0], # MVAr ... 'base': [100.0] * 3 # MVA ... }) device = WECDevice( ... name="RM3_101_0", ... dataframe=power_data, ... base=100.0, ... bus_location=14, ... model="RM3" ... )
Notes
- Variable power output based on wave conditions
- Typically operates at unity power factor (zero reactive power)
- Primary dataframe at 5-minute resolution for grid compatibility
- Full dataframe contains high-resolution WEC-Sim results
Source code in src/wecgrid/wec/device.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
WEC Farm
Collection of Wave Energy Converter devices at a common grid connection.
Manages multiple identical WEC devices sharing a grid connection bus. Aggregates device power outputs and coordinates time-series data for power system integration studies.
Attributes:
Name | Type | Description |
---|---|---|
farm_name |
str
|
Human-readable farm identifier. |
database |
Database interface for WEC simulation data. |
|
time |
Time manager for simulation synchronization. |
|
wec_sim_id |
int
|
Database simulation ID for WEC data retrieval. |
model |
str
|
WEC device model type (e.g., "RM3"). |
bus_location |
int
|
Grid bus number for farm connection. |
connecting_bus |
int
|
Network topology connection bus. |
id |
str
|
Unique generator identifier for power system integration. |
size |
int
|
Number of identical WEC devices in farm. |
config |
Dict
|
Configuration parameters for the farm. |
wec_devices |
List[WECDevice]
|
Collection of individual WEC devices. |
BASE |
float
|
Base power rating [MVA] for per-unit calculations. |
Example
farm = WECFarm( ... farm_name="Oregon Coast Farm", ... database=db, ... time=time_mgr, ... sim_id=101, ... model="RM3", ... bus_location=14, ... size=5 ... ) total_power = farm.power_at_snapshot(timestamp)
Notes
- All devices use identical power profiles from WEC-Sim data
- Power scales linearly with farm size
- Requires WEC-Sim simulation data in database
- Base power typically 100 MVA for utility-scale installations
TODO
- Add heterogeneous device support for different models
- Implement smart farm control and optimization
Source code in src/wecgrid/wec/farm.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
|
down_sample(wec_df, new_sample_period, timeshift=0)
Downsample WEC time-series data to a coarser time resolution.
Converts high-frequency WEC simulation data to lower frequency suitable for power system integration studies. Averages data over specified time windows to maintain energy conservation while reducing computational overhead.
Based on MATLAB DownSampleTS function with pandas DataFrame implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wec_df
|
DataFrame
|
Original high-frequency WEC data with 'time' column. Must contain time series data with consistent time step. |
required |
new_sample_period
|
float
|
New sampling period [seconds] for downsampled data. Typically 300s (5 minutes) for grid integration studies. |
required |
timeshift
|
int
|
Time alignment option. Defaults to 0. - 0: Samples at end of averaging period - 1: Samples centered within averaging period |
0
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Downsampled DataFrame with same columns as input. Time column adjusted to new sampling frequency. Data columns contain averaged values over sampling windows. |
Raises:
Type | Description |
---|---|
ValueError
|
If new_sample_period is smaller than original time step. |
KeyError
|
If 'time' column not found in input DataFrame. |
Example
Downsample 0.1s WEC data to 5-minute intervals
df_original = pd.DataFrame({ ... 'time': np.arange(0, 1000, 0.1), # 0.1s timestep ... 'p': np.random.rand(10000), # Power data ... 'eta': np.random.rand(10000) # Wave elevation ... }) df_downsampled = farm.down_sample(df_original, 300.0) # 5min print(f"Original: {len(df_original)} points") print(f"Downsampled: {len(df_downsampled)} points") Original: 10000 points Downsampled: 33 points
Averaging Process
- Calculate sample ratio: How many original points per new point
- Determine new time grid: Based on sample period and alignment
- Window averaging: Mean value over each time window
- Energy conservation: Maintains total energy content
Data Processing
- First window: Averages from start to first sample point
- Subsequent windows: Averages over fixed-width windows
- Missing data: Handles partial windows at end of series
- Column preservation: Maintains all non-time columns
Performance Considerations
- Memory efficient: Uses vectorized pandas operations
- Flexible windows: Handles non-integer sample ratios
- Large datasets: Suitable for long WEC simulations
- Numerical stability: Robust averaging implementation
Grid Integration Usage
- PSS®E studies: 5-minute resolution for stability analysis
- Economic dispatch: Hourly or 15-minute intervals
- Load forecasting: Daily or weekly aggregation
- Resource assessment: Monthly or seasonal averages
Wave Energy Applications
- Power smoothing: Reduces high-frequency fluctuations
- Grid compliance: Matches utility data requirements
- Forecast validation: Aligns with meteorological predictions
- Storage sizing: Determines energy storage requirements
Notes
- Preserves energy content through proper averaging
- Original time step must be consistent (fixed timestep)
- New sample period should be multiple of original timestep
- Returns DataFrame with same structure as input
- Time column values updated to new sampling frequency
See Also
_prepare_farm: Uses this method for WEC data preprocessing WECGridTime: Provides target sampling frequencies pandas.DataFrame.resample: Alternative pandas resampling method
Source code in src/wecgrid/wec/farm.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
|
power_at_snapshot(timestamp)
Calculate total farm power output at a specific simulation time.
Aggregates active power output from all WEC devices in the farm at the specified timestamp. This method provides the primary interface for power system integration, enabling time-varying renewable generation modeling in grid simulations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timestamp
|
Timestamp
|
Simulation time to query for power output. Must exist in the device DataFrame time index. Typically corresponds to grid simulation snapshots at 5-minute intervals. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Total active power output from all farm devices in per-unit on
the farm's |
Raises:
Type | Description |
---|---|
KeyError
|
If timestamp not found in device data index. |
AttributeError
|
If device DataFrame not properly initialized. |
Example
Get power at specific simulation time
timestamp = pd.Timestamp("2023-01-01 12:00:00") power_pu = farm.power_at_snapshot(timestamp) print(f"Farm output at noon: {power_pu:.4f} pu") Farm output at noon: 0.1575 pu
Time series power extraction
time_series = [] for snapshot in time_manager.snapshots: ... power_pu = farm.power_at_snapshot(snapshot) ... time_series.append(power_pu)
import matplotlib.pyplot as plt plt.plot(time_manager.snapshots, time_series) plt.ylabel("Farm Power Output [pu]")
Power Aggregation
- Linear summation: Total = Σ(device_power[i] at timestamp)
- Homogeneous devices: All devices have identical power profiles
- Realistic scaling: Based on actual WEC device physics
- Wave correlation: Devices respond to same ocean conditions
Data Requirements
- Valid timestamp: Must exist in device DataFrame index
- Initialized devices: All WECDevice objects must be properly created
- Power column: Device data must contain "p" column for active power
- Time alignment: Timestamp must match grid simulation schedule
Error Handling
- Missing data warning: Prints warning for devices with no data
- Graceful degradation: Continues calculation with available devices
- Zero fallback: Returns 0.0 if no devices have valid data
- Timestamp validation: Checks for existence in device index
Performance Considerations
- O(n) complexity: Scales linearly with number of devices
- DataFrame lookup: Efficient pandas indexing for time queries
- Memory efficiency: No data copying, direct access to device data
- Repeated calls: Suitable for time-series iteration
Grid Integration Usage
- PSS®E integration: Provides generator output at each time step
- PyPSA integration: Supplies renewable generation time series
- Load flow studies: Time-varying injection for stability analysis
- Economic dispatch: Variable renewable generation modeling
Wave Energy Characteristics
- Intermittent output: Power varies with wave conditions
- Predictable patterns: Follows ocean wave statistics
- Seasonal variation: Higher output in winter storm seasons
- Capacity factor: Typically 20-40% for ocean wave resources
Notes
- Output is in per-unit on the farm's
sbase
; multiply bysbase
for MW - Power output includes WEC device efficiency and control effects
- All devices share identical profiles (same wave field assumption)
- Negative power values possible during reactive conditions
- Zero output during calm conditions or device maintenance
- Farm total limited by grid connection capacity
See Also
WECDevice.dataframe: Individual device power time series Engine.simulate: Uses this method for grid integration WECGridPlotter.plot_wec_analysis: Visualizes farm power output
Source code in src/wecgrid/wec/farm.py
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
|