pyfluent: pySystemCoupling example fails with update of pyFluent to 0.30.2

🔍 Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

🐞 Description of the bug

pySystemCoupling has a doc build dependency on ansys-fluent-core as pyFluent is used in a number of our Sphinx Gallery examples. A dependabot PR was created recently to upgrade the dependency from 0.29.0 to 0.30.2. The doc builds are consistently failing for this update.

The issue is seen in the oscillating_plate example. This couples pyFluent with pyMAPDL. The main solve works fine but some Fluent post-processing facilities are used after the solve to generate a contour plot. The error is in a line that attempts to set the coloring.option value of a contour object to "banded". The error from pyFluent is that the coloring setting is currently “inactive”.

These are the relevant lines of code, for context:

fluent.results.graphics.contour["contour_static_pressure"] = {}
contour = fluent.results.graphics.contour["contour_static_pressure"]

contour.coloring.option = "banded"

This is the traceback:

Traceback (most recent call last):
  File "D:\Scratch\pyfluent_issue\oscillating_plate.py", line 234, in <module>
    contour.coloring.option = "banded"
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Scratch\pyfluent_issue\venv\Lib\site-packages\ansys\fluent\core\solver\flobject.py", line 1163, in __setattr__
    attr = getattr(self, name)
           ^^^^^^^^^^^^^^^^^^^
  File "D:\Scratch\pyfluent_issue\venv\Lib\site-packages\ansys\fluent\core\solver\flobject.py", line 1133, in __getattribute__
    raise InactiveObjectError(self.python_path)
ansys.fluent.core.solver.flobject.InactiveObjectError: '<session>.settings.results.graphics.contour["contour_static_pressure"].coloring' is currently inactive.

📝 Steps to reproduce

Although the GitHub run that fails is using a mixture of 25.1 and 25.2 components (Fluent and MAPDL using 25.1 images and SyC using a 25.2 image) this is not critical. To reproduce the issue on the desktop it was simpler to work with a recent 25.2 unified install so it is assumed in the following that this is available.

Steps are as follows:

  1. Create a clean directory as a working directory.
  2. From the pysystem-coupling repo, download the oscillating_plate.py file from examples/00-systemcoupling and copy to the working directory.
  3. From the pysystem-coupling repo download the ansys-systemcoupling-core-artifacts.zip archive from a recent build on main: (i) Go to Actions “tab”. (ii) Select “GitHub CI” on left sidebar. (iii) Select most recent run on “main” from the list of workflow runs. (iv) Scroll to find ansys-systemcoupling-core-artifacts, and click download icon on right.
  4. Copy the whl file from the downloaded artifact into the working directory.
  5. (i) Edit line 94 of oscillating_plate.py to add a version argument as follows: syc = pysyc.launch(start_output=True, version="25.2") (ii) Edit line 198 to reduce the end_time setting to 1 (keeps the run time manageable): syc.setup.solution_control.end_time = 1
  6. Create and activate a virtual environment. NB At this point the working directory should contain only the virtual env subdirectory, the oscillating_plate script and the whl file.
  7. pip install the PySystemCoupling wheel.
  8. pip install ansys-mapdl-core==0.69.3
  9. pip install ansys-fluent-core==0.29.0
  10. Run the script (python oscillating_plate.py) It should run to completion successfully and there should be a file oscplate_pressure_contour.png in the working directory which has been generated using Fluent postprocessing. (Note: Very occasionally, there might be a failure near the beginning of the run where the solvers fail to connect. If this happens try running the script again.)
  11. Clean up the working directory so that it contains only the three items mentioned in (6).
  12. pip uninstall ansys-fluent-core
  13. pip install ansys-fluent-core==0.30.2
  14. Repeat the run (python oscillating_plate.py). This time it fails at line 234 (contour.coloring.option = "banded"). The error is ansys.fluent.core.solver.flobject.InactiveObjectError: '<session>.settings.results.graphics.contour["contour_static_pressure"].coloring' is currently inactive.

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

25.2

🐍 Which Python version are you using?

3.11

📦 Installed packages

aiohappyeyeballs==2.6.1
aiohttp==3.11.18
aiosignal==1.3.2
ansys-api-fluent==0.3.35
ansys-api-mapdl==0.5.2
ansys-api-platform-instancemanagement==1.1.3
ansys-api-systemcoupling==0.2.0
ansys-api-tools-filetransfer==0.1.1
ansys-fluent-core==0.30.2
ansys-mapdl-core==0.69.3
ansys-mapdl-reader==0.54.2
ansys-math-core==0.2.2
ansys-platform-instancemanagement==1.1.2
ansys-systemcoupling-core @ file:///D:/Scratch/pyfluent_issue/ansys_systemcoupling_core-0.10.dev0-py3-none-any.whl#sha256=7126decc031f5beaa1f71533e72a90b11203de369eff0e407fac818640c57314
ansys-tools-filetransfer==0.1.1
ansys-tools-path==0.7.1
ansys-tools-visualization-interface==0.9.1
ansys-units==0.4.0
appdirs==1.4.4
attrs==24.2.0
certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
contourpy==1.3.2
cycler==0.12.1
defusedxml==0.7.1
docker==7.1.0
fonttools==4.57.0
frozenlist==1.6.0
geomdl==5.3.1
googleapis-common-protos==1.70.0
grpcio==1.71.0
grpcio-health-checking==1.62.3
grpcio-status==1.62.3
idna==3.10
importlib_metadata==8.6.1
joblib==1.4.2
kiwisolver==1.4.8
lxml==5.4.0
matplotlib==3.10.1
more-itertools==10.7.0
msgpack==1.1.0
multidict==6.4.3
nltk==3.9.1
numpy==2.2.5
packaging==25.0
pandas==2.2.3
pillow==11.2.1
platformdirs==4.3.7
pooch==1.8.2
propcache==0.3.1
protobuf==4.25.6
psutil==7.0.0
pyansys-tools-report==0.8.2
pyansys-tools-versioning==0.6.0
pyiges==0.3.1
pyparsing==3.2.3
python-dateutil==2.9.0.post0
pytz==2025.2
pyvista==0.45.0
pywin32==310
PyYAML==6.0.2
regex==2024.11.6
requests==2.32.3
scipy==1.15.2
scooby==0.10.0
six==1.17.0
tabulate==0.9.0
tqdm==4.67.1
trame==3.8.2
trame-client==3.7.1
trame-server==3.4.0
trame-vtk==2.8.15
trame-vuetify==3.0.1
typing_extensions==4.13.2
tzdata==2025.2
urllib3==2.4.0
vtk==9.4.2
websockets==15.0.1
wslink==2.3.3
yarl==1.20.0
zipp==3.21.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17

Most upvoted comments

@iboyd-ansys I have checked above working solution with 25R2 dev area.

Thanks @hpohekar .

So if I understand the idea is to apply the contour settings in one go using a state dictionary and that avoids the issue.

Should I also apply @prmukherj’s suggested change at the same time?

@iboyd-ansys You can use either the dictionary approach or the solution suggested by @prmukherj.

@iboyd-ansys I have checked above working solution with 25R2 dev area.

Thanks @hpohekar .

So if I understand the idea is to apply the contour settings in one go using a state dictionary and that avoids the issue.

Should I also apply @prmukherj’s suggested change at the same time?

You can just change that single line using the solution I have provided. Please update any other instances of the same if they exist. Thank you @iboyd-ansys

“colorings”

Thanks for confirming @prmukherj. I hadn’t been sure if this was a typo.

@iboyd-ansys I have checked above working solution with 25R2 dev area.

Actually there are 2 solutions for this:

  1. Please use “colorings.banded = True” instead of contour.coloring.option = “banded”. This is the updated syntax from settings-api. However the earlier should also work.
  2. For the deprecated to work, there was a small bug in PyFluent side. It has been fixed now and the change is in the latest main branch. We’ll soon create a dev release with it if required.

Please revert if you face further issues.

cc. @iboyd-ansys, @seanpearsonuk, @hpohekar, @mkundu1

Yes, I have confirmed that the inactive error was triggered from the is_deprecated() call.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "d:\test\test\Lib\site-packages\ansys\fluent\core\solver\flobject.py", line 1097, in __dir__
    if getattr(self, child)._is_deprecated()
       ~~~~~~~^^^^^^^^^^^^^
  File "d:\test\test\Lib\site-packages\ansys\fluent\core\solver\flobject.py", line 1133, in __getattribute__
    raise InactiveObjectError(self.python_path)
ansys.fluent.core.solver.flobject.InactiveObjectError: '<session>.settings.results.graphics.contour["contour_static_pressure"].coloring' is currently inactive.

Actually there are 2 solutions for this:

  1. Please use “colorings.banded = True” instead of contour.coloring.option = “banded”. This is the updated syntax from settings-api. However the earlier should also work.
  2. For the deprecated to work, there was a small bug in PyFluent side. It has been fixed now and the change is in the latest main branch. We’ll soon create a dev release with it if required.

Please revert if you face further issues.

cc. @iboyd-ansys, @seanpearsonuk, @hpohekar, @mkundu1

@seanpearsonuk @iboyd-ansys

I have tested Fluent part from the oscillating_plate.py

Following modification works fine with Fluent 25.2

import ansys.fluent.core as pyfluent
from ansys.systemcoupling.core import examples

fluent_cas_file = examples.download_file(
    "oscillating_plate.cas.h5", "pysystem-coupling/oscillating_plate"
)

fluent = pyfluent.launch_fluent()

fluent.file.read(file_type="case", file_name=fluent_cas_file)

fluent.solution.initialization.initialization_type = "standard"
fluent.solution.initialization.standard_initialize()

fluent.results.graphics.picture.use_window_resolution = False

fluent.results.graphics.picture.x_resolution = 1920
fluent.results.graphics.picture.y_resolution = 1440

fluent.results.graphics.contour.create(name="contour_static_pressure")
fluent.results.graphics.contour["contour_static_pressure"] = {
    "coloring": {
        "option": "banded",
    },
    "field": "pressure",
    "filled": True,
}
contour = fluent.results.graphics.contour["contour_static_pressure"]

contour.surfaces_list = ["symmetry1", "wall_deforming"]
contour.display()

fluent.results.graphics.views.restore_view(view_name="front")
fluent.results.graphics.views.auto_scale()
fluent.results.graphics.picture.save_picture(file_name="oscplate_pressure_contour.png")

fluent.exit()

oscplate_pressure_contour.png generated successfully.

Image

Image

Tested with ansys-fluent-core==0.30.2

(test) D:\test>pip freeze
ansys-api-fluent==0.3.35
ansys-api-platform-instancemanagement==1.1.3
ansys-api-systemcoupling==0.2.0
ansys-api-tools-filetransfer==0.1.1
ansys-fluent-core==0.30.2
ansys-platform-instancemanagement==1.1.2
ansys-systemcoupling-core @ file:///D:/test/ansys_systemcoupling_core-0.10.dev0-py3-none-any.whl#sha256=066592a44e16e902cb57a8fdd18bb24cfcb14b1a1f510d1590bb62527742abc9
ansys-tools-filetransfer==0.1.1
ansys-units==0.4.0
appdirs==1.4.4
certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
contourpy==1.3.2
cycler==0.12.1
defusedxml==0.7.1
docker==7.1.0
fonttools==4.57.0
googleapis-common-protos==1.70.0
grpcio==1.71.0
grpcio-health-checking==1.62.3
grpcio-status==1.62.3
idna==3.10
importlib_metadata==8.6.1
joblib==1.4.2
kiwisolver==1.4.8
lxml==5.4.0
matplotlib==3.10.1
nltk==3.9.1
numpy==2.2.5
packaging==25.0
pandas==2.2.3
pillow==11.2.1
protobuf==4.25.7
psutil==7.0.0
pyansys-tools-report==0.8.2
pyparsing==3.2.3
python-dateutil==2.9.0.post0
pytz==2025.2
pywin32==310
PyYAML==6.0.2
regex==2024.11.6
requests==2.32.3
scooby==0.10.0
setuptools==79.0.1
six==1.17.0
tqdm==4.67.1
tzdata==2025.2
urllib3==2.4.0
zipp==3.21.0

(test) D:\test>