|
27 | 27 | import sectionproperties.analysis.solver as solver |
28 | 28 | import sectionproperties.post.post as post |
29 | 29 |
|
| 30 | +from shapely.geometry import asPoint, Polygon |
| 31 | +from shapely.strtree import STRtree |
30 | 32 |
|
31 | 33 | class Section: |
32 | 34 | """Class for structural cross-sections. |
@@ -2129,7 +2131,7 @@ def get_sf_p(self): |
2129 | 2131 | def get_stress_at_point( |
2130 | 2132 | self, pt: List[float], N=0, Mxx=0, Myy=0, M11=0, M22=0, Mzz=0, Vx=0, Vy=0 |
2131 | 2133 | ) -> Tuple[float]: |
2132 | | - """Calaculates the stress at a point wiithin an element for given design actions |
| 2134 | + """Calaculates the stress at a point within an element for given design actions |
2133 | 2135 | and returns *(sigma_zz, tau_xz, tau_yz)* |
2134 | 2136 |
|
2135 | 2137 | :param pt: The point. A list of the x and y coordinate |
@@ -2196,6 +2198,90 @@ def get_stress_at_point( |
2196 | 2198 | return sigs |
2197 | 2199 |
|
2198 | 2200 |
|
| 2201 | + def get_stress_at_points( |
| 2202 | + self, pts: List[List[float]], N=0, Mxx=0, Myy=0, M11=0, M22=0, Mzz=0, Vx=0, Vy=0, agg_func=np.average |
| 2203 | + ) -> List[Tuple[float]]: |
| 2204 | + """Calaculates the stress at a set of points within an element for given design actions |
| 2205 | + and returns *(sigma_zz, tau_xz, tau_yz)* |
| 2206 | +
|
| 2207 | + :param pts: The points. A list of several x and y coordinates |
| 2208 | + :type pts: list[list[float, float]] |
| 2209 | + :param float N: Axial force |
| 2210 | + :param float Vx: Shear force acting in the x-direction |
| 2211 | + :param float Vy: Shear force acting in the y-direction |
| 2212 | + :param float Mxx: Bending moment about the centroidal xx-axis |
| 2213 | + :param float Myy: Bending moment about the centroidal yy-axis |
| 2214 | + :param float M11: Bending moment about the centroidal 11-axis |
| 2215 | + :param float M22: Bending moment about the centroidal 22-axis |
| 2216 | + :param float Mzz: Torsion moment about the centroidal zz-axis |
| 2217 | + :return: Resultant normal and shear stresses list[(sigma_zz, tau_xz, tau_yz)] |
| 2218 | + :rtype: list[tuple(float, float, float)] |
| 2219 | + """ |
| 2220 | + |
| 2221 | + action = { |
| 2222 | + "N": N, |
| 2223 | + "Mxx": Mxx, |
| 2224 | + "Myy": Myy, |
| 2225 | + "M11": M11, |
| 2226 | + "M22": M22, |
| 2227 | + "Mzz": Mzz, |
| 2228 | + "Vx": Vx, |
| 2229 | + "Vy": Vy, |
| 2230 | + } |
| 2231 | + |
| 2232 | + sect_prop = { |
| 2233 | + "ea": self.section_props.ea, |
| 2234 | + "cx": self.section_props.cx, |
| 2235 | + "cy": self.section_props.cy, |
| 2236 | + "ixx": self.section_props.ixx_c, |
| 2237 | + "iyy": self.section_props.iyy_c, |
| 2238 | + "ixy": self.section_props.ixy_c, |
| 2239 | + "i11": self.section_props.i11_c, |
| 2240 | + "i22": self.section_props.i22_c, |
| 2241 | + "phi": self.section_props.phi, |
| 2242 | + "j": self.section_props.j, |
| 2243 | + "Delta_s": self.section_props.Delta_s, |
| 2244 | + "nu": self.section_props.nu_eff, |
| 2245 | + } |
| 2246 | + |
| 2247 | + #create the search tree |
| 2248 | + p_mesh = [Polygon(self.geometry.mesh["vertices"][tri][0:3]) for tri in self.geometry.mesh["triangles"]] |
| 2249 | + s_tree = STRtree(p_mesh) |
| 2250 | + index_by_id = dict((id(poly), i) for i, poly in enumerate(p_mesh)) |
| 2251 | + |
| 2252 | + for pt in pts: |
| 2253 | + query_geom = asPoint(pt) |
| 2254 | + tri_ids = [index_by_id[id(poly)] for poly in s_tree.query(query_geom) if poly.intersects(query_geom)] |
| 2255 | + if len(tri_ids)==1: |
| 2256 | + tri = self.elements[tri_ids[0]] |
| 2257 | + sig = tri.local_element_stress( |
| 2258 | + p=pt, |
| 2259 | + **action, |
| 2260 | + **sect_prop, |
| 2261 | + omega=self.section_props.omega[tri.node_ids], |
| 2262 | + psi_shear=self.section_props.psi_shear[tri.node_ids], |
| 2263 | + phi_shear=self.section_props.phi_shear[tri.node_ids], |
| 2264 | + ) |
| 2265 | + else: |
| 2266 | + sigs = [] |
| 2267 | + for idx in tri_ids: |
| 2268 | + tri = self.elements[idx] |
| 2269 | + sigs.append(tri.local_element_stress( |
| 2270 | + p=pt, |
| 2271 | + **action, |
| 2272 | + **sect_prop, |
| 2273 | + omega=self.section_props.omega[tri.node_ids], |
| 2274 | + psi_shear=self.section_props.psi_shear[tri.node_ids], |
| 2275 | + phi_shear=self.section_props.phi_shear[tri.node_ids], |
| 2276 | + ) |
| 2277 | + ) |
| 2278 | + sig = ( |
| 2279 | + agg_func([sig[0] for sig in sigs]), |
| 2280 | + agg_func([sig[1] for sig in sigs]), |
| 2281 | + agg_func([sig[2] for sig in sigs]), |
| 2282 | + ) |
| 2283 | + yield sig |
| 2284 | + |
2199 | 2285 | class PlasticSection: |
2200 | 2286 | """Class for the plastic analysis of cross-sections. |
2201 | 2287 |
|
|
0 commit comments