Skip to content

Latest commit

 

History

History
240 lines (181 loc) · 8.84 KB

File metadata and controls

240 lines (181 loc) · 8.84 KB

FMU Integration Method

This directory documents the methodology for integrating Marine Hydrokinetic (MHK) device models into power system analysis tools using Functional Mock-up Units (FMUs).

Overview

The FMU (Functional Mock-up Unit) method enables co-simulation between detailed device models (typically developed in MATLAB/Simulink) and power system analysis software (such as PowerFactory). This approach allows:

  • Detailed device modeling in specialized simulation environments
  • System-level analysis in power system tools
  • Standardized interface through the FMI (Functional Mock-up Interface) standard
  • Efficient co-simulation without requiring full model ports

Why Use FMUs for MHK Integration?

Benefits

  • Preserve proprietary models: Device models remain encapsulated
  • Leverage specialized tools: Use best tool for each component
  • Standard interface: FMI is an open standard supported by many platforms
  • Computational efficiency: Optimized for co-simulation
  • Version control: FMUs are portable across different platforms

Use Cases

  • Grid impact studies with detailed MHK device models
  • Fault ride-through analysis
  • Power quality assessment
  • Integration planning and feasibility studies
  • Control strategy evaluation

FMU Integration Workflow

Phase 1: Prepare Simulink Model for FMU Export

  1. Define Interface Variables

    • Inputs from grid: Voltage (3-phase), frequency, grid events
    • Outputs to grid: Active power, reactive power, current
  2. Configure Model Settings

    • Set fixed-step solver (required for FMU export)
    • Choose appropriate time step (typically 10-100 μs for power electronics)
    • Ensure all blocks are compatible with code generation
  3. Add FMU Export Blocks

    • Use Simulink's "FMU Export" capability
    • Map input/output signals to FMU interface
    • Configure variable names and units
  4. Test in Simulink First

    • Verify model runs correctly standalone
    • Check output signal ranges and behavior
    • Validate control system response

Phase 2: Export FMU from Simulink

  1. Configure FMU Export Settings

    % In Simulink model configuration
    % Code Generation -> Interface -> Advanced parameters
    % Set "Support: Model reference" to FMU
  2. Build the FMU

    • Simulink Coder -> Build Model
    • Select FMU export type (typically Co-Simulation FMU)
    • Choose appropriate solver settings
  3. Verify FMU Package

    • Check that .fmu file is generated
    • Verify modelDescription.xml contains correct interface
    • Test FMU with FMU Checker tool (optional but recommended)

Phase 3: Import FMU into PowerFactory

Using the PowerFactory Template

We provide a template PowerFactory model that uses an AC Current Source as a proxy for the MHK device. This approach allows the FMU to control the current injection into the grid, providing a flexible and stable interface for co-simulation.

PowerFactory Composite Model PowerFactory template showing AC Current Source proxy for FMU integration

Template Structure

The PowerFactory template includes:

  1. AC Current Source (ElmIac)

    • Acts as the proxy element for the MHK device
    • Controlled by the FMU outputs (active and reactive current)
    • Connected at the point of common coupling (PCC)
  2. FMU Controller (ElmFmu)

    • Contains the MHK device model (WEC or CEC)
    • Receives voltage measurements from the grid
    • Outputs current commands to the AC current source
  3. Measurement Elements

    • Voltage measurement (StaVmea) - reads 3-phase voltage at PCC
    • Current measurement (StaImea) - monitors injected current (optional)
    • Frequency measurement - provides grid frequency to FMU
  4. Control Connections

    • Voltage signals from PCC → FMU inputs
    • FMU current outputs → AC Current Source setpoints
    • Proper signal scaling and unit conversion

Integration Steps

  1. Load Template Project

    • Open the PowerFactory template file
    • Identify the placeholder AC current source location
    • Note the existing measurement and control connections
  2. Import Your FMU

    • Navigate to Library → FMU Frames
    • Create new FMU frame element
    • Load your .fmu file (WEC or CEC model)
    • Verify FMU interface variables in the properties
  3. Configure FMU Interface

    Inputs (Grid → FMU):

    • Three-phase voltage magnitude and angle at PCC
    • Grid frequency
    • Any additional grid status signals (optional)

    Outputs (FMU → Grid):

    • Active current component (Id or Ip)
    • Reactive current component (Iq)
    • Device status signals (optional)
  4. Connect FMU to AC Current Source

    • Map FMU current outputs to the AC current source control inputs
    • Set proper scaling factors (ensure units match: A or pu)
    • Configure control block connections using composite model frame
  5. Configure Measurement Elements

    • Link voltage measurement at PCC to FMU voltage inputs
    • Set measurement element parameters (voltage level, nominal values)
    • Ensure proper coordinate transformations (abc → dq if needed)
  6. Set Co-simulation Parameters

    • Communication time step: Match Simulink FMU time step
    • Solver: Select RMS or EMT (EMT recommended for detailed dynamics)
    • Interpolation method: Zero-order hold or linear
    • Maximum iterations: 20-50 for convergence

Why AC Current Source?

Using an AC current source as a proxy offers several advantages:

  • Numerical Stability: Current sources are more stable than power sources in power flow calculations
  • Direct Control: FMU directly specifies current injection, avoiding additional conversion steps
  • Flexibility: Easy to switch between grid-feeding and grid-forming modes
  • Convergence: Better convergence properties in iterative co-simulation
  • Standard Practice: Widely used in power system analysis for converter modeling

Alternative: Controlled Voltage Source

For grid-forming applications, you can alternatively use a controlled voltage source (ElmVac), where the FMU specifies voltage magnitude and angle. However, the current source approach is more commonly used and more stable for grid-following inverters, which is typical for MHK devices.

Phase 4: Run and Validate Co-simulation

  1. Initial Testing

    • Start with steady-state conditions
    • Verify power flow convergence
    • Check variable magnitudes are reasonable
  2. Dynamic Simulation

    • Run time-domain simulation
    • Monitor FMU status and errors
    • Analyze power flows and device behavior
  3. Validation

    • Compare with standalone Simulink results
    • Verify energy conservation
    • Check numerical stability

Best Practices

Model Design

  • ⚡ Keep FMU interface simple (minimize number of variables)
  • ⚡ Use consistent units (SI units recommended)
  • ⚡ Document all interface variables clearly
  • ⚡ Include saturation limits on outputs to prevent numerical issues

Solver Configuration

  • ⚡ Match time steps between Simulink and PowerFactory
  • ⚡ Use fixed-step solvers in both environments
  • ⚡ Choose appropriate stiffness for solver selection
  • ⚡ Start with larger time steps, reduce if needed for stability

Debugging

  • ⚡ Test Simulink model thoroughly before FMU export
  • ⚡ Use signal logging to compare standalone vs. co-simulation
  • ⚡ Check FMU modelDescription.xml for correct interface
  • ⚡ Verify units and scaling factors match between tools

Performance

  • ⚡ Simplify models where possible without losing fidelity
  • ⚡ Use lookup tables for complex calculations when appropriate
  • ⚡ Minimize algebraic loops
  • ⚡ Balance accuracy with computational efficiency

Common Issues and Troubleshooting

Issue: FMU Export Fails

Solutions:

  • Ensure all Simulink blocks support code generation
  • Check that fixed-step solver is selected
  • Verify Simulink Coder license is available
  • Remove incompatible blocks (Scope, Display, etc.)

Issue: Co-simulation Diverges

Solutions:

  • Reduce communication time step
  • Check initial conditions match between models
  • Verify scaling of input/output variables
  • Add damping or filtering to outputs

Issue: Incorrect Power Exchange

Solutions:

  • Verify sign conventions match (generation vs. consumption)
  • Check per-unit vs. actual unit conversions
  • Validate measurement point locations
  • Ensure proper phase angle references

Issue: Slow Co-simulation

Solutions:

  • Increase communication time step (if stable)
  • Simplify FMU model complexity
  • Use more efficient numerical methods
  • Consider model order reduction

Templates and Examples

See the Synthetic Grid Example directory for complete working examples of:

  • PowerFactory projects with FMUs integrated
  • Pre-compiled FMU files
  • Configured interface connections