> 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/automation-api-and-scripting/hypersim-api-references/simulation.md).

# Simulation

## Function: getMonitoringAllValues

| **Section**    | **Description**                                                                                      |
| -------------- | ---------------------------------------------------------------------------------------------------- |
| **Action**     | Get the current value of all monitors during simulation                                              |
| **Parameters** | None                                                                                                 |
| **Returns**    | A dictionary where the key is the monitor name, and the value is the current value (dict\[str, str]) |
| **Raises**     | **AssertionError** – Raises exception on error                                                       |

## Function: getMonitoringValue

| **Section**    | **Description**                                      |
| -------------- | ---------------------------------------------------- |
| **Action**     | Get the current value of a monitor during simulation |
| **Parameters** | **monitorName** (*str*) – Name of the monitor        |
| **Returns**    | Value (str)                                          |
| **Raises**     | **AssertionError** – Raises exception on error       |

### **Example Usage**

{% code overflow="wrap" lineNumbers="true" %}

```python
HyWorksApi.getMonitoringValue('MyMonitor1')
```

{% endcode %}

## Function: getPreparationTimings

| **Section**    | **Description**                                                                                                                                                                                                                      |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Action**     | <p>Get the timings of the preparation phase of the current or provided model.<br>The preparation phase includes the topology build, analysis, load flow, task mapping, code generation,<br>simulation start and simulation stop.</p> |
| **Parameters** | **modelPath** (*str*) – path to the model file (Default: Currently opened model)                                                                                                                                                     |
| **Returns**    | An object containing the performance information (SimulationPreparationTimingsInfo)                                                                                                                                                  |
| **Raises**     | None                                                                                                                                                                                                                                 |

## Function: getReservedProcessorCount

| **Section**    | **Description**                                                         |
| -------------- | ----------------------------------------------------------------------- |
| **Action**     | Return the number of processor cores currently in the `Reserved` state. |
| **Parameters** | None                                                                    |
| **Returns**    | None                                                                    |
| **Raises**     | None                                                                    |

## Function: getSimulatingProcessorCount

| **Section**    | **Description**                                                           |
| -------------- | ------------------------------------------------------------------------- |
| **Action**     | Return the number of processor cores currently in the `Simulating` state. |
| **Parameters** | None                                                                      |
| **Returns**    | None                                                                      |
| **Raises**     | None                                                                      |

## Function: getSimulationCoreTimings

| **Section**    | **Description**                                                                                                                                               |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | <p>Get the core timings of the current or provided model.<br>This function gives the timings of the steps that occur during the simulation for each core.</p> |
| **Parameters** | **modelPath** (*str*) – path to the model file (Default: Currently opened model)                                                                              |
| **Returns**    | A list of objects containing the core timings (list\[SimulationCoreTimingsInfo])                                                                              |
| **Raises**     | None                                                                                                                                                          |

## Function: getSimulationOverruns

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Get the current simulation overrun count       |
| **Parameters** | None                                           |
| **Returns**    | Value (float)                                  |
| **Raises**     | **AssertionError** – Raises exception on error |

## Function: getSimulationPerformanceTimings

| **Section**    | **Description**                                                                                                                                                                                                                  |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | Retrieves real-time performance timing metrics for the current simulation, per processor core.                                                                                                                                   |
| **Parameters** | <p><strong>mode</strong> (<em>MonitoringMode</em>) – monitoring mode filter (Default: MonitoringMode.ALL)<br><strong>procs</strong> (<em>list\[int]</em>) – List of processor cores to retrieve the performance timings from</p> |
| **Returns**    | A RealTimeMonitoringInfos object containing the core performance timings (list\[SimulationCoreTimingsInfo])                                                                                                                      |
| **Raises**     | **AssertionError** – Raises exception on error                                                                                                                                                                                   |

## Function: getSimulationTime

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Get the current simulation time, in seconds    |
| **Parameters** | None                                           |
| **Returns**    | Value (float)                                  |
| **Raises**     | **AssertionError** – Raises exception on error |

## Function: getSimulationTimings

| **Section**    | **Description**                                                                                                                                                                                         |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | <p>Get the simulation timings of the current or provided model.<br>This function provides the timings for the steps that occur at the start of the simulation and during each subsequent iteration.</p> |
| **Parameters** | **modelPath** (*str*) – path to the model file (Default: Currently opened model)                                                                                                                        |
| **Returns**    | An object containing the simulation timings (SimulationTimings)                                                                                                                                         |
| **Raises**     | None                                                                                                                                                                                                    |

## Function: loadSnapshot

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Loads a snapshot in the simulation             |
| **Parameters** | None                                           |
| **Returns**    | Error value (int)                              |
| **Raises**     | **AssertionError** – Raises exception on error |

## Function: resetMonitoring

| **Section**    | **Description**                                                                                |
| -------------- | ---------------------------------------------------------------------------------------------- |
| **Action**     | Reset performance indicators and timings for simulation                                        |
| **Parameters** | **cpuList** (*list\[int]*) – list of cpu cores to reset. ex: \[1, 2, 3, 4] Returns error value |
| **Returns**    | None                                                                                           |
| **Raises**     | **AssertionError** – Raises exception on error                                                 |

## Function: resetPerfIndic

| **Section**    | **Description**                                                                                |
| -------------- | ---------------------------------------------------------------------------------------------- |
| **Action**     | Reset performance indicators for simulation                                                    |
| **Parameters** | **cpuList** (*list\[int]*) – list of cpu cores to reset. ex: \[1, 2, 3, 4] Returns error value |
| **Returns**    | None                                                                                           |
| **Raises**     | **AssertionError** – Raises exception on error                                                 |

## Function: resetSimulationPerformanceTimings

| **Section**    | **Description**                                                                                                                                                                          |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Action**     | <p>Reset the performance timings of the current simulation.<br>This function resets the specified processor timings.</p>                                                                 |
| **Parameters** | <p><strong>mode</strong> (<em>MonitoringMode</em>) – Monitoring mode<br><strong>procs</strong> (<em>list\[int]</em>) – List of processor cores to reset the performance timings from</p> |
| **Returns**    | Success status (bool)                                                                                                                                                                    |
| **Raises**     | None                                                                                                                                                                                     |

## Function: resetTiming

| **Section**    | **Description**                                                                                |
| -------------- | ---------------------------------------------------------------------------------------------- |
| **Action**     | Reset performance timing for simulation                                                        |
| **Parameters** | **cpuList** (*list\[int]*) – list of cpu cores to reset. ex: \[1, 2, 3, 4] Returns error value |
| **Returns**    | None                                                                                           |
| **Raises**     | **AssertionError** – Raises exception on error                                                 |

## Function: simtrig

| **Section**    | **Description**                                 |
| -------------- | ----------------------------------------------- |
| **Action**     | Trig the programmable devices in the simulation |
| **Parameters** | **sync** (*bool*) – synchronize with POW        |
| **Returns**    | Error value (int)                               |
| **Raises**     | **AssertionError** – Raises exception on error  |

## Function: startMonitoring

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Start monitoring                               |
| **Parameters** | None                                           |
| **Returns**    | Error value (int)                              |
| **Raises**     | **AssertionError** – Raises exception on error |

## Function: startSim

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Start simulation                               |
| **Parameters** | None                                           |
| **Returns**    | Error value (int)                              |
| **Raises**     | **AssertionError** – Raises exception on error |

## Function: stopMonitoring

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Stop monitoring                                |
| **Parameters** | None                                           |
| **Returns**    | Error value (int)                              |
| **Raises**     | **AssertionError** – Raises exception on error |

## Function: stopSim

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Stop simulation                                |
| **Parameters** | None                                           |
| **Returns**    | Error value (int)                              |
| **Raises**     | **AssertionError** – Raises exception on error |

## Function: takeSnapshot

| **Section**    | **Description**                                |
| -------------- | ---------------------------------------------- |
| **Action**     | Takes a snapshot of the simulation             |
| **Parameters** | None                                           |
| **Returns**    | Error value (int)                              |
| **Raises**     | **AssertionError** – Raises exception on error |


---

# 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/automation-api-and-scripting/hypersim-api-references/simulation.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.
