> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/hypersim/model-and-simulation/phasor-domain-with-ephasorsim/integrate-a-power-system-model-to-ephasorsim/use-a-powerfactory-model/prepare-the-dgs-xml-file.md).

# Prepare the DGS-XML File

## Verify compatibility

Importing data from PowerFactory to ePHASORSIM requires the model to first be exported in **DGS-XML** format. Before exporting the **PowerFactory** model, verify that the PowerFactory version and the model components are supported.

### Supported PowerFactory versions

* PowerFactory 2021
* PowerFactory 2022
* PowerFactory 2023
* PowerFactory 2024

### Supported components

ePHASORSIM supports a subset of PowerFactory network elements and dynamic models. The following sections describe the PowerFactory components that can be imported, their mappings to ePHASORSIM Native Library components, and the parameters used during import:

* [Network Component Mapping](https://www.opal-rt.com/docs/hypersim/model-and-simulation/phasor-domain-with-ephasorsim/integrate-a-power-system-model-to-ephasorsim/use-a-powerfactory-model/prepare-the-dgs-xml-file/network-component-mapping.md) (Elm)
* [Exciter Mapping](https://www.opal-rt.com/docs/hypersim/model-and-simulation/phasor-domain-with-ephasorsim/integrate-a-power-system-model-to-ephasorsim/use-a-powerfactory-model/prepare-the-dgs-xml-file/exciter-mapping.md)
* [Turbine Governor Mapping](https://www.opal-rt.com/docs/hypersim/model-and-simulation/phasor-domain-with-ephasorsim/integrate-a-power-system-model-to-ephasorsim/use-a-powerfactory-model/prepare-the-dgs-xml-file/turbine-governor-mapping.md)
* [Power System Stabilizer Mapping](https://www.opal-rt.com/docs/hypersim/model-and-simulation/phasor-domain-with-ephasorsim/integrate-a-power-system-model-to-ephasorsim/use-a-powerfactory-model/prepare-the-dgs-xml-file/power-system-stabilizer-mapping.md)

For components that are not supported, users can develop custom components in a Modelica environment and import them as **Functional Mock-up Units (FMUs)**. See [Include FMU Components](https://www.opal-rt.com/docs/hypersim/model-and-simulation/phasor-domain-with-ephasorsim/integrate-a-power-system-model-to-ephasorsim/include-fmu-components.md) for complete implementation and configuration details.

Replace or remove any unsupported element before exporting the DGS-XML file. Any field that is not listed in the tables is ignored during import.

{% hint style="danger" %}
**PowerFactory** imported models support only **positive-sequence components**.
{% endhint %}

{% hint style="danger" %}
Components marked as out of service in PowerFactory are still imported and treated as in service by ePHASORSIM. Remove such components if they must remain unavailable during simulation.
{% endhint %}

{% hint style="danger" %}
To obtain results in ePHASORSIM that match a PowerFactory simulation, run the simulation with the center-of-inertia reference set to the nominal frequency (`iopt_coiref = 2`) in the **Calculate Initial Conditions** settings. Because this parameter cannot be configured in ePHASORSIM, it should be set in PowerFactory before exporting the model.
{% endhint %}

## Export the DGS-XML file

Exporting a PowerFactory model to DGS-XML requires a dedicated **Export Definition** (referred to as a *Variable Section* in PowerFactory). After importing the Export Definition into the **Data Manager**, use it to generate the required DGS-XML file.

{% stepper %}
{% step %}

### Import of “Export Definition”

1. Open the Data Manager.
2. Right-click on the Project -> “Import”.
3. Select “OPAL-RT UDB Export Definition-v14.pfd” -> “Open”.
   1. For PowerFactory version 2019 use “OPAL-RT UDB Export Definition-PF2019-v14.pfd”
4. Optionally select a new destination path via “New Path” in your Data Manager
   1. Since this Export Definition is the same for all projects, it can be imported outside of a specific PowerFactory project and reused across multiple projects.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-b8574ef433fa8fa36b30783619d1237092cdc9a9%2Fimage%20(148).png?alt=media" alt=""><figcaption></figcaption></figure>

5. Click “OK” to import the export definition
6. Afterwards a new folder should appear in the project structure
   {% endstep %}

{% step %}

### Pack External References into the Project

1. Deactivate the project in the Data Manager.
2. Do a right-click on the project in the Data Manager, an select → External References → Pack External References.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-3be9f77770836dc448f26d6e12eb39f9dcc06994%2Feph-DGS-Import2.png?alt=media" alt=""><figcaption></figcaption></figure>

3. Use the default options and click on OK:

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-8a3c92298c0dcbbf60a0bd0aaed9aac91c87172a%2Fimage%20(150).png?alt=media" alt=""><figcaption></figcaption></figure>

4. All project external references are now internalized into the project hierarchy:

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-0f9981d610eff02b90c45e191f12ce5ee7b6a5ff%2Feph-DGS-Import4.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Export of Model

1. Activate the project in the Data Manager.
2. Open project in PowerFactory main window
3. Run a positive sequence AC Load Flow

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-a58e7a802df325635d00f9e53fb2c93e7c3cb9c7%2Feph-DGS-Import5.png?alt=media" alt=""><figcaption></figcaption></figure>

4. Select “File” -> “Export” -> “DGS Format...”

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-2293dd09ba6be345fee8e1bf4e479ffbdec188d5%2Feph-DGS-Import6.png?alt=media" alt=""><figcaption></figcaption></figure>

5. Configure the following settings in the DGS-Export dialog:
   1. General Tab
      1. DGS Version: V7.00
      2. Format: XML File
      3. Encoding: UTF-9 (with BOM) (Not an option in PowerFactory 2019)
      4. File name: The choice is yours
      5. Variable Sets: OPAL-RT UDB Export Definition (Step 1) (Only in PowerFactory 2019)

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-a755cd5fe91cd34e375b85f44a24d89222d46355%2Fimage%20(155).png?alt=media" alt=""><figcaption></figcaption></figure>

Selection tab (*not an option in PowerFactory 2019*):

* **Variable Sets:** OPAL-RT UDB Export Definition (from step 1) (*only in 2021 and higher versions*)
* **Base Selection:** All elements of the active project

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-db6e98deaf740dd605dc31bd2a6bd5568fc7fa89%2Feph-DGS-import8.png?alt=media" alt=""><figcaption></figcaption></figure>

6. Start export by clicking on "Execute"
   {% endstep %}

{% step %}

### Verify the export output

Verify that no errors or warnings are reported in PowerFactory's **Output** window.

If any errors are reported, the generated `*.xml` file may not be compatible with the OPAL-RT importer.
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/hypersim/model-and-simulation/phasor-domain-with-ephasorsim/integrate-a-power-system-model-to-ephasorsim/use-a-powerfactory-model/prepare-the-dgs-xml-file.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
