Skip to content

Commit a67bc2b

Browse files
authored
Added create_fan method to icepak.py (#822)
1 parent d2e1ab6 commit a67bc2b

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

_unittest/test_98_Icepak.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,13 @@ def test_39_import_idf(self):
366366
high_surface_thick="0.1in",
367367
)
368368

369+
def test_40_create_fan(self):
370+
fan = self.aedtapp.create_fan(origin=[5, 21, 1])
371+
assert fan
372+
assert (
373+
self.aedtapp.modeler.oeditor.Get3DComponentInstanceNames(fan.component_name)[0] == fan.component_name + "1"
374+
)
375+
369376
def test_88_create_heat_sink(self):
370377
self.aedtapp.insert_design("HS")
371378
assert self.aedtapp.create_parametric_fin_heat_sink()

pyaedt/icepak.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from pyaedt.generic.general_methods import generate_unique_name, aedt_exception_handler
1919
from pyaedt.generic.DataHandlers import _arg2dict
2020
from pyaedt.modules.Boundary import BoundaryObject, NativeComponentObject
21+
from pyaedt.generic.DataHandlers import random_string
22+
from pyaedt.modeler.GeometryOperators import GeometryOperators
2123

2224

2325
class Icepak(FieldAnalysisIcepak):
@@ -1881,6 +1883,133 @@ def get_link_data(self, linkData):
18811883

18821884
return arg
18831885

1886+
@aedt_exception_handler
1887+
def create_fan(
1888+
self,
1889+
name=None,
1890+
is_2d=False,
1891+
shape="Circular",
1892+
cross_section="XY",
1893+
radius="0.008mm",
1894+
hub_radius="0mm",
1895+
origin=None,
1896+
):
1897+
""" "Create a fan component in Icepak that is linked to an HFSS 3D Layout object.
1898+
1899+
Parameters
1900+
----------
1901+
name : str
1902+
Fan name.
1903+
is_2d : bool
1904+
Check if the fan is modeled as 2d or 3d.
1905+
shape : str
1906+
Fan Shape. It can be Circular or Rectangular.
1907+
cross_section : str
1908+
Fan Cross Section plane.
1909+
radius : str, float
1910+
Fan radius in modeler units.
1911+
hub_radius : str, float
1912+
Fan hub radius in modeler units.
1913+
origin : list
1914+
List of [x,y,z] position of the fan in the modeler.
1915+
1916+
Returns
1917+
-------
1918+
:class:`pyaedt.modules.Boundary.NativeComponentObject`
1919+
NativeComponentObject object.
1920+
1921+
References
1922+
----------
1923+
1924+
>>> oModule.InsertNativeComponent
1925+
"""
1926+
if not name:
1927+
name = generate_unique_name("Fan")
1928+
1929+
basic_component = OrderedDict(
1930+
{
1931+
"ComponentName": name,
1932+
"Company": "",
1933+
"Company URL": "",
1934+
"Model Number": "",
1935+
"Help URL": "",
1936+
"Version": "1.0",
1937+
"Notes": "",
1938+
"IconType": "Fan",
1939+
}
1940+
)
1941+
if is_2d:
1942+
model = "2D"
1943+
else:
1944+
model = "3D"
1945+
cross_section = GeometryOperators.cs_plane_to_plane_str(cross_section)
1946+
native_component = OrderedDict(
1947+
{
1948+
"Type": "Fan",
1949+
"Unit": self.modeler.model_units,
1950+
"ModelAs": model,
1951+
"Shape": shape,
1952+
"MovePlane": cross_section,
1953+
"Radius": self._arg_with_units(radius),
1954+
"HubRadius": self._arg_with_units(hub_radius),
1955+
"CaseSide": True,
1956+
"FlowDirChoice": "NormalPositive",
1957+
"FlowType": "Curve",
1958+
"SwirlType": "Magnitude",
1959+
"FailedFan": False,
1960+
"DimUnits": ["m3_per_s", "n_per_meter_sq"],
1961+
"X": ["0", "0.01"],
1962+
"Y": ["3", "0"],
1963+
"Pressure Loss Curve": OrderedDict(
1964+
{"DimUnits": ["m_per_sec", "n_per_meter_sq"], "X": ["", "", "", "3"], "Y": ["", "1", "10", "0"]}
1965+
),
1966+
"IntakeTemp": "AmbientTemp",
1967+
"Swirl": "0",
1968+
"OperatingRPM": "0",
1969+
"Magnitude": "1",
1970+
}
1971+
)
1972+
native_props = OrderedDict(
1973+
{
1974+
"TargetCS": "Global",
1975+
"SubmodelDefinitionName": name,
1976+
"ComponentPriorityLists": OrderedDict({}),
1977+
"NextUniqueID": 0,
1978+
"MoveBackwards": False,
1979+
"DatasetType": "ComponentDatasetType",
1980+
"DatasetDefinitions": OrderedDict({}),
1981+
"BasicComponentInfo": basic_component,
1982+
"GeometryDefinitionParameters": OrderedDict({"VariableOrders": OrderedDict()}),
1983+
"DesignDefinitionParameters": OrderedDict({"VariableOrders": OrderedDict()}),
1984+
"MaterialDefinitionParameters": OrderedDict({"VariableOrders": OrderedDict()}),
1985+
"MapInstanceParameters": "DesignVariable",
1986+
"UniqueDefinitionIdentifier": "57c8ab4e-4db9-4881-b6bb-"
1987+
+ random_string(12, char_set="abcdef0123456789"),
1988+
"OriginFilePath": "",
1989+
"IsLocal": False,
1990+
"ChecksumString": "",
1991+
"ChecksumHistory": [],
1992+
"VersionHistory": [],
1993+
"NativeComponentDefinitionProvider": native_component,
1994+
"InstanceParameters": OrderedDict(
1995+
{"GeometryParameters": "", "MaterialParameters": "", "DesignParameters": ""}
1996+
),
1997+
}
1998+
)
1999+
2000+
insts = list(self.modeler.oeditor.Get3DComponentInstanceNames(name))
2001+
2002+
native = NativeComponentObject(self, "Fan", name, native_props)
2003+
if native.create():
2004+
new_name = [i for i in list(self.modeler.oeditor.Get3DComponentInstanceNames(name)) if i not in insts][0]
2005+
self.modeler.primitives.refresh_all_ids()
2006+
self.materials._load_from_project()
2007+
self.native_components.append(native)
2008+
if origin:
2009+
self.modeler.move(new_name, origin)
2010+
return native
2011+
return False
2012+
18842013
@aedt_exception_handler
18852014
def create_ipk_3dcomponent_pcb(
18862015
self,

0 commit comments

Comments
 (0)