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

FEAT: Transient ambient temperature in design settings & Design settings class #4580

Merged
merged 28 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
eb7b0e6
Add IcepakDesignSettings class
lorenzovecchietti Apr 22, 2024
208189d
Add DesignSettingsClass
lorenzovecchietti Apr 23, 2024
3ced010
Revert "Add IcepakDesignSettings class"
lorenzovecchietti Apr 23, 2024
5a0141c
fix __repr__
lorenzovecchietti Apr 23, 2024
a424ea6
Merge branch 'main' into transient_ambient_temperature
lorenzovecchietti Apr 23, 2024
2881f4b
fix for manipulate_design
lorenzovecchietti Apr 23, 2024
6f5f31e
Update pyaedt/application/Design.py
lorenzovecchietti Apr 24, 2024
93825e1
Update pyaedt/application/Design.py
lorenzovecchietti Apr 24, 2024
f172122
Merge branch 'main' into transient_ambient_temperature
lorenzovecchietti Apr 24, 2024
215dafd
Fix docstring
lorenzovecchietti Apr 24, 2024
7c44cff
Tests fixes
lorenzovecchietti Apr 26, 2024
95e15fc
Fix ironpy ut
lorenzovecchietti Apr 26, 2024
13ba80f
Fix ironpy ut
lorenzovecchietti Apr 26, 2024
9c824a0
Merge branch 'main' into transient_ambient_temperature
lorenzovecchietti Apr 29, 2024
3c5f799
add transient support
lorenzovecchietti Apr 29, 2024
8b11707
add sherlock option
lorenzovecchietti Apr 29, 2024
f5efcc4
fix documentation
lorenzovecchietti Apr 29, 2024
4f78750
fix tests
lorenzovecchietti Apr 29, 2024
10d6606
Update pyaedt/application/Design.py
lorenzovecchietti Apr 29, 2024
a4dba12
improve architecture
lorenzovecchietti Apr 30, 2024
1813ab0
Apply suggestions from code review
lorenzovecchietti May 2, 2024
8b05d73
add abstract class
lorenzovecchietti May 2, 2024
101436f
add app attribute
lorenzovecchietti May 2, 2024
0a00666
add app attribute
lorenzovecchietti May 2, 2024
a4ee76f
ironpy compatibility
lorenzovecchietti May 2, 2024
969fdd1
fix
lorenzovecchietti May 2, 2024
24f7f55
Merge branch 'main' into transient_ambient_temperature
lorenzovecchietti May 2, 2024
58d607d
Merge branch 'main' into transient_ambient_temperature
lorenzovecchietti May 2, 2024
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
5 changes: 3 additions & 2 deletions _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pyaedt import Hfss3dLayout
from pyaedt import Icepak
from pyaedt import get_pyaedt_app
from pyaedt.application.Design import DesignSettings
from pyaedt.application.aedt_objects import AedtObjects
from pyaedt.application.design_solutions import model_names
from pyaedt.generic.general_methods import is_linux
Expand Down Expand Up @@ -418,9 +419,9 @@ def test_39_load_project(self, desktop):

def test_40_get_design_settings(self, add_app):
ipk = add_app(application=Icepak)
design_settings_dict = ipk.design_settings()
design_settings_dict = ipk.design_settings

assert isinstance(design_settings_dict, dict)
assert isinstance(design_settings_dict, DesignSettings)
assert "AmbTemp" in design_settings_dict
assert "AmbRadTemp" in design_settings_dict
assert "GravityVec" in design_settings_dict
Expand Down
30 changes: 28 additions & 2 deletions _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ def test_14_edit_design_settings(self):
assert self.aedtapp.edit_design_settings(gravity_dir=3)
assert self.aedtapp.edit_design_settings(ambtemp=20)
assert self.aedtapp.edit_design_settings(ambtemp="325kel")
self.aedtapp.solution_type = "Transient"
bc = self.aedtapp.create_linear_transient_assignment("0.01cel", "5")
assert self.aedtapp.edit_design_settings(ambtemp=bc)

def test_15_insert_new_icepak(self):
self.aedtapp.insert_design("Solve")
Expand Down Expand Up @@ -404,6 +407,7 @@ def test_33_create_source(self):
assert self.aedtapp.create_source_power(self.aedtapp.modeler["boxSource"].top_face_z.id, input_power="2W")
assert self.aedtapp.create_source_power(
self.aedtapp.modeler["boxSource"].bottom_face_z.id,
input_power="0W",
thermal_condtion="Fixed Temperature",
temperature="28cel",
)
Expand All @@ -426,6 +430,7 @@ def test_33_create_source(self):
voltage_current_choice="Current",
voltage_current_value="1A",
)
self.aedtapp.solution_type = "SteadyState"
assert not self.aedtapp.assign_source(
self.aedtapp.modeler["boxSource"].top_face_x.id,
"Total Power",
Expand Down Expand Up @@ -950,7 +955,6 @@ def test_54_assign_stationary_wall(self):
thickness="0mm",
material="Al-Extruded",
htc=10,
htc_dataset=None,
ref_temperature="AmbientTemp",
ht_correlation=True,
ht_correlation_type="Forced Convection",
Expand All @@ -966,7 +970,7 @@ def test_54_assign_stationary_wall(self):
name=None,
thickness="0mm",
material="Al-Extruded",
htc_dataset="ds1",
htc="ds1",
ref_temperature="AmbientTemp",
ht_correlation=False,
)
Expand Down Expand Up @@ -1583,3 +1587,25 @@ def test_74_boundary_conditions_dictionaries(self):
def test_75_native_component_load(self, add_app):
app = add_app(application=Icepak, project_name=native_import, subfolder=test_subfolder)
assert len(app.native_components) == 1

def test_76_design_settings(self):
d = self.aedtapp.design_settings
d["AmbTemp"] = 5
assert d["AmbTemp"] == "5cel"
d["AmbTemp"] = "5kel"
assert d["AmbTemp"] == "5kel"
d["AmbTemp"] = {"1": "2"}
assert d["AmbTemp"] == "5kel"
d["AmbGaugePressure"] = 5
assert d["AmbGaugePressure"] == "5n_per_meter_sq"
d["GravityVec"] = 1
assert d["GravityVec"] == "Global::Y"
assert d["GravityDir"] == "Positive"
d["GravityVec"] = 4
assert d["GravityVec"] == "Global::Y"
assert d["GravityDir"] == "Negative"
d["GravityVec"] = "+X"
assert d["GravityVec"] == "Global::X"
assert d["GravityDir"] == "Positive"
d["GravityVec"] = "Global::Y"
assert d["GravityVec"] == "Global::Y"
79 changes: 56 additions & 23 deletions pyaedt/application/Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from pyaedt.generic.LoadAEDTFile import load_entire_aedt_file
from pyaedt.generic.constants import AEDT_UNITS
from pyaedt.generic.constants import unit_system
from pyaedt.generic.general_methods import GrpcApiError
from pyaedt.generic.general_methods import check_and_download_file
from pyaedt.generic.general_methods import generate_unique_name
from pyaedt.generic.general_methods import is_ironpython
Expand Down Expand Up @@ -4019,33 +4020,65 @@ def set_temporary_directory(self, temp_dir_path):
self.odesktop.SetTempDirectory(temp_dir_path)
return True

@pyaedt_function_handler()
@property
def design_settings(self):
"""Get design settings for the current AEDT app.
"""Design settings for the AEDT app."""
return DesignSettings(self)

Returns
-------
dict
Dictionary of valid design settings.

References
----------
class DesignSettings:
"""Get design settings for the current AEDT app.

>>> oDesign.GetChildObject("Design Settings")
"""
References
----------

>>> oDesign.GetChildObject("Design Settings")
"""

def __init__(self, app):
self._app = app
self.manipulate_inputs = None
try:
design_settings = self._odesign.GetChildObject("Design Settings")
except Exception: # pragma: no cover
self.logger.error("Failed to retrieve design settings.")
return False
self.design_settings = self._app.odesign.GetChildObject("Design Settings")
except GrpcApiError: # pragma: no cover
self._app.logger.error("Failed to retrieve design settings.")
self.design_settings = None

prop_name_list = design_settings.GetPropNames()
design_settings_dict = {}
for prop in prop_name_list:
try:
design_settings_dict[prop] = design_settings.GetPropValue(prop)
except Exception: # pragma: no cover
self.logger.warning('Could not retrieve "{}" property value in design settings.'.format(prop))
design_settings_dict[prop] = None
@property
def available_properties(self):
lorenzovecchietti marked this conversation as resolved.
Show resolved Hide resolved
"""Available properties names for the current design."""
return [prop for prop in self.design_settings.GetPropNames() if not prop.endswith("/Choices")]

def __repr__(self):
lines = ["{"]
for prop in self.available_properties:
lines.append("\t{}: {}".format(prop, self.design_settings.GetPropValue(prop)))
lines.append("}")
return "\n".join(lines)

def __setitem__(self, key, value):
if key in self.available_properties:
value = self.manipulate_inputs.execute(key, value)
lorenzovecchietti marked this conversation as resolved.
Show resolved Hide resolved
key_choices = "{}/Choices".format(key)
if key_choices in self.design_settings.GetPropNames():
value_choices = self.design_settings.GetPropValue(key_choices)
if value not in value_choices:
self._app.logger.error(
"{} is not a valid choice. Possible choices are: {}".format(value, ", ".join(value_choices))
)
return False
self.design_settings.SetPropValue(key, value)
else:
self._app.logger.error("{} property is not available in design settings.".format(key))

return design_settings_dict
def __getitem__(self, key):
if key in self.available_properties:
return self.design_settings.GetPropValue(key)
else:
self._app.logger.error("{} property is not available in design settings.".format(key))
return None

def __contains__(self, item):
if item in self.available_properties:
return True
return False
lorenzovecchietti marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading