-
Notifications
You must be signed in to change notification settings - Fork 48
feat: physical quantities baseline code #3988
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
base: main
Are you sure you want to change the base?
Conversation
@@ -176,3 +179,9 @@ def version_info() -> str: | |||
|
|||
# Skip password check during rpc execution when Fluent is launched from PyFluent | |||
LAUNCH_FLUENT_SKIP_PASSWORD_CHECK = False | |||
|
|||
# `ansys.physicalquantities` will eventually be a separate package. Until then: | |||
# Inject `physicalquantities` into the `ansys` namespace if it doesn't already exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to use it this way requires importing PyFluent up front.
if not hasattr(sys.modules["ansys"], "physicalquantities"): | ||
sys.modules["ansys.physicalquantities"] = physicalquantities | ||
sys.modules["ansys"].physicalquantities = physicalquantities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoding module names as strings can lead to typos and makes refactoring harder. We can use constants or variables so that it will improve the error handling as follows::
ANSYS_MODULE = "ansys"
QUANTITIES_ATTR = "physicalquantities"
ANSYS_QUANTITIES_MODULE = f"{ANSYS_MODULE }.{QUANTITIES_ATTR }"
ansys_module = sys.modules.get(ANSYS_MODULE)
if ansys_module is not None and not hasattr(ansys_module , QUANTITIES_ATTR):
sys.modules[ANSYS_QUANTITIES_MODULE] = QUANTITIES_ATTR
setattr(ansys_module, QUANTITIES_ATTR, QUANTITIES_ATTR )
else:
raise ImportError(f"Module '{ANSYS_MODULE}' not found in sys.modules")
Example | ||
------- | ||
|
||
.. code-block:: python | ||
|
||
>>> from ansys.fluent.core.physicalquantities import PhysicalQuantities | ||
>>> from ansys.fluent.core.physicalquantities.strategies.fluent import FluentSVarStrategy | ||
|
||
>>> quantity = PhysicalQuantities.PRESSURE | ||
>>> strategy = FluentSVarStrategy() | ||
|
||
>>> print(strategy.to_string(quantity)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This will help to improve both user guide and API reference section.
This is just for demonstration purposes.
Provides a structured, extensible way to represent physical quantities (e.g., pressure, velocity) independently of any product-specific naming conventions.