Skip to content

Short fiber example: fiber orientation tensor #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 14, 2023
Merged

Conversation

FedericoNegri
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the maintenance Package and maintenance related label Apr 3, 2023
@FedericoNegri FedericoNegri marked this pull request as ready for review April 3, 2023 15:19
@FedericoNegri
Copy link
Contributor Author

@janvonrickenbach @greschd I downloaded the html doc artifact and was surprised to see that the Axx and Ayy plot have inverted titles!
image
I've already noticed in the past the order of saved images to be different than the actual commands, and I'm fine with that. But this is an issue. Ever seen it before?

These are the expected plots
image

@janvonrickenbach
Copy link
Contributor

@janvonrickenbach @greschd I downloaded the html doc artifact and was surprised to see that the Axx and Ayy plot have inverted titles! image I've already noticed in the past the order of saved images to be different than the actual commands, and I'm fine with that. But this is an issue. Ever seen it before?

These are the expected plots image

@PProfizi: We get strange results when plotting results on the same mesh. To me this looks related to ansys/pydpf-core#632.

@PProfizi
Copy link

PProfizi commented Apr 4, 2023

@janvonrickenbach @greschd I downloaded the html doc artifact and was surprised to see that the Axx and Ayy plot have inverted titles! image I've already noticed in the past the order of saved images to be different than the actual commands, and I'm fine with that. But this is an issue. Ever seen it before?
These are the expected plots image

@PProfizi: We get strange results when plotting results on the same mesh. To me this looks related to pyansys/pydpf-core#632.

Hi @janvonrickenbach, looking at the scalar bars between your "expected" and the "current", not only are the titles inverted but the maximum and minimum are not the same. I will take a look but I need to know how you got your "expected" reference. Is that with DPF-Core 0.7.4 or is that when run locally vs generated by Sphinx?

@FedericoNegri
Copy link
Contributor Author

@PProfizi Reference results were obtained by running the notebook locally step-wise in a venv with DPF-Core 0.7.4.

@greschd
Copy link
Member

greschd commented Apr 4, 2023

Another way I managed to produce the wrong results is by creating three different meshes to plot on (while keeping the rest the same). Still running the script locally:

I'm not sure if this is supposed to work, but it might be an easier way to get to the root cause since it takes Sphinx out of the equation.

@@ -50,6 +50,12 @@ data_sources.set_result_file_path(composite_files_on_server.rst)
 model = dpf.Model(data_sources=data_sources)
 mesh = model.metadata.meshed_region
 
+model2 = dpf.Model(data_sources=data_sources)
+mesh2 = model2.metadata.meshed_region
+
+model3 = dpf.Model(data_sources=data_sources)
+mesh3 = model3.metadata.meshed_region
+
 # %%
 # Plot input data
 # ~~~~~~~~~~~~~~~
@@ -112,6 +118,16 @@ aXX = fiber_orientation_tensor_fc.select_component(0)[0]
 aYY = fiber_orientation_tensor_fc.select_component(1)[0]
 aXZ = fiber_orientation_tensor_fc.select_component(5)[0]
 
+# %%
+# Plot Axx
 mesh.plot(aXX, title="Axx", text="Axx plot")
-mesh.plot(aYY, title="Ayy", text="Ayy plot")
-mesh.plot(aXZ, title="Axz", text="Axz plot")
+
+
+# %%
+# Plot Ayy
+mesh2.plot(aYY, title="Ayy", text="Ayy plot")
+
+
+# %%
+# Plot Axz
+mesh3.plot(aXZ, title="Axz", text="Axz plot")

@PProfizi
Copy link

PProfizi commented Apr 5, 2023

Hi @greschd @FedericoNegri, I did not manage to reproduce the issue when running 9_short_fiber_orientation_tensor.py, even with the three different meshes. I am using:

  • Windows
  • Python 3.10
  • This branch of pydpf-composites
  • I tried with Ansys 231 (DPF 5.0) and the latest 232 (DPF 6.1)
  • I have this list of packages installed:
ansys-dpf-composites     0.2.dev0  D:\ANSYSDev\Sandbox\pydpf-composites
ansys-dpf-core           0.7.4                                         
ansys-dpf-gate           0.3.1                                         
ansys-dpf-gatebin        0.3.1                                         
ansys-grpc-dpf           0.7.1                                         
appdirs                  1.4.4                                         
argcomplete              3.0.5
cachetools               5.3.0
certifi                  2022.12.7
charset-normalizer       3.1.0
click                    8.1.3
colorama                 0.4.6
contourpy                1.0.7
cycler                   0.11.0
fonttools                4.39.3
google-api-core          2.11.0
google-api-python-client 2.83.0
google-auth              2.17.1
google-auth-httplib2     0.1.0
googleapis-common-protos 1.59.0
grpcio                   1.53.0
httplib2                 0.22.0
idna                     3.4
imageio                  2.27.0
importlib-metadata       6.1.0
kiwisolver               1.4.4
matplotlib               3.7.1
numpy                    1.24.2
packaging                23.0
Pillow                   9.5.0
pip                      21.3.1
pipx                     1.2.0
protobuf                 4.22.1
psutil                   5.9.4
pyasn1                   0.4.8
pyasn1-modules           0.2.8
pyparsing                3.0.9
python-dateutil          2.8.2
pyvista                  0.36.1
requests                 2.28.2
rsa                      4.9
scipy                    1.10.1
scooby                   0.7.1
setuptools               60.2.0
six                      1.16.0
tqdm                     4.65.0
uritemplate              4.1.1
urllib3                  1.26.15
userpath                 1.8.0
vtk                      9.2.6
wheel                    0.37.1
zipp                     3.15.0

Is there something I am missing?

PS: I have added a while ago this step right before all of our PyDPF testing or documentation jobs. It has proved to make debugging a lot easier.

@greschd
Copy link
Member

greschd commented Apr 5, 2023

@PProfizi I realized the difference is not due to the three different meshes, but due to running via the pydpf-composites Docker container or directly from the unified install.

The unified install gives the correct output, whereas the Docker container does not. I'm not sure if this means it's a Linux-only issue, or if something is wrong only in the Docker container. I'll test a unified install on Linux to compare.

Debug instructions:

  • run docker run -d -p 21002:50052 -e ANSYSLMD_LICENSE_FILE=<license_server> -e ANSYS_DPF_ACCEPT_LA=Y ghcr.io/pyansys/pydpf-composites:latest
  • modify the example with
    diff --git a/examples/9_short_fiber_orientation_tensor.py b/examples/9_short_fiber_orientation_tensor.py
    index d28c8a1d..36f790ce 100644
    --- a/examples/9_short_fiber_orientation_tensor.py
    +++ b/examples/9_short_fiber_orientation_tensor.py
    @@ -32,7 +32,7 @@ from ansys.dpf.composites.server_helpers import connect_to_or_start_server
     #
     # * Mechanical APDL result (RST) file containing the simulation results
     # * Mechanical APDL input file (DS.DAT) containing the fiber orientation tensor data
    -server = connect_to_or_start_server()
    +server = connect_to_or_start_server(port=21002)
     composite_files_on_server = get_short_fiber_example_files(server, "short_fiber")
    
     # %%

@greschd
Copy link
Member

greschd commented Apr 6, 2023

The difference seems to be independent of plotting. I've modified the example to just print a result, and run with both a local and container server here.

Output on Windows:

<local server output>
Result local:  0.8476316975728202
Result container:  0.08833158599895692

@greschd
Copy link
Member

greschd commented Apr 6, 2023

@PProfizi FYI, we figured out the root cause for these issues. In the example, we're accessing some data by index instead of by label, and the order in which the arrays are added is not deterministic.

No further action needed from your side, thanks for your help.

@greschd
Copy link
Member

greschd commented Apr 6, 2023

@FedericoNegri please review the changes made to the example. The main change is using the field variable name to correctly identify them (since the index is non-deterministic).

…to fnegri/sfw_ex_fot

Update poetry lockfile.
@FedericoNegri FedericoNegri marked this pull request as draft April 13, 2023 07:31
@FedericoNegri FedericoNegri marked this pull request as ready for review April 14, 2023 06:44
@FedericoNegri FedericoNegri merged commit f704b66 into main Apr 14, 2023
@FedericoNegri FedericoNegri deleted the fnegri/sfw_ex_fot branch April 14, 2023 13:35
janvonrickenbach added a commit that referenced this pull request May 24, 2023
* Bump ansys-sphinx-theme from 0.9.5 to 0.9.6 (#240)

Bumps [ansys-sphinx-theme](https://github.com/ansys/ansys-sphinx-theme) from 0.9.5 to 0.9.6.
- [Release notes](https://github.com/ansys/ansys-sphinx-theme/releases)
- [Commits](ansys/ansys-sphinx-theme@v0.9.5...v0.9.6)

---
updated-dependencies:
- dependency-name: ansys-sphinx-theme
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Remove the poetry workaround for sphinx theme installation (#241)

* Update dpf core version (#243)

* Bump peter-evans/create-or-update-comment from 2 to 3 (#249)

Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 2 to 3.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](peter-evans/create-or-update-comment@v2...v3)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-comment
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pytest from 7.2.2 to 7.3.0 (#250)

Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.2.2 to 7.3.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](pytest-dev/pytest@7.2.2...7.3.0)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Short fiber example: fiber orientation tensor (#233)

* Bump ansys-dpf-core from 0.8.0 to 0.8.1 (#253)

Bumps [ansys-dpf-core](https://github.com/pyansys/pydpf-core) from 0.8.0 to 0.8.1.
- [Release notes](https://github.com/pyansys/pydpf-core/releases)
- [Commits](ansys/pydpf-core@v0.8.0...v0.8.1)

---
updated-dependencies:
- dependency-name: ansys-dpf-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pytest from 7.3.0 to 7.3.1 (#254)

Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.3.0 to 7.3.1.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](pytest-dev/pytest@7.3.0...7.3.1)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add info to explain switching of doc versions (#256)

Update main index.rst file with minor edits

Note: The display links to other topics should use the same title as the topic. This is a Google developer doc style guideline. Users can be confident that the have been taked to the correct place.

* Drop support for Python 3.7 (#257)

Drop support for Python 3.7, and remove it from the tox and
CI/CD configurations.

Upgrade mypy to avoid python/mypy#13499,
and add checks for 'None' to account for newly reported errors.

* Bump pre-commit from 2.21.0 to 3.2.2 (#259)

Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 2.21.0 to 3.2.2.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md)
- [Commits](pre-commit/pre-commit@v2.21.0...v3.2.2)

---
updated-dependencies:
- dependency-name: pre-commit
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update AWP_ROOT_DOCKER variable (#265)

* Update pre-commit dependencies, remove code obsolete with Python 3.7 drop (#258)

* Update pre-commit dependencies.
* Add and run the `pyupgrade` pre-commit hook.
* Remove `TYPE_CHECKING` guards for `numpy.typing`.
* Set the minimum requirement for `numpy` to `1.22`.

* Add 'build-wheelhouse' job to CI/CD (#264)

* Add 'build-wheelhouse' job to CI/CD

* Rename build-package to build-library, improve dependencies

* Add allow-last-days option to package cleanup

* Bump ansys-sphinx-theme from 0.9.7 to 0.9.8 (#266)

Bumps [ansys-sphinx-theme](https://github.com/ansys/ansys-sphinx-theme) from 0.9.7 to 0.9.8.
- [Release notes](https://github.com/ansys/ansys-sphinx-theme/releases)
- [Commits](ansys/ansys-sphinx-theme@v0.9.7...v0.9.8)

---
updated-dependencies:
- dependency-name: ansys-sphinx-theme
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: janvonrickenbach <[email protected]>

* Bump numpy from 1.22.0 to 1.24.3 (#267)

Bumps [numpy](https://github.com/numpy/numpy) from 1.22.0 to 1.24.3.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst)
- [Commits](numpy/numpy@v1.22.0...v1.24.3)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: janvonrickenbach <[email protected]>

* Bump pre-commit from 3.2.2 to 3.3.1 (#271)

Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 3.2.2 to 3.3.1.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md)
- [Commits](pre-commit/pre-commit@v3.2.2...v3.3.1)

---
updated-dependencies:
- dependency-name: pre-commit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump ansys-sphinx-theme from 0.9.8 to 0.9.9 (#273)

Bumps [ansys-sphinx-theme](https://github.com/ansys/ansys-sphinx-theme) from 0.9.8 to 0.9.9.
- [Release notes](https://github.com/ansys/ansys-sphinx-theme/releases)
- [Commits](ansys/ansys-sphinx-theme@v0.9.8...v0.9.9)

---
updated-dependencies:
- dependency-name: ansys-sphinx-theme
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Adapt to organization rename from 'pyansys' to 'ansys' (#276)

Change the following references:
- `github.com/pyansys` -> `github.com/ansys`
- `ghcr.io/pyansys` -> `ghcr.io/ansys`
- `pyansys/actions` -> `ansys/actions`
- `https://codecov.io/gh/pyansys/pydpf-composites` -> `https://codecov.io/gh/ansys/pydpf-composites`

* Adapt to change in Axes with maptlotlib==3.7.1 (#263)

Bump matplotlib to ``3.7.1`` in ``poetry.lock``.

The matplotlib 'Axes' class no longer inherits from 'SubplotBase'
since matplotlib/matplotlib#23573.

This breaks the '_get_subplot' method in 'sampling_point.py' which
checks if the passed 'axes_obj' is a 'SubplotBase' instance to
distinguish between indexable and non-indexable objects.

To fix this, we now use a try-except block to index into the
'axes_obj', and catch the 'TypeError' that is raised if it is
and 'Axes' (as opposed to an array).

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Gresch <[email protected]>

* Relax pyvista requirement upper bound (#278)

Allow all pyvista versions `<1` to be used. This is required for
compatibility
with `ansys-fluent-visualization`, which depends on `>=0.39.0`.

* Document docker container from customer portal (#277)

* Support customer portal docker images and update docs

* Remove --server-bin pytest option because it is not working anymore.

* Ignore generated result definitions.

* Update README.rst

* Automatically upload file to server in CompositeModel

* Add 2024_1_pre0 to supported directories.

* Add show function to show sampling point plots

---------

Co-authored-by: Dominik Gresch <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dominik Gresch <[email protected]>
Co-authored-by: Federico Negri <[email protected]>
Co-authored-by: Kathy Pippert <[email protected]>
Co-authored-by: Dominik Gresch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Package and maintenance related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants