-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathtest_20_HFSS.py
1646 lines (1470 loc) · 69.3 KB
/
test_20_HFSS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import math
import os
import shutil
from _unittest.conftest import config
from _unittest.conftest import local_path
from _unittest.conftest import settings
import pytest
small_number = 1e-10 # Used for checking equivalence.
from pyaedt.generic.near_field_import import convert_nearfield_data
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):
app = add_app(project_name="Test_20", design_name="test_20")
return app
@pytest.fixture(scope="class")
def fall_back_name(aedtapp):
name = aedtapp.design_name
return name
class TestClass:
@pytest.fixture(autouse=True)
def init(self, aedtapp, fall_back_name, local_scratch):
self.aedtapp = aedtapp
self.fall_back_name = fall_back_name
self.local_scratch = local_scratch
def test_01_save(self):
project_name = "Test_Exercse201119"
test_project = os.path.join(self.local_scratch.path, project_name + ".aedt")
self.aedtapp.save_project(test_project)
assert os.path.exists(test_project)
def test_01A_check_setup(self):
assert self.aedtapp.active_setup is None
def test_02_create_primitive(self):
coax1_len = 200
coax2_len = 70
r1 = 3.0
r2 = 10.0
r1_sq = 9.0 # Used to test area later.
coax1_origin = self.aedtapp.modeler.Position(0, 0, 0) # Thru coax origin.
coax2_origin = self.aedtapp.modeler.Position(125, 0, -coax2_len) # Perpendicular coax 1.
inner_1 = self.aedtapp.modeler.create_cylinder(self.aedtapp.AXIS.X, coax1_origin, r1, coax1_len, 0, "inner_1")
assert isinstance(inner_1.id, int)
inner_2 = self.aedtapp.modeler.create_cylinder(
self.aedtapp.AXIS.Z, coax2_origin, r1, coax2_len, 0, "inner_2", matname="copper"
)
assert len(inner_2.faces) == 3 # Cylinder has 3 faces.
# Check area of circular face.
assert abs(min([f.area for f in inner_2.faces]) - math.pi * r1_sq) < small_number
outer_1 = self.aedtapp.modeler.create_cylinder(self.aedtapp.AXIS.X, coax1_origin, r2, coax1_len, 0, "outer_1")
assert isinstance(outer_1.id, int)
outer_2 = self.aedtapp.modeler.create_cylinder(self.aedtapp.AXIS.Z, coax2_origin, r2, coax2_len, 0, "outer_2")
# Check the area of the outer surface of the cylinder "outer_2".
assert abs(max([f.area for f in outer_2.faces]) - 2 * coax2_len * r2 * math.pi) < small_number
inner = self.aedtapp.modeler.unite(["inner_1", "inner_2"])
outer = self.aedtapp.modeler.unite(["outer_1", "outer_2"])
assert outer == "outer_1"
assert inner == "inner_1"
assert self.aedtapp.modeler.subtract(outer_1, inner_1, keep_originals=True)
def test_03_2_assign_material(self):
udp = self.aedtapp.modeler.Position(0, 0, 0)
coax_length = 80
cyl_1 = self.aedtapp.modeler.create_cylinder(self.aedtapp.AXIS.X, udp, 10, coax_length, 0, "insulator")
self.aedtapp.modeler.subtract(cyl_1, "inner_1", keep_originals=True)
self.aedtapp.modeler["inner_1"].material_name = "Copper"
cyl_1.material_name = "teflon_based"
assert self.aedtapp.modeler["inner_1"].material_name == "copper"
assert cyl_1.material_name == "teflon_based"
def test_04_assign_coating(self):
id = self.aedtapp.modeler.get_obj_id("inner_1")
args = {
"mat": "aluminum",
"usethickness": True,
"thickness": "0.5mm",
"istwoside": True,
"issheelElement": True, # TODO: Is "sheelElement" a typo in native API?
"usehuray": True,
"radius": "0.75um",
"ratio": "3",
}
coat = self.aedtapp.assign_coating([id, "inner_1", 41], **args)
coat.name = "Coating1inner"
assert coat.update()
assert coat.object_properties
material = coat.props.get("Material", "")
assert material == "aluminum"
assert not self.aedtapp.assign_coating(["insulator2", 45])
def test_05_create_wave_port_from_sheets(self):
udp = self.aedtapp.modeler.Position(0, 0, 0)
o5 = self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.YZ, udp, 10, name="sheet1")
self.aedtapp.solution_type = "Terminal"
outer_1 = self.aedtapp.modeler["outer_1"]
# TODO: Consider allowing a TEM port to be created.
assert not self.aedtapp.wave_port(o5)
port = self.aedtapp.wave_port(
signal=o5,
deembed=5,
integration_line=self.aedtapp.AxisDir.XNeg,
impedance=40,
num_modes=2,
name="sheet1_Port",
renormalize=False,
reference=[outer_1.name],
terminals_rename=False,
)
assert port.object_properties
assert port.name == "sheet1_Port"
assert port.name in [i.name for i in self.aedtapp.boundaries]
assert port.props["RenormalizeAllTerminals"] is False
udp = self.aedtapp.modeler.Position(80, 0, 0)
o6 = self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.YZ, udp, 10, name="sheet1a")
self.aedtapp.modeler.subtract(o6, "inner_1", keep_originals=True)
port = self.aedtapp.wave_port(
signal=o6,
deembed=0,
integration_line=self.aedtapp.AxisDir.XNeg,
impedance=40,
num_modes=2,
name="sheet1a_Port",
renormalize=True,
reference=[outer_1.name],
create_pec_cap=True,
)
assert port.name == "sheet1a_Port"
assert port.name in [i.name for i in self.aedtapp.boundaries]
assert port.props["DoDeembed"] is False
# Get the object for "outer_1".
outer_1 = self.aedtapp.modeler["outer_1"]
bottom_port = self.aedtapp.wave_port(
outer_1.bottom_face_z,
reference=outer_1.name,
create_pec_cap=True,
name="bottom_probe_port",
)
assert bottom_port.name == "bottom_probe_port"
pec_objects = self.aedtapp.modeler.get_objects_by_material("pec")
assert len(pec_objects) == 2 # PEC cap created.
self.aedtapp.solution_type = "Modal"
assert len(self.aedtapp.boundaries) == 4
udp = self.aedtapp.modeler.Position(200, 0, 0)
o6 = self.aedtapp.modeler.create_circle(self.aedtapp.PLANE.YZ, udp, 10, name="sheet2")
port = self.aedtapp.wave_port(
signal=o6,
deembed=5,
integration_line=self.aedtapp.AxisDir.XPos,
impedance=40,
num_modes=2,
name="sheet2_Port",
renormalize=True,
)
assert port.name == "sheet2_Port"
assert port.name in [i.name for i in self.aedtapp.boundaries]
assert port.props["RenormalizeAllTerminals"] is True
id6 = self.aedtapp.modeler.create_box([20, 20, 20], [10, 10, 2], matname="Copper", name="My_Box")
id7 = self.aedtapp.modeler.create_box([20, 25, 30], [10, 2, 2], matname="Copper")
rect = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.YZ, [20, 25, 20], [2, 10])
port3 = self.aedtapp.wave_port(
signal=rect,
deembed=5,
integration_line=self.aedtapp.AxisDir.ZNeg,
impedance=30,
num_modes=1,
name="sheet3_Port",
renormalize=False,
)
assert port3.name in [i.name for i in self.aedtapp.boundaries]
def test_06a_create_linear_count_sweep(self):
setup = self.aedtapp.create_setup("MySetup")
setup.props["Frequency"] = "1GHz"
setup.props["BasisOrder"] = 2
setup.props["MaximumPasses"] = 1
assert setup.update()
assert self.aedtapp.create_linear_count_sweep("MySetup", "GHz", 0.8, 1.2, 401)
assert not self.aedtapp.setups[0].sweeps[0].is_solved
assert self.aedtapp.create_linear_count_sweep("MySetup", "GHz", 0.8, 1.2, 401)
assert self.aedtapp.create_linear_count_sweep(
setupname="MySetup",
sweepname="MySweep",
unit="MHz",
freqstart=1.1e3,
freqstop=1200.1,
num_of_freq_points=1234,
sweep_type="Interpolating",
)
assert self.aedtapp.create_linear_count_sweep(
setupname="MySetup",
sweepname="MySweep",
unit="MHz",
freqstart=1.1e3,
freqstop=1200.1,
num_of_freq_points=1234,
sweep_type="Interpolating",
)
assert self.aedtapp.create_linear_count_sweep(
setupname="MySetup",
sweepname="MySweepFast",
unit="MHz",
freqstart=1.1e3,
freqstop=1200.1,
num_of_freq_points=1234,
sweep_type="Fast",
)
num_points = 1752
freq_start = 1.1e3
freq_stop = 1200.1
units = "MHz"
sweep = self.aedtapp.create_linear_count_sweep(
setupname="MySetup",
sweepname=None,
unit=units,
freqstart=freq_start,
freqstop=freq_stop,
num_of_freq_points=num_points,
)
assert sweep.props["RangeCount"] == num_points
assert sweep.props["RangeStart"] == str(freq_start) + units
assert sweep.props["RangeEnd"] == str(freq_stop) + units
assert sweep.props["Type"] == "Discrete"
# Create a linear count sweep with the incorrect sweep type.
with pytest.raises(AttributeError) as execinfo:
self.aedtapp.create_linear_count_sweep(
setupname="MySetup",
sweepname="IncorrectStep",
unit="MHz",
freqstart=1.1e3,
freqstop=1200.1,
num_of_freq_points=1234,
sweep_type="Incorrect",
)
assert (
execinfo.args[0]
== "Invalid value for `sweep_type`. The value must be 'Discrete', 'Interpolating', or 'Fast'."
)
self.aedtapp["der_var"] = "1mm"
self.aedtapp["der_var2"] = "2mm"
setup2 = self.aedtapp.create_setup("MySetup_2", setuptype=0)
assert setup2.add_derivatives("der_var")
assert "der_var" in setup2.get_derivative_variables()
assert setup2.add_derivatives("der_var2")
assert "der_var2" in setup2.get_derivative_variables()
assert "der_var" in setup2.get_derivative_variables()
setup2.delete()
setup3 = self.aedtapp.create_setup("MySetup_3", setuptype=0)
assert setup3.add_derivatives("der_var")
assert "der_var" in setup3.get_derivative_variables()
assert setup3.add_derivatives("der_var2")
assert "der_var2" in setup3.get_derivative_variables()
assert "der_var" in setup3.get_derivative_variables()
setup3.delete()
def test_06b_setup_exists(self):
assert self.aedtapp.active_setup is not None
assert self.aedtapp.nominal_sweep is not None
def test_06c_create_linear_step_sweep(self):
step_size = 153.8
freq_start = 1.1e3
freq_stop = 1200.1
units = "MHz"
sweep = self.aedtapp.create_linear_step_sweep(
setupname="MySetup",
sweepname=None,
unit=units,
freqstart=freq_start,
freqstop=freq_stop,
step_size=step_size,
)
assert sweep.props["RangeStep"] == str(step_size) + units
assert sweep.props["RangeStart"] == str(freq_start) + units
assert sweep.props["RangeEnd"] == str(freq_stop) + units
assert sweep.props["Type"] == "Discrete"
step_size = 53.8
freq_start = 1.2e3
freq_stop = 1305.1
units = "MHz"
sweep = self.aedtapp.create_linear_step_sweep(
setupname="MySetup",
sweepname="StepFast",
unit=units,
freqstart=freq_start,
freqstop=freq_stop,
step_size=step_size,
sweep_type="Fast",
)
assert sweep.props["RangeStep"] == str(step_size) + units
assert sweep.props["RangeStart"] == str(freq_start) + units
assert sweep.props["RangeEnd"] == str(freq_stop) + units
assert sweep.props["Type"] == "Fast"
# Create a linear step sweep with the incorrect sweep type.
with pytest.raises(AttributeError) as execinfo:
self.aedtapp.create_linear_step_sweep(
setupname="MySetup",
sweepname="StepFast",
unit=units,
freqstart=freq_start,
freqstop=freq_stop,
step_size=step_size,
sweep_type="Incorrect",
)
assert (
execinfo.args[0]
== "Invalid value for 'sweep_type'. The value must be 'Discrete', 'Interpolating', or 'Fast'."
)
def test_06d_create_single_point_sweep(self):
assert self.aedtapp.create_single_point_sweep(
setupname="MySetup",
unit="MHz",
freq=1.2e3,
)
setup = self.aedtapp.get_setup("MySetup")
assert setup.create_single_point_sweep(
unit="GHz",
freq=1.2,
save_single_field=False,
)
assert self.aedtapp.create_single_point_sweep(
setupname="MySetup",
unit="GHz",
freq=[1.1, 1.2, 1.3],
)
assert self.aedtapp.create_single_point_sweep(
setupname="MySetup", unit="GHz", freq=[1.1e1, 1.2e1, 1.3e1], save_single_field=[True, False, True]
)
settings.enable_error_handler = True
assert not self.aedtapp.create_single_point_sweep(
setupname="MySetup", unit="GHz", freq=[1, 2e2, 3.4], save_single_field=[True, False]
)
settings.enable_error_handler = False
def test_06e_delete_setup(self):
setup_name = "SetupToDelete"
setuptd = self.aedtapp.create_setup(setupname=setup_name)
assert setuptd.name in self.aedtapp.existing_analysis_setups
assert self.aedtapp.delete_setup(setup_name)
assert setuptd.name not in self.aedtapp.existing_analysis_setups
def test_06f_sweep_add_subrange(self):
self.aedtapp.modeler.create_box([0, 0, 20], [10, 10, 5], "box_sweep", "Copper")
self.aedtapp.modeler.create_box([0, 0, 30], [10, 10, 5], "box_sweep2", "Copper")
self.aedtapp.wave_port(
signal="box_sweep",
reference="box_sweep2",
integration_line=self.aedtapp.AxisDir.XNeg,
create_port_sheet=True,
impedance=75,
num_modes=1,
name="WaveForSweep",
renormalize=False,
)
setup = self.aedtapp.create_setup(setupname="MySetupForSweep")
assert not setup.get_sweep()
sweep = setup.add_sweep()
sweep1 = setup.get_sweep(sweep.name)
assert sweep1 == sweep
sweep2 = setup.get_sweep()
assert sweep2 == sweep1
assert sweep.add_subrange("LinearCount", 1, 3, 10, "GHz")
assert sweep.add_subrange("LinearCount", 2, 4, 10, "GHz")
assert sweep.add_subrange("LinearStep", 1.1, 2.1, 0.4, "GHz")
assert sweep.add_subrange("LinearCount", 1, 1.5, 5, "MHz")
assert sweep.add_subrange("LogScale", 1, 3, 10, "GHz")
def test_06g_sweep_clear_subrange(self):
self.aedtapp.modeler.create_box([0, 0, 50], [10, 10, 5], "box_sweep3", "Copper")
self.aedtapp.modeler.create_box([0, 0, 60], [10, 10, 5], "box_sweep4", "Copper")
self.aedtapp.wave_port(
signal="box_sweep3",
reference="box_sweep4",
integration_line=self.aedtapp.AxisDir.XNeg,
create_port_sheet=True,
impedance=50,
num_modes=1,
name="WaveForSweepWithClear",
renormalize=False,
)
setup = self.aedtapp.create_setup(setupname="MySetupClearSweep")
sweep = setup.add_sweep()
assert sweep.add_subrange("LinearCount", 1.1, 3.6, 10, "GHz", clear=True)
assert sweep.props["RangeType"] == "LinearCount"
assert sweep.props["RangeStart"] == "1.1GHz"
assert sweep.props["RangeEnd"] == "3.6GHz"
assert sweep.props["RangeCount"] == 10
assert sweep.add_subrange("LinearCount", 2, 5, 10, "GHz")
setup.update()
sweep.update()
assert sweep.add_subrange("LinearCount", 3, 8, 10, "GHz", clear=True)
assert sweep.props["RangeType"] == "LinearCount"
assert sweep.props["RangeStart"] == "3GHz"
assert sweep.props["RangeEnd"] == "8GHz"
assert sweep.props["RangeCount"] == 10
assert sweep.add_subrange("LinearStep", 1.1, 2.1, 0.4, "GHz", clear=True)
assert sweep.props["RangeType"] == "LinearStep"
assert sweep.props["RangeStart"] == "1.1GHz"
assert sweep.props["RangeEnd"] == "2.1GHz"
assert sweep.props["RangeStep"] == "0.4GHz"
assert sweep.add_subrange("LogScale", 1, 3, 10, clear=True)
assert sweep.props["RangeType"] == "LogScale"
assert sweep.props["RangeStart"] == "1GHz"
assert sweep.props["RangeEnd"] == "3GHz"
assert sweep.props["RangeSamples"] == 10
sweep.props["Type"] = "Discrete"
sweep.update()
assert sweep.add_subrange("SinglePoints", 23, clear=True)
assert sweep.props["RangeType"] == "SinglePoints"
assert sweep.props["RangeStart"] == "23GHz"
assert sweep.props["RangeEnd"] == "23GHz"
assert sweep.props["SaveSingleField"] == False
def test_06z_validate_setup(self):
list, ok = self.aedtapp.validate_full_design(ports=len(self.aedtapp.excitations))
assert ok
def test_07_set_power(self):
assert self.aedtapp.edit_source("sheet1_Port" + ":1", "10W")
assert self.aedtapp.edit_sources(
{"sheet1_Port" + ":1": "10W", "sheet2_Port:1": ("20W", "20deg")},
include_port_post_processing=True,
max_available_power="40W",
)
assert self.aedtapp.edit_sources(
{"sheet1_Port" + ":1": "10W", "sheet2_Port:1": ("20W", "0deg", True)},
include_port_post_processing=True,
use_incident_voltage=True,
)
def test_08_create_circuit_port_from_edges(self):
plane = self.aedtapp.PLANE.XY
rect_1 = self.aedtapp.modeler.create_rectangle(plane, [10, 10, 10], [10, 10], name="rect1_for_port")
edges1 = self.aedtapp.modeler.get_object_edges(rect_1.id)
e1 = edges1[0]
rect_2 = self.aedtapp.modeler.create_rectangle(plane, [30, 10, 10], [10, 10], name="rect2_for_port")
edges2 = self.aedtapp.modeler.get_object_edges(rect_2.id)
e2 = edges2[0]
self.aedtapp.solution_type = "Modal"
assert self.aedtapp.composite is False
self.aedtapp.composite = True
assert self.aedtapp.composite is True
self.aedtapp.composite = False
self.aedtapp.hybrid = False
assert self.aedtapp.hybrid is False
self.aedtapp.hybrid = True
assert self.aedtapp.hybrid is True
assert (
self.aedtapp.circuit_port(
e1, e2, name="port10", impedance=50.1, renormalize=False, renorm_impedance="50"
).name
== "port10"
)
assert (
self.aedtapp.circuit_port(
e1, e2, name="port11", impedance="50+1i*55", renormalize=True, renorm_impedance=15.4
).name
== "port11"
)
assert self.aedtapp.set_source_context(["port10", "port11"])
assert self.aedtapp.set_source_context([])
assert self.aedtapp.set_source_context(["port10", "port11"], 0)
assert self.aedtapp.set_source_context(["port10", "port11", "sheet1_Port"])
assert self.aedtapp.set_source_context(["port10", "port11", "sheet1_Port"], 0)
self.aedtapp.solution_type = "Terminal"
assert (
self.aedtapp.circuit_port(
e1, e2, name="port20", impedance=50.1, renormalize=False, renorm_impedance="50+1i*55"
).name
== "port20"
)
bound = self.aedtapp.circuit_port(e1, e2, name="port32", impedance="50.1", renormalize=True)
assert bound
bound.name = "port21"
assert bound.update()
self.aedtapp.solution_type = "Modal"
def test_09_create_waveport_on_objects(self):
box1 = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], "BoxWG1", "Copper")
box2 = self.aedtapp.modeler.create_box([0, 0, 10], [10, 10, 5], "BoxWG2", "copper")
box2.material_name = "Copper"
port = self.aedtapp.wave_port(
signal="BoxWG1",
reference="BoxWG2",
integration_line=self.aedtapp.AxisDir.XNeg,
create_port_sheet=True,
impedance=50,
num_modes=1,
name="Wave1",
renormalize=False,
)
assert port.name == "Wave1"
port2 = self.aedtapp.wave_port(
signal="BoxWG1",
reference="BoxWG2",
integration_line=self.aedtapp.AxisDir.XPos,
create_port_sheet=True,
impedance=25,
num_modes=2,
name="Wave1",
renormalize=True,
deembed=5,
)
assert port2.name != "Wave1" and "Wave1" in port2.name
self.aedtapp.solution_type = "Terminal"
assert self.aedtapp.wave_port(
signal="BoxWG1",
reference="BoxWG2",
integration_line=self.aedtapp.AxisDir.XPos,
create_port_sheet=True,
impedance=25,
num_modes=2,
name="Wave3",
renormalize=True,
)
self.aedtapp.solution_type = "Modal"
assert self.aedtapp.wave_port(
signal="BoxWG1",
reference="BoxWG2",
integration_line=self.aedtapp.AxisDir.XPos,
create_port_sheet=True,
impedance=25,
num_modes=2,
name="Wave4",
renormalize=True,
deembed=5,
)
def test_09a_create_waveport_on_true_surface_objects(self):
cs = self.aedtapp.PLANE.XY
o1 = self.aedtapp.modeler.create_cylinder(
cs, [0, 0, 0], radius=5, height=100, numSides=0, name="inner", matname="Copper"
)
o3 = self.aedtapp.modeler.create_cylinder(
cs, [0, 0, 0], radius=10, height=100, numSides=0, name="outer", matname="Copper"
)
port1 = self.aedtapp.wave_port(
signal=o1.name,
reference=o3.name,
integration_line=self.aedtapp.AxisDir.XNeg,
create_port_sheet=True,
create_pec_cap=True,
name="P1",
)
assert port1.name.startswith("P1")
def test_10_create_lumped_on_objects(self):
box1 = self.aedtapp.modeler.create_box([0, 0, 50], [10, 10, 5], "BoxLumped1")
box1.material_name = "Copper"
box2 = self.aedtapp.modeler.create_box([0, 0, 60], [10, 10, 5], "BoxLumped2")
box2.material_name = "Copper"
port = self.aedtapp.lumped_port(
signal="BoxLumped1",
reference="BoxLumped2",
integration_line=self.aedtapp.AxisDir.XNeg,
create_port_sheet=True,
impedance=50,
renormalize=True,
name="Lump1xx",
)
assert not self.aedtapp.lumped_port(
signal="BoxLumped1111",
reference="BoxLumped2",
integration_line=self.aedtapp.AxisDir.XNeg,
create_port_sheet=True,
impedance=50,
renormalize=True,
name="Lump1xx",
)
assert self.aedtapp.lumped_port(
signal="BoxLumped1",
reference="BoxLumped2",
integration_line=self.aedtapp.AxisDir.XPos,
create_port_sheet=True,
impedance=50,
)
assert port.name == "Lump1xx"
port.name = "Lump1"
assert port.update()
port = self.aedtapp.lumped_port(
signal="BoxLumped1",
reference="BoxLumped2",
integration_line=self.aedtapp.AxisDir.XNeg,
create_port_sheet=True,
impedance=50,
renormalize=False,
deembed=True,
name="Lump2",
)
def test_11_create_circuit_on_objects(self):
self.aedtapp.insert_design("test_11")
box1 = self.aedtapp.modeler.create_box([0, 0, 80], [10, 10, 5], "BoxCircuit1", "Copper")
box2 = self.aedtapp.modeler.create_box([0, 0, 100], [10, 10, 5], "BoxCircuit2", "copper")
box2.material_name = "Copper"
port = self.aedtapp.circuit_port(
"BoxCircuit1", "BoxCircuit2", self.aedtapp.AxisDir.XNeg, 50, "Circ1", True, 50, False
)
assert port.name == "Circ1"
assert not self.aedtapp.circuit_port(
"BoxCircuit44", "BoxCircuit2", self.aedtapp.AxisDir.XNeg, 50, "Circ1", True, 50, False
)
self.aedtapp.delete_design("test_11", self.fall_back_name)
def test_12_create_perfects_on_objects(self):
self.aedtapp.insert_design("test_12")
box1 = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], "perfect1", "Copper")
box2 = self.aedtapp.modeler.create_box([0, 0, 10], [10, 10, 5], "perfect2", "copper")
pe = self.aedtapp.create_perfecth_from_objects(
"perfect1",
"perfect2",
self.aedtapp.AxisDir.ZPos,
)
ph = self.aedtapp.create_perfecte_from_objects("perfect1", "perfect2", self.aedtapp.AxisDir.ZNeg)
assert pe.name in self.aedtapp.modeler.get_boundaries_name()
assert pe.update()
assert ph.name in self.aedtapp.modeler.get_boundaries_name()
assert ph.update()
self.aedtapp.delete_design("test_12", self.fall_back_name)
def test_13_create_impedance_on_objects(self):
box1 = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], "imp1", "Copper")
box2 = self.aedtapp.modeler.create_box([0, 0, 10], [10, 10, 5], "imp2", "copper")
imp = self.aedtapp.create_impedance_between_objects(
box1.name, box2.name, self.aedtapp.AxisDir.XPos, "TL1", 50, 25
)
assert imp.name in self.aedtapp.modeler.get_boundaries_name()
assert imp.update()
pytest.mark.skipif(config["desktopVersion"] > "2023.2", reason="Crashing Desktop")
def test_14_create_lumpedrlc_on_objects(self):
box1 = self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 5], "rlc1", "Copper")
box2 = self.aedtapp.modeler.create_box([0, 0, 10], [10, 10, 5], "rlc2", "copper")
imp = self.aedtapp.create_lumped_rlc_between_objects(
box1.name, box2.name, self.aedtapp.AxisDir.XPos, Rvalue=50, Lvalue=1e-9
)
assert imp.name in self.aedtapp.modeler.get_boundaries_name()
assert imp.update()
box3 = self.aedtapp.modeler.create_box([0, 0, 20], [10, 10, 5], "rlc3", "copper")
lumped_rlc2 = self.aedtapp.create_lumped_rlc_between_objects(
box2.name, box3.name, self.aedtapp.AxisDir.XPos, Rvalue=50, Lvalue=1e-9, Cvalue=1e-9
)
assert lumped_rlc2.name in self.aedtapp.modeler.get_boundaries_name()
assert lumped_rlc2.update()
def test_15_create_perfects_on_sheets(self):
rect = self.aedtapp.modeler.create_rectangle(
self.aedtapp.PLANE.XY, [0, 0, 0], [10, 2], name="RectBound", matname="Copper"
)
pe = self.aedtapp.assign_perfecte_to_sheets(rect.name)
assert pe.name in self.aedtapp.modeler.get_boundaries_name()
ph = self.aedtapp.assign_perfecth_to_sheets(rect.name)
assert ph.name in self.aedtapp.modeler.get_boundaries_name()
solution_type = self.aedtapp.solution_type
self.aedtapp.solution_type = "Eigen Mode"
perfect_h_eigen = self.aedtapp.assign_perfecth_to_sheets(rect.name)
assert perfect_h_eigen.name in self.aedtapp.modeler.get_boundaries_name()
perfect_e_eigen = self.aedtapp.assign_perfecte_to_sheets(rect.name)
assert perfect_e_eigen.name in self.aedtapp.modeler.get_boundaries_name()
self.aedtapp.solution_type = "solution_type"
def test_16_create_impedance_on_sheets(self):
rect = self.aedtapp.modeler.create_rectangle(
self.aedtapp.PLANE.XY, [0, 0, 0], [10, 2], name="ImpBound", matname="Copper"
)
imp1 = self.aedtapp.assign_impedance_to_sheet(rect.name, "TL2", 50, 25)
assert imp1.name in self.aedtapp.modeler.get_boundaries_name()
assert imp1.update()
impedance_box = self.aedtapp.modeler.create_box([0, -100, 0], [200, 200, 200], "ImpedanceBox")
ids = self.aedtapp.modeler.get_object_faces(impedance_box.name)[:3]
imp2 = self.aedtapp.assign_impedance_to_sheet(ids, sourcename="ImpedanceToFaces", resistance=60, reactance=-20)
assert imp2.name in self.aedtapp.modeler.get_boundaries_name()
rect2 = self.aedtapp.modeler.create_rectangle(
self.aedtapp.PLANE.XY, [0, 0, 0], [10, 2], name="AniImpBound", matname="Copper"
)
assert not self.aedtapp.assign_impedance_to_sheet(rect2.name, "TL3", [50, 20, 0, 0], [25, 0, 5])
imp2 = self.aedtapp.assign_impedance_to_sheet(rect2.name, "TL3", [50, 20, 0, 0], [25, 0, 5, 0])
assert imp2.name in self.aedtapp.modeler.get_boundaries_name()
imp3 = self.aedtapp.assign_impedance_to_sheet(impedance_box.top_face_z.id, "TL4", [50, 20, 0, 0], [25, 0, 5, 0])
assert imp3.name in self.aedtapp.modeler.get_boundaries_name()
def test_17_create_lumpedrlc_on_sheets(self):
rect = self.aedtapp.modeler.create_rectangle(
self.aedtapp.PLANE.XY, [0, 0, 0], [10, 2], name="rlcBound", matname="Copper"
)
imp = self.aedtapp.assign_lumped_rlc_to_sheet(rect.name, self.aedtapp.AxisDir.XPos, Rvalue=50, Lvalue=1e-9)
names = self.aedtapp.modeler.get_boundaries_name()
assert imp.name in self.aedtapp.modeler.get_boundaries_name()
rect2 = self.aedtapp.modeler.create_rectangle(
self.aedtapp.PLANE.XY, [0, 0, 10], [10, 2], name="rlcBound2", matname="Copper"
)
imp = self.aedtapp.assign_lumped_rlc_to_sheet(
rect.name, self.aedtapp.AxisDir.XPos, rlctype="Serial", Rvalue=50, Lvalue=1e-9
)
names = self.aedtapp.modeler.get_boundaries_name()
assert imp.name in self.aedtapp.modeler.get_boundaries_name()
assert self.aedtapp.assign_lumped_rlc_to_sheet(
rect.name, [rect.bottom_edge_x.midpoint, rect.bottom_edge_y.midpoint], Lvalue=1e-9
)
assert not self.aedtapp.assign_lumped_rlc_to_sheet(rect.name, [rect.bottom_edge_x.midpoint], Lvalue=1e-9)
def test_17B_update_assignment(self):
bound = self.aedtapp.assign_perfecth_to_sheets(self.aedtapp.modeler["My_Box"].faces[0].id)
assert bound
bound.props["Faces"].append(self.aedtapp.modeler["My_Box"].faces[1])
assert bound.update_assignment()
def test_18_create_sources_on_objects(self):
box1 = self.aedtapp.modeler.create_box([30, 0, 0], [40, 10, 5], "BoxVolt1", "Copper")
box2 = self.aedtapp.modeler.create_box([30, 0, 10], [40, 10, 5], "BoxVolt2", "Copper")
port = self.aedtapp.create_voltage_source_from_objects(
box1.name, "BoxVolt2", self.aedtapp.AxisDir.XNeg, "Volt1"
)
assert port.name in self.aedtapp.excitations
port = self.aedtapp.create_current_source_from_objects("BoxVolt1", "BoxVolt2", self.aedtapp.AxisDir.XPos)
assert port.name in self.aedtapp.excitations
def test_19_create_lumped_on_sheet(self):
rect = self.aedtapp.modeler.create_rectangle(
self.aedtapp.PLANE.XY, [0, 0, 0], [10, 2], name="lump_port", matname="Copper"
)
port = self.aedtapp.lumped_port(
signal=rect.name,
integration_line=self.aedtapp.AxisDir.XNeg,
create_port_sheet=False,
impedance=50,
renormalize=True,
name="Lump_sheet",
)
assert port.name + ":1" in self.aedtapp.excitations
port2 = self.aedtapp.lumped_port(
signal=rect.name,
integration_line=self.aedtapp.AxisDir.XNeg,
create_port_sheet=False,
impedance=50,
renormalize=True,
name="Lump_sheet2",
deembed=True,
)
assert port2.name + ":1" in self.aedtapp.excitations
port3 = self.aedtapp.lumped_port(
signal=rect.name,
integration_line=[rect.bottom_edge_x.midpoint, rect.bottom_edge_y.midpoint],
create_port_sheet=False,
impedance=50,
renormalize=True,
name="Lump_sheet3",
deembed=True,
)
assert port3.name + ":1" in self.aedtapp.excitations
assert not self.aedtapp.lumped_port(
signal=rect.name,
integration_line=[rect.bottom_edge_x.midpoint],
create_port_sheet=False,
impedance=50,
renormalize=True,
name="Lump_sheet4",
deembed=True,
)
def test_20_create_voltage_on_sheet(self):
rect = self.aedtapp.modeler.create_rectangle(
self.aedtapp.PLANE.XY, [0, 0, 0], [10, 2], name="lump_volt", matname="Copper"
)
port = self.aedtapp.assign_voltage_source_to_sheet(rect.name, self.aedtapp.AxisDir.XNeg, "LumpVolt1")
assert port.name in self.aedtapp.excitations
assert self.aedtapp.get_property_value("BoundarySetup:LumpVolt1", "VoltageMag", "Excitation") == "1V"
port = self.aedtapp.assign_voltage_source_to_sheet(
rect.name, [rect.bottom_edge_x.midpoint, rect.bottom_edge_y.midpoint], "LumpVolt2"
)
assert port.name in self.aedtapp.excitations
port = self.aedtapp.assign_voltage_source_to_sheet(rect.name, [rect.bottom_edge_x.midpoint], "LumpVolt2")
assert not port
def test_21_create_open_region(self):
assert self.aedtapp.create_open_region("1GHz")
assert len(self.aedtapp.field_setups) == 3
assert self.aedtapp.create_open_region("1GHz", "FEBI")
assert self.aedtapp.create_open_region("1GHz", "PML", True, "-z")
def test_22_create_length_mesh(self):
box1 = self.aedtapp.modeler.create_box([30, 0, 0], [40, 10, 5], "BoxCircuit1", "Copper")
mesh = self.aedtapp.mesh.assign_length_mesh(["BoxCircuit1"])
assert mesh
mesh.props["NumMaxElem"] = "100"
assert mesh.props["NumMaxElem"] == self.aedtapp.odesign.GetChildObject("Mesh").GetChildObject(
mesh.name
).GetPropValue("Max Elems")
def test_23_create_skin_depth(self):
box1 = self.aedtapp.modeler.create_box([30, 0, 0], [40, 10, 5], "BoxCircuit2", "Copper")
mesh = self.aedtapp.mesh.assign_skin_depth(["BoxCircuit2"], "1mm")
assert mesh
mesh.props["SkinDepth"] = "3mm"
assert mesh.props["SkinDepth"] == self.aedtapp.odesign.GetChildObject("Mesh").GetChildObject(
mesh.name
).GetPropValue("Skin Depth")
def test_24_create_curvilinear(self):
box1 = self.aedtapp.modeler.create_box([30, 0, 0], [40, 10, 5], "BoxCircuit3", "Copper")
mesh = self.aedtapp.mesh.assign_curvilinear_elements(["BoxCircuit3"])
assert mesh
mesh.props["Apply"] = False
assert mesh.props["Apply"] == self.aedtapp.odesign.GetChildObject("Mesh").GetChildObject(
mesh.name
).GetPropValue("Apply Curvilinear Elements")
mesh.delete()
assert len(self.aedtapp.mesh.meshoperations) == 2
def test_30_assign_initial_mesh(self):
assert self.aedtapp.mesh.assign_initial_mesh_from_slider(6)
def test_30a_add_mesh_link(self):
self.aedtapp.duplicate_design(self.aedtapp.design_name)
self.aedtapp.set_active_design(self.aedtapp.design_list[0])
assert self.aedtapp.setups[0].add_mesh_link(design_name=self.aedtapp.design_list[1])
meshlink_props = self.aedtapp.setups[0].props["MeshLink"]
assert meshlink_props["Project"] == "This Project*"
assert meshlink_props["PathRelativeTo"] == "TargetProject"
assert meshlink_props["Design"] == self.aedtapp.design_list[1]
assert meshlink_props["Soln"] == "MySetup : LastAdaptive"
assert sorted(list(meshlink_props["Params"].keys())) == sorted(self.aedtapp.available_variations.variables)
assert sorted(list(meshlink_props["Params"].values())) == sorted(self.aedtapp.available_variations.variables)
assert not self.aedtapp.setups[0].add_mesh_link(design_name="")
assert self.aedtapp.setups[0].add_mesh_link(
design_name=self.aedtapp.design_list[1], solution_name="MySetup : LastAdaptive"
)
assert not self.aedtapp.setups[0].add_mesh_link(
design_name=self.aedtapp.design_list[1], solution_name="Setup_Test : LastAdaptive"
)
assert self.aedtapp.setups[0].add_mesh_link(
design_name=self.aedtapp.design_list[1],
parameters_dict=self.aedtapp.available_variations.nominal_w_values_dict,
)
example_project = os.path.join(
local_path, "../_unittest/example_models", test_subfolder, diff_proj_name + ".aedt"
)
example_project_copy = os.path.join(self.local_scratch.path, diff_proj_name + "_copy.aedt")
shutil.copyfile(example_project, example_project_copy)
assert self.aedtapp.setups[0].add_mesh_link(
design_name=self.aedtapp.design_list[1], project_name=example_project_copy
)
def test_31_create_microstrip_port(self):
self.aedtapp.insert_design("Microstrip")
self.aedtapp.solution_type = "Modal"
ms = self.aedtapp.modeler.create_box([4, 5, 0], [1, 100, 0.2], name="MS1", matname="copper")
sub = self.aedtapp.modeler.create_box([0, 5, -2], [20, 100, 2], name="SUB1", matname="FR4_epoxy")
gnd = self.aedtapp.modeler.create_box([0, 5, -2.2], [20, 100, 0.2], name="GND1", matname="FR4_epoxy")
port = self.aedtapp.wave_port(
signal=gnd.name,
reference=ms.name,
integration_line=1,
create_port_sheet=True,
is_microstrip=True,
name="MS1",
)
assert port.name == "MS1"
assert port.update()
self.aedtapp.solution_type = "Terminal"
assert self.aedtapp.wave_port(
signal=gnd.name,
reference=ms.name,
integration_line=1,
create_port_sheet=True,
is_microstrip=True,
name="MS2",
)
assert self.aedtapp.wave_port(
signal=gnd.name,
reference=ms.name,
integration_line=1,
create_port_sheet=True,
is_microstrip=True,
name="MS3",
deembed=1,
impedance=77,
)
def test_32_get_property_value(self):
rect = self.aedtapp.modeler.create_rectangle(
self.aedtapp.PLANE.XY, [0, 0, 0], [10, 2], name="RectProp", matname="Copper"
)
pe = self.aedtapp.assign_perfecte_to_sheets(rect.name, "PerfectE_1")
setup = self.aedtapp.create_setup("MySetup2")
setup.props["Frequency"] = "1GHz"
assert self.aedtapp.get_property_value("BoundarySetup:PerfectE_1", "Inf Ground Plane", "Boundary") == "false"
assert self.aedtapp.get_property_value("AnalysisSetup:MySetup2", "Solution Freq", "Setup") == "1GHz"
def test_33_copy_solid_bodies(self, add_app):
project_name = "HfssCopiedProject"
design_name = "HfssCopiedBodies"
new_design = add_app(project_name=project_name, design_name=design_name)
num_orig_bodies = len(self.aedtapp.modeler.solid_names)
assert new_design.copy_solid_bodies_from(self.aedtapp, no_vacuum=False, no_pec=False)
assert len(new_design.modeler.solid_bodies) == num_orig_bodies
new_design.delete_design(design_name)
new_design.close_project(project_name)
def test_34_object_material_properties(self):
self.aedtapp.insert_design("ObjMat")
self.aedtapp.solution_type = "Modal"
ms = self.aedtapp.modeler.create_box([4, 5, 0], [1, 100, 0.2], name="MS1", matname="copper")
props = self.aedtapp.get_object_material_properties("MS1", "conductivity")
assert props
def test_35_set_export_touchstone(self):
assert self.aedtapp.set_export_touchstone(True)
assert self.aedtapp.set_export_touchstone(False)
def test_36_assign_radiation_to_objects(self):
self.aedtapp.modeler.create_box([-100, -100, -100], [200, 200, 200], name="Rad_box")
rad = self.aedtapp.assign_radiation_boundary_to_objects("Rad_box")
rad.name = "Radiation1"
assert rad.update()
def test_37_assign_radiation_to_objects(self):
self.aedtapp.modeler.create_box([-100, -100, -100], [200, 200, 200], name="Rad_box2")
ids = [i.id for i in self.aedtapp.modeler["Rad_box2"].faces]
assert self.aedtapp.assign_radiation_boundary_to_faces(ids)
def test_38_get_all_sources(self):
sources = self.aedtapp.get_all_sources()
assert isinstance(sources, list)
def test_40_assign_current_source_to_sheet(self):
sheet = self.aedtapp.modeler.create_rectangle(
self.aedtapp.PLANE.XY, [0, 0, 0], [5, 1], name="RectangleForSource", matname="Copper"
)
assert self.aedtapp.assign_current_source_to_sheet(sheet.name)
assert self.aedtapp.assign_current_source_to_sheet(
sheet.name, [sheet.bottom_edge_x.midpoint, sheet.bottom_edge_y.midpoint]
)
assert not self.aedtapp.assign_current_source_to_sheet(sheet.name, [sheet.bottom_edge_x.midpoint])
def test_41_export_step(self):
file_name = "test"
self.aedtapp.modeler.create_box([0, 0, 0], [10, 10, 10])
assert self.aedtapp.export_3d_model(file_name, self.aedtapp.working_directory, ".x_t", [], [])
assert os.path.exists(os.path.join(self.aedtapp.working_directory, file_name + ".x_t"))
def test_42_floquet_port(self):
self.aedtapp.insert_design("floquet")
self.aedtapp.solution_type = "Modal"