Variable#

class pyedb.dotnet.database.Variables.Variable(expression, units=None, si_value=None, full_variables=None, name=None, app=None, readonly=False, hidden=False, description=None, postprocessing=False, circuit_parameter=True)#

Bases: object

Stores design properties and project variables and provides operations to perform on them.

Parameters:
valuefloat, str

Numerical value of the variable in SI units.

unitsstr

Units for the value.

Examples

>>> from pyedb.dotnet.database.Variables import Variable

Define a variable using a string value consistent with the AEDT properties.

>>> v = Variable("45mm")

Define an unitless variable with a value of 3.0.

>>> v = Variable(3.0)

Define a variable defined by a numeric result and a unit string.

>>> v = Variable(3.0 * 4.5, units="mm")
>>> assert v.numeric_value = 13.5
>>> assert v.units = "mm"

Overview#

decompose

Decompose a variable value to a floating with its unit.

rescale_to

Rescale the expression to a new unit within the current unit system.

format

Retrieve the string value with the specified numerical formatting.

name

Variable name.

is_optimization_enabled

“Check if optimization is enabled.

optimization_min_value

“Optimization min value.

optimization_max_value

“Optimization max value.

is_sensitivity_enabled

Check if Sensitivity is enabled.

sensitivity_min_value

“Sensitivity min value.

sensitivity_max_value

“Sensitivity max value.

sensitivity_initial_disp

“Sensitivity initial value.

is_tuning_enabled

Check if tuning is enabled.

tuning_min_value

“Tuning min value.

tuning_max_value

“Tuning max value.

tuning_step_value

“Tuning Step value.

is_statistical_enabled

Check if statistical is enabled.

read_only

Read-only flag value.

hidden

Hidden flag value.

description

Description value.

post_processing

Postprocessing flag value.

circuit_parameter

Circuit parameter flag value.

expression

Expression.

numeric_value

Numeric part of the expression as a float value.

unit_system

Unit system of the expression as a string.

units

Units.

value

Value.

evaluated_value

String value.

__mul__

Multiply the variable with a number or another variable and return a new object.

__add__

Add the variable to another variable to return a new object.

__sub__

Subtract another variable from the variable to return a new object.

__truediv__

Divide the variable by a number or another variable to return a new object.

__div__

__rtruediv__

Divide another object by this object.

Import detail#

from pyedb.dotnet.database.Variables import Variable

Property detail#

property Variable.name#

Variable name.

property Variable.is_optimization_enabled#

“Check if optimization is enabled.

property Variable.optimization_min_value#

“Optimization min value.

property Variable.optimization_max_value#

“Optimization max value.

property Variable.is_sensitivity_enabled#

Check if Sensitivity is enabled.

property Variable.sensitivity_min_value#

“Sensitivity min value.

property Variable.sensitivity_max_value#

“Sensitivity max value.

property Variable.sensitivity_initial_disp#

“Sensitivity initial value.

property Variable.is_tuning_enabled#

Check if tuning is enabled.

property Variable.tuning_min_value#

“Tuning min value.

property Variable.tuning_max_value#

“Tuning max value.

property Variable.tuning_step_value#

“Tuning Step value.

property Variable.is_statistical_enabled#

Check if statistical is enabled.

property Variable.read_only#

Read-only flag value.

property Variable.hidden#

Hidden flag value.

property Variable.description#

Description value.

property Variable.post_processing#

Postprocessing flag value.

property Variable.circuit_parameter#

Circuit parameter flag value.

property Variable.expression#

Expression.

property Variable.numeric_value#

Numeric part of the expression as a float value.

property Variable.unit_system#

Unit system of the expression as a string.

property Variable.units#

Units.

property Variable.value#

Value.

property Variable.evaluated_value#

String value.

The numeric value with the unit is concatenated and returned as a string. The numeric display in the modeler and the string value can differ. For example, you might see 10mm in the modeler and see 10.0mm returned as the string value.

Attribute detail#

Variable.__rmul__#

Method detail#

Variable.decompose()#

Decompose a variable value to a floating with its unit.

Returns:
tuple

The float value of the variable and the units exposed as a string.

Examples

>>> hfss = Hfss()
>>> hfss["v1"] = "3N"
>>> print(hfss.variable_manager["v1"].decompose("v1"))
>>> (3.0, "N")
Variable.rescale_to(units)#

Rescale the expression to a new unit within the current unit system.

Parameters:
unitsstr

Units to rescale to.

Examples

>>> from pyedb.dotnet.database.Variables import Variable
>>> v = Variable("10W")
>>> assert v.numeric_value == 10
>>> assert v.units == "W"
>>> v.rescale_to("kW")
>>> assert v.numeric_value == 0.01
>>> assert v.units == "kW"
Variable.format(format)#

Retrieve the string value with the specified numerical formatting.

Parameters:
formatstr

Format for the numeric value of the string. For example, '06.2f'. For more information, see the PyFormat documentation.

Returns:
str

String value with the specified numerical formatting.

Examples

>>> from pyedb.dotnet.database.Variables import Variable
>>> v = Variable("10W")
>>> assert v.format("f") == "10.000000W"
>>> assert v.format("06.2f") == "010.00W"
>>> assert v.format("6.2f") == " 10.00W"
Variable.__mul__(other)#

Multiply the variable with a number or another variable and return a new object.

Parameters:
othernumbers.Number or variable

Object to be multiplied.

Returns:
type

Variable.

Examples

>>> from pyedb.dotnet.database.Variables import Variable

Multiply 'Length1' by unitless 'None'` to obtain 'Length'. A numerical value is also considered to be unitless.

>>> import ansys.aedt.core.generic.constants
>>> v1 = Variable("10mm")
>>> v2 = Variable(3)
>>> result_1 = v1 * v2
>>> result_2 = v1 * 3
>>> assert result_1.numeric_value == 30.0
>>> assert result_1.unit_system == "Length"
>>> assert result_2.numeric_value == result_1.numeric_value
>>> assert result_2.unit_system == "Length"

Multiply voltage times current to obtain power.

>>> import ansys.aedt.core.generic.constants
>>> v3 = Variable("3mA")
>>> v4 = Variable("40V")
>>> result_3 = v3 * v4
>>> assert result_3.numeric_value == 0.12
>>> assert result_3.units == "W"
>>> assert result_3.unit_system == "Power"
Variable.__add__(other)#

Add the variable to another variable to return a new object.

Parameters:
otherclass:pyedb.dotnet.database.Variables.Variable

Object to be multiplied.

Returns:
type

Variable.

Examples

>>> from pyedb.dotnet.database.Variables import Variable
>>> import ansys.aedt.core.generic.constants
>>> v1 = Variable("3mA")
>>> v2 = Variable("10A")
>>> result = v1 + v2
>>> assert result.numeric_value == 10.003
>>> assert result.units == "A"
>>> assert result.unit_system == "Current"
Variable.__sub__(other)#

Subtract another variable from the variable to return a new object.

Parameters:
otherclass:pyedb.dotnet.database.Variables.Variable

Object to be subtracted.

Returns:
type

Variable.

Examples

>>> import ansys.aedt.core.generic.constants
>>> from pyedb.dotnet.database.Variables import Variable
>>> v3 = Variable("3mA")
>>> v4 = Variable("10A")
>>> result_2 = v3 - v4
>>> assert result_2.numeric_value == -9.997
>>> assert result_2.units == "A"
>>> assert result_2.unit_system == "Current"
Variable.__truediv__(other)#

Divide the variable by a number or another variable to return a new object.

Parameters:
othernumbers.Number or variable

Object by which to divide.

Returns:
type

Variable.

Examples

Divide a variable with units "W" by a variable with units "V" and automatically resolve the new units to "A".

>>> from pyedb.dotnet.database.Variables import Variable
>>> import ansys.aedt.core.generic.constants
>>> v1 = Variable("10W")
>>> v2 = Variable("40V")
>>> result = v1 / v2
>>> assert result_1.numeric_value == 0.25
>>> assert result_1.units == "A"
>>> assert result_1.unit_system == "Current"
Variable.__div__(other)#
Variable.__rtruediv__(other)#

Divide another object by this object.

Parameters:
othernumbers.Number or variable

Object to divide by.

Returns:
type

Variable.

Examples

Divide a number by a variable with units "s" and automatically determine that the result is in "Hz".

>>> import ansys.aedt.core.generic.constants
>>> from pyedb.dotnet.database.Variables import Variable
>>> v = Variable("1s")
>>> result = 3.0 / v
>>> assert result.numeric_value == 3.0
>>> assert result.units == "Hz"
>>> assert result.unit_system == "Freq"