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.
Examples | Expression Usage
Location
This example model can be found in the software under the category "How To" with the file name "Expression_Usage.ecf".
Description
This model illustrates various ways of setting Variables and Expressions onto component parameters.
Case 1 - Control Elements
In this case, This is a way that will make sure the output of the gain and of the product is the same. This is the most common use case of expressions.
Gain1.g = GainMultiplier.A
Case 2 - Preferences
It is possible to reuse certain preferences from the circuit into the model. We have 3 expressions used in that scenario :
ExpressionTs.A = simulation.calculationStep
SineFromPrefs.f = loadflow.frequency
SineFromPrefs.A = simulation.calculationStep
This will link these parameters to the values of the preferences set in the Simulation Settings. The effect will be that the sine wave output value will not exceed the time step of 50us
Note: it is recommended to only use it only at the top level of the model, to keep simpler expressions throughout the model.
Case 3 - Network Elements
Expressions may also be applied to network elements. In that context, we try to have a 10KV voltage on the left of the transformer and 5KV on its right .
Vsrc1.module = PrimaryVoltage.A ; BusPrimary.baseVolt = PrimaryVoltage.A
PQLoad1.Voltage = SecondaryVoltage.A ; BusSecondary.baseVolt = SecondaryVoltage.A
This technique helps setting the voltage throughout the network, which will enable the loadflow.
Case 4 - Python API
Using the Python API | Commands , we can set regular values as well as expressions. Using the https://opal-rt.atlassian.net/wiki/pages/createpage.action?spaceKey=pdochs&title=Sequence%20Manager&linkCreation=true&fromPageId=1406468175 , the script “Expression_Usage.py“ may be executed to configure the square wave. After execution, the expression may be visually seen in the form of the component. Note that the same syntax is used in the User Interface and in the Python API.
Case 5 - Subcircuits
This is the second case where expressions are most used.
Following the documentationTransmitting Variables within a Subcircuit , it is possible to create a mask for the subcircuit which will provide symbols which can be used within the subcircuit. In that case:
DEV1.Gain2.g = GainValue ; where GainValue is defined in the mask of DEV1
Components at the same level of the subcircuit can be referenced inside the subcircuit. As an example:
Dev1.Sine1.A = ForSubCircuit.A
This method is often used to create a control panel in the model, for runtime modifications.
It is also possible to perform that link in the other direction, so from inside the subcircuit to the parent
Triang1.A = DEV1.Amplitude.A
It is recommended to use the first method primarily, as it allows the subcircuit to be independent, portable in other models.
Case 6 - Common mistake
This last case illustrates the warning in the content editor for editing expressions.
VsrcNoExp has no expressions on the amplitude. We set the value to 0.707 (1/sqrt(2)) rmsLN in the component form.
This means that in the model unit, the amplitude is 0.707 * sqrt(2) which is 1 V peakLN
VsrcWithExp.A = “=0.70710“, set as an expression. Because of the equal symbol, HYPERSIM treats this value as an expression. Therefore it is set in the model unit (peakLN) instead of the view unit (rmsLN).
Therefore, after pressing apply, we see the blue value “VsrcWithExp.A = 0.500” rmsLN which is 0.707 peakLN
Because the 2 voltage amplitudes are different in the models, a different current output is expected.
Simulation and Results
The simulation has been executed and results can be observed using ScopeView template “Expression_Usage.svt”.