WEC Module
This module contains the Wave Energy Converter (WEC) device and farm abstractions used in WEC-Grid.
Overview
The WEC module provides: - WECDevice: Individual wave energy converter device modeling - WECFarm: Collection and management of multiple WEC devices - WECSimRunner: Integration with WEC-Sim simulation engine
API Reference
WEC-Grid WEC device/farm abstractions
WECDevice
dataclass
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 |
|
WECFarm
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 |
|
WECSimRunner
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 |
|