Open germa89 opened 2 years ago
It seems that DPF uses the SET
s for the Scoping
method when using time_freq_steps
location.
I couldn't find a way to use LOAD STEP, SUBSTEP
or CUMULATIVE
in the Scoping
operator. Although most of the times SET
and CUMULATIVE
are the same, we have seen in this VM that it might not be the case.
I found out the solution to my problem hence for me, this issue can be closed. However, I still believe some changes should be implemented to correctly handle this case in the future.
I would recommend then:
time_freq_steps
to time_freq_set
to match MAPDL, or at least clarify this in the documentation.CUMULATIVE
and another for LOAD STEP, SUBSTEP
(although this one can be converted to CUMULATIVE
using get_cumulative_index
.Pinging @pyansys/pydpf-admins for visibility.
Hi @germa89.
I tried replicating and managed to, yet one thing I noticed is you set the scoping to "time_freq_steps", which is not a valid scoping. So I modified your code and got another error. I Think it is basically because if you print the model you'll see that the substep 10 of step 1 is marked as "1".
from ansys.dpf import core as dpf
rst_file = r"D:\ANSYSDev\Sandbox\pydpf-core\Issues\Issue544\file.rst"
model = dpf.Model(rst_file)
print(model)
set_ = (1, 10)
cum_set = model.metadata.time_freq_support.get_cumulative_index(set_[0], set_[1])
print(f"Cumulative set for {set_}: {cum_set}")
scop = dpf.Scoping()
scop.location = dpf.common.locations.time_freq_step
scop.ids = [cum_set]
print(scop)
op = model.results.displacement()
op.inputs.time_scoping.connect(scop)
output = op.outputs.fields_container()[0].data
print(output)
Output obtained:
DPF Model
------------------------------
Static analysis
Unit system: SI: m, kg, s, V, A, K
Physics Type: Mechanical
Available results:
- displacement: Nodal Displacement
- velocity: Nodal Velocity
- acceleration: Nodal Acceleration
- reaction_force: Nodal Force
- element_nodal_forces: ElementalNodal Element nodal Forces
- elemental_volume: Elemental Volume
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
- artificial_hourglass_energy: Elemental Hourglass Energy
- thermal_dissipation_energy: Elemental thermal dissipation energy
- kinetic_energy: Elemental Kinetic Energy
- co_energy: Elemental co-energy
- incremental_energy: Elemental incremental energy
- structural_temperature: ElementalNodal Temperature
------------------------------
DPF Meshed Region:
3 nodes
3 elements
Unit:
With
------------------------------
DPF Time/Freq Support:
Number of sets: 110
Cumulative Time (s) LoadStep Substep
1 0.001000 1 1
2 0.002000 2 1
3 0.003000 2 2
4 0.004000 2 3
5 0.005000 2 4
6 0.006000 2 5
7 0.007000 2 6
8 0.008000 2 7
9 0.009000 2 8
10 0.010000 2 9
11 0.011000 2 10
12 0.012000 2 11
13 0.013000 2 12
14 0.014000 2 13
15 0.015000 2 14
16 0.016000 2 15
17 0.017000 2 16
18 0.018000 2 17
19 0.019000 2 18
20 0.020000 2 19
21 0.021000 2 20
22 0.022000 2 21
23 0.023000 2 22
24 0.024000 2 23
25 0.025000 2 24
26 0.026000 2 25
27 0.027000 2 26
28 0.028000 2 27
29 0.029000 2 28
30 0.030000 2 29
31 0.031000 2 30
32 0.032000 2 31
33 0.033000 2 32
34 0.034000 2 33
35 0.035000 2 34
36 0.036000 2 35
37 0.037000 2 36
38 0.038000 2 37
39 0.039000 2 38
40 0.040000 2 39
41 0.041000 2 40
42 0.042000 2 41
43 0.043000 2 42
44 0.044000 2 43
45 0.045000 2 44
46 0.046000 2 45
47 0.047000 2 46
48 0.048000 2 47
49 0.049000 2 48
50 0.050000 2 49
51 0.051000 2 50
52 0.052000 2 51
53 0.053000 2 52
54 0.054000 2 53
55 0.055000 2 54
56 0.056000 2 55
57 0.057000 2 56
58 0.058000 2 57
59 0.059000 2 58
60 0.060000 2 59
61 0.061000 2 60
62 0.062000 2 61
63 0.063000 2 62
64 0.064000 2 63
65 0.065000 2 64
66 0.066000 2 65
67 0.067000 2 66
68 0.068000 2 67
69 0.069000 2 68
70 0.070000 2 69
71 0.071000 2 70
72 0.072000 2 71
73 0.073000 2 72
74 0.074000 2 73
75 0.075000 2 74
76 0.076000 2 75
77 0.077000 2 76
78 0.078000 2 77
79 0.079000 2 78
80 0.080000 2 79
81 0.081000 2 80
82 0.082000 2 81
83 0.083000 2 82
84 0.084000 2 83
85 0.085000 2 84
86 0.086000 2 85
87 0.087000 2 86
88 0.088000 2 87
89 0.089000 2 88
90 0.090000 2 89
91 0.091000 2 90
92 0.092000 2 91
93 0.093000 2 92
94 0.094000 2 93
95 0.095000 2 94
96 0.096000 2 95
97 0.097000 2 96
98 0.098000 2 97
99 0.099000 2 98
100 0.100000 2 99
101 0.101000 2 100
102 0.102000 2 101
103 0.103000 2 102
104 0.104000 2 103
105 0.105000 2 104
106 0.106000 2 105
107 0.107000 2 106
108 0.108000 2 107
109 0.109000 2 108
110 0.110000 2 109
Cumulative set for (1, 10): 11
DPF Scoping:
with TimeFreq_steps location and 1 entity
Traceback (most recent call last):
File "D:\ANSYSDev\Sandbox\pydpf-core\Issues\Issue544\issue544.py", line 19, in <module>
output = op.outputs.fields_container()[0].data
File "d:\ansysdev\sandbox\pydpf-core\ansys\dpf\core\outputs.py", line 57, in __call__
return self.get_data()
File "d:\ansysdev\sandbox\pydpf-core\ansys\dpf\core\outputs.py", line 54, in get_data
return self._operator.get_output(self._pin, type_output)
File "d:\ansysdev\sandbox\pydpf-core\ansys\dpf\core\dpf_operator.py", line 375, in get_output
parameters = {type_tuple[2]: type_tuple[1](self, pin)}
File "D:\ANSYSDev\Sandbox\pydpf-core\venv\lib\site-packages\ansys\dpf\gate\generated\operator_capi.py", line 368, in operator_getoutput_fields_container
raise errors.DPFServerException(sError.value)
ansys.dpf.gate.errors.DPFServerException: U:28<-step of id 11 doesn't exist
@germa89 further modifying my previous code, I can obtain the right result by asking for:
set_ = (1, 0)
So:
get_cumulative_index
which seems to be zero-based for the substep. Edit: in the server code, the function does ask for a substep_index
and not the substep number, so the problem is in the Python client helper.print(model)
, yet I agree that this should be coherent with the initial numbering in the result file. Hi @germa89. So, following a discussion with Ramdane, it appears that the only thing that is guaranteed bijective between DPF and MAPDL is the Load Step ID. The substep ID or cumulative ID in MAPDL is not guaranteed when running in parallel. Thus DPF generates its own substep ID, starting from 1, for each Load Step. Following this, the "cumulative index" is the zero-based position in the data of the (loadstep+substep) combination, yet what is printed by DPF is a "cumulative ID" starting with one, which is thus equivalent to the MAPDL "set".
Clearly there is a lot going on and this required clarification/fixes.
Indeed a lot of going on... clearly this is challenging.
Thank you very much for your help @PProfizi
Before submitting the issue
Description of the bug
It seems that the scoping operator does not return the correct cumulative index in some cases.
Steps To Reproduce
Use the attached RST file.
file.zip
Open it, and run:
where
output
is:However, using MAPDL, and running:
I get:
I believe the issue is related to
get_cumulative_index
, because it retunscum_set= 11
, whereas MAPDL when issuedset,list
returns10
.If I run with
cum_set
equals1
, I do get the expected result:Which Operating System are you using?
Windows
Which Python version are you using?
3.9
Installed packages
Toggle me!
```text aiohttp==3.8.1 aiosignal==1.2.0 alabaster==0.7.12 ansys-api-mapdl==0.5.1 ansys-api-platform-instancemanagement==1.0.0b3 -e git+https://github.com/pyansys/pydpf-core.git@e03ab109e225bba5c7452c86d0ceb1be6939ce5f#egg=ansys_dpf_core ansys-dpf-gate==0.2.1 ansys-dpf-gatebin==0.2.1 -e git+https://github.com/pyansys/pydpf-post.git@f9a6412f906a0e70c1a3a7fe19b88248124933d7#egg=ansys_dpf_post ansys-grpc-dpf==0.4.0 -e git+https://github.com/pyansys/pymapdl.git@1274686a65b3815ce02b45c139d321fc8a598cb5#egg=ansys_mapdl_core ansys-mapdl-reader==0.52.0 ansys-platform-instancemanagement==1.0.2 ansys-sphinx-theme==0.5.2 anyio==3.5.0 appdirs==1.4.4 argcomplete==2.0.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 asttokens==2.0.5 async-timeout==4.0.2 atomicwrites==1.4.0 attrs==21.4.0 autobahn==22.2.2 Automat==20.2.0 autopep8==1.6.0 Babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.11.1 black==22.1.0 bleach==4.1.0 build==0.8.0 cachetools==5.0.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 charset-normalizer==2.0.12 click==8.0.4 colorama==0.4.4 commonmark==0.9.1 constantly==15.1.0 coverage==6.3.2 cryptography==36.0.1 cycler==0.11.0 debugpy==1.5.1 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.4 dnspython==2.2.0 docopt==0.6.2 docutils==0.17.1 entrypoints==0.3 esbonio==0.11.0 executing==0.8.2 fett==0.3.2 filelock==3.6.0 flake8 @ file:///opt/conda/conda-bld/flake8_1648129545443/work fonttools==4.29.1 frozenlist==1.3.0 geomdl==5.3.1 google==3.0.0 google-api-core==2.5.0 google-api-python-client==2.37.0 google-auth==2.6.0 google-auth-httplib2==0.1.0 googleapis-common-protos==1.54.0 grpcio==1.43.0 httplib2==0.20.4 hyperlink==21.0.0 identify==2.4.11 idna==3.3 imageio==2.21.3 imageio-ffmpeg==0.4.7 imagesize==1.3.0 importlib-metadata @ file:///C:/ci/importlib-metadata_1648562621412/work incremental==21.3.0 iniconfig==1.1.1 ipycanvas==0.12.0 ipydatawidgets==4.2.0 ipyevents==2.0.1 ipykernel==6.9.1 ipython==8.0.1 ipython-genutils==0.2.0 ipyvtklink==0.2.2 ipywidgets==7.6.5 jedi==0.18.1 Jinja2==3.1.2 json5==0.9.6 jsonschema==4.4.0 jupyter==1.0.0 jupyter-client==7.1.1 jupyter-console==6.4.0 jupyter-core==4.9.1 jupyter-server==1.13.5 jupyter-sphinx==0.4.0 jupyterlab==3.3.3 jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.0.2 keyring==23.6.0 kiwisolver==1.3.2 livereload==2.6.3 mapdl @ file:///C:/Program%20Files/ANSYS%20Inc/v212/ANSYS/syslib/ansGRPC/User/mapdl-pyupf.tar.gz MarkupSafe==2.1.1 matplotlib==3.5.3 matplotlib-inline==0.1.3 mccabe @ file:///opt/conda/conda-bld/mccabe_1644221741721/work mistune==0.8.4 mpmath==1.2.1 multidict==6.0.2 mypy-extensions==0.4.3 nbclassic==0.3.5 nbclient==0.5.10 nbconvert==6.5.0 nbformat==5.2.0 nbsphinx==0.8.8 nest-asyncio==1.5.4 networkx==2.6.3 nodeenv==1.6.0 nose==1.3.7 notebook==6.4.7 numpy==1.22.2 numpydoc==1.4.0 packaging==21.3 pandas==1.4.4 pandocfilters==1.5.0 parso==0.8.3 pathspec==0.9.0 pep517==0.12.0 pickleshare==0.7.5 Pillow==9.0.1 pipx==1.0.0 pkginfo==1.8.3 platformdirs==2.5.1 plotly==5.10.0 pluggy==1.0.0 pre-commit==2.17.0 progressbar2==4.0.0 prometheus-client==0.12.0 prompt-toolkit==3.0.28 protobuf==3.19.4 protoc-gen-swagger==0.1.0 psutil==5.9.1 pure-eval==0.2.2 py==1.11.0 pyansys-sphinx-theme==0.2.3 pyansys-tools-report==0.2.2 pyasn1==0.4.8 pyasn1-modules==0.2.8 pycodestyle @ file:///tmp/build/80754af9/pycodestyle_1636635402688/work pycparser==2.21 pydantic==1.8.2 pydata-sphinx-theme==0.9.0 pyflakes @ file:///tmp/build/80754af9/pyflakes_1636644436481/work pygls==0.11.3 Pygments==2.11.2 pyiges==0.2.1 pymongo==3.12.3 pypandoc==1.8.1 pyparsing==3.0.7 pyrsistent==0.18.1 pyspellchecker==0.6.3 pytest==7.0.1 pytest-cov==3.0.0 pytest-sphinx==0.5.0 python-dateutil==2.8.2 python-jsonrpc-server==0.3.4 python-utils==3.3.3 pythreejs==2.4.1 pytz==2021.3 pyvista==0.36.1 pywin32==303 pywin32-ctypes==0.2.0 pywinpty==1.1.6 PyYAML==5.4.1 pyzmq==22.3.0 qtconsole==5.2.2 QtPy==2.0.0 readme-renderer==35.0 requests==2.27.1 requests-toolbelt==0.9.1 rfc3986==2.0.0 rich==12.4.4 rsa==4.8 rstcheck==3.3.1 scipy==1.8.0 scooby==0.5.12 Send2Trash==1.8.0 six==1.16.0 sniffio==1.2.0 snooty-lextudio==1.12.0 snowballstemmer==2.2.0 soupsieve==2.3.2.post1 Sphinx==5.1.1 sphinx-autobuild==2021.3.14 sphinx-autodoc-typehints==1.19.2 sphinx-copybutton==0.5.0 sphinx-gallery==0.11.1 sphinx-notfound-page==0.8.3 sphinxcontrib-applehelp==1.0.2 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphinxcontrib-websupport==1.2.4 sphinxemoji==0.2.0 stack-data==0.2.0 sympy==1.9 tenacity==8.0.1 terminado==0.12.1 testpath==0.5.0 tinycss2==1.1.1 toml==0.10.2 tomli==2.0.1 tornado==6.1 tox==3.25.0 tqdm==4.62.3 traitlets==5.1.1 traittypes==0.2.1 twine==4.0.1 Twisted==22.1.0 twisted-iocpsupport==1.0.2 txaio==22.2.1 typeguard==2.13.3 typing_extensions==4.1.1 uritemplate==4.1.1 urllib3==1.26.8 userpath==1.8.0 virtualenv==20.13.2 vtk==9.0.3 watchdog==1.0.2 wcwidth==0.2.5 webencodings==0.5.1 websocket-client==1.3.1 widgetsnbextension==3.5.2 wincertstore==0.2 wslink==1.4.1 xlrd==2.0.1 yarl==1.7.2 zipp @ file:///opt/conda/conda-bld/zipp_1641824620731/work zope.interface==5.4.0 ```