> 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/pe-add-on-simulink/model-and-simulation/create-a-circuit-model.md).

# Create a Circuit Model

## Create the circuit model in MathWorks Simulink

In MathWorks Simulink, use the Simscape Electrical Specialized Power Systems Blockset to design a circuit model for simulation with the eHS Solver. You may also use a [**Template Circuit**](https://www.opal-rt.com/docs/pe-add-on-simulink/examples/template-circuits.md) as a starting point.

Add a **powergui** block to the Simulink model.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2F5doEzOhzxyS5qFBDSC26%2Fimage.png?alt=media&amp;token=eaecd018-02cb-42db-a959-1123ff21d024" alt=""><figcaption></figcaption></figure>

You can configure the parameters in the Solver tab by double clicking the powergui block as follow:

| Configuration Parameters | Value          |
| ------------------------ | -------------- |
| **Simulation type**      | Discrete       |
| **Solver type**          | Backward Euler |
| **Sample time (s)**      | 1e-6           |

Navigate to **Simulation >> Configuration Parameters >> Solver**, and set the **Solver Type** to Fixed-Step. Under **Additional Parameters**, set the **Fixed Step Size** to 1e-6 (this value must match the one in the powergui block).

{% hint style="info" %}
The parameters configured in steps 4 and 5 do not affect the eHS solver; they are used only if the model is executed directly in Simulink (offline mode). Offline simulation is typically done for model validation purposes, and to generate benchmark data to compare against the results from the eHS Solver. The Discrete Backward Euler solver generates offline results most similar to those of the eHS solver.
{% endhint %}

## Recommendation

* Build the circuit using only **supported components**. See [**Supported Circuit Editors**](https://www.opal-rt.com/docs/pe-add-on-simulink/appendix/supported-circuit-editors.md) for more information.
* Add Current and Voltage **Measurement blocks** at locations of interest. The eHS solver will output these measurements during the simulation.
* Configure the parameters of each individual block and provide descriptive names. It is recommended, but not required, to start **Source block** names with the index U*XX*, **Switch** block names with SW*XX*, and **Measurement** block names with Y*XX*.
* Add a **Ground** block to the circuit, this is required.
* Add Scope blocks and signal generators to the source blocks to allow the model to generate results offline (this is optional). Note that these and any other components not supported by the eHS solver will be ignored during the FPGA simulation. They are for offline execution only.
* **Save** the model and press **Run** to confirm that there are no errors. A model that does not run successfully cannot be loaded into eHS.


---

# 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/pe-add-on-simulink/model-and-simulation/create-a-circuit-model.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.
