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 Apr 2, 2024
2 parents 17f8476 + 37d8b7f commit 4d807b0
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ repos:

# validate GitHub workflow files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.0
rev: 0.28.1
hooks:
- id: check-github-workflows

Expand Down
2 changes: 2 additions & 0 deletions _unittest/test_07_Object3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ def test_07_object_clone_and_get_properties(self):
assert len(new_object.faces) == 6
assert len(new_object.edges) == 12
assert new_object.display_wireframe == initial_object.display_wireframe
new_object.name = "Properties_Box"
assert not new_object.name == "Properties_Box"

def test_08_set_model(self):
o = self.create_copper_box()
Expand Down
1 change: 1 addition & 0 deletions _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ def test_32_matrix(self, add_app):
rectangle4 = m3d.modeler.create_rectangle(0, [32.5, 1.5, 0], [2.5, 5], name="Sheet4")

m3d.assign_voltage(rectangle1.faces[0], amplitude=1, name="Voltage1")
m3d.assign_voltage("Sheet1", amplitude=1, name="Voltage5")
m3d.assign_voltage(rectangle2.faces[0], amplitude=1, name="Voltage2")
m3d.assign_voltage(rectangle3.faces[0], amplitude=1, name="Voltage3")
m3d.assign_voltage(rectangle4.faces[0], amplitude=1, name="Voltage4")
Expand Down
2 changes: 1 addition & 1 deletion examples/03-Maxwell/Maxwell_Control_Program.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
# ~~~~~~~~~~~~
# Plot Solved Results.

sols = m2d.post.get_solution_data("FluxLinkage(Winding1)",variations={"Time":["All"]}, primary_sweep_variable="Time")
sols = m2d.post.get_solution_data("FluxLinkage(Winding1)", variations={"Time":["All"]}, primary_sweep_variable="Time")
sols.plot()

###################################################################################
Expand Down
2 changes: 1 addition & 1 deletion examples/07-Circuit/Circuit_Transient.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
bn = np.array(b)
cellst = np.append(cellst, an)
cellsv = np.append(cellsv, bn)
plt.plot(cellst.T, cellsv.T, zorder=0)
plt.plot(cellst.T, cellsv.T, zorder=0)
plt.show()

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion examples/07-EMIT/interference_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def closeEvent(self, event):
# Launch the GUI. If you want to run the GUI, uncomment the ``window.show()`` and
# ``app.exec_()`` method calls.

if __name__ == '__main__' and os.getenv("PYAEDT_DOC_GENERATION", "False") != "1":
if __name__ == '__main__' and os.getenv("PYAEDT_DOC_GENERATION", "False") != "1":
app = QtWidgets.QApplication([])
window = MainWindow()
window.show()
Expand Down
6 changes: 3 additions & 3 deletions pyaedt/application/Analysis3DLayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ def get_next_xtalk_list(self, trlist=[], tx_prefix=""):
>>> oModule.GetAllPorts
"""
next = []
next_xtalks = []
if not trlist:
trlist = [i for i in self.excitations if tx_prefix in i]
for i in trlist:
k = trlist.index(i) + 1
while k < len(trlist):
next.append("S({},{})".format(i, trlist[k]))
next_xtalks.append("S({},{})".format(i, trlist[k]))
k += 1
return next
return next_xtalks

@pyaedt_function_handler()
def get_fext_xtalk_list(self, trlist=None, reclist=None, tx_prefix="", rx_prefix="", skip_same_index_couples=True):
Expand Down
6 changes: 3 additions & 3 deletions pyaedt/application/AnalysisNexxim.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,15 +483,15 @@ def get_next_xtalk_list(self, trlist=[], tx_prefix=""):
>>> oEditor.GetAllPorts
"""
next = []
next_xtalks = []
if not trlist:
trlist = [i for i in list(self.excitations.keys()) if tx_prefix in i]
for i in trlist:
k = trlist.index(i) + 1
while k < len(trlist):
next.append("S({},{})".format(i, trlist[k]))
next_xtalks.append("S({},{})".format(i, trlist[k]))
k += 1
return next
return next_xtalks

@pyaedt_function_handler()
def get_fext_xtalk_list(self, trlist=None, reclist=None, tx_prefix="", rx_prefix="", skip_same_index_couples=True):
Expand Down
24 changes: 12 additions & 12 deletions pyaedt/application/Variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,26 +784,26 @@ def __init__(self, app):

@property
def _independent_variables(self):
all = {}
all.update(self._independent_project_variables)
all.update(self._independent_design_variables)
return all
all_independent = {}
all_independent.update(self._independent_project_variables)
all_independent.update(self._independent_design_variables)
return all_independent

@property
def _dependent_variables(self):
all = {}
all_dependent = {}
for k, v in self._dependent_project_variables.items():
all[k] = v
all_dependent[k] = v
for k, v in self._dependent_design_variables.items():
all[k] = v
return all
all_dependent[k] = v
return all_dependent

@property
def _all_variables(self):
all = {}
all.update(self._independent_variables)
all.update(self._dependent_variables)
return all
all_variables = {}
all_variables.update(self._independent_variables)
all_variables.update(self._dependent_variables)
return all_variables

@pyaedt_function_handler()
def __delitem__(self, key):
Expand Down
15 changes: 4 additions & 11 deletions pyaedt/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@

modules = [tup[1] for tup in pkgutil.iter_modules()]

python_grpc_wrapper = None


@pyaedt_function_handler()
def launch_aedt(full_path, non_graphical, port, student_version, first_run=True):
Expand Down Expand Up @@ -239,7 +237,6 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api):
``True`` when successful, ``False`` when failed.
"""
global python_grpc_wrapper
if settings.remote_rpc_session or (settings.aedt_version >= "2022.2" and is_grpc_api and not is_ironpython):
if close_desktop and desktop_class.parent_desktop_id:
pyaedt_logger.error("A child desktop session is linked to this session.")
Expand Down Expand Up @@ -273,9 +270,8 @@ def _close_aedt_application(desktop_class, close_desktop, pid, is_grpc_api):
return False
else:
try:
if not python_grpc_wrapper:
python_grpc_wrapper = __import__("pyaedt.generic.grpc_plugin")
# import pyaedt.generic.grpc_plugin as StandalonePyScriptWrapper
import pyaedt.generic.grpc_plugin as python_grpc_wrapper

python_grpc_wrapper.AedtAPI.ReleaseAll()
return True
except Exception: # pragma: no cover
Expand Down Expand Up @@ -911,7 +907,6 @@ def _initialize(
version=None,
is_grpc=True,
):
global python_grpc_wrapper
if not is_grpc:
from pyaedt.generic.clr_module import _clr

Expand All @@ -934,10 +929,8 @@ def _initialize(
os.environ["DesktopPluginPyAEDT"] = os.path.join(settings.aedt_install_dir, "PythonFiles", "DesktopPlugin")
launch_msg = "AEDT installation Path {}".format(base_path)
self.logger.info(launch_msg)
if not python_grpc_wrapper:
python_grpc_wrapper = __import__("pyaedt.generic.grpc_plugin")
python_grpc_wrapper = python_grpc_wrapper.generic.grpc_plugin
# import pyaedt.generic.grpc_plugin as StandalonePyScriptWrapper
import pyaedt.generic.grpc_plugin as python_grpc_wrapper

if _desktop_sessions:
last_session = list(_desktop_sessions.values())[-1]
all_desktop = [i for i in last_session.odesktop.GetRunningInstancesMgr().GetAllRunningInstances()]
Expand Down
24 changes: 17 additions & 7 deletions pyaedt/generic/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime
import json
import os
import pkgutil
import tempfile

import pyaedt
Expand Down Expand Up @@ -692,12 +691,23 @@ def __init__(self, app):
self.options = ConfigurationsOptions()
self.results = ImportResults()

# Read the default configuration schema from pyaedt
schema_bytes = pkgutil.get_data(
__name__, os.path.join(os.path.dirname(pyaedt.__file__), "misc", "config.schema.json")
)
schema_string = schema_bytes.decode("utf-8")
self._schema = json.loads(schema_string)
pyaedt_installed_path = os.path.dirname(pyaedt.__file__)

schema_bytes = None

config_schema_path = os.path.join(pyaedt_installed_path, "misc", "config.schema.json")

if os.path.exists(config_schema_path):
with open(config_schema_path, "rb") as schema:
schema_bytes = schema.read()

if schema_bytes:
# Read the default configuration schema from pyaedt
schema_string = schema_bytes.decode("utf-8")
self._schema = json.loads(schema_string)
else: # pragma: no cover
self._app.logger.error("Failed to load configuration schema.")
self._schema = None

@staticmethod
@pyaedt_function_handler()
Expand Down
8 changes: 7 additions & 1 deletion pyaedt/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,13 @@ def assign_voltage(self, face_list, amplitude=1, name=None):
if self.design_type == "Maxwell 2D":
props = OrderedDict({"Objects": face_list, "Value": amplitude})
else:
props = OrderedDict({"Faces": face_list, "Voltage": amplitude})
if len(face_list) == 1:
if isinstance(face_list[0], str) and face_list[0] in self.modeler.object_names:
props = OrderedDict({"Objects": face_list, "Voltage": amplitude})
else:
props = OrderedDict({"Faces": face_list, "Value": amplitude})
else:
props = OrderedDict({"Faces": face_list, "Voltage": amplitude})
bound = BoundaryObject(self, name, props, "Voltage")
if bound.create():
self._boundaries[bound.name] = bound
Expand Down
25 changes: 13 additions & 12 deletions pyaedt/modeler/cad/Primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -4651,16 +4651,17 @@ def import_spaceclaim_document(self, SCFile):
>>> oEditor.CreateUserDefinedModel
"""
environlist = os.environ
latestversion = ""
for l in environlist:
if "AWP_ROOT" in l:
if l > latestversion:
latestversion = l
if not latestversion:
env_var = os.environ
latest_version = ""
for variable in env_var:
if "AWP_ROOT" in variable:
if variable > latest_version:
latest_version = variable
break
if not latest_version:
self.logger.error("SpaceClaim is not found.")
else:
scdm_path = os.path.join(os.environ[latestversion], "scdm")
scdm_path = os.path.join(os.environ[latest_version], "scdm")
self.oeditor.CreateUserDefinedModel(
[
"NAME:UserDefinedModelParameters",
Expand Down Expand Up @@ -5094,11 +5095,11 @@ def automatic_thicken_sheets(self, inputlist, value, internalExtr=True, internal
objID = self.oeditor.GetFaceIDs(el)
faceCenter = self.oeditor.GetFaceCenter(int(objID[0]))
directionfound = False
l = 10
thickness = 10
while not directionfound:
self.oeditor.ThickenSheet(
["NAME:Selections", "Selections:=", el, "NewPartsModelFlag:=", "Model"],
["NAME:SheetThickenParameters", "Thickness:=", str(l) + "mm", "BothSides:=", False],
["NAME:SheetThickenParameters", "Thickness:=", str(thickness) + "mm", "BothSides:=", False],
)
aedt_bounding_box2 = self.get_model_bounding_box()
self._odesign.Undo()
Expand All @@ -5107,7 +5108,7 @@ def automatic_thicken_sheets(self, inputlist, value, internalExtr=True, internal
directionfound = True
self.oeditor.ThickenSheet(
["NAME:Selections", "Selections:=", el, "NewPartsModelFlag:=", "Model"],
["NAME:SheetThickenParameters", "Thickness:=", "-" + str(l) + "mm", "BothSides:=", False],
["NAME:SheetThickenParameters", "Thickness:=", "-" + str(thickness) + "mm", "BothSides:=", False],
)
aedt_bounding_box2 = self.get_model_bounding_box()

Expand All @@ -5117,7 +5118,7 @@ def automatic_thicken_sheets(self, inputlist, value, internalExtr=True, internal
directions[el] = "Internal"
directionfound = True
else:
l = l + 10
thickness = thickness + 10
for el in inputlist:
objID = self.oeditor.GetFaceIDs(el)
faceCenter = self.oeditor.GetFaceCenter(int(objID[0]))
Expand Down
4 changes: 2 additions & 2 deletions pyaedt/modeler/cad/Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ def create_torus(self, center, major_radius, minor_radius, axis=None, name=None,

# fmt: off
@pyaedt_function_handler()
def create_bondwire(self, start_position, end_position, h1=0.2, h2=0, alpha=80, beta=5, bond_type=0,
diameter=0.025, facets=6, name=None, matname=None, cs_axis="Z", **kwargs): # fmt: on
def create_bondwire(self, start_position, end_position, h1=0.2, h2=0, alpha=80, beta=5, bond_type=0,
diameter=0.025, facets=6, name=None, matname=None, cs_axis="Z", **kwargs): # fmt: on
# type : (list, list, float|str=0.2, float|str=0, float=80, float=5, int=0, float|str=0.025, int=6, str=None,
# str=None) -> Object3d
"""Create a bondwire.
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/modeler/cad/object3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ def name(self, obj_name):
self._primitives.add_new_objects()
self._primitives.cleanup_objects()
else:
pass
self.logger.warning("{} is already used in current design.".format(obj_name))

@property
def valid_properties(self):
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/modules/solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2598,7 +2598,7 @@ def _update_both(self):

self.ff.mesh = self.ff.get_far_field_mesh(self.farfield_quantity, self.quantity_format)

self.output.overwrite(self.ff.mesh)
self.output.copy_from(self.ff.mesh)
return

@pyaedt_function_handler()
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies = [

[project.optional-dependencies]
tests = [
"imageio>=2.30.0,<2.34",
"imageio>=2.30.0,<2.35",
"ipython>=7.30.0,<8.23",
"joblib>=1.0.0,<1.4",
"matplotlib>=3.5.0,<3.9",
Expand All @@ -47,7 +47,7 @@ tests = [
"osmnx>=1.1.0,<1.10",
"pandas>=1.1.0,<2.3",
"pytest>=7.4.0,<8.2",
"pytest-cov>=4.0.0,<4.2",
"pytest-cov>=4.0.0,<5.1",
"pytest-xdist>=3.5.0,<3.6",
"pyedb>=0.4.0,<0.5; python_version == '3.7'",
"pyedb>=0.5.0,<0.8; python_version > '3.7'",
Expand All @@ -66,11 +66,11 @@ dotnet = [
"pywin32>=303; platform_system=='Windows'",
]
doc = [
"ansys-sphinx-theme>=0.10.0,<0.15",
"ansys-sphinx-theme>=0.10.0,<0.16",
"imageio>=2.30.0,<2.35",
#"imageio-ffmpeg>=0.4.0,<0.5",
"ipython>=7.34.0; python_version == '3.7'",
"ipython>=8.13.0,<8.23; python_version > '3.7'",
"ipython>=8.13.0,<8.24; python_version > '3.7'",
#"ipywidgets>=8.0.0,<8.2",
"joblib>=1.3.0,<1.4",
"jupyterlab>=4.0.0,<4.3",
Expand Down Expand Up @@ -102,7 +102,7 @@ doc = [
"vtk==9.2.6",
]
doc-noexamples = [
"ansys-sphinx-theme>=0.10.0,<0.15",
"ansys-sphinx-theme>=0.10.0,<0.16",
"imageio>=2.30.0,<2.35",
#"imageio-ffmpeg",
"numpydoc>=1.5.0,<1.8",
Expand Down

0 comments on commit 4d807b0

Please sign in to comment.