ansys-speos-core 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/PKG-INFO +14 -5
  2. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/pyproject.toml +14 -5
  3. ansys_speos_core-0.4.0/src/ansys/speos/core/generic/constants.py +36 -0
  4. ansys_speos_core-0.4.0/src/ansys/speos/core/generic/general_methods.py +229 -0
  5. ansys_speos_core-0.4.0/src/ansys/speos/core/generic/visualization_methods.py +289 -0
  6. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/client.py +63 -34
  7. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/launcher.py +81 -2
  8. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/logger.py +1 -1
  9. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/lxp.py +35 -14
  10. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/project.py +88 -13
  11. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/sensor.py +222 -0
  12. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/source.py +1 -0
  13. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/speos.py +26 -6
  14. ansys_speos_core-0.3.0/src/ansys/speos/core/generic/general_methods.py +0 -64
  15. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/LICENSE +0 -0
  16. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/README.rst +0 -0
  17. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/__init__.py +0 -0
  18. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/body.py +0 -0
  19. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/face.py +0 -0
  20. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/geo_ref.py +0 -0
  21. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/intensity.py +0 -0
  22. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/__init__.py +0 -0
  23. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/body.py +0 -0
  24. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/crud.py +0 -0
  25. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/face.py +0 -0
  26. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/intensity_template.py +0 -0
  27. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/job.py +0 -0
  28. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/part.py +0 -0
  29. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/proto_message_utils.py +0 -0
  30. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/scene.py +0 -0
  31. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/sensor_template.py +0 -0
  32. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/simulation_template.py +0 -0
  33. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/sop_template.py +0 -0
  34. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/source_template.py +0 -0
  35. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/spectrum.py +0 -0
  36. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/kernel/vop_template.py +0 -0
  37. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/opt_prop.py +0 -0
  38. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/part.py +0 -0
  39. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/proto_message_utils.py +0 -0
  40. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/simulation.py +0 -0
  41. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/spectrum.py +0 -0
  42. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/workflow/__init__.py +0 -0
  43. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/workflow/combine_speos.py +0 -0
  44. {ansys_speos_core-0.3.0 → ansys_speos_core-0.4.0}/src/ansys/speos/core/workflow/open_result.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: ansys-speos-core
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A Python wrapper for Ansys Speos
5
5
  Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
6
6
  Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
@@ -19,14 +19,15 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Topic :: Software Development :: Libraries
20
20
  Classifier: Topic :: Scientific/Engineering :: Physics
21
21
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
22
+ License-File: LICENSE
22
23
  Requires-Dist: protobuf>=3.20,<6
23
24
  Requires-Dist: grpcio>=1.50.0,<1.71
24
25
  Requires-Dist: grpcio-health-checking>=1.45.0,<1.68
25
26
  Requires-Dist: ansys-api-speos==0.14.2
27
+ Requires-Dist: ansys-tools-path>=0.3.1
26
28
  Requires-Dist: numpy>=1.20.3,<3
27
- Requires-Dist: pyvista>=0.40.0,<0.45
28
29
  Requires-Dist: comtypes>=1.4,<1.5
29
- Requires-Dist: ansys-sphinx-theme==1.3.3 ; extra == "doc"
30
+ Requires-Dist: ansys-sphinx-theme==1.4.2 ; extra == "doc"
30
31
  Requires-Dist: numpydoc==1.8.0 ; extra == "doc"
31
32
  Requires-Dist: Sphinx==8.1.3 ; extra == "doc"
32
33
  Requires-Dist: sphinx-copybutton==0.5.2 ; extra == "doc"
@@ -41,14 +42,21 @@ Requires-Dist: jupyterlab==4.3.6 ; extra == "doc"
41
42
  Requires-Dist: jupyter-server==2.15.0 ; extra == "doc"
42
43
  Requires-Dist: nbconvert==7.16.6 ; extra == "doc"
43
44
  Requires-Dist: pyvista[jupyter]>=0.43,<0.45 ; extra == "doc"
45
+ Requires-Dist: ansys-tools-visualization-interface>=0.8.3 ; extra == "doc"
46
+ Requires-Dist: pyvista>=0.40.0,<0.45 ; extra == "graphics"
47
+ Requires-Dist: ansys-tools-visualization-interface>=0.8.3 ; extra == "graphics"
44
48
  Requires-Dist: matplotlib ; extra == "jupyter"
45
49
  Requires-Dist: jupyterlab>=3 ; extra == "jupyter"
46
50
  Requires-Dist: ipywidgets ; extra == "jupyter"
47
51
  Requires-Dist: pyvista[jupyter]>=0.43,<0.45 ; extra == "jupyter"
52
+ Requires-Dist: ansys-tools-visualization-interface>=0.8.3 ; extra == "jupyter"
48
53
  Requires-Dist: notebook==7.3.3 ; extra == "jupyter"
54
+ Requires-Dist: psutil==7.0.0 ; extra == "tests"
49
55
  Requires-Dist: pytest==8.3.5 ; extra == "tests"
56
+ Requires-Dist: pyvista>=0.40.0,<0.45 ; extra == "tests"
57
+ Requires-Dist: ansys-tools-visualization-interface>=0.8.3 ; extra == "tests"
50
58
  Requires-Dist: ansys-platform-instancemanagement>=1.0.3 ; extra == "tests"
51
- Requires-Dist: pytest-cov==6.0.0 ; extra == "tests"
59
+ Requires-Dist: pytest-cov==6.1.1 ; extra == "tests"
52
60
  Project-URL: Changelog, https://github.com/ansys/pyspeos/blob/main/doc/source/changelog.rst
53
61
  Project-URL: Discussions, https://github.com/ansys/pyspeos/discussions
54
62
  Project-URL: Documentation, https://speos.docs.pyansys.com/
@@ -56,6 +64,7 @@ Project-URL: Issues, https://github.com/ansys/pyspeos/issues
56
64
  Project-URL: Releases, https://github.com/ansys/pyspeos/releases
57
65
  Project-URL: Source, https://github.com/ansys/pyspeos
58
66
  Provides-Extra: doc
67
+ Provides-Extra: graphics
59
68
  Provides-Extra: jupyter
60
69
  Provides-Extra: tests
61
70
 
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["flit_core >=3.2,<3.11"] # THIS SHOULD BE REVERTED TO '["flit_core >=3.2,<4"]'
2
+ requires = ["flit_core >=3.2,<4"]
3
3
  build-backend = "flit_core.buildapi"
4
4
 
5
5
  [project]
6
6
  name = "ansys-speos-core"
7
- version = "0.3.0"
7
+ version = "0.4.0"
8
8
  description = "A Python wrapper for Ansys Speos"
9
9
  readme = "README.rst"
10
10
  requires-python = ">=3.10"
@@ -31,26 +31,34 @@ dependencies=[
31
31
  "grpcio>=1.50.0,<1.71",
32
32
  "grpcio-health-checking>=1.45.0,<1.68",
33
33
  "ansys-api-speos==0.14.2",
34
+ "ansys-tools-path>=0.3.1",
34
35
  "numpy>=1.20.3,<3",
35
- "pyvista>=0.40.0,<0.45",
36
36
  "comtypes>=1.4,<1.5",
37
37
  ]
38
38
 
39
39
  [project.optional-dependencies]
40
+ graphics = [
41
+ "pyvista>=0.40.0,<0.45",
42
+ "ansys-tools-visualization-interface>=0.8.3",
43
+ ]
40
44
  tests = [
45
+ "psutil==7.0.0",
41
46
  "pytest==8.3.5",
47
+ "pyvista>=0.40.0,<0.45",
48
+ "ansys-tools-visualization-interface>=0.8.3",
42
49
  "ansys-platform-instancemanagement>=1.0.3",
43
- "pytest-cov==6.0.0",
50
+ "pytest-cov==6.1.1",
44
51
  ]
45
52
  jupyter = [
46
53
  "matplotlib",
47
54
  "jupyterlab>=3",
48
55
  "ipywidgets",
49
56
  "pyvista[jupyter]>=0.43,<0.45",
57
+ "ansys-tools-visualization-interface>=0.8.3",
50
58
  "notebook==7.3.3",
51
59
  ]
52
60
  doc = [
53
- "ansys-sphinx-theme==1.3.3",
61
+ "ansys-sphinx-theme==1.4.2",
54
62
  "numpydoc==1.8.0",
55
63
  "Sphinx==8.1.3",
56
64
  "sphinx-copybutton==0.5.2",
@@ -65,6 +73,7 @@ doc = [
65
73
  "jupyter-server==2.15.0",
66
74
  "nbconvert==7.16.6",
67
75
  "pyvista[jupyter]>=0.43,<0.45",
76
+ "ansys-tools-visualization-interface>=0.8.3",
68
77
  ]
69
78
 
70
79
  [project.urls]
@@ -0,0 +1,36 @@
1
+ # Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ """Collection of all constants used in pySpeos."""
24
+
25
+ import os
26
+
27
+ DEFAULT_HOST = "localhost"
28
+ """Default host used by Speos RPC server and client """
29
+ DEFAULT_PORT = "50098"
30
+ """Default port used by Speos RPC server and client """
31
+ DEFAULT_VERSION = "251"
32
+ """Latest supported Speos version of the current PySpeos Package"""
33
+ MAX_MESSAGE_LENGTH = int(os.environ.get("SPEOS_MAX_MESSAGE_LENGTH", 256 * 1024**2))
34
+ """Maximum message length value accepted by the Speos RPC server,
35
+ By default, value stored in environment variable SPEOS_MAX_MESSAGE_LENGTH or 268 435 456.
36
+ """
@@ -0,0 +1,229 @@
1
+ # Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ """General methods and helpers collection.
24
+
25
+ this includes decorator and methods
26
+ """
27
+
28
+ from functools import lru_cache, wraps
29
+ import os
30
+ from pathlib import Path
31
+ from typing import List, Optional, Union
32
+ import warnings
33
+
34
+ import numpy as np
35
+
36
+ from ansys.speos.core.generic.constants import DEFAULT_VERSION
37
+ from ansys.tools.path import get_available_ansys_installations
38
+
39
+ _GRAPHICS_AVAILABLE = None
40
+
41
+ GRAPHICS_ERROR = (
42
+ "Preview unsupported without 'ansys-tools-visualization_interface' installed. "
43
+ "You can install this using `pip install ansys-speos-core[graphics]`."
44
+ )
45
+
46
+
47
+ def deprecate_kwargs(old_arguments: dict, removed_version="0.3.0"):
48
+ """Issues deprecation warnings for arguments.
49
+
50
+ Parameters
51
+ ----------
52
+ old_arguments : dict
53
+ key old argument value new argument name
54
+ removed_version : str
55
+ Release version with which argument support will be removed
56
+ By Default, next major release
57
+
58
+ """
59
+
60
+ def decorator(function):
61
+ @wraps(function)
62
+ def wrapper(*args, **kwargs):
63
+ func_name = function.__name__
64
+ for alias, new in old_arguments.items():
65
+ if alias in kwargs:
66
+ if new in kwargs:
67
+ msg = f"{func_name} received both {alias} and {new} as arguments!\n"
68
+ msg += f"{alias} is deprecated, use {new} instead."
69
+ raise TypeError(msg)
70
+ msg = f"Argument `{alias}` is deprecated for method `{func_name}`; it will be "
71
+ msg += f"removed with Release v{removed_version}. Please use `{new}` instead."
72
+ kwargs[new] = kwargs.pop(alias)
73
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
74
+ retval = function(*args, **kwargs)
75
+ return retval
76
+
77
+ return wrapper
78
+
79
+ return decorator
80
+
81
+
82
+ @lru_cache
83
+ def run_if_graphics_required(warning=False):
84
+ """Check if graphics are available."""
85
+ global _GRAPHICS_AVAILABLE
86
+ if _GRAPHICS_AVAILABLE is None:
87
+ try:
88
+ import pyvista as pv # noqa: F401
89
+
90
+ from ansys.tools.visualization_interface import Plotter # noqa: F401
91
+
92
+ _GRAPHICS_AVAILABLE = True
93
+ except ImportError: # pragma: no cover
94
+ _GRAPHICS_AVAILABLE = False
95
+
96
+ if _GRAPHICS_AVAILABLE is False and warning is False: # pragma: no cover
97
+ raise ImportError(GRAPHICS_ERROR)
98
+ elif _GRAPHICS_AVAILABLE is False: # pragma: no cover
99
+ warnings.warn(GRAPHICS_ERROR)
100
+
101
+
102
+ def graphics_required(method):
103
+ """Decorate a method as requiring graphics.
104
+
105
+ Parameters
106
+ ----------
107
+ method : callable
108
+ Method to decorate.
109
+
110
+ Returns
111
+ -------
112
+ callable
113
+ Decorated method.
114
+ """
115
+
116
+ def wrapper(*args, **kwargs):
117
+ run_if_graphics_required()
118
+ return method(*args, **kwargs)
119
+
120
+ return wrapper
121
+
122
+
123
+ def magnitude_vector(vector: Union[List[float], np.array]) -> float:
124
+ """
125
+ Compute the magnitude (length) of a 2D or 3D vector using NumPy.
126
+
127
+ Parameters
128
+ ----------
129
+ vector: List[float]
130
+ A 2D or 3D vector as a list [x, y] or [x, y, z].
131
+
132
+ Returns
133
+ -------
134
+ float
135
+ The magnitude (length) of the vector.
136
+ """
137
+ vector_np = np.array(vector, dtype=float)
138
+ if vector_np.size not in (2, 3):
139
+ raise ValueError("Input vector must be either 2D or 3D")
140
+ return np.linalg.norm(vector_np)
141
+
142
+
143
+ def normalize_vector(vector: Union[List[float], np.array]) -> List[float]:
144
+ """
145
+ Normalize a 2D or 3D vector to have a length of 1 using NumPy.
146
+
147
+ Parameters
148
+ ----------
149
+ vector: List[float]
150
+ A vector as a list [x, y] for 2D or [x, y, z] for 3D.
151
+
152
+ Returns
153
+ -------
154
+ List[float]
155
+ The normalized vector.
156
+ """
157
+ vector_np = np.array(vector, dtype=float)
158
+ if vector_np.size not in (2, 3):
159
+ raise ValueError("Input vector must be either 2D or 3D")
160
+
161
+ magnitude = magnitude_vector(vector_np)
162
+ if magnitude == 0:
163
+ raise ValueError("Cannot normalize the zero vector")
164
+
165
+ return (vector_np / magnitude).tolist()
166
+
167
+
168
+ def error_no_install(install_path: Union[Path, str], version: Union[int, str]):
169
+ """Raise error that installation was not found at a location.
170
+
171
+ Parameters
172
+ ----------
173
+ install_path : Union[Path, str]
174
+ Installation Path
175
+ version : Union[int, str]
176
+ Version
177
+ """
178
+ install_loc_msg = ""
179
+ if install_path:
180
+ install_loc_msg = f"at {Path(install_path).parent}"
181
+ raise FileNotFoundError(
182
+ f"Ansys Speos RPC server installation not found{install_loc_msg}. "
183
+ f"Please define AWP_ROOT{version} environment variable"
184
+ )
185
+
186
+
187
+ def retrieve_speos_install_dir(
188
+ speos_rpc_path: Optional[Union[Path, str]] = None, version: str = DEFAULT_VERSION
189
+ ) -> Path:
190
+ """Retrieve Speos install location based on Path or Environment.
191
+
192
+ Parameters
193
+ ----------
194
+ speos_rpc_path : Optional[str, Path]
195
+ location of Speos rpc executable
196
+ version : Union[str, int]
197
+ The Speos server version to run, in the 3 digits format, such as "242".
198
+ If unspecified, the version will be chosen as
199
+ ``ansys.speos.core.kernel.client.LATEST_VERSION``.
200
+
201
+ """
202
+ if not speos_rpc_path:
203
+ speos_rpc_path = ""
204
+ if not speos_rpc_path or not Path(speos_rpc_path).exists():
205
+ if not Path(speos_rpc_path).exists():
206
+ warnings.warn(
207
+ "Provided executable location not found, looking for local installation",
208
+ UserWarning,
209
+ )
210
+ versions = get_available_ansys_installations()
211
+ ansys_loc = versions.get(int(version), False)
212
+ if not ansys_loc:
213
+ ansys_loc = os.environ.get("AWP_ROOT{}".format(version), False)
214
+ if not ansys_loc:
215
+ error_no_install(speos_rpc_path, int(version))
216
+
217
+ speos_rpc_path = Path(ansys_loc) / "Optical Products" / "SPEOS_RPC"
218
+ elif Path(speos_rpc_path).is_file():
219
+ if "SpeosRPC_Server" not in Path(speos_rpc_path).name:
220
+ error_no_install(speos_rpc_path, int(version))
221
+ else:
222
+ speos_rpc_path = Path(speos_rpc_path).parent
223
+ if os.name == "nt":
224
+ speos_exec = speos_rpc_path / "SpeosRPC_Server.exe"
225
+ else:
226
+ speos_exec = speos_rpc_path / "SpeosRPC_Server.x"
227
+ if not speos_exec.is_file():
228
+ error_no_install(speos_rpc_path, int(version))
229
+ return speos_rpc_path
@@ -0,0 +1,289 @@
1
+ # Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ """Provides the ``VisualData`` class."""
24
+
25
+ from typing import TYPE_CHECKING, List
26
+
27
+ from ansys.speos.core.generic.general_methods import (
28
+ graphics_required,
29
+ magnitude_vector,
30
+ normalize_vector,
31
+ )
32
+
33
+ if TYPE_CHECKING: # pragma: no cover
34
+ import pyvista as pv
35
+
36
+
37
+ @graphics_required
38
+ class _VisualCoordinateSystem:
39
+ """Visualization data for the coordinate system..
40
+
41
+ By default, there is empty visualization data.
42
+
43
+ Notes
44
+ -----
45
+ **Do not instantiate this class yourself**.
46
+ """
47
+
48
+ def __init__(self):
49
+ import pyvista as pv
50
+
51
+ self.__origin = [0.0, 0.0, 0.0]
52
+ self.__x_axis = pv.Arrow(
53
+ start=self.__origin,
54
+ direction=[1.0, 0.0, 0.0],
55
+ scale=10.0,
56
+ tip_radius=0.05,
57
+ shaft_radius=0.01,
58
+ )
59
+ self.__y_axis = pv.Arrow(
60
+ start=self.__origin,
61
+ direction=[0.0, 1.0, 0.0],
62
+ scale=10.0,
63
+ tip_radius=0.05,
64
+ shaft_radius=0.01,
65
+ )
66
+ self.__z_axis = pv.Arrow(
67
+ start=self.__origin,
68
+ direction=[0.0, 0.0, 1.0],
69
+ scale=10.0,
70
+ tip_radius=0.05,
71
+ shaft_radius=0.01,
72
+ )
73
+
74
+ @property
75
+ def origin(self) -> List[float]:
76
+ """Returns the origin of the coordinate system.
77
+
78
+ Returns
79
+ -------
80
+ List[float]
81
+ The origin of the coordinate system.
82
+
83
+ """
84
+ return self.__origin
85
+
86
+ @origin.setter
87
+ def origin(self, value: List[float]) -> None:
88
+ """Set the origin of the coordinate system.
89
+
90
+ Parameters
91
+ ----------
92
+ value: List[float]
93
+ The origin of the coordinate system.
94
+
95
+ Returns
96
+ -------
97
+ None
98
+ """
99
+ if len(value) != 3:
100
+ raise ValueError("origin must be a List of three values.")
101
+ self.__origin = value
102
+
103
+ @property
104
+ def x_axis(self) -> "pv.Arrow":
105
+ """Returns the x-axis of the coordinate system.
106
+
107
+ Returns
108
+ -------
109
+ pv.Arrow
110
+ pyvista.Arrow the x-axis of the coordinate system.
111
+
112
+ """
113
+ return self.__x_axis
114
+
115
+ @x_axis.setter
116
+ def x_axis(self, x_vector: List[float]) -> None:
117
+ """Set the x-axis of the coordinate system.
118
+
119
+ Parameters
120
+ ----------
121
+ x_vector: List[float]
122
+ The x-axis of the coordinate system.
123
+
124
+ Returns
125
+ -------
126
+ None
127
+ """
128
+ import pyvista as pv
129
+
130
+ if len(x_vector) != 3:
131
+ raise ValueError("x_axis must be a List of three values.")
132
+ self.__x_axis = pv.Arrow(
133
+ start=self.__origin,
134
+ direction=normalize_vector(vector=x_vector),
135
+ scale=magnitude_vector(vector=x_vector),
136
+ tip_radius=0.05,
137
+ shaft_radius=0.01,
138
+ )
139
+
140
+ @property
141
+ def y_axis(self) -> "pv.Arrow":
142
+ """
143
+ Returns the y-axis of the coordinate system.
144
+
145
+ Returns
146
+ -------
147
+ pv.Arrow
148
+ pyvista.Arrow the y-axis of the coordinate system.
149
+
150
+ """
151
+ return self.__y_axis
152
+
153
+ @y_axis.setter
154
+ def y_axis(self, y_vector: List[float]) -> None:
155
+ """Set the y-axis of the coordinate system.
156
+
157
+ Parameters
158
+ ----------
159
+ y_vector: List[float]
160
+ The y-axis of the coordinate system.
161
+
162
+ Returns
163
+ -------
164
+ None
165
+ """
166
+ import pyvista as pv
167
+
168
+ if len(y_vector) != 3:
169
+ raise ValueError("y_axis must be a List of three values.")
170
+ self.__y_axis = pv.Arrow(
171
+ start=self.__origin,
172
+ direction=normalize_vector(vector=y_vector),
173
+ scale=magnitude_vector(vector=y_vector),
174
+ tip_radius=0.05,
175
+ shaft_radius=0.01,
176
+ )
177
+
178
+ @property
179
+ def z_axis(self) -> "pv.Arrow":
180
+ """
181
+ Returns the z-axis of the coordinate system.
182
+
183
+ Returns
184
+ -------
185
+ pv.Arrow
186
+ pyvista.Arrow the z-axis of the coordinate system.
187
+
188
+ """
189
+ return self.__z_axis
190
+
191
+ @z_axis.setter
192
+ def z_axis(self, z_vector: List[float]) -> None:
193
+ """Set the z-axis of the coordinate system.
194
+
195
+ Parameters
196
+ ----------
197
+ z_vector: List[float]
198
+ The z-axis of the coordinate system.
199
+
200
+ Returns
201
+ -------
202
+ None
203
+ """
204
+ import pyvista as pv
205
+
206
+ if len(z_vector) != 3:
207
+ raise ValueError("z_axis must be a List of three values.")
208
+ self.__z_axis = pv.Arrow(
209
+ start=self.__origin,
210
+ direction=normalize_vector(vector=z_vector),
211
+ scale=magnitude_vector(vector=z_vector),
212
+ tip_radius=0.05,
213
+ shaft_radius=0.01,
214
+ )
215
+
216
+
217
+ @graphics_required
218
+ class _VisualData:
219
+ """Visualization data for the sensor.
220
+
221
+ By default, there is empty visualization data.
222
+
223
+ Notes
224
+ -----
225
+ **Do not instantiate this class yourself**
226
+ """
227
+
228
+ def __init__(self, coordinate_system=True):
229
+ import pyvista as pv
230
+
231
+ self.__data = pv.PolyData()
232
+ self.coordinates = _VisualCoordinateSystem() if coordinate_system else None
233
+ self.updated = False
234
+
235
+ @property
236
+ def data(self) -> "pv.PolyData":
237
+ """
238
+ Returns the data of the sensor.
239
+
240
+ Returns
241
+ -------
242
+ pv.PolyData
243
+ The data of the surface visualization.
244
+
245
+ """
246
+ return self.__data
247
+
248
+ def add_data_triangle(self, triangle_vertices: List[List[float]]) -> None:
249
+ """
250
+ Add surface data triangle to Visualization data.
251
+
252
+ Parameters
253
+ ----------
254
+ triangle_vertices: List[List[float]]
255
+ The vertices of the triangle.
256
+
257
+ Returns
258
+ -------
259
+ None
260
+ """
261
+ import pyvista as pv
262
+
263
+ if len(triangle_vertices) != 3 or any(len(vertex) != 3 for vertex in triangle_vertices):
264
+ raise ValueError(
265
+ "triangle_vertices is expected to be composed of 3 vertices with 3 elements each."
266
+ )
267
+ faces = [[3, 0, 1, 2]]
268
+ self.__data = self.__data.append_polydata(pv.PolyData(triangle_vertices, faces))
269
+
270
+ def add_data_rectangle(self, rectangle_vertices: List[List[float]]) -> None:
271
+ """
272
+ Add surface data rectangle to Visualization data.
273
+
274
+ Parameters
275
+ ----------
276
+ rectangle_vertices: List[List[float]]
277
+ The vertices of the rectangle.
278
+
279
+ Returns
280
+ -------
281
+ None
282
+ """
283
+ import pyvista as pv
284
+
285
+ if len(rectangle_vertices) != 3 or any(len(vertex) != 3 for vertex in rectangle_vertices):
286
+ raise ValueError(
287
+ "rectangle_vertices is expected to be composed of 3 vertices with 3 elements each."
288
+ )
289
+ self.__data = self.__data.append_polydata(pv.Rectangle(rectangle_vertices))