Skip to content

Commit

Permalink
New array class (#3850)
Browse files Browse the repository at this point in the history
* First array class commit

* Array class first properties

* Add array properties

* Add coordinate system

* Array parser

* Edit Array implementation

* Cells property

* Add empty cell

* Add empty cell

* Create array

* Unit test and documentation

* Unit test and documentation

* Fix codacy

* Fix codecov

* Fix tests

* Fix codacy

* Update pyaedt/hfss.py

Co-authored-by: Kathy Pippert <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix comment

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Fix comment

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Fix export_array_info

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Fix comments

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Fix comments

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Fix comments

* Merged Sebastien refactoring

* Fix typo

* Fix codacy

* Add getitem method

* Add getitem method

* Add getitem method

* Fix component dictionary

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modeler/cad/component_array.py

Co-authored-by: Kathy Pippert <[email protected]>

* Add Sebastien comments

---------

Co-authored-by: Kathy Pippert <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 8, 2023
1 parent d6df01f commit 70c105a
Show file tree
Hide file tree
Showing 12 changed files with 26,051 additions and 1,760 deletions.
15,602 changes: 15,602 additions & 0 deletions _unittest/example_models/T20/Array_232.aedt

Large diffs are not rendered by default.

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions _unittest/example_models/T20/array_info.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ArrayName,A1
Size Along A Vector,8
Size Along B Vector,8
A Vector,02_Patch1_LatticePair1
B Vector,02_Patch1_LatticePair2
Component Index,Component Name
1,02_Patch1
2,01_Metal_Only1
3,03_Radome_Side1
4,Radome_Corner1
Source Row,Source Column,Source Name,Magnitude,Phase
3,3,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (2*ScanPhaseShiftA + 2*ScanPhaseShiftB)
3,4,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (2*ScanPhaseShiftA + 3*ScanPhaseShiftB)
3,5,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (2*ScanPhaseShiftA + 4*ScanPhaseShiftB)
3,6,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (2*ScanPhaseShiftA + 5*ScanPhaseShiftB)
4,3,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (3*ScanPhaseShiftA + 2*ScanPhaseShiftB)
4,4,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (3*ScanPhaseShiftA + 3*ScanPhaseShiftB)
4,5,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (3*ScanPhaseShiftA + 4*ScanPhaseShiftB)
4,6,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (3*ScanPhaseShiftA + 5*ScanPhaseShiftB)
5,3,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (4*ScanPhaseShiftA + 2*ScanPhaseShiftB)
5,4,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (4*ScanPhaseShiftA + 3*ScanPhaseShiftB)
5,5,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (4*ScanPhaseShiftA + 4*ScanPhaseShiftB)
5,6,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (4*ScanPhaseShiftA + 5*ScanPhaseShiftB)
6,3,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (5*ScanPhaseShiftA + 2*ScanPhaseShiftB)
6,4,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (5*ScanPhaseShiftA + 3*ScanPhaseShiftB)
6,5,02_Patch1_1:1,ScanMag1*1,ScanPhase1 + (5*ScanPhaseShiftA + 4*ScanPhaseShiftB)
Array,Format: Component_index:Rotation_angle:Active_or_Passive
4,3,3,3,3,3,3,4:90.0deg,
3:270.0deg,2,2,2,2,2,2,3:90.0deg,
3:270.0deg,2:0,1,1,1,1,2,3:90.0deg,
3:270.0deg,2,1,1,1,1,2,3:90.0deg,
3:270.0deg,2,1,1,1,1,2,3:90.0deg:0,
3:270.0deg,2,1,1,1,1:0,2,,
3:270.0deg,2,2,,2,2,2,3:90.0deg,
4:270.0deg,3:180.0deg,3:180.0deg,,3:180.0deg,3:180.0deg,3:180.0deg,4:180.0deg,
44 changes: 44 additions & 0 deletions _unittest/example_models/T20/array_simple_232.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"primarylattice": "Circ_Patch_5GHz_232_1_Primary1",
"secondarylattice": "Circ_Patch_5GHz_232_1_Primary2",
"useairobjects": true,
"rowdimension": 3,
"columndimension": 3,
"visible": false,
"showcellnumber": false,
"paddingcells": 0,
"referencecsid": 1,
"cells": {
"(1,1)": {
"name": "Circ_Patch_5GHz_232_1",
"color": "(255,0,20)",
"active": true,
"postprocessing": true,
"rotation": 0.0
},
"(1,2)": {
"name": "Circ_Patch_5GHz_232_1"
},
"(1,3)": {
"name": "Circ_Patch_5GHz_232_1"
},
"(2,1)": {
"name": "Circ_Patch_5GHz_232_1"
},
"(2,2)": {
"name": "Circ_Patch_5GHz_232_1"
},
"(2,3)": {
"name": "Circ_Patch_5GHz_232_1"
},
"(3,1)": {
"name": "Circ_Patch_5GHz_232_1"
},
"(3,2)": {
"name": "Circ_Patch_5GHz_232_1"
},
"(3,3)": {
"name": "Circ_Patch_5GHz_232_1"
}
}
}
152 changes: 144 additions & 8 deletions _unittest/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@
test_subfolder = "T20"

if config["desktopVersion"] > "2022.2":
component = "Circ_Patch_5GHz_232.a3dcomp"
else:
component = "Circ_Patch_5GHz.a3dcomp"

if config["desktopVersion"] > "2023.1":
diff_proj_name = "differential_pairs_231"
else:
diff_proj_name = "differential_pairs"

component_array = "Array_232"


@pytest.fixture(scope="class")
def aedtapp(add_app):
Expand Down Expand Up @@ -1257,16 +1264,32 @@ def test_51a_array(self):
self.aedtapp.insert_design("Array_simple", "Modal")
from pyaedt.generic.DataHandlers import json_to_dict

dict_in = json_to_dict(
os.path.join(local_path, "../_unittest/example_models", test_subfolder, "array_simple.json")
)
dict_in["Circ_Patch_5GHz1"] = os.path.join(
local_path, "../_unittest/example_models", test_subfolder, "Circ_Patch_5GHz.a3dcomp"
)
dict_in["cells"][(3, 3)] = {"name": "Circ_Patch_5GHz1"}
if config["desktopVersion"] > "2023.1":
dict_in = json_to_dict(
os.path.join(local_path, "../_unittest/example_models", test_subfolder, "array_simple_232.json")
)
dict_in["Circ_Patch_5GHz_232_1"] = os.path.join(
local_path, "../_unittest/example_models", test_subfolder, component
)
dict_in["cells"][(3, 3)] = {"name": "Circ_Patch_5GHz_232_1"}
else:
dict_in = json_to_dict(
os.path.join(local_path, "../_unittest/example_models", test_subfolder, "array_simple.json")
)
dict_in["Circ_Patch_5GHz1"] = os.path.join(
local_path, "../_unittest/example_models", test_subfolder, component
)
dict_in["cells"][(3, 3)] = {"name": "Circ_Patch_5GHz1"}

assert self.aedtapp.add_3d_component_array_from_json(dict_in)
array_name = self.aedtapp.component_array_names[0]
assert self.aedtapp.component_array[array_name].cells[2][2].rotation == 0
assert self.aedtapp.component_array_names
dict_in["cells"][(3, 3)]["rotation"] = 90
assert self.aedtapp.add_3d_component_array_from_json(dict_in)
component_array = self.aedtapp.add_3d_component_array_from_json(dict_in)
assert component_array.cells[2][2].rotation == 90
component_array.cells[2][2].rotation = 0
assert component_array.cells[2][2].rotation == 0

def test_51b_set_material_threshold(self):
assert self.aedtapp.set_material_threshold()
Expand Down Expand Up @@ -1470,3 +1493,116 @@ def test_64_import_dxf(self):
dxf_layers = self.aedtapp.get_dxf_layers(dxf_file)
assert isinstance(dxf_layers, list)
assert self.aedtapp.import_dxf(dxf_file, dxf_layers)

def test_65_component_array(self, add_app):
hfss_array = add_app(project_name=component_array, subfolder=test_subfolder)
assert len(hfss_array.component_array) == 1

array = hfss_array.component_array["A1"]
assert array.name == hfss_array.component_array_names[0]

cell1 = array.get_cell(1, 1)
cell2 = array[1, 1]
assert cell2
assert cell1.rotation == 0

assert not array.get_cell(0, 0)
assert not array.get_cell(10, 0)

lc = array.lattice_vector()
assert len(lc) == 6

assert len(array.component_names) == 4

assert len(array.post_processing_cells) == 4
post_cells = array.post_processing_cells
post_cells["Radome_Corner1"] = [8, 1]
array.post_processing_cells = post_cells
assert array.post_processing_cells["Radome_Corner1"] == [8, 1]

array.cells[0][1].component = None
assert not array.cells[0][1].component

array.cells[1][1].rotation = 90
assert array.cells[1][1].rotation == 90

array.cells[1][1].rotation = 10
assert not array.cells[1][1].rotation == 10

array.cells[1][1].is_active = False
array.cells[1][1].is_active = 1
assert not array.cells[1][1].is_active

assert array.cells[1][2].component == array.component_names[2]
assert not array.cells[1][2].component == "test"

array.cells[0][1].component = array.component_names[3]
assert array.cells[0][1].component == array.component_names[3]

hfss_array.component_array["A1"].name = "Array_new"
assert hfss_array.component_array_names[0] == "Array_new"
hfss_array.component_array["Array_new"].name = "A1"

omodel = hfss_array.get_oo_object(hfss_array.odesign, "Model")
oarray = hfss_array.get_oo_object(omodel, "A1")

assert array.visible
array.visible = False
assert not oarray.GetPropValue("Visible")
array.visible = True
assert oarray.GetPropValue("Visible")

assert array.show_cell_number
array.show_cell_number = False
assert not oarray.GetPropValue("Show Cell Number")
array.show_cell_number = True
assert oarray.GetPropValue("Show Cell Number")

assert array.render == "Shaded"
array.render = "Wireframe"
assert oarray.GetPropValue("Render") == "Wireframe"
array.render = "Shaded"
assert oarray.GetPropValue("Render") == "Shaded"
array.render = "Shaded1"
assert not array.render == "Shaded1"

a_choices = array.a_vector_choices
assert array.a_vector_name in a_choices
array.a_vector_name = a_choices[0]
assert oarray.GetPropValue("A Vector") == a_choices[0]
array.a_vector_name = "Test"
assert not array.a_vector_name == "Test"

b_choices = array.b_vector_choices
assert array.b_vector_name in b_choices
array.b_vector_name = b_choices[1]
assert oarray.GetPropValue("B Vector") == b_choices[1]
array.b_vector_name = "Test"
assert not array.b_vector_name == "Test"

assert array.a_size == 8

assert array.b_size == 8

assert array.padding_cells == 0
array.padding_cells = 2
assert oarray.GetPropValue("Padding") == "2"
array.padding_cells = 0

assert array.coordinate_system == "Global"
array.coordinate_system = "Corner"
array.coordinate_system = "Global"

array_csv = os.path.join(local_path, "../_unittest/example_models", test_subfolder, "array_info.csv")
array_info = array.parse_array_info_from_csv(array_csv)
assert len(array_info) == 4
assert array_info["component"][1] == "02_Patch1"

# Delete 3D Component
hfss_array.modeler.user_defined_components["03_Radome_Side1"].delete()
array.update_properties()
assert len(array.component_names) == 3
assert len(array.post_processing_cells) == 3

array.delete()
assert not hfss_array.component_array
Loading

0 comments on commit 70c105a

Please sign in to comment.