ritchie46 / anaStruct

2D structural analysis in Python
GNU General Public License v3.0
367 stars 104 forks source link

SystemElements.show_displacement() renders the displacement incorrectly for the same structure. #326

Closed thisisapple closed 1 month ago

thisisapple commented 1 month ago

I define a 2D frame as shown in this figure. I checked the internal forces and the displacement. The issue is that the displacement was rendered incorrectly for the original 2D frame.

Nodal Displacement

I checked the nodal displacement for Node No. 4 of the original frame, which will be Node No. 5 for the second frame. I noticed that the movement is the same at the same location. Surprisingly, you see very different outcomes from the SystemElements.show_displacement() for the same structure as shown below.

Conclusion

I think SystemElements.show_displacement() is causing the problem. The show_displacement function is rendering the displacement incorrectly.

d = structure.get_node_displacements(node_id=4)
print(d)

Below is the nodal result. {'id': 4, 'ux': np.float64(-0.016609195402298816), 'uy': np.float64(-0.25626438577585275), 'phi_z': np.float64(0.0027801727729883222)}

Original 2D Frame (a total of 3 beam elements)

I apply a line load to the last beam element image The problem is that the show_displacement() cannot render the results correctly. image

from anastruct import SystemElements

## Input
E_s = 29E3
I = 500
A = 102.5
EI = E_s * I
EA = E_s * A

structure = SystemElements(EI=EI, mesh=100)
structure.add_element(location=[
    [0, 59.5],
    [0, 17]
])

structure.add_element(location=[
    [0, 17],
    [0, 0]
])

structure.add_element(location=[
    [0, 0],
    [100, 0]
])

structure.add_support_hinged(node_id=1)
structure.add_support_hinged(node_id=2)

# I assign the same line load to the structure.
structure.q_load(q=-0.125, element_id=[3]) 

structure.show_structure()
structure.solve()
structure.show_displacement()

Same 2D Structure with 4 beam elements

I redefine the structure by splitting the last element into two elements, the displacement is correct.

from anastruct import SystemElements

## Input
E_s = 29E3
I = 500
A = 102.5
EI = E_s * I
EA = E_s * A

structure = SystemElements(EI=EI, mesh=100)
structure.add_element(location=[
    [0, 59.5],
    [0, 17]
])

structure.add_element(location=[
    [0, 17],
    [0, 0]
])

structure.add_element(location=[
    [0, 0],
    [50, 0]
])

structure.add_element(location=[
    [50, 0],
    [100, 0]
])

structure.add_support_hinged(node_id=1)
structure.add_support_hinged(node_id=2)

# I assign the same line load to the structure.
structure.q_load(q=-0.125, element_id=[3,4]) 

structure.show_structure()
structure.solve()
structure.show_reaction_force()
structure.show_displacement()

image image

thisisapple commented 1 month ago

I checked the nodal displacement for Node No. 4 of the original frame, which will be Node No. 5 for the second frame. Surprisingly, I noticed that the movement is the same for the same node.

Conclusion

I think SystemElements.show_displacement() is causing the problem. The show_displacement function is rendering the displacement incorrectly.

d = structure.get_node_displacements(node_id=4)
print(d)

Below is the nodal result. {'id': 4, 'ux': np.float64(-0.016609195402298816), 'uy': np.float64(-0.25626438577585275), 'phi_z': np.float64(0.0027801727729883222)}

thisisapple commented 1 month ago

I realized the problem was related the parameter named factor. The problem is fixed when I specify factor=40.

structure.show_displacement(factor=40)

smith120bh commented 1 month ago

@thisisapple : So yes, you can override the scale factor for any plot (that factor=x parameter). However, anaStruct also should be automatically figuring out a scale factor that reasonably keeps the deformed structure within the plot window. In your first screenshot, it's clearly not doing that correctly. As long as you were using the most recent anaStruct release, then I'm pretty sure I know where the problem is... I'll try to get to fixing this this weekend.

smith120bh commented 1 month ago

@thisisapple : Actually, it turns out that I fixed this already in some recent work I did to add Total Deflection outputs. I've just pushed out a new release (v1.6.1) which now contains those updates and the fix to this bug. So please install v1.6.1 to fix the diagram autoscaling!

Screenshots of your scripts as run on v1.6.1 - which is, I think, what you expect!:

image image