ansys / pyfluent

Pythonic interface to Ansys Fluent
https://fluent.docs.pyansys.com
MIT License
265 stars 41 forks source link

Problem with overwriting fluent output files #1741

Open domengnidovec opened 1 year ago

domengnidovec commented 1 year ago

🐞 Description of the bug

Hello everybody,

I am dealing with multi-scale-modelling as a project for my master thesis. I already have a fluent journal file scripts written and then running these scripts though terminal with python. Since the nature of the modelling is such that there is a lot of iterating through the same case (same .cas file), the journal file code provided below is kind of slow:

pwd

/file/confirm-overwrite yes

/file/read-case TransientUDF.cas.h5

/file/read-data transient_state_5.dat.h5

/solve/set/time-step 0.02

/solve/dual-time-iterate 1 150

no

yes

/file/write-data "transient_state_6.dat.h5"

yes

/exit ok

In order to make my model faster, I discovered pyansys package, more exactly ansys.fluent.core. I managed to convert basically the whole journal file in your function calls, except I really can’t find how to deal with overwriting output files. By default, it creates new file if there already exists one, but I want my files to be overwritten. In journal file I simply input “no” or “yes” statements as the answer to the prompts that are raised in fluent. Here is different and I kindly ask if you can provide me any function or advice on how to have my output files overwritten.

Moreover, I want to ask about reading and writing files. Apparently using TUI object doesn’t succeed to reed and write files, while using ROOT object does the work. Can you additionally explain if there is some mistake from my side or is there some kind of bug. If there is a way to resolve this I would prefer to use TUI object rather than ROOT, if not I am okay with ROOT object as well.

I kindly ask for your feedback; it would help a lot in the progress of my master thesis! Thanks in advance.

Best regards!

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

2023 R1

🐍 Which Python version are you using?

3.9

📦 Installed packages

aiofiles @ file:///C:/b/abs_9ex6mi6b56/croot/aiofiles_1683773603390/work
aiosqlite @ file:///C:/b/abs_9djc_0pyi3/croot/aiosqlite_1683773915844/work
anaconda-client==1.11.2
anaconda-navigator==2.4.0
anaconda-project @ file:///C:/Windows/TEMP/abs_91fu4tfkih/croots/recipe/anaconda-project_1660339890874/work
ansys-api-fluent==0.3.12
ansys-api-mapdl==0.5.1
ansys-api-mechanical==0.1.0
ansys-api-meshing-prime==0.1.1
ansys-api-platform-instancemanagement==1.0.0b3
ansys-api-sherlock==0.1.14
ansys-api-systemcoupling==0.1.0
ansys-dpf-composites==0.2.0
ansys-dpf-core==0.8.1
ansys-dpf-gate==0.3.1
ansys-dpf-gatebin==0.3.1
ansys-dpf-post==0.4.0
ansys-fluent-core==0.14.0
ansys-fluent-parametric==0.7.1
ansys-fluent-visualization==0.7.1
ansys-grantami-bomanalytics==1.1.3
ansys-grantami-bomanalytics-openapi==1.0.0
ansys-grantami-recordlists==1.0.0
ansys-grantami-serverapi-openapi==1.0.0
ansys-grpc-dpf==0.7.1
ansys-mapdl-core==0.64.1
ansys-mapdl-reader==0.52.16
ansys-math-core==0.1.1
ansys-mechanical-core==0.8.0
ansys-meshing-prime==0.3.2
ansys-motorcad-core==0.1.3
ansys-openapi-common==1.2.1
ansys-optislang-core==0.2.1
ansys-platform-instancemanagement==1.1.1
ansys-pythonnet==3.1.0rc1
ansys-seascape==0.2.0
ansys-sherlock-core==0.2.0
ansys-systemcoupling-core==0.1.3
anyio @ file:///C:/ci/anyio_1644481856696/work/dist
appdirs==1.4.4
argon2-cffi @ file:///opt/conda/conda-bld/argon2-cffi_1645000214183/work
argon2-cffi-bindings @ file:///C:/ci/argon2-cffi-bindings_1644569876605/work
asttokens @ file:///opt/conda/conda-bld/asttokens_1646925590279/work
attrs @ file:///C:/b/abs_09s3y775ra/croot/attrs_1668696195628/work
Babel @ file:///C:/b/abs_a2shv_3tqi/croot/babel_1671782804377/work
backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work
backports.functools-lru-cache @ file:///tmp/build/80754af9/backports.functools_lru_cache_1618170165463/work
backports.tempfile @ file:///home/linux1/recipes/ci/backports.tempfile_1610991236607/work
backports.weakref==1.0.post1
beautifulsoup4 @ file:///C:/b/abs_0agyz1wsr4/croot/beautifulsoup4-split_1681493048687/work
bleach @ file:///opt/conda/conda-bld/bleach_1641577558959/work
boltons @ file:///C:/b/abs_707eo7c09t/croot/boltons_1677628723117/work
Bottleneck==1.3.7
brotlipy==0.7.0
cachetools==5.3.1
certifi @ file:///C:/b/abs_4a0polqwty/croot/certifi_1683875377622/work/certifi
cffi @ file:///C:/b/abs_49n3v2hyhr/croot/cffi_1670423218144/work
chardet @ file:///C:/ci_310/chardet_1642114080098/work
charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work
click==8.1.3
clr-loader==0.2.5
clyent==1.2.2
colorama @ file:///C:/b/abs_a9ozq0l032/croot/colorama_1672387194846/work
comm @ file:///C:/b/abs_1419earm7u/croot/comm_1671231131638/work
conda @ file:///C:/b/abs_a1khk4epoo/croot/conda_1685025197412/work
conda-build==3.24.0
conda-content-trust @ file:///C:/Windows/TEMP/abs_4589313d-fc62-4ccc-81c0-b801b4449e833j1ajrwu/croots/recipe/conda-content-trust_1658126379362/work
conda-pack @ file:///tmp/build/80754af9/conda-pack_1611163042455/work
conda-package-handling @ file:///C:/b/abs_fcga8w0uem/croot/conda-package-handling_1672865024290/work
conda-repo-cli==1.0.41
conda-token @ file:///Users/paulyim/miniconda3/envs/c3i/conda-bld/conda-token_1662660369760/work
conda-verify==3.4.2
conda_package_streaming @ file:///C:/b/abs_0e5n5hdal3/croot/conda-package-streaming_1670508162902/work
contourpy==1.1.0
cryptography @ file:///C:/b/abs_8ecplyc3n2/croot/cryptography_1677533105000/work
cycler==0.11.0
debugpy @ file:///C:/ci_310/debugpy_1642079916595/work
decorator @ file:///opt/conda/conda-bld/decorator_1643638310831/work
defusedxml @ file:///tmp/build/80754af9/defusedxml_1615228127516/work
entrypoints @ file:///C:/ci/entrypoints_1649926676279/work
executing @ file:///opt/conda/conda-bld/executing_1646925071911/work
fastjsonschema @ file:///C:/Users/BUILDE~1/AppData/Local/Temp/abs_ebruxzvd08/croots/recipe/python-fastjsonschema_1661376484940/work
filelock @ file:///C:/b/abs_c7yrhs9uz2/croot/filelock_1672387617533/work
fonttools==4.40.0
future @ file:///C:/b/abs_3dcibf18zi/croot/future_1677599891380/work
glob2 @ file:///home/linux1/recipes/ci/glob2_1610991677669/work
google-api-core==2.11.1
google-api-python-client==2.90.0
google-auth==2.21.0
google-auth-httplib2==0.1.0
googleapis-common-protos==1.59.1
grpcio==1.56.0
grpcio-status==1.48.2
h5py==3.9.0
httplib2==0.22.0
idna @ file:///C:/b/abs_bdhbebrioa/croot/idna_1666125572046/work
importlib-metadata==6.7.0
ipykernel @ file:///C:/b/abs_b4f07tbsyd/croot/ipykernel_1672767104060/work
ipython @ file:///C:/b/abs_d1yx5tjhli/croot/ipython_1680701887259/work
ipython-genutils @ file:///tmp/build/80754af9/ipython_genutils_1606773439826/work
ipywidgets @ file:///C:/b/abs_5awapknmz_/croot/ipywidgets_1679394824767/work
jedi @ file:///C:/ci/jedi_1644315428305/work
Jinja2 @ file:///C:/b/abs_7cdis66kl9/croot/jinja2_1666908141852/work
json5 @ file:///tmp/build/80754af9/json5_1624432770122/work
jsonpatch @ file:///tmp/build/80754af9/jsonpatch_1615747632069/work
jsonpointer==2.1
jsonschema @ file:///C:/b/abs_6ccs97j_l8/croot/jsonschema_1676558690963/work
jupyter @ file:///C:/Windows/TEMP/abs_56xfdi__li/croots/recipe/jupyter_1659349053177/work
jupyter-console @ file:///C:/b/abs_82xaa6i2y4/croot/jupyter_console_1680000189372/work
jupyter-events @ file:///C:/b/abs_4cak_28ewz/croot/jupyter_events_1684268050893/work
jupyter-ydoc @ file:///C:/b/abs_e7m6nh5lao/croot/jupyter_ydoc_1683747253535/work
jupyter_client @ file:///C:/b/abs_059idvdagk/croot/jupyter_client_1680171872444/work
jupyter_core @ file:///C:/b/abs_9d0ttho3bs/croot/jupyter_core_1679906581955/work
jupyter_server @ file:///C:/b/abs_3eh8sm27tx/croot/jupyter_server_1686059851383/work
jupyter_server_fileid @ file:///C:/b/abs_f1yjnmiq_6/croot/jupyter_server_fileid_1684273602142/work
jupyter_server_terminals @ file:///C:/b/abs_ec0dq4b50j/croot/jupyter_server_terminals_1686870763512/work
jupyter_server_ydoc @ file:///C:/b/abs_8ai39bligw/croot/jupyter_server_ydoc_1686767445888/work
jupyterlab @ file:///C:/b/abs_c1msr8zz3y/croot/jupyterlab_1686179674844/work
jupyterlab-pygments @ file:///tmp/build/80754af9/jupyterlab_pygments_1601490720602/work
jupyterlab-widgets @ file:///C:/b/abs_38ad427jkz/croot/jupyterlab_widgets_1679055289211/work
jupyterlab_server @ file:///C:/b/abs_e0qqsihjvl/croot/jupyterlab_server_1680792526136/work
kiwisolver==1.4.4
libarchive-c @ file:///tmp/build/80754af9/python-libarchive-c_1617780486945/work
lxml @ file:///C:/b/abs_c2bg6ck92l/croot/lxml_1679646459966/work
MarkupSafe @ file:///C:/ci/markupsafe_1654508036328/work
matplotlib==3.7.1
matplotlib-inline @ file:///C:/ci/matplotlib-inline_1661934094726/work
menuinst @ file:///C:/Users/BUILDE~1/AppData/Local/Temp/abs_455sf5o0ct/croots/recipe/menuinst_1661805970842/work
mistune @ file:///C:/ci_310/mistune_1642084168466/work
navigator-updater==0.4.0
nbclassic @ file:///C:/b/abs_c8_rs7b3zw/croot/nbclassic_1681756186106/work
nbclient @ file:///C:/ci/nbclient_1650308592199/work
nbconvert @ file:///C:/b/abs_4av3q4okro/croot/nbconvert_1668450658054/work
nbformat @ file:///C:/b/abs_85_3g7dkt4/croot/nbformat_1670352343720/work
nest-asyncio @ file:///C:/b/abs_3a_4jsjlqu/croot/nest-asyncio_1672387322800/work
nodejs==0.1.1
notebook @ file:///C:/b/abs_49d8mc_lpe/croot/notebook_1681756182078/work
notebook_shim @ file:///C:/b/abs_ebfczttg6x/croot/notebook-shim_1668160590914/work
numexpr==2.8.4
numpy==1.25.0
optional-django==0.1.0
packaging @ file:///C:/b/abs_ed_kb9w6g4/croot/packaging_1678965418855/work
pandas==2.0.2
pandocfilters @ file:///opt/conda/conda-bld/pandocfilters_1643405455980/work
parso @ file:///opt/conda/conda-bld/parso_1641458642106/work
pathlib @ file:///Users/ktietz/demo/mc3/conda-bld/pathlib_1629713961906/work
pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work
Pillow==9.4.0
pkginfo @ file:///C:/b/abs_d18srtr68x/croot/pkginfo_1679431192239/work
platformdirs @ file:///C:/b/abs_73cc5cz_1u/croots/recipe/platformdirs_1662711386458/work
pluggy @ file:///C:/ci/pluggy_1648042746254/work
plumbum==1.8.2
ply==3.11
pooch==1.7.0
prometheus-client @ file:///C:/Windows/TEMP/abs_ab9nx8qb08/croots/recipe/prometheus_client_1659455104602/work
prompt-toolkit @ file:///C:/b/abs_6coz5_9f2s/croot/prompt-toolkit_1672387908312/work
protobuf==3.20.3
protoc-gen-swagger==0.1.0
psutil==5.9.5
pure-eval @ file:///opt/conda/conda-bld/pure_eval_1646925070566/work
pyaedt==0.6.76
pyansys==2023.2.4
pyansys-tools-versioning==0.4.0
pyasn1==0.5.0
pyasn1-modules==0.3.0
pycosat @ file:///C:/b/abs_4b1rrw8pn9/croot/pycosat_1666807711599/work
pycparser @ file:///tmp/build/80754af9/pycparser_1636541352034/work
Pygments @ file:///C:/b/abs_fay9dpq4n_/croot/pygments_1684279990574/work
pyiges==0.3.0
PyJWT @ file:///C:/ci/pyjwt_1657529477795/work
pyOpenSSL @ file:///C:/b/abs_552w85x1jz/croot/pyopenssl_1677607703691/work
pyparsing==3.1.0
pypiwin32==223
PyQt5==5.15.7
PyQt5-sip @ file:///C:/Windows/Temp/abs_d7gmd2jg8i/croots/recipe/pyqt-split_1659273064801/work/pyqt_sip
pyreadline3==3.4.1
pyrsistent @ file:///C:/ci_310/pyrsistent_1642117077485/work
PySide6==6.5.1.1
PySide6-Addons==6.5.1.1
PySide6-Essentials==6.5.1.1
PySocks @ file:///C:/ci_310/pysocks_1642089375450/work
pyspnego==0.9.1
python-dateutil @ file:///tmp/build/80754af9/python-dateutil_1626374649649/work
python-json-logger @ file:///C:/b/abs_cblnsm6puj/croot/python-json-logger_1683824130469/work
pythonnet==3.0.1
pytwin==0.3.0
pytz @ file:///C:/b/abs_22fofvpn1x/croot/pytz_1671698059864/work
pyvista==0.39.1
pyvistaqt==0.10.0
pywin32==305.1
pywinpty @ file:///C:/b/abs_73vshmevwq/croot/pywinpty_1677609966356/work/target/wheels/pywinpty-2.0.10-cp310-none-win_amd64.whl
PyYAML @ file:///C:/b/abs_d0g7dqt2xw/croot/pyyaml_1670514768165/work
pyzmq @ file:///C:/b/abs_655zk4a3s8/croot/pyzmq_1686601465034/work
qtconsole @ file:///C:/b/abs_eb4u9jg07y/croot/qtconsole_1681402843494/work
QtPy @ file:///C:/ci/qtpy_1662015130233/work
requests @ file:///C:/b/abs_41owkd5ymz/croot/requests_1682607524657/work
requests-negotiate-sspi==0.5.2
requests-ntlm==1.2.0
requests-toolbelt @ file:///Users/ktietz/demo/mc3/conda-bld/requests-toolbelt_1629456163440/work
rfc3339-validator @ file:///C:/b/abs_ddfmseb_vm/croot/rfc3339-validator_1683077054906/work
rfc3986-validator @ file:///C:/b/abs_6e9azihr8o/croot/rfc3986-validator_1683059049737/work
rpyc==5.3.1
rsa==4.9
ruamel-yaml-conda @ file:///C:/b/abs_6ejaexx82s/croot/ruamel_yaml_1667489767827/work
ruamel.yaml @ file:///C:/b/abs_30ee5qbthd/croot/ruamel.yaml_1666304562000/work
ruamel.yaml.clib @ file:///C:/b/abs_aarblxbilo/croot/ruamel.yaml.clib_1666302270884/work
scipy==1.10.1
scooby==0.7.2
Send2Trash @ file:///tmp/build/80754af9/send2trash_1632406701022/work
shiboken6==6.5.1.1
sip @ file:///C:/Windows/Temp/abs_b8fxd17m2u/croots/recipe/sip_1659012372737/work
six @ file:///tmp/build/80754af9/six_1644875935023/work
sniffio @ file:///C:/ci_310/sniffio_1642092172680/work
soupsieve @ file:///C:/b/abs_a989exj3q6/croot/soupsieve_1680518492466/work
stack-data @ file:///opt/conda/conda-bld/stack_data_1646927590127/work
terminado @ file:///C:/b/abs_25nakickad/croot/terminado_1671751845491/work
tinycss2 @ file:///C:/b/abs_52w5vfuaax/croot/tinycss2_1668168823131/work
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tomli @ file:///C:/Windows/TEMP/abs_ac109f85-a7b3-4b4d-bcfd-52622eceddf0hy332ojo/croots/recipe/tomli_1657175513137/work
toolz @ file:///C:/b/abs_cfvk6rc40d/croot/toolz_1667464080130/work
tornado @ file:///C:/ci/tornado_1662476985533/work
tqdm @ file:///C:/b/abs_f76j9hg7pv/croot/tqdm_1679561871187/work
traitlets @ file:///C:/b/abs_e5m_xjjl94/croot/traitlets_1671143896266/work
typing_extensions @ file:///C:/b/abs_5em9ekwz24/croot/typing_extensions_1686602003259/work
tzdata==2023.3
ujson @ file:///C:/ci/ujson_1657525893897/work
uritemplate==4.1.1
urllib3 @ file:///C:/b/abs_889_loyqv4/croot/urllib3_1686163174463/work
vtk==9.2.6
wcwidth @ file:///Users/ktietz/demo/mc3/conda-bld/wcwidth_1629357192024/work
webencodings==0.5.1
websocket-client @ file:///C:/ci_310/websocket-client_1642093970919/work
widgetsnbextension @ file:///C:/b/abs_882k4_4kdf/croot/widgetsnbextension_1679313880295/work
win-inet-pton @ file:///C:/ci_310/win_inet_pton_1642658466512/work
wincertstore==0.2
y-py @ file:///C:/b/abs_b7f5go6r0j/croot/y-py_1683662173571/work
ypy-websocket @ file:///C:/b/abs_4e65ywlnv8/croot/ypy-websocket_1684172103529/work
zipp==3.15.0
zstandard==0.19.0
seanpearsonuk commented 1 year ago

Hello @domengnidovec I have changed this to question (it is a question). I cannot see your Python code, but no matter. If in your Python version of this script, you are directly calling TUI commands via Python (e.g. solver.tui.file.write_data then the prompts that would normally be issued by the TUI become arguments instead. E.g., solver.tui.file.write_data(file_name, "yes"). If you are using the new settings objects interface for that operation, it will anyway overwrite the file automatically. N.b. you can also generate the Python equivalent of TUI scripts by journaling to Python in Fluent.

domengnidovec commented 1 year ago

Dear Sean Pearson,

Thank you very much for your reply, I appreciate it very much! What I am also interested in is the overwriting of report files when running the simulation. For example, when running steady-state simulation with this command: solver.tui.solve.iterate(500) prompts issued in the GUI are if I want to create new files and, if no, if I am okay with overwriting. I dont want to create new files and want to overwrite my report files. Is the method of defining this commands the same, something like: solve.tui.solve.iterate(500, "no", "yes"), where "no" is an answer to the questions if I want to create new files and "yes" is the answer to the question if I am okay with that. I kindly ask for your help.

Thanks in advance.

Best regards,

Domen Gnidovec

V V pon., 3. jul. 2023 ob 10:33 je oseba Sean Pearson < @.***> napisala:

Hello @domengnidovec https://github.com/domengnidovec I have changed this to question (it is a question). I cannot see your Python code, but no matter. If in your Python version of this script, you are directly calling TUI commands via Python (e.g. solver.tui.file.write_data then the prompts that would normally be issued by the TUI become arguments instead. E.g., solver.tui.file.write_data(file_name, "yes"). If you are using the new settings objects interface for that operation, it will anyway overwrite the file automatically.

— Reply to this email directly, view it on GitHub https://github.com/ansys/pyfluent/issues/1741#issuecomment-1617626986, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ5OEGDE7KLNXFJISXNSX23XOJ7V5ANCNFSM6AAAAAAZYWSJQA . You are receiving this because you were mentioned.Message ID: @.***>

seanpearsonuk commented 1 year ago

@domengnidovec when you run /solve/iterate 500 does the TUI prompt for yes and no answers about those files?

domengnidovec commented 1 year ago

Yes, exactly. Even if I write TUI command in graphics, it prompts for yes and no answers about overwriting report files. Here is my problem, because I dont know how to answer this through TUI object. As you can see in journal file it is handled simply by just inputting yes and no.

seanpearsonuk commented 1 year ago

@domengnidovec as I mentioned previously, those TUI prompts need to be provided as arguments to the Python "TUI" method. Is that point clear?