@@ -2480,27 +2480,51 @@ def add_derivatives(self, derivative_list):
2480
2480
def set_tuning_offset (self , offsets ):
2481
2481
"""Set derivative variable to a specific offset value.
2482
2482
2483
+ This method adjusts the tuning ranges for derivative variables in the design, allowing for specific offset
2484
+ values to be applied. If a variable is not specified in the ``offsets`` dictionary,
2485
+ its offset is set to ``0`` by default. Each value must be within ±10% of the nominal
2486
+ value of the corresponding variable.
2487
+
2483
2488
Parameters
2484
2489
----------
2485
2490
offsets : dict
2486
- Dictionary containing the variable name and it's offset value .
2491
+ Dictionary where keys are variable names and values are the corresponding offset values to be applied .
2487
2492
2488
2493
Returns
2489
2494
-------
2490
2495
bool
2496
+ ``True`` when successful, ``False`` when failed.
2497
+
2498
+ References
2499
+ ----------
2500
+ >>> oDesign.SetTuningRanges
2501
+
2502
+ Examples
2503
+ --------
2504
+ >>> from ansys.aed.core import Hfss
2505
+ >>> hfss = Hfss()
2506
+ >>> hfss["der_var"] = "1mm"
2507
+ >>> setup = hfss.create_setup(setup_type=1)
2508
+ >>> setup.add_derivatives("der_var")
2509
+ >>> hfss.analyze()
2510
+ >>> setup.set_tuning_offset({"der_var": 0.05})
2491
2511
"""
2492
2512
variables = self .get_derivative_variables ()
2493
2513
for v in variables :
2494
2514
if v not in offsets :
2495
2515
offsets [v ] = 0
2496
- arg = []
2516
+ arg = ["NAME:TuningRanges" ]
2497
2517
for k , v in offsets .items ():
2498
- arg .append (f"DeltaOffset({ k } )" )
2499
- arg .append (f"{ abs (self ._app .variable_manager [k ].numeric_value ) * (- 0.1 )} " )
2500
- arg .append (f"{ v } " )
2501
- arg .append (f"{ abs (self ._app .variable_manager [k ].numeric_value ) * 0.1 } " )
2518
+ arg .append ("Range:=" )
2519
+ arg2 = [
2520
+ f"DeltaOffset({ k } )" ,
2521
+ abs (self ._app .variable_manager [k ].numeric_value ) * (- 0.1 ),
2522
+ v ,
2523
+ abs (self ._app .variable_manager [k ].numeric_value ) * 0.1 ,
2524
+ ]
2525
+ arg .append (arg2 )
2502
2526
if self .is_solved :
2503
- self ._app .osolution . SetTuningOffsets ([ "TuningRanges:=" , arg ] )
2527
+ self ._app .odesign . SetTuningRanges ( arg )
2504
2528
return True
2505
2529
else :
2506
2530
self ._app .logger .error (f"Setup { self .name } is not solved. Solve it before tuning variables." )
@@ -3197,27 +3221,51 @@ def add_derivatives(self, derivative_list):
3197
3221
def set_tuning_offset (self , offsets ):
3198
3222
"""Set derivative variable to a specific offset value.
3199
3223
3224
+ This method adjusts the tuning ranges for derivative variables in the design, allowing for specific offset
3225
+ values to be applied. If a variable is not specified in the ``offsets`` dictionary,
3226
+ its offset is set to ``0`` by default. Each value must be within ±10% of the nominal
3227
+ value of the corresponding variable.
3228
+
3200
3229
Parameters
3201
3230
----------
3202
3231
offsets : dict
3203
- Dictionary containing the variable name and it's offset value .
3232
+ Dictionary where keys are variable names and values are the corresponding offset values to be applied .
3204
3233
3205
3234
Returns
3206
3235
-------
3207
3236
bool
3237
+ ``True`` when successful, ``False`` when failed.
3238
+
3239
+ References
3240
+ ----------
3241
+ >>> oDesign.SetTuningRanges
3242
+
3243
+ Examples
3244
+ --------
3245
+ >>> from ansys.aed.core import Hfss
3246
+ >>> hfss = Hfss()
3247
+ >>> hfss["der_var"] = "1mm"
3248
+ >>> setup = hfss.create_setup(setup_type=0)
3249
+ >>> setup.add_derivatives("der_var")
3250
+ >>> hfss.analyze()
3251
+ >>> setup.set_tuning_offset({"der_var": 0.05})
3208
3252
"""
3209
3253
variables = self .get_derivative_variables ()
3210
3254
for v in variables :
3211
3255
if v not in offsets :
3212
3256
offsets [v ] = 0
3213
- arg = []
3257
+ arg = ["NAME:TuningRanges" ]
3214
3258
for k , v in offsets .items ():
3215
- arg .append (f"DeltaOffset({ k } )" )
3216
- arg .append (f"{ abs (self ._app .variable_manager [k ].numeric_value ) * (- 0.1 )} " )
3217
- arg .append (f"{ v } " )
3218
- arg .append (f"{ abs (self ._app .variable_manager [k ].numeric_value ) * 0.1 } " )
3259
+ arg .append ("Range:=" )
3260
+ arg2 = [
3261
+ f"DeltaOffset({ k } )" ,
3262
+ abs (self ._app .variable_manager [k ].numeric_value ) * (- 0.1 ),
3263
+ v ,
3264
+ abs (self ._app .variable_manager [k ].numeric_value ) * 0.1 ,
3265
+ ]
3266
+ arg .append (arg2 )
3219
3267
if self .is_solved :
3220
- self ._app .osolution . SetTuningOffsets ([ "TuningRanges:=" , arg ] )
3268
+ self ._app .odesign . SetTuningRanges ( arg )
3221
3269
return True
3222
3270
else :
3223
3271
self ._app .logger .error (f"Setup { self .name } is not solved. Solve it before tuning variables." )
0 commit comments