-
Notifications
You must be signed in to change notification settings - Fork 164
Edit Sources in Q3D and Q2D #1298
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c055b5e
Edit Sources in Q3D
Samuelopez-ansys 2d718b9
- Allow unit value A_per_m and A_per_meter
Samuelopez-ansys 8eebfb2
UT Fixed
Samuelopez-ansys b9e75a2
Improving UT Coverage
Samuelopez-ansys af1065c
Update pyaedt/q3d.py
Samuelopez-ansys 0209fdf
Update pyaedt/q3d.py
Samuelopez-ansys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,6 +12,7 @@ | |||||||||
from pyaedt.generic.general_methods import pyaedt_function_handler | ||||||||||
from pyaedt.modules.Boundary import BoundaryObject | ||||||||||
from pyaedt.modules.Boundary import Matrix | ||||||||||
from pyaedt.application.Variables import decompose_variable_value | ||||||||||
|
||||||||||
|
||||||||||
class QExtractor(FieldAnalysis3D, object): | ||||||||||
|
@@ -189,6 +190,158 @@ def export_mesh_stats(self, setup_name, variation_string="", mesh_path=None, set | |||||||||
self.odesign.ExportMeshStats(setup_name, variation_string, setup_type, mesh_path) | ||||||||||
return mesh_path | ||||||||||
|
||||||||||
@pyaedt_function_handler() | ||||||||||
def edit_sources( | ||||||||||
self, | ||||||||||
cg=None, | ||||||||||
acrl=None, | ||||||||||
dcrl=None, | ||||||||||
): | ||||||||||
"""Set up the source loaded for Q3D or Q2D in multiple sources simultaneously. | ||||||||||
|
||||||||||
Parameters | ||||||||||
---------- | ||||||||||
cg : dict, optional | ||||||||||
Dictionary of input sources to modify module and phase of CG solution. | ||||||||||
Dictionary values can be: | ||||||||||
- 1 Value to setup 0deg as default or | ||||||||||
- 2 values tuple or list (magnitude and phase). | ||||||||||
acrl : dict, optional | ||||||||||
Dictionary of input sources to modify module and phase of ACRL solution. | ||||||||||
Dictionary values can be: | ||||||||||
- 1 Value to setup 0deg as default or | ||||||||||
- 2 values tuple or list (magnitude and phase). | ||||||||||
Comment on lines
+212
to
+213
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
dcrl : dict, optional | ||||||||||
Dictionary of input sources to modify module and phase of DCRL solution, only available for Q3D. | ||||||||||
Dictionary values can be: | ||||||||||
- 1 Value to setup 0deg as default or | ||||||||||
- 2 values tuple or list (magnitude and phase). | ||||||||||
Samuelopez-ansys marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
Returns | ||||||||||
------- | ||||||||||
bool | ||||||||||
|
||||||||||
Examples | ||||||||||
-------- | ||||||||||
>>> sources_cg = {"Box1": ("1V", "0deg"), "Box1_2": "1V"} | ||||||||||
>>> sources_acrl = {"Box1:Source1": ("5A", "0deg")} | ||||||||||
>>> sources_dcrl = {"Box1_1:Source2": ("5V", "0deg")} | ||||||||||
>>> hfss.edit_sources(sources_cg, sources_acrl, sources_dcrl) | ||||||||||
""" | ||||||||||
setting_AC = [] | ||||||||||
setting_CG = [] | ||||||||||
setting_DC = [] | ||||||||||
if cg: | ||||||||||
net_list = ["NAME:Source Names"] | ||||||||||
if self.default_solution_type == "Q3D Extractor": | ||||||||||
excitation = self.nets | ||||||||||
else: | ||||||||||
excitation = self.excitations | ||||||||||
|
||||||||||
for key, value in cg.items(): | ||||||||||
if key not in excitation: | ||||||||||
self.logger.error("Not existing net " + key) | ||||||||||
return False | ||||||||||
else: | ||||||||||
net_list.append(key) | ||||||||||
|
||||||||||
if self.default_solution_type == "Q3D Extractor": | ||||||||||
value_list = ["NAME:Source Values"] | ||||||||||
phase_list = ["NAME:Source Values"] | ||||||||||
else: | ||||||||||
value_list = ["NAME:Magnitude"] | ||||||||||
phase_list = ["NAME:Phase"] | ||||||||||
|
||||||||||
for key, vals in cg.items(): | ||||||||||
if isinstance(vals, str): | ||||||||||
value = vals | ||||||||||
phase = "0deg" | ||||||||||
else: | ||||||||||
value = vals[0] | ||||||||||
if len(vals) == 1: | ||||||||||
phase = "0deg" | ||||||||||
else: | ||||||||||
phase = vals[1] | ||||||||||
value_list.append(value) | ||||||||||
phase_list.append(phase) | ||||||||||
if self.default_solution_type == "Q3D Extractor": | ||||||||||
setting_CG = ["NAME:Cap", "Value Type:=", "N", net_list, value_list, phase_list] | ||||||||||
else: | ||||||||||
setting_CG = ["NAME:CGSources", net_list, value_list, phase_list] | ||||||||||
if acrl: | ||||||||||
source_list = ["NAME:Source Names"] | ||||||||||
unit = "V" | ||||||||||
for key, value in acrl.items(): | ||||||||||
excitation = self.excitations | ||||||||||
if key not in excitation: | ||||||||||
self.logger.error("Not existing excitation " + key) | ||||||||||
return False | ||||||||||
else: | ||||||||||
source_list.append(key) | ||||||||||
if self.default_solution_type == "Q3D Extractor": | ||||||||||
value_list = ["NAME:Source Values"] | ||||||||||
phase_list = ["NAME:Source Values"] | ||||||||||
else: | ||||||||||
value_list = ["NAME:Magnitude"] | ||||||||||
phase_list = ["NAME:Phase"] | ||||||||||
for key, vals in acrl.items(): | ||||||||||
if isinstance(vals, str): | ||||||||||
magnitude = decompose_variable_value(vals) | ||||||||||
value = vals | ||||||||||
phase = "0deg" | ||||||||||
else: | ||||||||||
value = vals[0] | ||||||||||
magnitude = decompose_variable_value(value) | ||||||||||
if len(vals) == 1: | ||||||||||
phase = "0deg" | ||||||||||
else: | ||||||||||
phase = vals[1] | ||||||||||
if magnitude[1]: | ||||||||||
unit = magnitude[1] | ||||||||||
else: | ||||||||||
value += unit | ||||||||||
|
||||||||||
value_list.append(value) | ||||||||||
phase_list.append(phase) | ||||||||||
|
||||||||||
if self.default_solution_type == "Q3D Extractor": | ||||||||||
setting_AC = ["NAME:AC", "Value Type:=", unit, source_list, value_list] | ||||||||||
else: | ||||||||||
setting_AC = ["NAME:RLSources", source_list, value_list, phase_list] | ||||||||||
if dcrl and self.default_solution_type == "Q3D Extractor": | ||||||||||
unit = "V" | ||||||||||
source_list = ["NAME:Source Names"] | ||||||||||
for key, value in dcrl.items(): | ||||||||||
excitation = self.excitations | ||||||||||
if key not in excitation: | ||||||||||
self.logger.error("Not existing excitation " + key) | ||||||||||
return False | ||||||||||
else: | ||||||||||
source_list.append(key) | ||||||||||
if self.default_solution_type == "Q3D Extractor": | ||||||||||
value_list = ["NAME:Source Values"] | ||||||||||
else: | ||||||||||
value_list = ["NAME:Magnitude"] | ||||||||||
for key, vals in dcrl.items(): | ||||||||||
magnitude = decompose_variable_value(vals) | ||||||||||
if magnitude[1]: | ||||||||||
unit = magnitude[1] | ||||||||||
else: | ||||||||||
vals += unit | ||||||||||
if isinstance(vals, str): | ||||||||||
value = vals | ||||||||||
else: | ||||||||||
value = vals[0] | ||||||||||
value_list.append(value) | ||||||||||
setting_DC = ["NAME:DC", "Value Type:=", unit, source_list, value_list] | ||||||||||
|
||||||||||
if self.default_solution_type == "Q3D Extractor": | ||||||||||
self.osolution.EditSources(setting_AC, setting_CG, setting_DC) | ||||||||||
else: | ||||||||||
self.osolution.EditSources(setting_CG, setting_AC) | ||||||||||
|
||||||||||
return True | ||||||||||
|
||||||||||
|
||||||||||
class Q3d(QExtractor, object): | ||||||||||
"""Provides the Q3D application interface. | ||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.