Skip to content

PyFluent APIs for iteration and exit doesn't work when Fluent server is launched from WB using PyWorkbench #2123

@mkvani

Description

@mkvani

🔍 Before submitting the issue

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

🐞 Description of the bug

PyWorkbench development recently added support for PyFluent. Through this, we can connect to Fluent server (on WB platform).

I was able to connect to Fluent server using this method and setup Fluent case using PyFluent APIs. However, when I try to start iterations or exit, it doesn't work. It seems that Fluent under WB platform performs additional operations before iterating or exiting (save case/date). That is why the PyFluent APIs are not working.

📝 Steps to reproduce

You may have to first install PyWB:

https://workbench.docs.pyansys.com/version/stable/installation.html

Following is the test code for PyFluent. Please execute. It doesn't work for iterations (line 34) and exit (line 37)

##############################

from ansys.workbench.core import launch_workbench
import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples

client_dir = r'D:\users\mvani\PyWB\PyWB-examples\pyfluent_mixing_elbow\client_work_dir'
server_dir = r'D:\users\mvani\PyWB\PyWB-examples\pyfluent_mixing_elbow\server_work_dir'

host = 'localhost'
release = '241'

wb = launch_workbench(release=release, server_workdir=server_dir, client_workdir=client_dir)

Create Fluent system on WB

wb.run_script_string('template1 = GetTemplate(TemplateName="FLUENT")')
wb.run_script_string('system1 = template1.CreateSystem()')

import_filename = examples.download_file("mixing_elbow.msh.h5", "pyfluent/mixing_elbow")
wb.upload_file(import_filename)

Launch Fluent

server_info_file = wb.start_fluent_server(system_name= "FLU")
fluent_session = pyfluent.connect_to_fluent(server_info_filepath= server_info_file)

Read mesh file

import_filename = os.path.join(server_dir, 'mixing_elbow.msh.h5')
fluent_session.file.read(file_type="case", file_name= import_filename)

fluent_session.solution.initialization.hybrid_initialize()

fluent_session.solution.run_calculation.iterate(iter_count=150)

fluent_session.exit()

##########################################################

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

2024 R1

🐍 Which Python version are you using?

3.8

📦 Installed packages

ansys-api-fluent==0.3.17                              
ansys-api-platform-instancemanagement==1.0.0
ansys-api-workbench==0.1.7
ansys-fluent-core==0.17.1
ansys-fluent-visualization==0.7.1
ansys-platform-instancemanagement==1.1.2
ansys-pythonnet==3.1.0rc1
ansys-tools-path==0.3.1
ansys-workbench-core==0.3.dev0
asttokens==2.4.0
backcall==0.2.0
certifi==2023.7.22
cffi==1.15.1
charset-normalizer==3.2.0
clr-loader==0.2.6
colorama==0.4.6
comm==0.1.4
contourpy==1.1.1
cycler==0.12.1
debugpy==1.8.0
decorator==5.1.1
docker==6.1.3
executing==1.2.0
fonttools==4.43.1
grpcio==1.58.0
grpcio-health-checking==1.48.2
h5py==3.9.0
idna==3.4
importlib-metadata==6.8.0
importlib-resources==6.1.0
ipykernel==6.25.2
ipython==8.12.2
jedi==0.19.0
jupyter-client==8.3.1
jupyter-core==5.3.1
kiwisolver==1.4.5
lxml==4.9.3
matplotlib==3.7.3
matplotlib-inline==0.1.6
nest-asyncio==1.5.8
numpy==1.24.4
packaging==23.1
pandas==2.0.3
parso==0.8.3
pickleshare==0.7.5
Pillow==10.0.1
platformdirs==3.10.0
pooch==1.7.0
prompt-toolkit==3.0.39
protobuf==3.20.3
psutil==5.9.5
pure-eval==0.2.2
pycparser==2.21
Pygments==2.16.1
pyparsing==3.1.1
PySide6==6.5.3
PySide6-Addons==6.5.3
PySide6-Essentials==6.5.3
python-dateutil==2.8.2
pytz==2023.3.post1
pyvista==0.42.3
pyvistaqt==0.11.0
pywin32==306
PyYAML==6.0.1
pyzmq==25.1.1
QtPy==2.4.0
requests==2.31.0
scooby==0.7.4
shiboken6==6.5.3
six==1.16.0
stack-data==0.6.2
tornado==6.3.3
tqdm==4.66.1
traitlets==5.10.0
typing-extensions==4.8.0
tzdata==2023.3
urllib3==2.0.5
vtk==9.2.6
wcwidth==0.2.6
websocket-client==1.6.3
WMI==1.5.1
zipp==3.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprove any current implemented feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions