Skip to content

Commit

Permalink
Merge branch 'main' into release/0.52
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Nov 22, 2022
2 parents 8ca7c54 + 9036c64 commit d218aee
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/testing-and-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
- uses: actions/checkout@v3

- name: Build wheels
uses: pypa/[email protected].1
uses: pypa/[email protected].2

- name: List generated wheels
run: |
Expand Down Expand Up @@ -274,6 +274,7 @@ jobs:
run: |
pip install twine
twine upload --skip-existing ./**/*.whl
twine upload --skip-existing ./**/*.tar.gz
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
Expand All @@ -282,6 +283,7 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: |
./**/*.tar.gz
./**/*.whl
./**/*.zip
./**/*.pdf
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ repos:
"--force-sort-within-sections",
"--skip-glob", "*__init__.py",
]
- repo: https://gitlab.com/PyCQA/flake8
rev: 3.9.2

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.2
hooks:
- id: codespell

Expand Down
2 changes: 1 addition & 1 deletion ansys/mapdl/reader/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def parse_header(table, keys):


def two_ints_to_long(intl, inth):
"""Interpert two ints as one long"""
"""Interpret two ints as one long"""
longint = struct.pack(">I", inth) + struct.pack(">I", intl)
return struct.unpack(">q", longint)[0]

Expand Down
21 changes: 12 additions & 9 deletions ansys/mapdl/reader/cyclic_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ def _expand_cyclic_modal(
result_expanded *= cjang.reshape(-1, 1, 1)
if as_complex:
return result_expanded
else:
return np.real(result_expanded)
return np.real(result_expanded)

def _expand_cyclic_modal_tensor(
self, result, result_r, hindex, phase, as_complex, full_rotor, stress=True
Expand Down Expand Up @@ -1083,7 +1082,7 @@ def principal_nodal_stress(self, rnum, phase=0, as_complex=False, full_rotor=Fal
equivalent stress.
"""
if as_complex and full_rotor:
raise ValueError("complex and full_rotor cannot both be True")
raise ValueError("`complex` and `full_rotor` cannot both be True")

# get component stress
nnum, stress = self.nodal_stress(rnum, phase, as_complex, full_rotor)
Expand All @@ -1093,25 +1092,29 @@ def principal_nodal_stress(self, rnum, phase=0, as_complex=False, full_rotor=Fal
stress_r = np.imag(stress)
stress = np.real(stress)

if not stress.flags["C_CONTIGUOUS"]:
stress = np.ascontiguousarray(stress)
if not stress_r.flags["C_CONTIGUOUS"]:
stress_r = np.ascontiguousarray(stress_r)

pstress, isnan = _binary_reader.compute_principal_stress(stress)
pstress[isnan] = np.nan
pstress_r, isnan = _binary_reader.compute_principal_stress(stress_r)
pstress_r[isnan] = np.nan

return nnum, pstress + 1j * pstress_r

elif full_rotor:
if full_rotor:
# compute principle stress for each sector
pstress = np.empty((self.n_sector, stress.shape[1], 5), np.float64)
for i in range(stress.shape[0]):
pstress[i], isnan = _binary_reader.compute_principal_stress(stress[i])
pstress[i, isnan] = np.nan
return nnum, pstress

else:
pstress, isnan = _binary_reader.compute_principal_stress(stress)
pstress[isnan] = np.nan
return nnum, pstress
pstress, isnan = _binary_reader.compute_principal_stress(stress)
pstress[isnan] = np.nan
return nnum, pstress

def plot_nodal_solution(
self,
Expand Down Expand Up @@ -1139,7 +1142,7 @@ def plot_nodal_solution(
comp : str, optional
Display component to display. Options are 'x', 'y', 'z',
and 'norm', corresponding to the x directin, y direction,
and 'norm', corresponding to the x direction, y direction,
z direction, and the normalized direction:
``(x**2 + y**2 + z**2)**0.5``
Expand Down
6 changes: 3 additions & 3 deletions ansys/mapdl/reader/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def _load_section_data(self):
table = self.read_record(ptr_sec + offset)
self._section_data[int(table[0])] = table[1:]

# it might be possible to interpert the section data...
# it might be possible to interpret the section data...
# sec[3] # total thickness
# sec[4] # number of layers (?)
# sec[5] # total integration points (?)
Expand Down Expand Up @@ -1358,8 +1358,8 @@ def nodal_solution(self, rnum, in_nodal_coord_sys=False, nodes=None):
Examples
--------
Return the nodal soltuion (in this case, displacement) for the
first result of ``"file.rst"``
Return the nodal solution (in this case, displacement) for the
first result of ``"file.rst"``.
>>> from ansys.mapdl import reader as pymapdl_reader
>>> rst = pymapdl_reader.read_binary('file.rst')
Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
],
# path where to save gallery generated examples
"gallery_dirs": ["examples"],
# Patter to search for example files
# Pattern to search for example files
"filename_pattern": r"\.py",
# Remove the "Download all examples" button from the top level gallery
# "download_all_examples": False,
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/loading_results.rst
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ will return which modes are available:
Available modes: [0 1 2 3 4 5 6 7 8 9]
Results from a cyclic analysis require additional post processing to
be interperted correctly. Mode shapes are stored within the result
be interpreted correctly. Mode shapes are stored within the result
file as unprocessed parts of the real and imaginary parts of a modal
solution. ``ansys-mapdl-reader`` combines these values into a single
complex array and then returns the real result of that array.
Expand Down
8 changes: 4 additions & 4 deletions requirements/requirements_docs.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Sphinx==5.3.0
ansys-sphinx-theme==0.6.1
ansys-sphinx-theme==0.7.1
notfound==1.0.2
pypandoc==1.9
pyvista==0.36.1
sphinx-copybutton==0.5.0
pypandoc==1.10
pyvista==0.37.0
sphinx-copybutton==0.5.1
sphinx-gallery==0.11.1
sphinx-notfound-page==0.8.3
vtk==9.2.2
17 changes: 16 additions & 1 deletion tests/test_cyclic.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,25 @@ def test_nodal_cyclic_modal(academic_rotor, load_step, sub_step, rtype):
# np.abs(pdiff).max()
# this number is small (aprox 0.0002%)

# verify we can get complex results
nnum, stress = academic_rotor.principal_nodal_stress(
rnum,
as_complex=False,
)
nnum_com, stress_com = academic_rotor.principal_nodal_stress(
rnum,
as_complex=True,
)
assert np.allclose(np.real(stress_com), stress)
assert np.allclose(nnum, nnum_com)

with pytest.raises(ValueError, match="cannot both be True"):
academic_rotor.principal_nodal_stress(rnum, as_complex=True, full_rotor=True)


def test_non_cyclic():
with pytest.raises(TypeError):
rst = CyclicResult(examples.rstfile)
CyclicResult(examples.rstfile)


@skip_windows
Expand Down

0 comments on commit d218aee

Please sign in to comment.