Skip to content

feat: physical quantities baseline code - #3988

Closed
seanpearsonuk wants to merge 13 commits into
mainfrom
feat/physical-quantities
Closed

seanpearsonuk wants to merge 13 commits into
mainfrom
feat/physical-quantities

Conversation

@seanpearsonuk

@seanpearsonuk seanpearsonuk commented Apr 30, 2025 •

Copy link
Copy Markdown
Collaborator

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.

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
Copy Markdown
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

@hpohekar hpohekar May 5, 2025 •

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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.

@seanpearsonuk
seanpearsonuk deleted the feat/physical-quantities branch May 20, 2025 10:24
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