Skip to content

Commit

Permalink
Merge branch 'main' into release/0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys committed Mar 8, 2024
2 parents 651d8dc + 10b617f commit ca9eff6
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 11 deletions.
9 changes: 9 additions & 0 deletions _unittest/test_98_Icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pyaedt.generic.settings import settings
from pyaedt.modules.Boundary import NativeComponentObject
from pyaedt.modules.Boundary import NetworkObject
from pyaedt.modules.SetupTemplates import SetupKeys

test_subfolder = "T98"

Expand Down Expand Up @@ -163,6 +164,14 @@ def test_08_Setup(self):
assert self.aedtapp.get_property_value("AnalysisSetup:DomSetup", "Iterations", "Setup")
assert my_setup.update()
assert self.aedtapp.assign_2way_coupling(setup_name, 2, True, 20)
templates = SetupKeys().get_default_icepak_template(default_type="Natural Convection")
assert templates
self.aedtapp.setups[0].props = templates["IcepakSteadyState"]
assert self.aedtapp.setups[0].update()
assert SetupKeys().get_default_icepak_template(default_type="Default")
assert SetupKeys().get_default_icepak_template(default_type="Forced Convection")
with pytest.raises(AttributeError):
SetupKeys().get_default_icepak_template(default_type="Default Convection")

def test_09_existing_sweeps(self):
assert self.aedtapp.existing_analysis_sweeps
Expand Down
8 changes: 4 additions & 4 deletions examples/07-TwinBuilder/02-Wiring_A_Rectifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@

# Create the four diodes of the bridge rectifier.

diode1 = tb.modeler.schematic.create_diode(compname="D1", location=[10 * G, 6 * G], angle=3 * math.pi / 2)
diode2 = tb.modeler.schematic.create_diode(compname="D2", location=[20 * G, 6 * G], angle=3 * math.pi / 2)
diode3 = tb.modeler.schematic.create_diode(compname="D3", location=[10 * G, -4 * G], angle=3 * math.pi / 2)
diode4 = tb.modeler.schematic.create_diode(compname="D4", location=[20 * G, -4 * G], angle=3 * math.pi / 2)
diode1 = tb.modeler.schematic.create_diode(compname="D1", location=[10 * G, 6 * G], angle=270)
diode2 = tb.modeler.schematic.create_diode(compname="D2", location=[20 * G, 6 * G], angle=270)
diode3 = tb.modeler.schematic.create_diode(compname="D3", location=[10 * G, -4 * G], angle=270)
diode4 = tb.modeler.schematic.create_diode(compname="D4", location=[20 * G, -4 * G], angle=270)

# Create a capacitor filter.

Expand Down
7 changes: 7 additions & 0 deletions pyaedt/misc/install_extra_toolkits.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"installation_path": "Project",
"package_name": "ansys.aedt.toolkits.choke",
},
"MagnetSegmentationWizard": {
"pip": "git+https://github.com/ansys/magnet-segmentation-toolkit.git",
"image": "pyansys.png",
"toolkit_script": "ansys/aedt/toolkits/magnet_segmentation/run_toolkit.py",
"installation_path": "Maxwell3d",
"package_name": "magnet-segmentation-toolkit",
},
}


Expand Down
121 changes: 120 additions & 1 deletion pyaedt/modules/SetupTemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,8 +1666,81 @@ def HFSS3DLayout_AdaptiveFrequencyData(freq):
}
)

icepak_newkeys_241 = {
"GPU Convergence Criteria - Flow": "0.001",
"GPU Convergence Criteria - Energy": "1e-05",
"GPU Convergence Criteria - Turbulent Kinetic Energy": "0.001",
"GPU Convergence Criteria - Turbulent Dissipation Rate": "0.001",
"GPU Convergence Criteria - Specific Dissipation Rate": "0.001",
"GPU Convergence Criteria - Discrete Ordinates": "1e-05",
"GPU Convergence Criteria - Joule Heating": "1e-07",
"Solution Initialization - Use Model Based Flow Initialization": False,
"Include Solar": False,
"Solar Radiation Model": "Solar Radiation Calculator",
"Solar Enable Participating Solids": False,
"Solar Radiation - Scattering Fraction": "0",
"Solar Radiation - North X": "0",
"Solar Radiation - North Y": "0",
"Solar Radiation - North Z": "1",
"Solar Radiation - Day": 1,
"Solar Radiation - Month": 1,
"Solar Radiation - Hours": 0,
"Solar Radiation - Minutes": 0,
"Solar Radiation - GMT": "0",
"Solar Radiation - Latitude": "0",
"Solar Radiation - Latitude Direction": "North",
"Solar Radiation - Longitude": "0",
"Solar Radiation - Longitude Direction": "East",
"Solar Radiation - Ground Reflectance": "0",
"Solar Radiation - Sunshine Fraction": "0",
"Linear Solver Type - Joule Heating": "F",
"Linear Solver Termination Criterion - Joule Heating": "1e-09",
"Linear Solver Residual Reduction Tolerance - Joule Heating": "1e-09",
"Maximum Cycles": "30",
"Linear Solver Stabilization - Joule Heating": "None",
"Coupled pressure-velocity formulation": False,
"2D Profile Interpolation Method": "Inverse Distance Weighted",
"TEC Coupling": False,
}

SteadyTemperatureOnly_241 = copy.deepcopy(SteadyTemperatureOnly)
SteadyFlowOnly_241 = copy.deepcopy(SteadyFlowOnly)
SteadyTemperatureAndFlow_241 = copy.deepcopy(SteadyTemperatureAndFlow)
TransientTemperatureOnly_241 = copy.deepcopy(TransientTemperatureOnly)
TransientTemperatureAndFlow_241 = copy.deepcopy(TransientTemperatureAndFlow)
TransientFlowOnly_241 = copy.deepcopy(TransientFlowOnly)
SteadyTemperatureOnly_241.update(icepak_newkeys_241)
SteadyFlowOnly_241.update(icepak_newkeys_241)
SteadyTemperatureAndFlow_241.update(icepak_newkeys_241)
TransientTemperatureOnly_241.update(icepak_newkeys_241)
TransientTemperatureAndFlow_241.update(icepak_newkeys_241)
TransientFlowOnly_241.update(icepak_newkeys_241)

list_modules = dir()

icepak_forced_convection_update = {
"Convergence Criteria - Energy": "1e-12",
"Linear Solver Termination Criterion - Temperature": "1e-06",
"Linear Solver Residual Reduction Tolerance - Temperature": "1e-06",
"Sequential Solve of Flow and Energy Equations": True,
}

icepak_natural_convection_update = {
"Include Gravity": True,
"Solution Initialization - Z Velocity": "0.000980665m_per_sec",
"IsEnabled": True,
"Radiation Model": "Discrete Ordinates Model",
"Flow Iteration Per Radiation Iteration": "10",
"Time Step Interval": "1",
"ThetaDivision": "2",
"PhiDivision": "2",
"ThetaPixels": "2",
"Under-relaxation - Pressure": "0.7",
"Under-relaxation - Momentum": "0.3",
"Linear Solver Termination Criterion - Temperature": "1e-06",
"Linear Solver Residual Reduction Tolerance - Temperature": "1e-06",
}


class SetupKeys:
"""Provides setup keys."""
Expand Down Expand Up @@ -1803,6 +1876,15 @@ class SetupKeys:
}
SetupTemplates_232 = {}

SetupTemplates_241 = {
11: SteadyTemperatureAndFlow_241,
12: SteadyTemperatureOnly_241,
13: SteadyFlowOnly_241,
36: TransientTemperatureAndFlow_241,
37: TransientTemperatureOnly_241,
38: TransientFlowOnly_241,
}

@staticmethod
def _add_to_template(template_in, template_to_append):
template_out = template_in.copy()
Expand All @@ -1815,10 +1897,47 @@ def get_setup_templates():
from pyaedt.generic.general_methods import settings

template = SetupKeys.SetupTemplates
if settings.aedt_version is not None and settings.aedt_version >= "2023.1":
if settings.aedt_version is not None and settings.aedt_version >= "2024.1":
template = SetupKeys._add_to_template(SetupKeys.SetupTemplates, SetupKeys.SetupTemplates_231)
template = SetupKeys._add_to_template(template, SetupKeys.SetupTemplates_232)
template = SetupKeys._add_to_template(template, SetupKeys.SetupTemplates_241)
elif settings.aedt_version is not None and settings.aedt_version >= "2023.2":
template = SetupKeys._add_to_template(SetupKeys.SetupTemplates, SetupKeys.SetupTemplates_231)
template = SetupKeys._add_to_template(template, SetupKeys.SetupTemplates_232)
elif settings.aedt_version is not None and settings.aedt_version >= "2023.1":
template = SetupKeys._add_to_template(SetupKeys.SetupTemplates, SetupKeys.SetupTemplates_231)

return template

def get_default_icepak_template(self, default_type):
"""
Update the setup based on the class arguments or a dictionary.
Parameters
----------
default_type : str
Which default template to use. Available options are ``"Default"``,
``"Forced Convection"``, ``"Mixed Convection"``
and ``"Natural Convection"``.
Returns
-------
dict
Dictionary containing the Icepak default setup for the chosen simulation type.
"""
icepak_setups_n = [11, 12, 13, 36, 37, 38]
template = self.get_setup_templates()
icepak_template = {self.SetupNames[i]: template[i] for i in icepak_setups_n}
if default_type == "Default":
return icepak_template
elif default_type == "Forced Convection":
expand_dict = icepak_forced_convection_update
elif default_type == "Natural Convection" or default_type == "Mixed Convection":
expand_dict = icepak_natural_convection_update
else:
raise AttributeError("default_type {} is not supported.".format(default_type))
for i in icepak_setups_n:
icepak_template[self.SetupNames[i]].update(expand_dict)
return icepak_template
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tests = [
"matplotlib==3.7.3; python_version == '3.8'",
"matplotlib==3.8.3; python_version > '3.8'",
"numpy==1.21.6; python_version <= '3.9'",
"numpy==1.26.0; python_version > '3.9'",
"numpy==1.26.4; python_version > '3.9'",
"mock",
"openpyxl==3.1.2",
"osmnx",
Expand All @@ -53,7 +53,7 @@ tests = [
"pandas==2.1.1; python_version > '3.9'",
"pytest==8.0.2",
"pytest-cov==4.1.0",
"pytest-xdist==3.3.1",
"pytest-xdist==3.5.0",
"vtk==9.2.6",
"pyvista==0.38.0; python_version <= '3.7'",
"pyvista==0.43.3; python_version > '3.7'",
Expand All @@ -71,7 +71,7 @@ dotnet = [
"dotnetcore2 ==3.1.23;platform_system=='Linux'",
]
doc = [
"ansys-sphinx-theme==0.13.1",
"ansys-sphinx-theme==0.14.0",
"imageio==2.31.5",
"imageio-ffmpeg==0.4.9",
"ipython==8.13.0; python_version < '3.9'",
Expand All @@ -96,7 +96,7 @@ doc = [
"scikit-learn==1.3.1; python_version > '3.7'",
"Sphinx==7.1.2; python_version <= '3.9'",
"Sphinx==7.2.6; python_version >= '3.9'",
"sphinx-autobuild==2021.3.14",
"sphinx-autobuild==2024.2.4",
"sphinx-autodoc-typehints==1.24.0",
"sphinx-copybutton==0.5.2",
"sphinx-gallery==0.14.0",
Expand All @@ -116,7 +116,7 @@ full = [
"matplotlib==3.7.3; python_version == '3.8'",
"matplotlib==3.8.3; python_version > '3.8'",
"numpy==1.21.6; python_version <= '3.9'",
"numpy==1.26.0; python_version > '3.9'",
"numpy==1.26.4; python_version > '3.9'",
"pandas==1.3.5; python_version == '3.7'",
"pandas==2.0.3; python_version == '3.8'",
"pandas==2.1.1; python_version > '3.9'",
Expand All @@ -135,7 +135,7 @@ all = [
"matplotlib==3.7.3; python_version == '3.8'",
"matplotlib==3.8.3; python_version > '3.8'",
"numpy==1.21.6; python_version <= '3.9'",
"numpy==1.26.0; python_version > '3.9'",
"numpy==1.26.4; python_version > '3.9'",
"pandas==1.3.5; python_version == '3.7'",
"pandas==2.0.3; python_version == '3.9'",
"pandas==2.0.3; python_version == '3.8'",
Expand Down

0 comments on commit ca9eff6

Please sign in to comment.