@@ -226,9 +226,18 @@ def field_setup_names(self):
226
226
class BoundaryType (object ):
227
227
"""Creates and manages boundaries."""
228
228
229
- (PerfectE , PerfectH , Aperture , Radiation , Impedance , LayeredImp , LumpedRLC , FiniteCond , Hybrid , FEBI ) = range (
230
- 0 , 10
231
- )
229
+ (
230
+ PerfectE ,
231
+ PerfectH ,
232
+ Aperture ,
233
+ Radiation ,
234
+ Impedance ,
235
+ LayeredImp ,
236
+ LumpedRLC ,
237
+ FiniteCond ,
238
+ Hybrid ,
239
+ FEBI ,
240
+ ) = range (0 , 10 )
232
241
233
242
@property
234
243
def hybrid (self ):
@@ -3633,8 +3642,8 @@ def assign_impedance_to_sheet(self, sheet_name, sourcename=None, resistance=50,
3633
3642
3634
3643
Parameters
3635
3644
----------
3636
- sheet_name : str
3637
- Name of the sheet to apply the boundary to.
3645
+ sheet_name : str or list
3646
+ Name of the sheet or list to apply the boundary to.
3638
3647
sourcename : str, optional
3639
3648
Name of the impedance. The default is ``None``.
3640
3649
resistance : optional
@@ -3675,17 +3684,127 @@ def assign_impedance_to_sheet(self, sheet_name, sourcename=None, resistance=50,
3675
3684
sourcename = generate_unique_name ("Imped" )
3676
3685
elif sourcename in self .modeler .get_boundaries_name ():
3677
3686
sourcename = generate_unique_name (sourcename )
3687
+
3688
+ objects = self .modeler .convert_to_selections (sheet_name , True )
3689
+
3678
3690
props = OrderedDict (
3679
3691
{
3680
- "Objects" : [sheet_name ],
3681
- "Resistance" : str (resistance ),
3682
- "Reactance" : str (reactance ),
3683
- "InfGroundPlane" : is_infground ,
3692
+ "Faces" : objects ,
3684
3693
}
3685
3694
)
3695
+ if isinstance (objects [0 ], str ):
3696
+ props = OrderedDict (
3697
+ {
3698
+ "Objects" : objects ,
3699
+ }
3700
+ )
3701
+ props ["Resistance" ] = str (resistance )
3702
+ props ["Reactance" ] = str (reactance )
3703
+ props ["InfGroundPlane" ] = is_infground
3704
+
3686
3705
return self ._create_boundary (sourcename , props , "Impedance" )
3687
3706
return False
3688
3707
3708
+ @pyaedt_function_handler ()
3709
+ def assign_impedance_to_sheet (
3710
+ self , sheet_name , sourcename = None , resistance = 50.0 , reactance = 0.0 , is_infground = False , reference_cs = "Global"
3711
+ ):
3712
+ """Create an impedance taking one sheet.
3713
+
3714
+ Parameters
3715
+ ----------
3716
+ sheet_name : str or list
3717
+ Name of the sheet or list to apply the boundary to.
3718
+ sourcename : str, optional
3719
+ Name of the impedance. The default is ``None``.
3720
+ resistance : float or list, optional
3721
+ Resistance value in ohms. The default is ``50.0``.
3722
+ If a list of four elements is passed, an anisotropic impedance is assigned with the following order,
3723
+ [``Zxx``, ``Zxy``, ``Zyx``, ``Zyy``].
3724
+ reactance : optional
3725
+ Reactance value in ohms. The default is ``0.0``.
3726
+ If a list of four elements is passed, an anisotropic impedance is assigned with the following order,
3727
+ [``Zxx``, ``Zxy``, ``Zyx``, ``Zyy``].
3728
+ is_infground : bool, optional
3729
+ Whether the impedance is an infinite ground. The default is ``False``.
3730
+ reference_cs : str, optional
3731
+ Name of the coordinate system for the XY plane. The default is ``"Global"``.
3732
+ This parameter is only used for anisotropic impedance assignment.
3733
+
3734
+ Returns
3735
+ -------
3736
+ :class:`pyaedt.modules.Boundary.BoundaryObject`
3737
+ Boundary object if successful, ``False`` otherwise.
3738
+
3739
+ References
3740
+ ----------
3741
+
3742
+ >>> oModule.AssignImpedance
3743
+
3744
+ Examples
3745
+ --------
3746
+
3747
+ Create a sheet and use it to create an impedance.
3748
+
3749
+ >>> sheet = hfss.modeler.create_rectangle(hfss.PLANE.XY,
3750
+ ... [0, 0, -90], [10, 2], name="ImpedanceSheet",
3751
+ ... matname="Copper")
3752
+ >>> impedance_to_sheet = hfss.assign_impedance_to_sheet(sheet.name, "ImpedanceFromSheet", 100, 50)
3753
+
3754
+ Create a sheet and use it to create an anisotropic impedance.
3755
+
3756
+ >>> sheet = hfss.modeler.create_rectangle(hfss.PLANE.XY,
3757
+ ... [0, 0, -90], [10, 2], name="ImpedanceSheet",
3758
+ ... matname="Copper")
3759
+ >>> anistropic_impedance_to_sheet = hfss.assign_impedance_to_sheet(sheet.name, "ImpedanceFromSheet",
3760
+ ... [377, 0, 0, 377], [0, 50, 0, 0])
3761
+
3762
+ """
3763
+
3764
+ if self .solution_type in ["Modal" , "Terminal" , "Transient Network" ]:
3765
+ if not sourcename :
3766
+ sourcename = generate_unique_name ("Imped" )
3767
+ elif sourcename in self .modeler .get_boundaries_name ():
3768
+ sourcename = generate_unique_name (sourcename )
3769
+
3770
+ objects = self .modeler .convert_to_selections (sheet_name , True )
3771
+
3772
+ props = OrderedDict (
3773
+ {
3774
+ "Faces" : objects ,
3775
+ }
3776
+ )
3777
+ if isinstance (objects [0 ], str ):
3778
+ props = OrderedDict (
3779
+ {
3780
+ "Objects" : objects ,
3781
+ }
3782
+ )
3783
+
3784
+ if isinstance (resistance , list ) and isinstance (reactance , list ):
3785
+ if len (resistance ) == 4 and len (reactance ) == 4 :
3786
+ props ["UseInfiniteGroundPlane" ] = is_infground
3787
+ props ["CoordSystem" ] = reference_cs
3788
+ props ["HasExternalLink" ] = False
3789
+ props ["ZxxResistance" ] = str (resistance [0 ])
3790
+ props ["ZxxReactance" ] = str (reactance [0 ])
3791
+ props ["ZxyResistance" ] = str (resistance [1 ])
3792
+ props ["ZxyReactance" ] = str (reactance [1 ])
3793
+ props ["ZyxResistance" ] = str (resistance [2 ])
3794
+ props ["ZyxReactance" ] = str (reactance [2 ])
3795
+ props ["ZyyResistance" ] = str (resistance [3 ])
3796
+ props ["ZyyReactance" ] = str (reactance [3 ])
3797
+ else :
3798
+ self .logger .error ("Number of elements in resistance and reactance must be four." )
3799
+ return False
3800
+ return self ._create_boundary (sourcename , props , "Anisotropic Impedance" )
3801
+ else :
3802
+ props ["Resistance" ] = str (resistance )
3803
+ props ["Reactance" ] = str (reactance )
3804
+ props ["InfGroundPlane" ] = is_infground
3805
+ return self ._create_boundary (sourcename , props , "Impedance" )
3806
+ return False
3807
+
3689
3808
@pyaedt_function_handler ()
3690
3809
def create_circuit_port_from_edges (
3691
3810
self ,
0 commit comments