Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve method get_solution_data to avoid intrinsics as arguments and… #3898

Merged
merged 6 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions _unittest/test_12_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,9 @@ def test_09_manipulate_report_D(self, field_test):
def test_09_manipulate_report_E(self, field_test):
field_test.modeler.create_polyline([[0, 0, 0], [0, 5, 30]], name="Poly1", non_model=True)
variations2 = field_test.available_variations.nominal_w_values_dict
variations2["Theta"] = ["All"]
variations2["Phi"] = ["All"]
variations2["Freq"] = ["30GHz"]
variations2["Distance"] = ["All"]
assert field_test.post.create_report(

assert field_test.setups[0].create_report(
"Mag_E",
field_test.nominal_adaptive,
variations=variations2,
primary_sweep_variable="Distance",
context="Poly1",
report_category="Fields",
Expand All @@ -226,11 +221,10 @@ def test_09_manipulate_report_E(self, field_test):
new_report.polyline = "Poly1"
assert new_report.create()
new_report = field_test.post.reports_by_category.modal_solution("S(1,1)")
new_report.plot_type = "Smith Chart"
new_report.report_type = "Smith Chart"
assert new_report.create()
data = field_test.post.get_solution_data(
data = field_test.setups[0].get_solution_data(
"Mag_E",
field_test.nominal_adaptive,
variations=variations2,
primary_sweep_variable="Theta",
context="Poly1",
Expand Down Expand Up @@ -269,7 +263,7 @@ def test_17_circuit(self, circuit_test):
circuit_test.analyze_setup("LNA")
circuit_test.analyze_setup("Transient")
assert circuit_test.setups[0].is_solved
assert circuit_test.post.create_report(["dB(S(Port1, Port1))", "dB(S(Port1, Port2))"], "LNA")
assert circuit_test.setups[0].create_report(["dB(S(Port1, Port1))", "dB(S(Port1, Port2))"])
new_report = circuit_test.post.reports_by_category.standard(
["dB(S(Port1, Port1))", "dB(S(Port1, Port2))"], "LNA"
)
Expand Down Expand Up @@ -382,7 +376,7 @@ def test_55_time_plot(self, sbr_test):
assert sbr_test.setups[0].is_solved
solution_data = sbr_test.post.get_solution_data(
expressions=["NearEX", "NearEY", "NearEZ"],
variations={"_u": ["All"], "_v": ["All"], "Freq": ["All"]},
# variations={"_u": ["All"], "_v": ["All"], "Freq": ["All"]},
context="Near_Field",
report_category="Near Fields",
)
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/application/Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ def _create_setup(self, setupname="MySetupAuto", setuptype=None, props=None):
setup = SetupHFSSAuto(self, setuptype, name)
elif setuptype == 4:
setup = SetupSBR(self, setuptype, name)
elif setuptype in [5, 6, 7, 8, 9, 10]:
elif setuptype in [5, 6, 7, 8, 9, 10, 56]:
setup = SetupMaxwell(self, setuptype, name)
elif setuptype in [14]:
setup = SetupQ3D(self, setuptype, name)
Expand Down
39 changes: 35 additions & 4 deletions pyaedt/application/design_solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@
"name": None,
"options": None,
"report_type": None,
"default_setup": None,
"default_setup": 8,
"default_adaptive": "LastAdaptive",
"intrinsics": ["Freq", "Phase"],
},
"DCConduction": {
"name": None,
"options": None,
"report_type": None,
"default_setup": None,
"default_setup": 8,
"default_adaptive": "LastAdaptive",
},
"ElectroDCConduction": {
Expand All @@ -138,13 +138,21 @@
},
},
"Twin Builder": {
"TR": {"name": None, "options": None, "report_type": "Standard", "default_setup": 35, "default_adaptive": None},
"TR": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 35,
"default_adaptive": None,
"intrinsics": ["Time"],
},
"AC": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": None,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
"DC": {
"name": None,
Expand All @@ -161,6 +169,7 @@
"report_type": "Standard",
"default_setup": 15,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
"NexximDC": {
"name": None,
Expand All @@ -175,85 +184,104 @@
"report_type": "Standard",
"default_setup": 17,
"default_adaptive": None,
"intrinsics": ["Time"],
},
"NexximVerifEye": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 19,
"default_adaptive": None,
"intrinsics": ["Time"],
},
"NexximQuickEye": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 18,
"default_adaptive": None,
"intrinsics": ["Time"],
},
"NexximAMI": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 20,
"default_adaptive": None,
"intrinsics": ["Time"],
},
"NexximOscillatorRSF": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 21,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
"NexximOscillator1T": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 22,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
"NexximOscillatorNT": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 23,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
"NexximHarmonicBalance1T": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 24,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
"NexximHarmonicBalanceNT": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 25,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
"NexximSystem": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 26,
"default_adaptive": None,
"intrinsics": ["Time"],
},
"NexximTVNoise": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 27,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
"HSPICE": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 28,
"default_adaptive": None,
"intrinsics": ["Time"],
},
"TR": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 17,
"default_adaptive": None,
"intrinsics": ["Time"],
},
"TR": {"name": None, "options": None, "report_type": "Standard", "default_setup": 17, "default_adaptive": None},
},
"2D Extractor": {
"Open": {
Expand Down Expand Up @@ -353,6 +381,7 @@
"report_type": "Modal Solution Data",
"default_setup": 4,
"default_adaptive": "Sweep",
"intrinsics": ["Freq", "Phase"],
},
},
"Icepak": {
Expand Down Expand Up @@ -439,13 +468,15 @@
"report_type": "Standard",
"default_setup": 41,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
"LNA3DLayout": {
"name": None,
"options": None,
"report_type": "Standard",
"default_setup": 42,
"default_adaptive": None,
"intrinsics": ["Freq"],
},
},
"Mechanical": {
Expand Down
37 changes: 29 additions & 8 deletions pyaedt/modeler/modeler3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,16 @@
lines = f.read().splitlines()
id = 0
for line in lines:
line_split = [line[i : i + 8] for i in range(0, len(line), 8)]
if line.startswith("$") or line.startswith("*"):
continue
if "*" in line:
line = line.strip()[:-1] + lines[lines.index(line) + 1][8:]
line_split = [line[:8]] + [line[i : i + 16] for i in range(8, len(line), 16)]

Check warning on line 896 in pyaedt/modeler/modeler3d.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modeler/modeler3d.py#L895-L896

Added lines #L895 - L896 were not covered by tests
else:
line_split = [line[i : i + 8] for i in range(0, len(line), 8)]

line_split = [i for i in line_split if i.replace(" ", "").replace("\t", "")]

if len(line_split) < 5:
continue
if line_split[0].startswith("GRID"):
Expand All @@ -915,7 +924,16 @@
nas_to_dict["PointsId"][int(line_split[1])] = id
id += 1
except:
pass
try:
nas_to_dict["Points"][int(line_split[1])] = [

Check warning on line 928 in pyaedt/modeler/modeler3d.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modeler/modeler3d.py#L927-L928

Added lines #L927 - L928 were not covered by tests
float(line_split[2]),
float(line_split[3]),
float(line_split[4]),
]
nas_to_dict["PointsId"][int(line_split[1])] = id
id += 1
except:
pass

Check warning on line 936 in pyaedt/modeler/modeler3d.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modeler/modeler3d.py#L933-L936

Added lines #L933 - L936 were not covered by tests
elif line_split[0].startswith("CTRIA3"):
if int(line_split[2]) in nas_to_dict["Triangles"]:
nas_to_dict["Triangles"][int(line_split[2])].append(
Expand All @@ -926,13 +944,16 @@
]
)
else:
nas_to_dict["Triangles"][int(line_split[2])] = [
[
int(line_split[3]),
int(line_split[4]),
int(line_split[5]),
try:
nas_to_dict["Triangles"][int(line_split[2])] = [
[
int(line_split[3]),
int(line_split[4]),
int(line_split[5]),
]
]
]
except:
pass

Check warning on line 956 in pyaedt/modeler/modeler3d.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modeler/modeler3d.py#L955-L956

Added lines #L955 - L956 were not covered by tests
elif line_split[0].startswith("CPENTA"):
if int(line_split[2]) in nas_to_dict["Solids"]:
nas_to_dict["Solids"][int(line_split[2])].append(
Expand Down
36 changes: 28 additions & 8 deletions pyaedt/modules/PostProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,15 @@
... "InputCurrent(PHA)", domain="Time", primary_sweep_variable="Time", plotname="Winding Plot 1"
... )
"""
if not setup_sweep_name:
setup_sweep_name = self._app.nominal_sweep
if not domain:
domain = "Sweep"
setup_name = setup_sweep_name.split(":")[0]
if setup_name:
for setup in self._app.setups:
if setup.name == setup_name and "Time" in setup.default_intrinsics:
domain = "Time"

Check warning on line 1596 in pyaedt/modules/PostProcessor.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modules/PostProcessor.py#L1591-L1596

Added lines #L1591 - L1596 were not covered by tests
if domain in ["Spectral", "Spectrum"]:
report_category = "Spectrum"
elif not report_category and not self._app.design_solutions.report_type:
Expand All @@ -1598,15 +1607,16 @@
report_class = TEMPLATES_BY_NAME["Fields"]
else:
report_class = TEMPLATES_BY_NAME["Standard"]
if not setup_sweep_name:
setup_sweep_name = self._app.nominal_sweep

report = report_class(self, report_category, setup_sweep_name)
if not expressions:
expressions = [
i for i in self.available_report_quantities(report_category=report_category, context=context)
]
report.expressions = expressions
report.domain = domain
if not variations:
variations = self._app.available_variations.nominal_w_values_dict
if primary_sweep_variable:
report.primary_sweep = primary_sweep_variable
elif domain == "DCIR": # pragma: no cover
Expand All @@ -1617,8 +1627,8 @@
variations = {"Index": "All"}
if secondary_sweep_variable:
report.secondary_sweep = secondary_sweep_variable
if variations:
report.variations = variations

report.variations = variations
report.report_type = plot_type
report.sub_design_id = subdesign_id
report.point_number = polyline_points
Expand Down Expand Up @@ -1669,7 +1679,7 @@
self,
expressions=None,
setup_sweep_name=None,
domain="Sweep",
domain=None,
variations=None,
primary_sweep_variable=None,
report_category=None,
Expand All @@ -1696,7 +1706,7 @@
Plot Domain. Options are "Sweep" for frequency domain related results and "Time" for transient related data.
variations : dict, optional
Dictionary of all families including the primary sweep.
The default is ``None`` which will use the nominal variations of the design.
The default is ``None`` which will use the nominal variations of the setup.
primary_sweep_variable : str, optional
Name of the primary sweep. The default is ``"None"`` which, depending on the context,
will internally assign the primary sweep to:
Expand Down Expand Up @@ -1784,6 +1794,15 @@
...)
"""
expressions = [expressions] if isinstance(expressions, str) else expressions
if not setup_sweep_name:
setup_sweep_name = self._app.nominal_sweep
if not domain:
domain = "Sweep"
setup_name = setup_sweep_name.split(":")[0]
if setup_name:
for setup in self._app.setups:
if setup.name == setup_name and "Time" in setup.default_intrinsics:
domain = "Time"

Check warning on line 1805 in pyaedt/modules/PostProcessor.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modules/PostProcessor.py#L1805

Added line #L1805 was not covered by tests
if domain in ["Spectral", "Spectrum"]:
report_category = "Spectrum"
if not report_category and not self._app.design_solutions.report_type:
Expand All @@ -1797,8 +1816,7 @@
report_class = TEMPLATES_BY_NAME["Fields"]
else:
report_class = TEMPLATES_BY_NAME["Standard"]
if not setup_sweep_name:
setup_sweep_name = self._app.nominal_sweep

report = report_class(self, report_category, setup_sweep_name)
if not expressions:
expressions = [
Expand All @@ -1812,6 +1830,8 @@
report.primary_sweep = primary_sweep_variable
if variations:
report.variations = variations
else:
report.variations = self._app.available_variations.nominal_w_values_dict
report.sub_design_id = subdesign_id
report.point_number = polyline_points
if context == "Differential Pairs":
Expand Down
Loading
Loading