Cyclic analysis: forward/backward mode direction is inconsistent
- Dominant language
- Python
- Stars
- 60
- Forks
- 32
- Avg merge
- 5h 50m
- Merged PRs (30d)
- 8
Description
For a cyclic analysis, it looks like there's some inconsistency between the harmonic index of the result set, and the harmonic index as calculated from the sector boundary. Sometimes they match, and sometimes they don't.
Here's an uploaded results file (file_cyclic_test.rst) generated from Mechanical 2020R2:
http://filedropper.com/325u3Hvx
(simple model with 36 base sector nodes, 8 sectors, with results calculated at 1 ND)
And some code to calculate the harmonic index from two nodes on the sector boundary, and compare with the value from the result set:
```
from ansys.mapdl import reader as pymapdl_reader
import numpy as np
from math import pi
rstfile = 'D:/temp/file_cyclic_test.rst' # replace with path to uploaded RST file
result = pymapdl_reader.read_binary(rstfile)
low_node_index = 28 # index of low side node
high_node_index = 35 # index of matching high side node
for i_result in range(0, result.n_results):
node_deflection = result.nodal_displacement(i_result, as_complex=True)
# only need one component to calculate phase angle
deflection_low = node_deflection[1][low_node_index, 2]
deflection_high = node_deflection[1][high_node_index, 2]
angle_low = np.angle(deflection_low)
angle_high = np.angle(deflection_high)
# calculated nodal diameter from sector boundary phase angles
nd_calculated = (angle_high - angle_low)*result.n_sector / (2*pi)
# make sure this lies between -n_sector/2 and n_sector/2
if nd_calculated > result.n_sector/2:
nd_calculated -= result.n_sector
if nd_calculated <= -1*result.n_sector/2:
nd_calculated += result.n_sector
# round to get rid of small floating point errors
nd_calculated = round(nd_calculated, 3)
print('\nResult set ' + str(i_result))
print('Harmonic index from result set: ' + str(result.harmonic_indices[i_result]))
print('Harmonic index calculated from boundary: ' + str(nd_calculated))
if result.harmonic_indices[i_result] == int(nd_calculated):
print('Match!')
else:
print('No match!')
```
This gives the following result:
> Result set 0
> Harmonic index from result set: 1
> Harmonic index calculated from boundary: 1.0
> Match!
>
> Result set 1
> Harmonic index from result set: -1
> Harmonic index calculated from boundary: -1.0
> Match!
>
> Result set 2
> Harmonic index from result set: 1
> Harmonic index calculated from boundary: 1.0
> Match!
>
> Result set 3
> Harmonic index from result set: -1
> Harmonic index calculated from boundary: -1.0
> Match!
>
> Result set 4
> Harmonic index from result set: 1
> Harmonic index calculated from boundary: -1.0
> No match!
>
> Result set 5
> Harmonic index from result set: -1
> Harmonic index calculated from boundary: 1.0
> No match!
>
> Result set 6
> Harmonic index from result set: 1
> Harmonic index calculated from boundary: 1.0
> Match!
>
> Result set 7
> Harmonic index from result set: -1
> Harmonic index calculated from boundary: -1.0
> Match!
>
> Result set 8
> Harmonic index from result set: 1
> Harmonic index calculated from boundary: -1.0
> No match!
>
> Result set 9
> Harmonic index from result set: -1
> Harmonic index calculated from boundary: 1.0
> No match!
>
> Result set 10
> Harmonic index from result set: 1
> Harmonic index calculated from boundary: 1.0
> Match!
>
> Result set 11
> Harmonic index from result set: -1
> Harmonic index calculated from boundary: -1.0
> Match!
>
> Process finished with exit code 0
>
In the first two mode pairs (0,1 and 2,3), the direction matches between the result set and the boundary calculation, but for the third mode pair (4,5) the direction doesn't.
Contributor guide
Research direction
Reproduce the mismatch with file_cyclic_test.rst and the provided script, starting at read_binary, nodal_displacement, and harmonic_indices. Compare how harmonic indices are parsed or assigned for the reported mode pairs, then verify the result-set direction agrees with the boundary calculation for all pairs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100