Description
🔍 Before submitting the issue
- I have searched among the existing issues
- I am using a Python virtual environment
🐞 Description of the bug
I am using Fluent v 2024R2, Python v 3.11.8, Pyfluent v 0.30.5.
I am attempting to build a case-assembly script. I am creating a new particle injection, and I need to hook a loaded user-defined function for the Drag Law. The code that should be able to do this is:
solver.setup.models.discrete_phase.injections["your_injection_name"].physical_models.particle_drag.option = "udf 'your_udf_name'"
This raises an error. The allowed values (accessed through option.allowed_values()
) are not updated when the UDF library is loaded. I've tried a couple of work arounds using the _setattr()
command, but I am not familiar enough with the background processes to know how to do this effectively.
I am looking for a work around to append the allowed-values' attribute of the option object and I'd like to see the code appended for future versions so that the attribute is automatically updated based on the presence of a DEFINE_DPM_DRAG UDF in the loaded UDF library.
Quick note: I do have a working solver.tui . . .
approach for accomplishing the injection setup for now, but the tui argument strings vary with other submodels, so controlling the case setup through direct object manipulation is much more robust. I look forward to learning a little more about the background processes so I can recommend similar edits in the future (I run into this sort of issue frequently when working with Pyfluent).
Thank you for any and all feedback!
Morgan
📝 Steps to reproduce
- Connect to Fluent and obtain a
solver
object. - Load a DEFINE_DPM_DRAG UDF with the name "test_drag" as a compiled function.
- Execute these commands:
solver.setup.models.discrete_phase.injections.create("test")
solver.setup.models.discrete_phase.injections["test"].physical_models.particle_drag.option = "udf test_drag::libudf"
The second command raises the error.
💻 Which operating system are you using?
Windows
📀 Which ANSYS version are you using?
2024 R2
🐍 Which Python version are you using?
3.11
📦 Installed packages
ansys-api-fluent==0.3.35
ansys-api-platform-instancemanagement==1.1.3
ansys-api-tools-filetransfer==0.1.1
ansys-fluent-core==0.30.5
ansys-platform-instancemanagement==1.1.2
ansys-tools-filetransfer==0.1.1
ansys-units==0.4.0
certifi==2025.4.26
charset-normalizer==3.4.2
click==8.1.8
colorama==0.4.6
contourpy==1.3.2
cycler==0.12.1
defusedxml==0.7.1
docker==7.1.0
et_xmlfile==2.0.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.7.0
joblib==1.5.0
julia==0.6.2
kiwisolver==1.4.8
matplotlib==3.10.1
nltk==3.9.1
numpy==2.2.5
openpyxl==3.1.5
packaging==25.0
pandas==2.2.3
pillow==11.2.1
protobuf==4.25.7
pyansys-tools-report==0.8.2
Pygments==2.19.1
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.1
six==1.17.0
tqdm==4.67.1
typing_extensions==4.13.2
tzdata==2025.2
urllib3==2.4.0
vedo==2025.5.3
vtk==9.4.2
zipp==3.21.0