Skip to content

Handle empty sample sets in member result arrays - #373

Open
Tonylo-lab wants to merge 1 commit into
JWock82:mainfrom
Tonylo-lab:fix/empty-member-result-samples
Open

Tonylo-lab wants to merge 1 commit into
JWock82:mainfrom
Tonylo-lab:fix/empty-member-result-samples

Conversation

@Tonylo-lab

Copy link
Copy Markdown

Sparse sample positions on a physical member can leave a submember with no points to evaluate. _extract_vector_results() then concatenates an empty list and raises ValueError: need at least one array to concatenate. This affects the deflection, shear, moment, axial and torque arrays, including 20-point sampling on a member split into 32 submembers.

Return an empty (2, 0) result when the sample array is empty so the physical member can assemble the remaining results. Only Pynite/Member3D.py is changed.

Minimal reproduction (SI units):

from Pynite import FEModel3D

m = FEModel3D()
for i in range(4):
    m.add_node(f'N{i}', i, 0, 0)
m.add_material('Steel', 200e9, 80e9, 0.3, 7850.)
m.add_section('S', 0.01, 8e-6, 8e-6, 1e-5)
m.add_member('M', 'N0', 'N3', 'Steel', 'S')
m.def_support('N0', True, True, True, True, True, True)
m.add_node_load('N3', 'FY', -1000.)
m.analyze_linear()
print(m.members['M'].deflection_array('dy', 2))

The expected endpoint displacements are 0 and -0.005625 m, matching the cantilever solution; before the fix this raises instead.

Validation on Windows / Python 3.12.15:

  • 25 local sampling checks: before, 15 failed and 10 controls passed; after, all passed. Displacements were checked against the closed-form cantilever solution and array results against scalar queries.
  • 6 existing member/beam/tension-compression tests: passed.
  • Ruff and git diff --check: passed.

Verification scripts and reports are retained locally outside the repository. No test or changelog files are added to this PR.

Not run: the complete test suite, graphical visualization, or other platforms/Python versions.

AI assistance: OpenAI Codex assisted with investigation, the minimal patch and local verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant