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:
objectStores design properties and project variables and provides operations to perform on them.
- Parameters:
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 a variable value to a floating with its unit. |
|
Rescale the expression to a new unit within the current unit system. |
|
Retrieve the string value with the specified numerical formatting. |
Variable name. |
|
“Check if optimization is enabled. |
|
“Optimization min value. |
|
“Optimization max value. |
|
Check if Sensitivity is enabled. |
|
“Sensitivity min value. |
|
“Sensitivity max value. |
|
“Sensitivity initial value. |
|
Check if tuning is enabled. |
|
“Tuning min value. |
|
“Tuning max value. |
|
“Tuning Step value. |
|
Check if statistical is enabled. |
|
Read-only flag value. |
|
Hidden flag value. |
|
Description value. |
|
Postprocessing flag value. |
|
Circuit parameter flag value. |
|
Expression. |
|
Numeric part of the expression as a float value. |
|
Unit system of the expression as a string. |
|
Units. |
|
Value. |
|
String value. |
Multiply the variable with a number or another variable and return a new object. |
|
Add the variable to another variable to return a new object. |
|
Subtract another variable from the variable to return a new object. |
|
Divide the variable by a number or another variable to return a new object. |
|
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.
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
10mmin the modeler and see10.0mmreturned as the string value.
Attribute detail#
- Variable.__rmul__#
Method detail#
- Variable.decompose()#
Decompose a variable value to a floating with its unit.
- Returns:
tupleThe 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:
- units
str Units to rescale to.
- units
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:
- format
str Format for the numeric value of the string. For example,
'06.2f'. For more information, see the PyFormat documentation.
- format
- Returns:
strString 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:
- other
numbers.Numberorvariable Object to be multiplied.
- other
- Returns:
typeVariable.
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:
typeVariable.
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:
typeVariable.
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:
- other
numbers.Numberorvariable Object by which to divide.
- other
- Returns:
typeVariable.
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:
- other
numbers.Numberorvariable Object to divide by.
- other
- Returns:
typeVariable.
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"