Skip to content

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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

seanpearsonuk
Copy link
Collaborator

@seanpearsonuk seanpearsonuk commented Apr 30, 2025

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.

@@ -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
Copy link
Collaborator Author

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.

@seanpearsonuk seanpearsonuk changed the title physical quantities baseline code feat: physical quantities baseline code May 1, 2025
@github-actions github-actions bot added the new feature Request or proposal for a new feature label May 1, 2025
Comment on lines +185 to +187
if not hasattr(sys.modules["ansys"], "physicalquantities"):
sys.modules["ansys.physicalquantities"] = physicalquantities
sys.modules["ansys"].physicalquantities = physicalquantities
Copy link
Collaborator

@hpohekar hpohekar May 5, 2025

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")

Comment on lines +29 to +40
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))
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Request or proposal for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants