@@ -1544,6 +1544,12 @@ class PlasticSection:
15441544 :cvar elements: List of finite element objects describing the cross-section
15451545 mesh
15461546 :vartype elements: list[:class:`~sectionproperties.analysis.fea.Tri6`]
1547+ :cvar float f_top: Current force in the top region
1548+ :cvar c_top: Centroid of the force in the top region *(c_top_x, c_top_y)*
1549+ :type c_top: list[float, float]
1550+ :cvar c_bot: Centroid of the force in the bottom region
1551+ *(c_bot_x, c_bot_y)*
1552+ :type c_bot: list[float, float]
15471553 """
15481554
15491555 def __init__ (self , geometry , materials , debug ):
@@ -1881,7 +1887,7 @@ def evaluate_force_eq(self, d, u, u_p):
18811887 self .plot_mesh (nodes , elements , element_list , self .materials )
18821888
18831889 # calculate force equilibrium
1884- (f_top , f_bot , _ , _ ) = (
1890+ (f_top , f_bot ) = (
18851891 self .calculate_plastic_force (element_list , u , p ))
18861892
18871893 # return the force norm
@@ -1926,16 +1932,7 @@ def pc_algorithm(self, u, dlim, axis, pc_region):
19261932 (d , r ) = brentq (self .evaluate_force_eq , a , b , args = (u , u_p ),
19271933 full_output = True , disp = False , xtol = 1e-6 , rtol = 1e-6 )
19281934
1929- # get centroids of the areas
1930- # TODO: consider saving f, c_top, c_bot as class variables so we don't
1931- # have to run it again
1932- p = np .array ([d * u_p [0 ], d * u_p [1 ]])
1933- mesh = self .create_plastic_mesh ([p , u ])
1934- (nodes , elements , element_list ) = self .get_elements (mesh )
1935- (f_top , f_bot , c_top , c_bot ) = (
1936- self .calculate_plastic_force (element_list , u , p ))
1937-
1938- return (d , r , f_top , c_top , c_bot )
1935+ return (d , r , self .f_top , self .c_top , self .c_bot )
19391936
19401937 def calculate_plastic_force (self , elements , u , p ):
19411938 """Sums the forces above and below the axis defined by unit vector *u*
@@ -1948,9 +1945,8 @@ def calculate_plastic_force(self, elements, u, p):
19481945 :type u: :class:`numpy.ndarray`
19491946 :param p: Point on the axis
19501947 :type p: :class:`numpy.ndarray`
1951- :return: Force in the top and bottom areas and centroids of these
1952- forces *(f_top, f_bot, [c_top_x, c_top_y], [c_bot_x, c_bot_y])*
1953- :rtype: tuple(float, float, list[float, float], list[float, float])
1948+ :return: Force in the top and bottom areas *(f_top, f_bot)*
1949+ :rtype: tuple(float, float)
19541950 """
19551951
19561952 # initialise variables
@@ -1976,11 +1972,12 @@ def calculate_plastic_force(self, elements, u, p):
19761972 qx_bot += qx_el
19771973 qy_bot += qy_el
19781974
1979- # calculate the centroid of the top and bottom segments
1980- c_top = [qy_top / ea_top , qx_top / ea_top ]
1981- c_bot = [qy_bot / ea_bot , qx_bot / ea_bot ]
1975+ # calculate the centroid of the top and bottom segments and save
1976+ self .c_top = [qy_top / ea_top , qx_top / ea_top ]
1977+ self .c_bot = [qy_bot / ea_bot , qx_bot / ea_bot ]
1978+ self .f_top = f_top
19821979
1983- return (f_top , f_bot , c_top , c_bot )
1980+ return (f_top , f_bot )
19841981
19851982 def create_plastic_mesh (self , new_line = None ):
19861983 """Generates a triangular mesh of a deep copy of the geometry stored in
@@ -2317,31 +2314,38 @@ def plot_stress_vector(self, sigxs, sigys, title, pause):
23172314 # set up the colormap
23182315 cmap = cm .get_cmap (name = 'jet' )
23192316
2317+ # initialise quiver plot list max scale
2318+ quiv_list = []
2319+ max_scale = 0
2320+
23202321 # plot the vectors
23212322 for (i , sigx ) in enumerate (sigxs ):
23222323 sigy = sigys [i ]
23232324
23242325 # scale the colour with respect to the magnitude of the vector
23252326 c = np .hypot (sigx , sigy )
23262327
2327- # The scale is defined by the scale of the first plot
2328- # TODO: return all scales then use the largest one???
2328+ quiv = ax .quiver (
2329+ self .cross_section .mesh_nodes [:, 0 ],
2330+ self .cross_section .mesh_nodes [:, 1 ],
2331+ sigx , sigy , c , cmap = cmap )
2332+
2333+ # get the scale and store the max value
2334+ quiv ._init ()
2335+ max_scale = max (max_scale , quiv .scale )
2336+ quiv_list .append (quiv )
2337+
2338+ # update the colormap values
23292339 if i == 0 :
23302340 c_min = min (c )
23312341 c_max = max (c )
2332-
2333- quiv = ax .quiver (
2334- self .cross_section .mesh_nodes [:, 0 ],
2335- self .cross_section .mesh_nodes [:, 1 ],
2336- sigx , sigy , c , cmap = cmap , scale = None )
23372342 else :
23382343 c_min = min (c_min , min (c ))
23392344 c_max = max (c_max , max (c ))
23402345
2341- ax .quiver (
2342- self .cross_section .mesh_nodes [:, 0 ],
2343- self .cross_section .mesh_nodes [:, 1 ],
2344- sigx , sigy , c , cmap = cmap , scale = quiv .scale )
2346+ # apply the scale
2347+ for quiv_plot in quiv_list :
2348+ quiv_plot .scale = max_scale
23452349
23462350 # apply the colourbar
23472351 v1 = np .linspace (c_min , c_max , 15 , endpoint = True )
0 commit comments