Documentation Home Page HYPERSIM Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

Transmitting Variables within a Subcircuit

Transmitting Variables within a Subcircuit

Create a simple circuit by adding these elements and connecting them:

Number to add



Number to add




Control Sources

Constant, integer


Control Sources

Constant, float


Control Nonlinear And Delay


Then add these parts to the schematic:

Put them in a subcircuit (see Create a subcircuit).

Right-click the subcircuit and click Open Parameter Form:

In this Window, enter the values to transmit to the subcircuit.

Click Execute Script, and check the box next to these in the Variables to transmit tab:

Due to the use of JavaScript in this mask, there are eight reserved variables which cannot be used. See below.

These variables have fixed values:




Euler’s number




Square root of 2


Square root of ½


Natural logarithm of 2


Natural logarithm of 10


Base 2 logarithm of E


Base 10 logarithm of E

Select the value(s) to transmit to the subcircuit:

Linking Variables to a Subcircuit Component

The next step is to link the variable(s) set to the subcircuit components.

  • First, display the subcircuit.

  • To do so, use the Hotkey shortcut: CTRL+SHIFT+I or Right-click the subcircuit, click Subcircuit Info… and click the Open button.

  • To set a value click on the textbox and enter “=” + name of the variable.

Do the same with both of the Constant, float





Const1 (Constant, integer)


Const2 (Constant, float)


Const3 (Constant, float)


You can now edit values underneath the mask without opening every mask.


The Rules tab allows you to define other variables. While the Initial values are meant to be directly changed at the top level, and the variables defined in rules are designed to be calculated based on the initial values. They can then be transmitted within the subcircuit in the same way.

For example:

  • Initial Value: "radius=4"

  • Rules: "surface=PI*radius*radius"

  • Execute script

  • Variable to transmit will offer both radius and surface

The final script is the concatenation of both the Initial Values and Script, the 2 sections are split for clarity when defining the variables.

A good practice is to hide the variables generated by the Rules section if a Custom View was generated for the subcircuit.


The Options section helps to choose display options for the subcircuit.

  • Custom View: After clicking the Generate button on the right, an xml file will be generated designing a default layout for the form. The next time the subcircuit form is opened, the new layout will be displayed, which can then be manually customized.

    • The xml file can be found in the _hyp folder of the model, under the /view subfolder.

  • Category: This field will be used in the netlist to sort within the subcircuits.

  • Read-only: When checked, this option prevents the edition from the UI of the components inside the subcircuit. Therefore, if you enter the subcircuit above after checking this option, the constant fields cannot be edited anymore. This funnels all editions of the content of the subcircuit into the mask defined for the subcircuit.

  • Single block: With this option, elements within the subcircuit will not be part of the netlist, effectively helping to hide a component in a subcircuit. 

When generating a form for a subcircuit, we can always get back to the subcircuit configuration using the button left of the sensor form.

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | | +1 514-935-2323