From e629f33c92366a6de2f04ac88ccc6b4ab9799391 Mon Sep 17 00:00:00 2001 From: John Vouvakis Manousakis Date: Wed, 1 May 2024 14:44:46 -0700 Subject: [PATCH] Format code with `black` --- src/osmg/component_assembly.py | 4 +- src/osmg/defaults.py | 5 +- src/osmg/gen/component_gen.py | 314 +++++++-------- src/osmg/gen/material_gen.py | 61 +-- src/osmg/gen/mesh_shapes.py | 7 +- src/osmg/gen/query.py | 25 +- src/osmg/gen/section_gen.py | 4 +- src/osmg/gen/steel/brb.py | 50 +-- src/osmg/gen/zerolength_gen.py | 285 ++++++++------ src/osmg/graphics/graphics_common_3d.py | 2 +- src/osmg/graphics/postprocessing_3d.py | 294 +++++++------- src/osmg/graphics/preprocessing_3d.py | 364 ++++++++++-------- src/osmg/ground_motion_utils.py | 8 +- src/osmg/load_case.py | 19 +- src/osmg/mesh.py | 19 +- src/osmg/model.py | 30 +- src/osmg/obj_collections.py | 3 +- src/osmg/ops/element.py | 21 +- src/osmg/ops/section.py | 7 +- src/osmg/ops/uniaxial_material.py | 20 +- src/osmg/postprocessing/basic_forces.py | 5 +- src/osmg/preprocessing/self_weight_mass.py | 8 +- src/osmg/preprocessing/split_component.py | 30 +- .../preprocessing/tributary_area_analysis.py | 27 +- src/osmg/solver.py | 19 +- 25 files changed, 866 insertions(+), 765 deletions(-) diff --git a/src/osmg/component_assembly.py b/src/osmg/component_assembly.py index 69ab4de8..238b6d7b 100644 --- a/src/osmg/component_assembly.py +++ b/src/osmg/component_assembly.py @@ -61,9 +61,7 @@ class ComponentAssembly: def __post_init__(self): self.external_nodes = obj_collections.NodeCollection(self) self.internal_nodes = obj_collections.NodeCollection(self) - self.elements = ( - obj_collections.CollectionWithConnectivity(self) - ) + self.elements = obj_collections.CollectionWithConnectivity(self) def __srepr__(self): """ diff --git a/src/osmg/defaults.py b/src/osmg/defaults.py index 7ebc303d..9626d4d9 100644 --- a/src/osmg/defaults.py +++ b/src/osmg/defaults.py @@ -66,10 +66,7 @@ def load_default_elastic(model: Model, sec_name: str) -> None: sgen = SectionGenerator(model) # generate a default elastic section and add it to the model sgen.generate_generic_elastic( - name=sec_name, - e_times_a=1.00, - e_times_i=1.00, - g_times_j=1.00 + name=sec_name, e_times_a=1.00, e_times_i=1.00, g_times_j=1.00 ) diff --git a/src/osmg/gen/component_gen.py b/src/osmg/gen/component_gen.py index f3e1f9ad..8f66153e 100644 --- a/src/osmg/gen/component_gen.py +++ b/src/osmg/gen/component_gen.py @@ -56,8 +56,12 @@ def retrieve_snap_pt_global_offset( - placement: str, section: ElasticSection | FiberSection, - p_i: nparr, p_j: nparr, angle: float) -> nparr: + placement: str, + section: ElasticSection | FiberSection, + p_i: nparr, + p_j: nparr, + angle: float, +) -> nparr: """ Returns the necessary offset to connect an element at a specified snap point of the section. @@ -150,9 +154,7 @@ def beam_placement_lookup( "bottom_left", "bottom_right", ]: - elm = component.elements.named_contents[ - "elm_interior" - ] + elm = component.elements.named_contents["elm_interior"] d_z, d_y = elm.section.snap_points[snap] sec_offset_local: nparr = -np.array([0.00, d_y, d_z]) # retrieve local coordinate system @@ -198,7 +200,8 @@ def beam_placement_lookup( ) t_loc_to_glob = t_glob_to_loc.T sec_offset_global = ( - t_loc_to_glob @ sec_offset_local) + t_loc_to_glob @ sec_offset_local + ) e_o += sec_offset_global return node, e_o @@ -232,25 +235,25 @@ class TrussBarGenerator: model: Model = field(repr=False) def add( - self, - xi_coord: float, - yi_coord: float, - lvl_key_i: int, - offset_i: nparr, - snap_i: str, - xj_coord: float, - yj_coord: float, - lvl_key_j: int, - offset_j: nparr, - snap_j: str, - transf_type: str, - area: float, - mat: UniaxialMaterial, - outside_shape: Mesh, - weight_per_length: float = 0.00, - split_existing_i: bool = None, - split_existing_j: bool = None, - component_purpose: str = 'Truss Element' + self, + xi_coord: float, + yi_coord: float, + lvl_key_i: int, + offset_i: nparr, + snap_i: str, + xj_coord: float, + yj_coord: float, + lvl_key_j: int, + offset_j: nparr, + snap_j: str, + transf_type: str, + area: float, + mat: UniaxialMaterial, + outside_shape: Mesh, + weight_per_length: float = 0.00, + split_existing_i: bool = None, + split_existing_j: bool = None, + component_purpose: str = 'Truss Element', ) -> ComponentAssembly: """ Adds a truss bar element. @@ -302,12 +305,10 @@ def add( # offset, to move the ends of the brace back where we want # them to be. The effect of this is that the rigid offsets # (twonodelinks) will connect to that other node. - i_diff = (np.array((xi_coord, yi_coord)) - - np.array(node_i.coords[0:2])) + i_diff = np.array((xi_coord, yi_coord)) - np.array(node_i.coords[0:2]) if np.linalg.norm(i_diff) > common.EPSILON: eo_i[0:2] += i_diff - j_diff = (np.array((xj_coord, yj_coord)) - - np.array(node_j.coords[0:2])) + j_diff = np.array((xj_coord, yj_coord)) - np.array(node_j.coords[0:2]) if np.linalg.norm(j_diff) > common.EPSILON: eo_j[0:2] += j_diff @@ -323,9 +324,7 @@ def add( component.external_nodes.add(node_i) component.external_nodes.add(node_j) - def prepare_connection( - node_x: Node, eo_x: nparr) \ - -> Node: + def prepare_connection(node_x: Node, eo_x: nparr) -> Node: """ For each end of the bar element, creates a rigid link if an offset exists, and returns the node to which the bar @@ -340,21 +339,25 @@ def prepare_connection( if np.linalg.norm(eo_x) > common.EPSILON: int_node_x = Node( self.model.uid_generator.new('node'), - [*(np.array(node_x.coords) + eo_x)] + [*(np.array(node_x.coords) + eo_x)], ) component.internal_nodes.add(int_node_x) n_x = int_node_x dirs, mats = zerolength_gen.fix_all(self.model) # flip the nodes if the element is about to be defined # upside down - if np.allclose( + if ( + np.allclose( np.array(node_x.coords[0:2]), np.array(int_node_x.coords[0:2]), - ) and int_node_x.coords[2] > node_x.coords[2]: + ) + and int_node_x.coords[2] > node_x.coords[2] + ): x_axis, y_axis, _ = local_axes_from_points_and_angle( np.array(int_node_x.coords), np.array(node_x.coords), - 0.00) + 0.00, + ) elm_link = TwoNodeLink( component, self.model.uid_generator.new("element"), @@ -368,7 +371,8 @@ def prepare_connection( x_axis, y_axis, _ = local_axes_from_points_and_angle( np.array(node_x.coords), np.array(int_node_x.coords), - 0.00) + 0.00, + ) elm_link = TwoNodeLink( component, self.model.uid_generator.new("element"), @@ -396,7 +400,7 @@ def prepare_connection( area=area, mat=mat, outside_shape=outside_shape, - weight_per_length=weight_per_length + weight_per_length=weight_per_length, ) # add it to the component assembly @@ -415,18 +419,18 @@ class BeamColumnGenerator: model: Model = field(repr=False) def define_beamcolumn( - self, - assembly: ComponentAssembly, - node_i: Node, - node_j: Node, - offset_i: nparr, - offset_j: nparr, - transf_type: str, - section: ElasticSection | FiberSection, - element_type: Type[Union[ElasticBeamColumn, DispBeamColumn]], - angle: float = 0.00, - n_x: Optional[float] = None, - n_y: Optional[float] = None + self, + assembly: ComponentAssembly, + node_i: Node, + node_j: Node, + offset_i: nparr, + offset_j: nparr, + transf_type: str, + section: ElasticSection | FiberSection, + element_type: Type[Union[ElasticBeamColumn, DispBeamColumn]], + angle: float = 0.00, + n_x: Optional[float] = None, + n_y: Optional[float] = None, ) -> ElasticBeamColumn | DispBeamColumn: """ Adds a beamcolumn element to the model, connecting the @@ -454,7 +458,8 @@ def define_beamcolumn( nodes=[node_i, node_j], section=section, geomtransf=transf, - n_x=n_x, n_y=n_y + n_x=n_x, + n_y=n_y, ) res: Union[ElasticBeamColumn, DispBeamColumn] = elm_el elif element_type.__name__ == "DispBeamColumn": @@ -484,8 +489,7 @@ def define_beamcolumn( ) res = elm_disp else: - raise ValueError( - 'Invalid element type: {element_type.__name__}') + raise ValueError('Invalid element type: {element_type.__name__}') return res def define_zerolength( @@ -557,7 +561,7 @@ def add_beamcolumn_elements_in_series( camber_2, camber_3, n_x=None, - n_y=None + n_y=None, ): """ Adds beamcolumn elemens in series. @@ -616,9 +620,11 @@ def add_beamcolumn_elements_in_series( n_j = intnodes[i] o_j = np.zeros(3) if element_type.__name__ not in { - 'ElasticBeamColumn', 'DispBeamColumn'}: + 'ElasticBeamColumn', + 'DispBeamColumn', + }: raise TypeError( - "Unsupported element type:" f" {element_type.__name__}" + f"Unsupported element type: {element_type.__name__}" ) element = self.define_beamcolumn( assembly=component, @@ -630,7 +636,8 @@ def add_beamcolumn_elements_in_series( section=section, element_type=element_type, angle=angle, - n_x=n_x, n_y=n_y + n_x=n_x, + n_y=n_y, ) component.elements.add(element) @@ -650,7 +657,7 @@ def generate_plain_component_assembly( camber_2, camber_3, n_x=None, - n_y=None + n_y=None, ): """ Generates a plain component assembly, with line elements in @@ -691,7 +698,8 @@ def generate_plain_component_assembly( angle, camber_2, camber_3, - n_x, n_y + n_x, + n_y, ) return component @@ -711,7 +719,8 @@ def generate_hinged_component_assembly( angle, camber_2, camber_3, - n_x, n_y, + n_x, + n_y, zerolength_gen_i, zerolength_gen_args_i, zerolength_gen_j, @@ -753,7 +762,6 @@ def generate_hinged_component_assembly( # we can have hinges at both ends, or just one of the two ends. # ...or even no hinges! if zerolength_gen_i: - hinge_location_i = p_i + x_axis * zerolength_gen_args_i["distance"] nh_i_out = Node( self.model.uid_generator.new("node"), [*hinge_location_i] @@ -796,9 +804,13 @@ def generate_hinged_component_assembly( ) elif element_type_i.__name__ == "TwoNodeLink": elm = self.define_two_node_link( - component, node_i, nh_i_out, - x_axis, y_axis, - zerolength_gen.fix_all, {} + component, + node_i, + nh_i_out, + x_axis, + y_axis, + zerolength_gen.fix_all, + {}, ) component.elements.add(elm) else: @@ -819,7 +831,6 @@ def generate_hinged_component_assembly( conn_node_i = node_i conn_eo_i = eo_i if zerolength_gen_j: - hinge_location_j = p_i + x_axis * ( clear_length - zerolength_gen_args_j["distance"] ) @@ -860,13 +871,17 @@ def generate_hinged_component_assembly( element_type_j, angle, 0.00, - 0.00 + 0.00, ) elif element_type_j.__name__ == "TwoNodeLink": elm = self.define_two_node_link( - component, nh_j_out, node_j, - x_axis, y_axis, - zerolength_gen.fix_all, {} + component, + nh_j_out, + node_j, + x_axis, + y_axis, + zerolength_gen.fix_all, + {}, ) component.elements.add(elm) else: @@ -900,7 +915,8 @@ def generate_hinged_component_assembly( angle, camber_2, camber_3, - n_x, n_y + n_x, + n_y, ) return component @@ -1033,9 +1049,9 @@ def add_horizontal_active( ) # type: ignore p_i_init += h_offset_i * x_axis - p_j_init += - h_offset_j * x_axis + p_j_init += -h_offset_j * x_axis offset_i += h_offset_i * x_axis - offset_j += - h_offset_j * x_axis + offset_j += -h_offset_j * x_axis if section.snap_points and (placement != "centroid"): # obtain offset from section (local system) @@ -1095,26 +1111,27 @@ def add_horizontal_active( return defined_component_assemblies def add_diagonal_active( - self, - xi_coord: float, - yi_coord: float, - xj_coord: float, - yj_coord: float, - offset_i: nparr, - offset_j: nparr, - snap_i: str, - snap_j: str, - transf_type: str, - n_sub: int, - section: ElasticSection, - element_type: Type[Union[ElasticBeamColumn, DispBeamColumn]], - placement: str = 'centroid', - angle: float = 0.00, - camber_2: float = 0.00, camber_3: float = 0.00, - split_existing_i: Optional[ComponentAssembly] = None, - split_existing_j: Optional[ComponentAssembly] = None, - method: str = 'generate_plain_component_assembly', - additional_args: dict[str, object] = {} + self, + xi_coord: float, + yi_coord: float, + xj_coord: float, + yj_coord: float, + offset_i: nparr, + offset_j: nparr, + snap_i: str, + snap_j: str, + transf_type: str, + n_sub: int, + section: ElasticSection, + element_type: Type[Union[ElasticBeamColumn, DispBeamColumn]], + placement: str = 'centroid', + angle: float = 0.00, + camber_2: float = 0.00, + camber_3: float = 0.00, + split_existing_i: Optional[ComponentAssembly] = None, + split_existing_j: Optional[ComponentAssembly] = None, + method: str = 'generate_plain_component_assembly', + additional_args: dict[str, object] = {}, ) -> dict[int, ComponentAssembly]: """ Adds a diagonal beamcolumn element to all active levels. @@ -1128,7 +1145,7 @@ def add_diagonal_active( defined_component_assemblies: dict[int, ComponentAssembly] = {} for key in lvls.active: lvl = lvls[key] - lvl_prev = lvls.get(key-1) + lvl_prev = lvls.get(key - 1) if not lvl_prev: continue @@ -1141,28 +1158,39 @@ def add_diagonal_active( d_z, d_y = section.snap_points[placement] sec_offset_local: nparr = np.array([0.00, d_y, d_z]) # retrieve local coordinate system - x_axis, y_axis, z_axis = \ - local_axes_from_points_and_angle( - p_i_init, p_j_init, angle) # type: ignore - t_glob_to_loc = transformation_matrix( - x_axis, y_axis, z_axis) + x_axis, y_axis, z_axis = local_axes_from_points_and_angle( + p_i_init, p_j_init, angle + ) # type: ignore + t_glob_to_loc = transformation_matrix(x_axis, y_axis, z_axis) t_loc_to_glob = t_glob_to_loc.T sec_offset_global = t_loc_to_glob @ sec_offset_local else: sec_offset_global = np.zeros(3) node_i, eo_i = beam_placement_lookup( - xi_coord, yi_coord, query, ndg, - lvls, key, offset_i, + xi_coord, + yi_coord, + query, + ndg, + lvls, + key, + offset_i, sec_offset_global, split_existing_i, - snap_i) + snap_i, + ) node_j, eo_j = beam_placement_lookup( - xj_coord, yj_coord, query, ndg, - lvls, key-1, offset_j, + xj_coord, + yj_coord, + query, + ndg, + lvls, + key - 1, + offset_j, sec_offset_global, split_existing_j, - snap_j) + snap_j, + ) args = { 'component_purpose': 'diagonal_component', @@ -1177,27 +1205,26 @@ def add_diagonal_active( 'transf_type': transf_type, 'angle': angle, 'camber_2': camber_2, - 'camber_3': camber_3 + 'camber_3': camber_3, } args.update(additional_args) - assert hasattr(self, method), \ - f'Method not available: {method}' + assert hasattr(self, method), f'Method not available: {method}' mthd = getattr(self, method) defined_component_assemblies[key] = mthd(**args) return defined_component_assemblies def add_pz_active( - self, - x_coord: float, - y_coord: float, - section: ElasticSection, - physical_material: PhysicalMaterial, - angle: float, - column_depth: float, - beam_depth: float, - zerolength_method: str, - zerolength_args: dict[str, object], + self, + x_coord: float, + y_coord: float, + section: ElasticSection, + physical_material: PhysicalMaterial, + angle: float, + column_depth: float, + beam_depth: float, + zerolength_method: str, + zerolength_args: dict[str, object], ) -> dict[int, ComponentAssembly]: """ Adds a component assembly representing a steel W-section @@ -1211,7 +1238,6 @@ def add_pz_active( assert lvls.active, "No active levels." defined_components: dict[int, ComponentAssembly] = {} for key in lvls.active: - lvl = lvls[key] if key - 1 not in lvls: continue @@ -1312,13 +1338,13 @@ def add_pz_active( outside_shape=None, snap_points=None, e_mod=section.e_mod, - area=section.area*factor_a, - i_y=section.i_y*factor_i, - i_x=section.i_x*factor_i, + area=section.area * factor_a, + i_y=section.i_y * factor_i, + i_x=section.i_x * factor_i, g_mod=section.g_mod, - j_mod=section.j_mod*factor_j, + j_mod=section.j_mod * factor_j, sec_w=0.00, - ) + ) elm_top_h_f = ElasticBeamColumn( component, @@ -1483,16 +1509,16 @@ def add_pz_active( elm_interior.visibility.hidden_at_line_plots = True assert hasattr( - zerolength_gen, zerolength_method), \ - f"Method not available: {zerolength_method}" + zerolength_gen, zerolength_method + ), f"Method not available: {zerolength_method}" mthd = getattr(zerolength_gen, zerolength_method) # define zerolength elements zerolength_gen_args = { - "section": section, - "physical_material": physical_material, - "pz_length": beam_depth - } + "section": section, + "physical_material": physical_material, + "pz_length": beam_depth, + } zerolength_gen_args.update(zerolength_args) zerolen_top_f = self.define_zerolength( component, @@ -1501,7 +1527,7 @@ def add_pz_active( x_axis, y_axis, mthd, - zerolength_gen_args + zerolength_gen_args, ) zerolen_top_b = self.define_zerolength( component, @@ -1510,7 +1536,7 @@ def add_pz_active( x_axis, y_axis, zerolength_gen.release_6, - {} + {}, ) zerolen_bottom_f = self.define_zerolength( component, @@ -1519,7 +1545,7 @@ def add_pz_active( x_axis, y_axis, zerolength_gen.release_6, - {} + {}, ) zerolen_bottom_b = self.define_zerolength( component, @@ -1528,7 +1554,7 @@ def add_pz_active( x_axis, y_axis, zerolength_gen.release_6, - {} + {}, ) # fill component assembly @@ -1551,17 +1577,9 @@ def add_pz_active( component.internal_nodes.add(bottom_v_b) component.elements.add(elm_top_h_f) - ( - component.elements.named_contents[ - "elm_top_h_f" - ] - ) = elm_top_h_f + (component.elements.named_contents["elm_top_h_f"]) = elm_top_h_f component.elements.add(elm_top_h_b) - ( - component.elements.named_contents[ - "elm_top_h_b" - ] - ) = elm_top_h_b + (component.elements.named_contents["elm_top_h_b"]) = elm_top_h_b component.elements.add(elm_bottom_h_f) component.elements.add(elm_bottom_h_b) component.elements.add(elm_top_v_f) @@ -1569,17 +1587,11 @@ def add_pz_active( component.elements.add(elm_bottom_v_f) component.elements.add(elm_bottom_v_b) component.elements.add(elm_interior) - ( - component.elements.named_contents[ - "elm_interior" - ] - ) = elm_interior + (component.elements.named_contents["elm_interior"]) = elm_interior component.elements.add(zerolen_top_f) ( - component.elements.named_contents[ - "nonlinear_spring" - ] + component.elements.named_contents["nonlinear_spring"] ) = zerolen_top_f # type: ignore component.elements.add(zerolen_top_b) component.elements.add(zerolen_bottom_f) diff --git a/src/osmg/gen/material_gen.py b/src/osmg/gen/material_gen.py index e02913d0..bc8a4b25 100644 --- a/src/osmg/gen/material_gen.py +++ b/src/osmg/gen/material_gen.py @@ -144,7 +144,7 @@ def generate_steel_hss_circ_brace_fatigue_mat( a1=0.2, a2=1.0, a3=0.2, - a4=1.0 + a4=1.0, ) fatigue_mat = Fatigue( @@ -152,7 +152,7 @@ def generate_steel_hss_circ_brace_fatigue_mat( "auto_fatigue_brace_mat", steel02_mat, var_e0, - var_m + var_m, ) return fatigue_mat @@ -170,7 +170,7 @@ def generate_steel_w_imk_material( direction="strong", moment_modifier=1.00, n_parameter=0.00, - only_elastic=False + only_elastic=False, ): """ Lignos, D. G., & Krawinkler, H. (2011). Deterioration modeling of @@ -224,7 +224,6 @@ def generate_steel_w_imk_material( # consider cases if rbs_factor: - # RBS case assert direction == "strong" assert rbs_factor <= 1.00, "rbs_factor must be <= 1.00" @@ -249,15 +248,13 @@ def generate_steel_w_imk_material( print(section.name, "\n") if not 2.5 < elm_l / sec_d < 7.0: print( - f"Warning: L/d={elm_l/sec_d:.2f}" - " outside regression range" + f"Warning: L/d={elm_l/sec_d:.2f} outside regression range" ) print("2.5 < elm_l/sec_d < 7.0") print(section.name, "\n") if not 4.00 < sec_d < 36.00: print( - f"Warning: Section d={sec_d:.2f} " - "outside regression range" + f"Warning: Section d={sec_d:.2f} outside regression range" ) print("4.00 < sec_d < 36.00") print(section.name, "\n") @@ -296,7 +293,6 @@ def generate_steel_w_imk_material( mcmy_minus = 1.10 else: - # Other-than-RBS case if axial_load_ratio: # column case @@ -330,25 +326,34 @@ def generate_steel_w_imk_material( ) if axial_load_ratio <= 0.20: sec_m = ( - 1.15/1.10 * (sec_z * mat_fy) * 1.0e3 - * (1.00 - axial_load_ratio / 2.00)) + 1.15 + / 1.10 + * (sec_z * mat_fy) + * 1.0e3 + * (1.00 - axial_load_ratio / 2.00) + ) else: sec_m = ( - 1.15/1.10 * (sec_z * mat_fy) * 1.0e3 - * 9.0/8.0 * (1.00 - axial_load_ratio)) + 1.15 + / 1.10 + * (sec_z * mat_fy) + * 1.0e3 + * 9.0 + / 8.0 + * (1.00 - axial_load_ratio) + ) mcmy = ( 12.5 * (sec_d / sec_tw) ** (-0.20) * lbry ** (-0.40) * (1.00 - axial_load_ratio) ** (0.40) - ) + ) mcmy = min(mcmy, 1.00) mcmy = max(mcmy, 1.30) mcmy_plus = mcmy mcmy_minus = mcmy else: - # non-RBS beam case theta_p = ( 0.0865 @@ -388,7 +393,6 @@ def generate_steel_w_imk_material( m_minus = -sec_m if consider_composite: - # Elkady, A., & Lignos, D. G. (2014). Modeling of the # composite action in fully restrained beam‐to‐column # connections: implications in the seismic design and @@ -396,11 +400,12 @@ def generate_steel_w_imk_material( # frames. Earthquake Engineering & Structural Dynamics, # 43(13), 1935-1954. Table II - assert axial_load_ratio == 0.00, \ - "Can't consider composite action for columns" - assert direction == "strong", \ - "Composite action affects the " \ - "behavior in strong-axis bending" + assert ( + axial_load_ratio == 0.00 + ), "Can't consider composite action for columns" + assert ( + direction == "strong" + ), "Composite action affects the behavior in strong-axis bending" theta_p_plus *= 1.80 theta_p_minus *= 0.95 @@ -417,16 +422,14 @@ def generate_steel_w_imk_material( # adjust parameters to account for the presence of the elastic element stiffness_init = 6.00 * section.e_mod * sec_i / elm_h - stiffness = (n_parameter+1.00) * stiffness_init + stiffness = (n_parameter + 1.00) * stiffness_init theta_y = sec_m / stiffness_init theta_p_plus -= (mcmy_plus - 1.0) * (sec_m / stiffness) theta_p_minus -= (mcmy_minus - 1.0) * (sec_m / stiffness) theta_pc_plus += theta_y + (mcmy_plus - 1.0) * (sec_m / stiffness) theta_pc_plus += theta_y + (mcmy_minus - 1.0) * (sec_m / stiffness) beta_plus = (mcmy_plus - 1.0) * m_plus / theta_p_plus / stiffness - beta_minus = ( - -(mcmy_minus - 1.0) * m_minus / theta_p_minus / stiffness - ) + beta_minus = -(mcmy_minus - 1.0) * m_minus / theta_p_minus / stiffness # # old model # from ..ops.uniaxial_material import Bilin @@ -464,7 +467,7 @@ def generate_steel_w_imk_material( elastic_mat = Elastic( self.model.uid_generator.new("uniaxial material"), "auto_IMK", - stiffness * moment_modifier + stiffness * moment_modifier, ) return elastic_mat bilin_mat = IMKBilin( @@ -474,13 +477,13 @@ def generate_steel_w_imk_material( theta_p_plus, theta_pc_plus, theta_u, - m_plus*moment_modifier, + m_plus * moment_modifier, (1.0 + beta_plus), residual_plus, theta_p_minus, theta_pc_minus, theta_u, - -m_minus*moment_modifier, + -m_minus * moment_modifier, (1.0 + beta_minus), residual_minus, lamda, @@ -490,6 +493,6 @@ def generate_steel_w_imk_material( 1.00, 1.00, d_plus, - d_minus + d_minus, ) return bilin_mat diff --git a/src/osmg/gen/mesh_shapes.py b/src/osmg/gen/mesh_shapes.py index 7612c0d0..c080cd5d 100644 --- a/src/osmg/gen/mesh_shapes.py +++ b/src/osmg/gen/mesh_shapes.py @@ -247,10 +247,9 @@ def circ_mesh(dim_d): vertices = [] for i in range(num_vertices): angle = i * angle_increment - vertices.append(Vertex(( - radius * np.cos(angle), - radius * np.sin(angle) - ))) + vertices.append( + Vertex((radius * np.cos(angle), radius * np.sin(angle))) + ) edges = define_edges(vertices) return generate(edges) diff --git a/src/osmg/gen/query.py b/src/osmg/gen/query.py index c59f6ee3..e56fca52 100644 --- a/src/osmg/gen/query.py +++ b/src/osmg/gen/query.py @@ -173,8 +173,8 @@ def retrieve_component_from_nodes( return retrieved_component def retrieve_component( - self, x_loc: float, y_loc: float, lvl: int) \ - -> Optional[ComponentAssembly]: + self, x_loc: float, y_loc: float, lvl: int + ) -> Optional[ComponentAssembly]: """ Retrieves a component assembly of a level if any of its line elements passes trhough the specified point. @@ -192,10 +192,13 @@ def retrieve_component( for component in level.components.values(): if len(component.external_nodes) != 2: continue - line_elems: list[Union[ - element.TrussBar, - element.ElasticBeamColumn, - element.DispBeamColumn]] = [] + line_elems: list[ + Union[ + element.TrussBar, + element.ElasticBeamColumn, + element.DispBeamColumn, + ] + ] = [] for elm in component.elements.values(): if isinstance(elm, element.TrussBar): line_elems.append(elm) @@ -209,10 +212,12 @@ def retrieve_component( p_i = np.array(elm.nodes[0].coords) p_j = np.array(elm.nodes[1].coords) else: - p_i = np.array( - elm.nodes[0].coords) + elm.geomtransf.offset_i - p_j = np.array( - elm.nodes[1].coords) + elm.geomtransf.offset_j + p_i = ( + np.array(elm.nodes[0].coords) + elm.geomtransf.offset_i + ) + p_j = ( + np.array(elm.nodes[1].coords) + elm.geomtransf.offset_j + ) if np.linalg.norm(p_i[0:2] - p_j[0:2]) < common.EPSILON: if ( np.linalg.norm(np.array((x_loc, y_loc)) - p_i[0:2]) diff --git a/src/osmg/gen/section_gen.py b/src/osmg/gen/section_gen.py index 71738f6e..dc5f0582 100644 --- a/src/osmg/gen/section_gen.py +++ b/src/osmg/gen/section_gen.py @@ -345,9 +345,7 @@ def load_aisc_from_database( sec_h = sec_data["OD"] sec_t = sec_data["tdes"] outside_shape = mesh_shapes.circ_mesh(sec_h) - hole = mesh_shapes.circ_mesh( - sec_h - 2.00 * sec_t - ) + hole = mesh_shapes.circ_mesh(sec_h - 2.00 * sec_t) bbox = outside_shape.bounding_box() z_min, y_min, z_max, y_max = bbox.flatten() snap_points = { diff --git a/src/osmg/gen/steel/brb.py b/src/osmg/gen/steel/brb.py index 121df843..50c8ac52 100644 --- a/src/osmg/gen/steel/brb.py +++ b/src/osmg/gen/steel/brb.py @@ -37,6 +37,7 @@ class BRBGenSettings: fewer arguments. """ + steel4_b_k: float = field(default=0.003) steel4_b_kc: float = field(default=0.023) steel4_R_0: float = field(default=25.00) @@ -81,22 +82,22 @@ class BRBGenerator: settings: BRBGenSettings = field(default_factory=BRBGenSettings) def add_brb( - self, - xi_coord: float, - yi_coord: float, - lvl_key_i: int, - offset_i: nparr, - snap_i: str, - xj_coord: float, - yj_coord: float, - lvl_key_j: int, - offset_j: nparr, - snap_j: str, - area: float, - f_y: float, - e_0: float, - casing_size: float, - unit_weight: float + self, + xi_coord: float, + yi_coord: float, + lvl_key_i: int, + offset_i: nparr, + snap_i: str, + xj_coord: float, + yj_coord: float, + lvl_key_j: int, + offset_j: nparr, + snap_j: str, + area: float, + f_y: float, + e_0: float, + casing_size: float, + unit_weight: float, ) -> None: """ Adds a BRB element to the model. @@ -139,8 +140,7 @@ def add_brb( trg = TrussBarGenerator(self.model) - uid = self.model.uid_generator.new( - "uniaxial material") + uid = self.model.uid_generator.new("uniaxial material") mat = Steel4( uid=uid, name=f'auto_BRB_{uid}', @@ -164,20 +164,22 @@ def add_brb( R_ic=self.settings.steel4_R_ic, l_yp=self.settings.steel4_l_yp, ) - uid = self.model.uid_generator.new( - "uniaxial material") + uid = self.model.uid_generator.new("uniaxial material") mat_fatigue = Fatigue( uid=uid, name=f'auto_BRB_fatigue_{uid}', predecessor=mat, e_mod=self.settings.fatigue_e_mod, - var_m=self.settings.fatigue_var_m) + var_m=self.settings.fatigue_var_m, + ) trg.add( - xi_coord, yi_coord, + xi_coord, + yi_coord, lvl_key_i, offset_i, snap_i, - xj_coord, yj_coord, + xj_coord, + yj_coord, lvl_key_j, offset_j, snap_j, @@ -185,5 +187,5 @@ def add_brb( area=area, mat=mat_fatigue, outside_shape=rect_mesh(casing_size, casing_size), - weight_per_length=unit_weight*casing_size**2 + weight_per_length=unit_weight * casing_size**2, ) diff --git a/src/osmg/gen/zerolength_gen.py b/src/osmg/gen/zerolength_gen.py index 150b56d4..beacac93 100644 --- a/src/osmg/gen/zerolength_gen.py +++ b/src/osmg/gen/zerolength_gen.py @@ -34,8 +34,8 @@ def fix_all( - model: Model, **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, **kwargs: dict[object, object] +) -> tuple[list[int], list[UniaxialMaterial]]: """ Fixed in all directions. @@ -50,8 +50,8 @@ def fix_all( def release_6( - model: Model, **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, **kwargs: dict[object, object] +) -> tuple[list[int], list[UniaxialMaterial]]: """ Frees strong axis bending. @@ -66,8 +66,8 @@ def release_6( def release_5( - model: Model, **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, **kwargs: dict[object, object] +) -> tuple[list[int], list[UniaxialMaterial]]: """ Frees weak axis bending. @@ -82,8 +82,8 @@ def release_5( def release_56( - model: Model, **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, **kwargs: dict[object, object] +) -> tuple[list[int], list[UniaxialMaterial]]: """ Frees both strong and weak axis bending. @@ -98,17 +98,17 @@ def release_56( def imk_6( - model: Model, - element_length: float, - lboverl: float, - loverh: float, - rbs_factor: Optional[float], - consider_composite: bool, - axial_load_ratio: float, - section: ElasticSection, - physical_material: PhysicalMaterial, - **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, + element_length: float, + lboverl: float, + loverh: float, + rbs_factor: Optional[float], + consider_composite: bool, + axial_load_ratio: float, + section: ElasticSection, + physical_material: PhysicalMaterial, + **kwargs: dict[object, object], +) -> tuple[list[int], list[UniaxialMaterial]]: """ Lignos, D. G., & Krawinkler, H. (2011). Deterioration modeling of steel components in support of collapse prediction of steel moment @@ -140,7 +140,7 @@ def imk_6( direction="strong", moment_modifier=moment_modifier, n_parameter=n_parameter, - only_elastic=only_elastic + only_elastic=only_elastic, ) dirs = [1, 2, 3, 4, 5, 6] mat_repo = model.uniaxial_materials @@ -151,17 +151,17 @@ def imk_6( def imk_56( - model: Model, - element_length: float, - lboverl: float, - loverh: float, - rbs_factor: Optional[float], - consider_composite: bool, - axial_load_ratio: float, - section: ElasticSection, - physical_material: PhysicalMaterial, - **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, + element_length: float, + lboverl: float, + loverh: float, + rbs_factor: Optional[float], + consider_composite: bool, + axial_load_ratio: float, + section: ElasticSection, + physical_material: PhysicalMaterial, + **kwargs: dict[object, object], +) -> tuple[list[int], list[UniaxialMaterial]]: """ release in the weak axis bending direction, :func:`~osmg.gen.zerolength_gen.imk_6` in the strong axis bending @@ -186,7 +186,7 @@ def imk_56( direction="strong", moment_modifier=moment_modifier, n_parameter=n_parameter, - only_elastic=only_elastic + only_elastic=only_elastic, ) mat_weak = mat_generator.generate_steel_w_imk_material( section, @@ -199,7 +199,7 @@ def imk_56( axial_load_ratio, direction="weak", moment_modifier=moment_modifier, - only_elastic=only_elastic + only_elastic=only_elastic, ) dirs = [1, 2, 3, 4, 5, 6] mat_repo = model.uniaxial_materials @@ -210,17 +210,17 @@ def imk_56( def imk_6_release_5( - model: Model, - element_length: float, - lboverl: float, - loverh: float, - rbs_factor: Optional[float], - consider_composite: bool, - axial_load_ratio: float, - section: ElasticSection, - physical_material: PhysicalMaterial, - **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, + element_length: float, + lboverl: float, + loverh: float, + rbs_factor: Optional[float], + consider_composite: bool, + axial_load_ratio: float, + section: ElasticSection, + physical_material: PhysicalMaterial, + **kwargs: dict[object, object], +) -> tuple[list[int], list[UniaxialMaterial]]: """ release in the weak axis bending direction, :func:`~osmg.gen.zerolength_gen.imk_6` in the strong axis bending @@ -245,7 +245,7 @@ def imk_6_release_5( direction="strong", moment_modifier=moment_modifier, n_parameter=n_parameter, - only_elastic=only_elastic + only_elastic=only_elastic, ) dirs = [1, 2, 3, 4, 6] mat_repo = model.uniaxial_materials @@ -256,12 +256,12 @@ def imk_6_release_5( def gravity_shear_tab( - model: Model, - consider_composite: bool, - section: ElasticSection, - physical_material: PhysicalMaterial, - **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, + consider_composite: bool, + section: ElasticSection, + physical_material: PhysicalMaterial, + **kwargs: dict[object, object], +) -> tuple[list[int], list[UniaxialMaterial]]: """ Elkady, A., & Lignos, D. G. (2015). Effect of gravity framing on the overstrength and collapse capacity of steel frame buildings @@ -401,16 +401,16 @@ def gravity_shear_tab( def steel_w_col_pz( - model: Model, - section: ElasticSection, - physical_material: PhysicalMaterial, - pz_length: float, - pz_doubler_plate_thickness: float, - pz_hardening: float, - only_elastic: bool = False, - moment_modifier: float = 1.00, - **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, + section: ElasticSection, + physical_material: PhysicalMaterial, + pz_length: float, + pz_doubler_plate_thickness: float, + pz_hardening: float, + only_elastic: bool = False, + moment_modifier: float = 1.00, + **kwargs: dict[object, object], +) -> tuple[list[int], list[UniaxialMaterial]]: """ Gupta, A., & Krawinkler, H. (1999). Seismic demands for the performance evaluation of steel moment resisting frame @@ -437,18 +437,18 @@ def steel_w_col_pz( gamma_1 = v_y / k_e gamma_2 = 4.0 * gamma_1 gamma_3 = 100.0 * gamma_1 - m1y = (gamma_1 * k_e * pz_length - * moment_modifier) - m2y = (m1y + k_p * pz_length * (gamma_2 - gamma_1) - * moment_modifier) - m3y = (m2y + (hardening * k_e * pz_length) * (gamma_3 - gamma_2) - * moment_modifier) + m1y = gamma_1 * k_e * pz_length * moment_modifier + m2y = m1y + k_p * pz_length * (gamma_2 - gamma_1) * moment_modifier + m3y = ( + m2y + + (hardening * k_e * pz_length) * (gamma_3 - gamma_2) * moment_modifier + ) if only_elastic: mat: UniaxialMaterial = Elastic( model.uid_generator.new("uniaxial material"), "auto_steel_W_PZ", - m1y/gamma_1 + m1y / gamma_1, ) else: mat = Hysteretic( @@ -486,8 +486,8 @@ def steel_w_col_pz_updated( location: str, only_elastic: bool = False, moment_modifier: float = 1.00, - **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + **kwargs: dict[object, object], +) -> tuple[list[int], list[UniaxialMaterial]]: """ Skiadopoulos, A., Elkady, A. and D. G. Lignos (2020). "Proposed Panel Zone Model for Seismic Design of Steel Moment-Resisting @@ -526,15 +526,28 @@ def steel_w_col_pz_updated( # Stiffness Calculation Ks = tpz * (d_Col - tf_Col) * g_mod - Kb = (12.0 * e_mod * (Ix_Col + tdp * - ((d_Col - 2.0 * tf_Col)**3) / 12.00) / (d_Beam**3) * d_Beam) + Kb = ( + 12.0 + * e_mod + * (Ix_Col + tdp * ((d_Col - 2.0 * tf_Col) ** 3) / 12.00) + / (d_Beam**3) + * d_Beam + ) Ke = Ks * Kb / (Ks + Kb) # flange stiffness: shear contribution Ksf = 2.0 * (bf_Col * tf_Col) * g_mod # flange stiffness: bending contribution - Kbf = (2.0 * 12.0 * e_mod * bf_Col - * (tf_Col**3) / 12.0 / (d_Beam**3) * d_Beam) + Kbf = ( + 2.0 + * 12.0 + * e_mod + * bf_Col + * (tf_Col**3) + / 12.0 + / (d_Beam**3) + * d_Beam + ) # flange stiffness: total contribution Kef = (Ksf * Kbf) / (Ksf + Kbf) @@ -551,16 +564,26 @@ def steel_w_col_pz_updated( Vy = r * 0.577 * f_y * ay * (d_Col - tf_Col) * tpz # Plastic Shear Force at 4 gammaY Vp_4gamma = ( - r * 0.577 * f_y * ( - aw_eff_4gamma * (d_Col - tf_Col) - * tpz + af_eff_4gamma * (bf_Col - tw_Col) * 2*tf_Col)) + r + * 0.577 + * f_y + * ( + aw_eff_4gamma * (d_Col - tf_Col) * tpz + + af_eff_4gamma * (bf_Col - tw_Col) * 2 * tf_Col + ) + ) # Plastic Shear Force at 6 gammaY Vp_6gamma = ( - r * 0.577 * f_y * ( - aw_eff_6gamma * (d_Col - tf_Col) - * tpz + af_eff_6gamma * (bf_Col - tw_Col) * 2*tf_Col)) + r + * 0.577 + * f_y + * ( + aw_eff_6gamma * (d_Col - tf_Col) * tpz + + af_eff_6gamma * (bf_Col - tw_Col) * 2 * tf_Col + ) + ) - gamma_y = Vy/Ke + gamma_y = Vy / Ke gamma4_y = 4.0 * gamma_y My_P = Vy * d_BeamP @@ -596,37 +619,61 @@ def steel_w_col_pz_updated( M3_N *= moment_modifier if not consider_composite: - args = ((M1_N, gamma1), - (M2_N, gamma2), - (M3_N, gamma3), - (-M1_N, -gamma1), - (-M2_N, -gamma2), - (-M3_N, -gamma3), - 0.25, 0.75, 0.0, 0.0, 0.0) + args = ( + (M1_N, gamma1), + (M2_N, gamma2), + (M3_N, gamma3), + (-M1_N, -gamma1), + (-M2_N, -gamma2), + (-M3_N, -gamma3), + 0.25, + 0.75, + 0.0, + 0.0, + 0.0, + ) elif location == 'interior': - args = ((M1_P, gamma1), - (M2_P, gamma2), - (M3_P, gamma3), - (-M1_P, -gamma1), - (-M2_P, -gamma2), - (-M3_P, -gamma3), - 0.25, 0.75, 0.0, 0.0, 0.0) + args = ( + (M1_P, gamma1), + (M2_P, gamma2), + (M3_P, gamma3), + (-M1_P, -gamma1), + (-M2_P, -gamma2), + (-M3_P, -gamma3), + 0.25, + 0.75, + 0.0, + 0.0, + 0.0, + ) elif location == 'exterior_first': - args = ((M1_N, gamma1), - (M2_N, gamma2), - (M3_N, gamma3), - (-M1_P, -gamma1), - (-M2_P, -gamma2), - (-M3_P, -gamma3), - 0.25, 0.75, 0.0, 0.0, 0.0) + args = ( + (M1_N, gamma1), + (M2_N, gamma2), + (M3_N, gamma3), + (-M1_P, -gamma1), + (-M2_P, -gamma2), + (-M3_P, -gamma3), + 0.25, + 0.75, + 0.0, + 0.0, + 0.0, + ) elif location == 'exterior_last': - args = ((M1_P, gamma1), - (M2_P, gamma2), - (M3_P, gamma3), - (-M1_N, -gamma1), - (-M2_N, -gamma2), - (-M3_N, -gamma3), - 0.25, 0.75, 0.0, 0.0, 0.0) + args = ( + (M1_P, gamma1), + (M2_P, gamma2), + (M3_P, gamma3), + (-M1_N, -gamma1), + (-M2_N, -gamma2), + (-M3_N, -gamma3), + 0.25, + 0.75, + 0.0, + 0.0, + 0.0, + ) else: raise ValueError(f'Invalid Location: {location}') @@ -635,13 +682,13 @@ def steel_w_col_pz_updated( mat: UniaxialMaterial = Elastic( model.uid_generator.new("uniaxial material"), "auto_steel_W_PZ", - m1y/gamma_1 # type: ignore + m1y / gamma_1, # type: ignore ) else: mat = Hysteretic( model.uid_generator.new("uniaxial material"), "auto_steel_W_pz_updated", - *args + *args, ) # minmaxmat = MinMax( # model.uid_generator.new("uniaxial material"), @@ -657,14 +704,14 @@ def steel_w_col_pz_updated( def steel_brace_gusset( - model: Model, - physical_mat: PhysicalMaterial, - d_brace: float, - l_c: float, - t_p: float, - l_b: float, - **kwargs: dict[object, object]) \ - -> tuple[list[int], list[UniaxialMaterial]]: + model: Model, + physical_mat: PhysicalMaterial, + d_brace: float, + l_c: float, + t_p: float, + l_b: float, + **kwargs: dict[object, object], +) -> tuple[list[int], list[UniaxialMaterial]]: """ Hsiao, P-C., Lehman, D.E., and Roeder, C.W., 2012, Improved analytical model for special concentrically braced frames, Journal diff --git a/src/osmg/graphics/graphics_common_3d.py b/src/osmg/graphics/graphics_common_3d.py index 7439b5ea..22f131ec 100644 --- a/src/osmg/graphics/graphics_common_3d.py +++ b/src/osmg/graphics/graphics_common_3d.py @@ -72,7 +72,7 @@ def global_layout(mdl, camera=None): x=(p_max[0] - p_min[0]) / (ref_len / 4.0), y=(p_max[1] - p_min[1]) / (ref_len / 4.0), z=(p_max[2] - p_min[2]) / (ref_len / 4.0), - ) + ), # note: # aspectmode='data': was causing issues with # the camera 'moving' across different animation frames diff --git a/src/osmg/graphics/postprocessing_3d.py b/src/osmg/graphics/postprocessing_3d.py index 4d6b9d59..d0b0424f 100644 --- a/src/osmg/graphics/postprocessing_3d.py +++ b/src/osmg/graphics/postprocessing_3d.py @@ -237,7 +237,9 @@ def add_data__extruded_line_elms_deformed_mesh( transformations.local_axes_from_points_and_angle( np.array(elm.nodes[0].coords), np.array(elm.nodes[1].coords), - 0.00)) + 0.00, + ) + ) outside_shape = elm.outside_shape else: offset_i = elm.geomtransf.offset_i @@ -249,18 +251,21 @@ def add_data__extruded_line_elms_deformed_mesh( u_i_o = transformations.offset_transformation(offset_i, u_i, r_i) u_j_o = transformations.offset_transformation(offset_j, u_j, r_j) if isinstance(elm, element.TrussBar): - d_global = np.column_stack(( - np.linspace(u_i[0], u_j[0], num_points), - np.linspace(u_i[1], u_j[1], num_points), - np.linspace(u_i[2], u_j[2], num_points), - )) + d_global = np.column_stack( + ( + np.linspace(u_i[0], u_j[0], num_points), + np.linspace(u_i[1], u_j[1], num_points), + np.linspace(u_i[2], u_j[2], num_points), + ) + ) r_local = np.zeros((num_points, 3)) interpolation_points = interp_3d_points( elm, d_global, num_points, scaling ) else: d_global, r_local = interp_3d_deformation( - elm, u_i_o, r_i, u_j_o, r_j, num_points) + elm, u_i_o, r_i, u_j_o, r_j, num_points + ) interpolation_points = interp_3d_points( elm, d_global, num_points, scaling ) @@ -326,20 +331,15 @@ def add_data__extruded_line_elms_deformed_mesh( loc1 = loc_j_global + defo_ja_global loc2 = loc_j_global + defo_jb_global loc3 = loc_i_global + defo_ib_global - x_list.extend(( - loc0[0], loc1[0], loc2[0], loc3[0])) - y_list.extend(( - loc0[1], loc1[1], loc2[1], loc3[1])) - z_list.extend(( - loc0[2], loc1[2], loc2[2], loc3[2])) - i_list.extend(( - index + 0, index + 0)) - j_list.extend(( - index + 1, index + 2)) - k_list.extend(( - index + 2, index + 3)) + x_list.extend((loc0[0], loc1[0], loc2[0], loc3[0])) + y_list.extend((loc0[1], loc1[1], loc2[1], loc3[1])) + z_list.extend((loc0[2], loc1[2], loc2[2], loc3[2])) + i_list.extend((index + 0, index + 0)) + j_list.extend((index + 1, index + 2)) + k_list.extend((index + 2, index + 3)) intensity.append( - float(np.sqrt(d_global[i, :] @ d_global[i, :]))) + float(np.sqrt(d_global[i, :] @ d_global[i, :])) + ) intensity.append( float(np.sqrt(d_global[i + 1, :] @ d_global[i + 1, :])) ) @@ -347,7 +347,8 @@ def add_data__extruded_line_elms_deformed_mesh( float(np.sqrt(d_global[i + 1, :] @ d_global[i + 1, :])) ) intensity.append( - float(np.sqrt(d_global[i, :] @ d_global[i, :]))) + float(np.sqrt(d_global[i, :] @ d_global[i, :])) + ) index += 4 data_dict.append( { @@ -409,11 +410,13 @@ def add_data__line_elms_deformed( ) else: # for a truss member, just connect the two ends - d_global = np.column_stack(( - np.linspace(u_i[0], u_j[0], num_points), - np.linspace(u_i[1], u_j[1], num_points), - np.linspace(u_i[2], u_j[2], num_points), - )) + d_global = np.column_stack( + ( + np.linspace(u_i[0], u_j[0], num_points), + np.linspace(u_i[1], u_j[1], num_points), + np.linspace(u_i[2], u_j[2], num_points), + ) + ) interpolation_points = interp_3d_points( elm, d_global, num_points, scaling ) @@ -539,7 +542,6 @@ def add_data__frames_undeformed(data_dict, list_of_line_elems): z_list: list[Optional[float]] = [] for elm in list_of_line_elems: - if isinstance(elm, element.TrussBar): p_i = np.array(elm.nodes[0].coords) p_j = np.array(elm.nodes[1].coords) @@ -612,14 +614,16 @@ def add_data__nodes_deformed( "y": location_data[:, 1] + displacement_data[:, 1] * scaling, "z": location_data[:, 2] + displacement_data[:, 2] * scaling, "customdata": displacement_data, - "hovertemplate": "ux: %{customdata[0]:.6g}
" - + "uy: %{customdata[1]:.6g}
" - + "uz: %{customdata[2]:.6g}
" - + "combined: %{customdata[6]:.6g}
" - + "rx: %{customdata[3]:.6g} (rad)
" - + "ry: %{customdata[4]:.6g} (rad)
" - + "rz: %{customdata[5]:.6g} (rad)
" - + "Node %{customdata[7]:d}", + "hovertemplate": ( + "ux: %{customdata[0]:.6g}
" + + "uy: %{customdata[1]:.6g}
" + + "uz: %{customdata[2]:.6g}
" + + "combined: %{customdata[6]:.6g}
" + + "rx: %{customdata[3]:.6g} (rad)
" + + "ry: %{customdata[4]:.6g} (rad)
" + + "rz: %{customdata[5]:.6g} (rad)
" + + "Node %{customdata[7]:d}" + ), "marker": { "symbol": marker, "color": color, @@ -641,13 +645,9 @@ def get_auto_scaling_deformation(analysis, case_name, mdl, step): ref_len = mdl.reference_length() # maximum displacement max_d = 0.00 - elms: list[ - Union[element.ElasticBeamColumn, - element.DispBeamColumn]] = [] - elms.extend( - mdl.list_of_specific_element(element.ElasticBeamColumn)) - elms.extend( - mdl.list_of_specific_element(element.DispBeamColumn)) + elms: list[Union[element.ElasticBeamColumn, element.DispBeamColumn]] = [] + elms.extend(mdl.list_of_specific_element(element.ElasticBeamColumn)) + elms.extend(mdl.list_of_specific_element(element.DispBeamColumn)) for elm in elms: u_i = analysis.results[case_name].node_displacements[elm.nodes[0].uid][ @@ -679,19 +679,18 @@ def get_auto_scaling_deformation(analysis, case_name, mdl, step): def show_deformed_shape( - analysis: Analysis, - case_name: str, - step: int, - scaling: float, - extrude: bool, - camera: Optional[dict[str, object]] = None, - subset_model: Model = None, - animation: bool = False, - init_step: int = 0, - step_skip: int = 0, - to_html_file: Optional[str] = None + analysis: Analysis, + case_name: str, + step: int, + scaling: float, + extrude: bool, + camera: Optional[dict[str, object]] = None, + subset_model: Model = None, + animation: bool = False, + init_step: int = 0, + step_skip: int = 0, + to_html_file: Optional[str] = None, ) -> dict[str, Any]: - """ Visualize the model in its deformed state @@ -733,12 +732,13 @@ def show_deformed_shape( # gather lists of associated objects list_of_line_elems: list[element.Element] = [] + list_of_line_elems.extend(mdl.list_of_specific_element(element.TrussBar)) list_of_line_elems.extend( - mdl.list_of_specific_element(element.TrussBar)) - list_of_line_elems.extend( - mdl.list_of_specific_element(element.ElasticBeamColumn)) + mdl.list_of_specific_element(element.ElasticBeamColumn) + ) list_of_line_elems.extend( - mdl.list_of_specific_element(element.DispBeamColumn)) + mdl.list_of_specific_element(element.DispBeamColumn) + ) list_of_primary_nodes = mdl.list_of_primary_nodes() list_of_internal_nodes = mdl.list_of_internal_nodes() # list_of_parent_nodes = mdl.list_of_parent_nodes() @@ -800,7 +800,7 @@ def frame_args(duration): if animation: step_of_frame = [] - for j in range(first_step, step+1, step_skip + 1): + for j in range(first_step, step + 1, step_skip + 1): step_of_frame.append(j) for _, j in enumerate(step_of_frame): frame_data_dict.append([]) @@ -934,7 +934,7 @@ def show_basic_forces( global_axes=False, camera=None, subset_model=None, - to_html_file=None + to_html_file=None, ): """ Visualize the model and plot the frame element basic forces. @@ -972,20 +972,16 @@ def show_basic_forces( mdl = analysis.mdl elms: list[ - Union[element.TrussBar, - element.ElasticBeamColumn, - element.DispBeamColumn]] = [] - elms.extend( - mdl.list_of_specific_element(element.TrussBar)) - elms.extend( - mdl.list_of_specific_element(element.ElasticBeamColumn)) - elms.extend( - mdl.list_of_specific_element(element.DispBeamColumn)) + Union[ + element.TrussBar, element.ElasticBeamColumn, element.DispBeamColumn + ] + ] = [] + elms.extend(mdl.list_of_specific_element(element.TrussBar)) + elms.extend(mdl.list_of_specific_element(element.ElasticBeamColumn)) + elms.extend(mdl.list_of_specific_element(element.DispBeamColumn)) list_of_line_elements = [ - elm - for elm in elms - if not elm.visibility.skip_opensees_definition + elm for elm in elms if not elm.visibility.skip_opensees_definition ] layout = graphics_common_3d.global_layout(mdl, camera) @@ -1053,7 +1049,6 @@ def show_basic_forces( my_vecs = {} for elm in list_of_line_elements: - if elm.visibility.hidden_basic_forces: continue @@ -1115,7 +1110,6 @@ def show_basic_forces( scaling_m = 1.00 for elm in list_of_line_elements: - if elm.visibility.hidden_basic_forces: continue @@ -1127,7 +1121,8 @@ def show_basic_forces( my_vec = my_vecs[elm.uid] mz_vec = mz_vecs[elm.uid] if isinstance( - elm, (element.ElasticBeamColumn, element.DispBeamColumn)): + elm, (element.ElasticBeamColumn, element.DispBeamColumn) + ): x_vec = elm.geomtransf.x_axis y_vec = elm.geomtransf.y_axis z_vec = elm.geomtransf.z_axis @@ -1140,13 +1135,14 @@ def show_basic_forces( i_pos = np.array(elm.nodes[0].coords) x_vec, y_vec, z_vec = ( transformations.local_axes_from_points_and_angle( - p_i, p_j, 0.00)) + p_i, p_j, 0.00 + ) + ) len_clr = np.linalg.norm(p_i - p_j) t_vec = np.linspace(0.00, len_clr, num=num_points) for i in range(num_points - 1): - p_start = i_pos + t_vec[i] * x_vec p_end = i_pos + t_vec[i + 1] * x_vec @@ -1261,7 +1257,7 @@ def show_basic_forces( "z": z1_a, "visible": False, "customdata": customdata_a, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_a}, } ] @@ -1274,7 +1270,7 @@ def show_basic_forces( "z": z1_b, "visible": False, "customdata": customdata_b, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_b}, } ] @@ -1287,7 +1283,7 @@ def show_basic_forces( "z": z1_c, "visible": False, "customdata": customdata_c, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_c}, } ] @@ -1300,7 +1296,7 @@ def show_basic_forces( "z": z1_d, "visible": False, "customdata": customdata_d, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_d}, } ] @@ -1313,7 +1309,7 @@ def show_basic_forces( "z": z1_e, "visible": False, "customdata": customdata_e, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_e}, } ] @@ -1326,7 +1322,7 @@ def show_basic_forces( "z": z1_f, "visible": False, "customdata": customdata_f, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_f}, } ] @@ -1352,9 +1348,11 @@ def show_basic_forces( method="update", args=[ { - "visible": [True] * len(data_dict) - + [True] - + [False] * 5 + "visible": ( + [True] * len(data_dict) + + [True] + + [False] * 5 + ) } ], ), @@ -1363,10 +1361,12 @@ def show_basic_forces( method="update", args=[ { - "visible": [True] * len(data_dict) - + [False] - + [True] - + [False] * 4 + "visible": ( + [True] * len(data_dict) + + [False] + + [True] + + [False] * 4 + ) } ], ), @@ -1375,10 +1375,12 @@ def show_basic_forces( method="update", args=[ { - "visible": [True] * len(data_dict) - + [False] * 2 - + [True] - + [False] * 3 + "visible": ( + [True] * len(data_dict) + + [False] * 2 + + [True] + + [False] * 3 + ) } ], ), @@ -1387,10 +1389,12 @@ def show_basic_forces( method="update", args=[ { - "visible": [True] * len(data_dict) - + [False] * 3 - + [True] - + [False] * 2 + "visible": ( + [True] * len(data_dict) + + [False] * 3 + + [True] + + [False] * 2 + ) } ], ), @@ -1399,10 +1403,12 @@ def show_basic_forces( method="update", args=[ { - "visible": [True] * len(data_dict) - + [False] * 4 - + [True] - + [False] + "visible": ( + [True] * len(data_dict) + + [False] * 4 + + [True] + + [False] + ) } ], ), @@ -1411,9 +1417,11 @@ def show_basic_forces( method="update", args=[ { - "visible": [True] * len(data_dict) - + [False] * 5 - + [True] + "visible": ( + [True] * len(data_dict) + + [False] * 5 + + [True] + ) } ], ), @@ -1450,7 +1458,7 @@ def show_basic_forces_combo( global_axes=False, camera=None, subset_model=None, - to_html_file=None + to_html_file=None, ): """ Visualize the model and plot the enveloped frame element basic forces @@ -1489,19 +1497,15 @@ def show_basic_forces_combo( else: mdl = combo.mdl elms: list[ - Union[element.TrussBar, - element.ElasticBeamColumn, - element.DispBeamColumn]] = [] - elms.extend( - mdl.list_of_specific_element(element.TrussBar)) - elms.extend( - mdl.list_of_specific_element(element.ElasticBeamColumn)) - elms.extend( - mdl.list_of_specific_element(element.DispBeamColumn)) + Union[ + element.TrussBar, element.ElasticBeamColumn, element.DispBeamColumn + ] + ] = [] + elms.extend(mdl.list_of_specific_element(element.TrussBar)) + elms.extend(mdl.list_of_specific_element(element.ElasticBeamColumn)) + elms.extend(mdl.list_of_specific_element(element.DispBeamColumn)) list_of_line_elements = [ - elm - for elm in elms - if not elm.visibility.skip_opensees_definition + elm for elm in elms if not elm.visibility.skip_opensees_definition ] layout = graphics_common_3d.global_layout(mdl, camera) @@ -1563,7 +1567,6 @@ def show_basic_forces_combo( my_vecs_max = {} for elm in list_of_line_elements: - if elm.visibility.hidden_basic_forces: continue @@ -1651,7 +1654,6 @@ def show_basic_forces_combo( scaling_m = 1.00 for elm in list_of_line_elements: - if elm.visibility.hidden_basic_forces: continue @@ -1671,7 +1673,8 @@ def show_basic_forces_combo( mz_vec_max = mz_vecs_max[elm.uid] if isinstance( - elm, (element.ElasticBeamColumn, element.DispBeamColumn)): + elm, (element.ElasticBeamColumn, element.DispBeamColumn) + ): x_vec = elm.geomtransf.x_axis y_vec = elm.geomtransf.y_axis z_vec = elm.geomtransf.z_axis @@ -1684,13 +1687,14 @@ def show_basic_forces_combo( i_pos = np.array(elm.nodes[0].coords) x_vec, y_vec, z_vec = ( transformations.local_axes_from_points_and_angle( - p_i, p_j, 0.00)) + p_i, p_j, 0.00 + ) + ) len_clr = np.linalg.norm(p_i - p_j) t_vec = np.linspace(0.00, len_clr, num=num_points) for i in range(num_points - 1): - p_start = i_pos + t_vec[i] * x_vec p_end = i_pos + t_vec[i + 1] * x_vec @@ -1822,7 +1826,7 @@ def show_basic_forces_combo( "z": z1_a, "visible": False, "customdata": customdata_a, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_a}, } ] @@ -1835,7 +1839,7 @@ def show_basic_forces_combo( "z": z1_b, "visible": False, "customdata": customdata_b, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_b}, } ] @@ -1848,7 +1852,7 @@ def show_basic_forces_combo( "z": z1_c, "visible": False, "customdata": customdata_c, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_c}, } ] @@ -1861,7 +1865,7 @@ def show_basic_forces_combo( "z": z1_d, "visible": False, "customdata": customdata_d, - "hovertemplate": " %{customdata:.0f}
" "", + "hovertemplate": " %{customdata:.0f}
", "line": {"width": 3, "color": colors1_d}, } ] @@ -1887,9 +1891,11 @@ def show_basic_forces_combo( method="update", args=[ { - "visible": [True] * len(data_dict) - + [True] - + [False] * 3 + "visible": ( + [True] * len(data_dict) + + [True] + + [False] * 3 + ) } ], ), @@ -1898,10 +1904,12 @@ def show_basic_forces_combo( method="update", args=[ { - "visible": [True] * len(data_dict) - + [False] - + [True] - + [False] * 2 + "visible": ( + [True] * len(data_dict) + + [False] + + [True] + + [False] * 2 + ) } ], ), @@ -1910,10 +1918,12 @@ def show_basic_forces_combo( method="update", args=[ { - "visible": [True] * len(data_dict) - + [False] * 2 - + [True] - + [False] + "visible": ( + [True] * len(data_dict) + + [False] * 2 + + [True] + + [False] + ) } ], ), @@ -1922,9 +1932,11 @@ def show_basic_forces_combo( method="update", args=[ { - "visible": [True] * len(data_dict) - + [False] * 3 - + [True] + "visible": ( + [True] * len(data_dict) + + [False] * 3 + + [True] + ) } ], ), diff --git a/src/osmg/graphics/preprocessing_3d.py b/src/osmg/graphics/preprocessing_3d.py index a9ef842d..423229bd 100644 --- a/src/osmg/graphics/preprocessing_3d.py +++ b/src/osmg/graphics/preprocessing_3d.py @@ -84,18 +84,19 @@ def add_data__nodes(data_dict, mdl, load_case): "z": z_list, "customdata": customdata, "text": restraints, - "hovertemplate": "Coordinates: " - "(%{x:.2f}, %{y:.2f}, %{z:.2f})
" - + "Restraint: %{text}
" - + "Mass: (%{customdata[1]:.3g}, " - + "%{customdata[2]:.3g}, %{customdata[3]:.3g}, " - + "%{customdata[4]:.3g}, %{customdata[5]:.3g}, " - + "%{customdata[6]:.3g})
" - + "Load: (%{customdata[7]:.3g}, " - + "%{customdata[8]:.3g}, %{customdata[9]:.3g}, " - + "%{customdata[10]:.3g}, %{customdata[11]:.3g}, " - + "%{customdata[12]:.3g})" - + "Node: %{customdata[0]:d}", + "hovertemplate": ( + "Coordinates: (%{x:.2f}, %{y:.2f}, %{z:.2f})
" + + "Restraint: %{text}
" + + "Mass: (%{customdata[1]:.3g}, " + + "%{customdata[2]:.3g}, %{customdata[3]:.3g}, " + + "%{customdata[4]:.3g}, %{customdata[5]:.3g}, " + + "%{customdata[6]:.3g})
" + + "Load: (%{customdata[7]:.3g}, " + + "%{customdata[8]:.3g}, %{customdata[9]:.3g}, " + + "%{customdata[10]:.3g}, %{customdata[11]:.3g}, " + + "%{customdata[12]:.3g})" + + "Node: %{customdata[0]:d}" + ), "marker": { "symbol": [ graphics_common_3d.node_marker[sym][0] @@ -124,10 +125,11 @@ def add_data__nodes(data_dict, mdl, load_case): "z": z_list, "customdata": customdata, "text": restraints, - "hovertemplate": "Coordinates: " - "(%{x:.2f}, %{y:.2f}, %{z:.2f})
" - + "Restraint: %{text}
" - + "Node: %{customdata[0]:d}", + "hovertemplate": ( + "Coordinates: (%{x:.2f}, %{y:.2f}, %{z:.2f})
" + + "Restraint: %{text}
" + + "Node: %{customdata[0]:d}" + ), "marker": { "symbol": [ graphics_common_3d.node_marker[sym][0] @@ -148,8 +150,8 @@ def add_data__nodes(data_dict, mdl, load_case): def add_data__parent_nodes( - data_dict: list[dict[str, object]], - load_case: LoadCase) -> None: + data_dict: list[dict[str, object]], load_case: LoadCase +) -> None: """ Adds a trace containing parent nodes @@ -186,25 +188,27 @@ def add_data__parent_nodes( "z": z_list, "customdata": customdata, "text": restraints, - "hovertemplate": "Coordinates: (%{x:.2f}, %{y:.2f}, %{z:.2f})
" - + "Restraint: %{text}
" - + "Mass: (%{customdata[1]:.3g}, " - + "%{customdata[2]:.3g}, %{customdata[3]:.3g}, " - + "%{customdata[4]:.3g}, %{customdata[5]:.3g}, " - + "%{customdata[6]:.3g})
" - + "Load: (%{customdata[7]:.3g}, " - + "%{customdata[8]:.3g}, %{customdata[9]:.3g}, " - + "%{customdata[10]:.3g}, %{customdata[11]:.3g}, " - + "%{customdata[12]:.3g})" - + "Parent Node: %{customdata[0]:d}", + "hovertemplate": ( + "Coordinates: (%{x:.2f}, %{y:.2f}, %{z:.2f})
" + + "Restraint: %{text}
" + + "Mass: (%{customdata[1]:.3g}, " + + "%{customdata[2]:.3g}, %{customdata[3]:.3g}, " + + "%{customdata[4]:.3g}, %{customdata[5]:.3g}, " + + "%{customdata[6]:.3g})
" + + "Load: (%{customdata[7]:.3g}, " + + "%{customdata[8]:.3g}, %{customdata[9]:.3g}, " + + "%{customdata[10]:.3g}, %{customdata[11]:.3g}, " + + "%{customdata[12]:.3g})" + + "Parent Node: %{customdata[0]:d}" + ), "marker": { - "symbol": [ - graphics_common_3d.node_marker[ - "parent"][0]]*len(list_of_nodes), + "symbol": [graphics_common_3d.node_marker["parent"][0]] * len( + list_of_nodes + ), "color": graphics_common.NODE_PRIMARY_COLOR, - "size": [ - graphics_common_3d.node_marker[ - "parent"][1]]*len(list_of_nodes), + "size": [graphics_common_3d.node_marker["parent"][1]] * len( + list_of_nodes + ), "line": { "color": graphics_common.NODE_PRIMARY_COLOR, "width": 4, @@ -215,8 +219,10 @@ def add_data__parent_nodes( def add_data__internal_nodes( - data_dict: list[dict[str, object]], - mdl: Model, load_case: Optional[LoadCase] = None) -> None: + data_dict: list[dict[str, object]], + mdl: Model, + load_case: Optional[LoadCase] = None, +) -> None: """ Adds a trace containing internal nodes @@ -264,14 +270,15 @@ def add_data__internal_nodes( "z": z_list, "customdata": customdata, "text": restraints, - "hovertemplate": "Coordinates: " - "(%{x:.2f}, %{y:.2f}, %{z:.2f})
" - + "Restraint: %{text}
" - + "Mass: (%{customdata[1]:.3g}, " - + "%{customdata[2]:.3g}, %{customdata[3]:.3g})
" - + "Load: (%{customdata[4]:.3g}, " - + "%{customdata[5]:.3g}, %{customdata[6]:.3g})" - + "Node: %{customdata[0]:d}", + "hovertemplate": ( + "Coordinates: (%{x:.2f}, %{y:.2f}, %{z:.2f})
" + + "Restraint: %{text}
" + + "Mass: (%{customdata[1]:.3g}, " + + "%{customdata[2]:.3g}, %{customdata[3]:.3g})
" + + "Load: (%{customdata[4]:.3g}, " + + "%{customdata[5]:.3g}, %{customdata[6]:.3g})" + + "Node: %{customdata[0]:d}" + ), "marker": { "symbol": [ graphics_common_3d.node_marker[sym][0] @@ -300,10 +307,11 @@ def add_data__internal_nodes( "z": z_list, "customdata": customdata, "text": restraints, - "hovertemplate": "Coordinates: " - "(%{x:.2f}, %{y:.2f}, %{z:.2f})
" - + "Restraint: %{text}
" - + "Node: %{customdata[0]:d}", + "hovertemplate": ( + "Coordinates: (%{x:.2f}, %{y:.2f}, %{z:.2f})
" + + "Restraint: %{text}
" + + "Node: %{customdata[0]:d}" + ), "marker": { "symbol": [ graphics_common_3d.node_marker[sym][0] @@ -324,8 +332,8 @@ def add_data__internal_nodes( def add_data__release_nodes( - data_dict: list[dict[str, object]], - list_of_nodes: list[node_module.Node]) -> None: + data_dict: list[dict[str, object]], list_of_nodes: list[node_module.Node] +) -> None: """ Adds a trace containing release nodes @@ -363,9 +371,10 @@ def add_data__release_nodes( def add_data__frames( - data_dict: list[dict[str, object]], - mdl: Model, - load_case: Optional[LoadCase] = None) -> None: + data_dict: list[dict[str, object]], + mdl: Model, + load_case: Optional[LoadCase] = None, +) -> None: """ Adds a trace containing frame element centroidal axis lines @@ -378,18 +387,21 @@ def add_data__frames( """ line_elems: list[ - Union[element.ElasticBeamColumn, - element.DispBeamColumn]] = [] + Union[element.ElasticBeamColumn, element.DispBeamColumn] + ] = [] # >>> # it feels ridiculous to do this, but it's the only way I am # getting rid of type checking warnings. elms_elastic = [ - elm for elm in mdl.list_of_specific_element(element.ElasticBeamColumn) - if isinstance(elm, element.ElasticBeamColumn)] + elm + for elm in mdl.list_of_specific_element(element.ElasticBeamColumn) + if isinstance(elm, element.ElasticBeamColumn) + ] line_elems.extend(elms_elastic) elms_disp = [ - elm for elm in mdl.list_of_specific_element(element.DispBeamColumn) + elm + for elm in mdl.list_of_specific_element(element.DispBeamColumn) if isinstance(elm, element.DispBeamColumn) ] line_elems.extend(elms_disp) @@ -452,12 +464,14 @@ def add_data__frames( "z": z_list, "text": section_names, "customdata": customdata, - "hovertemplate": "Section: %{text}
" - + "UDL (local): (%{customdata[1]:.3g}, " - + "%{customdata[2]:.3g}, %{customdata[3]:.3g})" - + "Element: %{customdata[0]:d}
" - + "Node @ this end: %{customdata[4]:d}
" - "Parent: %{customdata[5]}
", + "hovertemplate": ( + "Section: %{text}
" + + "UDL (local): (%{customdata[1]:.3g}, " + + "%{customdata[2]:.3g}, %{customdata[3]:.3g})" + + "Element: %{customdata[0]:d}
" + + "Node @ this end: %{customdata[4]:d}
" + "Parent: %{customdata[5]}
" + ), "line": {"width": 5, "color": graphics_common.FRAME_COLOR}, } ) @@ -473,19 +487,22 @@ def add_data__frames( "z": z_list, "text": section_names, "customdata": customdata, - "hovertemplate": "Section: %{text}
" - + "Element: %{customdata[0]:d}
" - + "Node @ this end: %{customdata[1]:d}
" - "Parent: %{customdata[2]}
", + "hovertemplate": ( + "Section: %{text}
" + + "Element: %{customdata[0]:d}
" + + "Node @ this end: %{customdata[1]:d}
" + "Parent: %{customdata[2]}
" + ), "line": {"width": 5, "color": graphics_common.FRAME_COLOR}, } ) def add_data__bars( - data_dict: list[dict[str, object]], - mdl: Model, - load_case: Optional[LoadCase] = None) -> None: + data_dict: list[dict[str, object]], + mdl: Model, + load_case: Optional[LoadCase] = None, +) -> None: """ Adds a trace containing frame element centroidal axis lines @@ -496,8 +513,11 @@ def add_data__bars( """ - line_elems = [elm for elm in mdl.list_of_specific_element(element.TrussBar) - if isinstance(elm, element.TrussBar)] + line_elems = [ + elm + for elm in mdl.list_of_specific_element(element.TrussBar) + if isinstance(elm, element.TrussBar) + ] if not line_elems: return x_list: list[Optional[float]] = [] @@ -553,10 +573,12 @@ def add_data__bars( "z": z_list, "text": section_areas, "customdata": customdata, - "hovertemplate": "Section area: %{text}
" - + "Element: %{customdata[0]:d}
" - + "Node @ this end: %{customdata[1]:d}
" - "Parent: %{customdata[2]}
", + "hovertemplate": ( + "Section area: %{text}
" + + "Element: %{customdata[0]:d}
" + + "Node @ this end: %{customdata[1]:d}
" + "Parent: %{customdata[2]}
" + ), "line": {"width": 5, "color": graphics_common.FRAME_COLOR}, } ) @@ -572,18 +594,20 @@ def add_data__bars( "z": z_list, "text": section_areas, "customdata": customdata, - "hovertemplate": "Section area: %{text}
" - + "Element: %{customdata[0]:d}
" - + "Node @ this end: %{customdata[1]:d}
" - "Parent: %{customdata[2]}
", + "hovertemplate": ( + "Section area: %{text}
" + + "Element: %{customdata[0]:d}
" + + "Node @ this end: %{customdata[1]:d}
" + "Parent: %{customdata[2]}
" + ), "line": {"width": 5, "color": graphics_common.FRAME_COLOR}, } ) def add_data__twonodelinks( - data_dict: list[dict[str, object]], - mdl: Model) -> None: + data_dict: list[dict[str, object]], mdl: Model +) -> None: """ Adds a trace containing twonodelink elements @@ -596,7 +620,8 @@ def add_data__twonodelinks( link_elems = [ elm for elm in mdl.list_of_elements() - if isinstance(elm, element.TwoNodeLink)] + if isinstance(elm, element.TwoNodeLink) + ] if not link_elems: return @@ -629,18 +654,20 @@ def add_data__twonodelinks( "z": z_list, # "text": section_names, "customdata": customdata, - "hovertemplate": "Section: %{text}
" - + "Element: %{customdata[0]:d}
" - + "Node @ this end: %{customdata[1]:d}
" - "Parent: %{customdata[2]}
", + "hovertemplate": ( + "Section: %{text}
" + + "Element: %{customdata[0]:d}
" + + "Node @ this end: %{customdata[1]:d}
" + "Parent: %{customdata[2]}
" + ), "line": {"width": 5, "color": graphics_common.LINK_COLOR}, } ) def add_data__frame_offsets( - data_dict: list[dict[str, object]], - mdl: Model) -> None: + data_dict: list[dict[str, object]], mdl: Model +) -> None: """ Adds a trace containing frame element rigid offset lines @@ -650,12 +677,13 @@ def add_data__frame_offsets( """ - beamcolumn_elems: list[ - element.Element] = [] + beamcolumn_elems: list[element.Element] = [] beamcolumn_elems.extend( - mdl.list_of_specific_element(element.ElasticBeamColumn)) + mdl.list_of_specific_element(element.ElasticBeamColumn) + ) beamcolumn_elems.extend( - mdl.list_of_specific_element(element.DispBeamColumn)) + mdl.list_of_specific_element(element.DispBeamColumn) + ) if not beamcolumn_elems: return @@ -666,7 +694,8 @@ def add_data__frame_offsets( for elm in beamcolumn_elems: assert isinstance( - elm, (element.ElasticBeamColumn, element.DispBeamColumn)) + elm, (element.ElasticBeamColumn, element.DispBeamColumn) + ) p_i: nparr = np.array(elm.nodes[0].coords) p_io: nparr = np.array(elm.nodes[0].coords) + elm.geomtransf.offset_i p_j: nparr = np.array(elm.nodes[1].coords) @@ -694,9 +723,8 @@ def add_data__frame_offsets( def add_data__frame_axes( - data_dict: list[dict[str, object]], - mdl: Model, - ref_len: float) -> None: + data_dict: list[dict[str, object]], mdl: Model, ref_len: float +) -> None: """ Adds a trace containing frame element local axis lines @@ -708,12 +736,13 @@ def add_data__frame_axes( """ beamcolumn_elems: list[element.Element] = [] + beamcolumn_elems.extend(mdl.list_of_specific_element(element.TrussBar)) beamcolumn_elems.extend( - mdl.list_of_specific_element(element.TrussBar)) - beamcolumn_elems.extend( - mdl.list_of_specific_element(element.ElasticBeamColumn)) + mdl.list_of_specific_element(element.ElasticBeamColumn) + ) beamcolumn_elems.extend( - mdl.list_of_specific_element(element.DispBeamColumn)) + mdl.list_of_specific_element(element.DispBeamColumn) + ) if not beamcolumn_elems: return scaling = ref_len * 0.025 @@ -723,7 +752,8 @@ def add_data__frame_axes( colors: list[Optional[str]] = [] for elm in beamcolumn_elems: assert isinstance( - elm, (element.ElasticBeamColumn, element.DispBeamColumn)) + elm, (element.ElasticBeamColumn, element.DispBeamColumn) + ) if elm.visibility.hidden_at_line_plots: continue x_vec = elm.geomtransf.x_axis @@ -759,8 +789,8 @@ def add_data__frame_axes( def add_data__zerolength_axes( - data_dict: list[dict[str, object]], - mdl: Model, ref_len: float) -> None: + data_dict: list[dict[str, object]], mdl: Model, ref_len: float +) -> None: """ Adds a trace containing zerolength element local axis lines @@ -773,7 +803,8 @@ def add_data__zerolength_axes( zerolength_elements: list[element.Element] = [] zerolength_elements.extend( - mdl.list_of_specific_element(element.ZeroLength)) + mdl.list_of_specific_element(element.ZeroLength) + ) if not zerolength_elements: return scaling = ref_len * 0.025 @@ -814,8 +845,8 @@ def add_data__zerolength_axes( def add_data__global_axes( - data_dict: list[dict[str, object]], - ref_len: float) -> None: + data_dict: list[dict[str, object]], ref_len: float +) -> None: """ Adds a trace containing global axes @@ -865,8 +896,8 @@ def add_data__global_axes( def add_data__diaphragm_lines( - data_dict: list[dict[str, object]], - loadcase: LoadCase) -> None: + data_dict: list[dict[str, object]], loadcase: LoadCase +) -> None: """ Adds a trace containing lines indicating rigid diaphragm constraints. @@ -891,7 +922,6 @@ def add_data__diaphragm_lines( # for each level that has a parent node, draw the lines mdl = loadcase.parent_model for lvl_uid, pnode in pnodes.items(): - level = mdl.levels[lvl_uid] level_primary_nodes = level.nodes.values() for node in level_primary_nodes: @@ -915,8 +945,8 @@ def add_data__diaphragm_lines( def add_data__tributary_area_boundaries( - data_dict: list[dict[str, object]], - loadcase: LoadCase) -> None: + data_dict: list[dict[str, object]], loadcase: LoadCase +) -> None: """ Adds a trace containing lines indicating tributary area boundaries that are used for load distribution. @@ -934,7 +964,6 @@ def add_data__tributary_area_boundaries( z_list: list[Optional[float]] = [] for analysis in trib_area_analysis_collection.values(): - level = analysis.parent_level data = analysis.data edge_polygons = data.edge_polygons @@ -947,7 +976,7 @@ def add_data__tributary_area_boundaries( y_vals.append(y_vals[0]) x_list.extend((*x_vals, None)) y_list.extend((*y_vals, None)) - z_list.extend((*[level.elevation]*len(x_vals), None)) + z_list.extend((*[level.elevation] * len(x_vals), None)) data_dict.append( { @@ -964,7 +993,8 @@ def add_data__tributary_area_boundaries( def add_data__extruded_frames_mesh( - data_dict: list[dict[str, object]], mdl: Model) -> None: + data_dict: list[dict[str, object]], mdl: Model +) -> None: """ Adds a trace containing frame element extrusion mesh @@ -976,9 +1006,11 @@ def add_data__extruded_frames_mesh( beamcolumn_elems: list[element.Element] = [] beamcolumn_elems.extend( - mdl.list_of_specific_element(element.ElasticBeamColumn)) + mdl.list_of_specific_element(element.ElasticBeamColumn) + ) beamcolumn_elems.extend( - mdl.list_of_specific_element(element.DispBeamColumn)) + mdl.list_of_specific_element(element.DispBeamColumn) + ) if not beamcolumn_elems: return x_list: list[Optional[float]] = [] @@ -990,7 +1022,8 @@ def add_data__extruded_frames_mesh( index = 0 for elm in beamcolumn_elems: assert isinstance( - elm, (element.ElasticBeamColumn, element.DispBeamColumn)) + elm, (element.ElasticBeamColumn, element.DispBeamColumn) + ) if elm.visibility.hidden_when_extruded: continue side_a = np.array(elm.nodes[0].coords) + elm.geomtransf.offset_i @@ -1006,31 +1039,29 @@ def add_data__extruded_frames_mesh( loc0 = ( halfedge.vertex.coords[0] * z_vec + halfedge.vertex.coords[1] * y_vec - + side_a) + + side_a + ) loc1 = ( halfedge.vertex.coords[0] * z_vec + halfedge.vertex.coords[1] * y_vec - + side_b) + + side_b + ) loc2 = ( halfedge.nxt.vertex.coords[0] * z_vec + halfedge.nxt.vertex.coords[1] * y_vec - + side_b) + + side_b + ) loc3 = ( halfedge.nxt.vertex.coords[0] * z_vec + halfedge.nxt.vertex.coords[1] * y_vec - + side_a) - x_list.extend(( - loc0[0], loc1[0], loc2[0], loc3[0])) - y_list.extend(( - loc0[1], loc1[1], loc2[1], loc3[1])) - z_list.extend(( - loc0[2], loc1[2], loc2[2], loc3[2])) - i_list.extend(( - index + 0, index + 0)) - j_list.extend(( - index + 1, index + 2)) - k_list.extend(( - index + 2, index + 3)) + + side_a + ) + x_list.extend((loc0[0], loc1[0], loc2[0], loc3[0])) + y_list.extend((loc0[1], loc1[1], loc2[1], loc3[1])) + z_list.extend((loc0[2], loc1[2], loc2[2], loc3[2])) + i_list.extend((index + 0, index + 0)) + j_list.extend((index + 1, index + 2)) + k_list.extend((index + 2, index + 3)) index += 4 data_dict.append( { @@ -1049,7 +1080,8 @@ def add_data__extruded_frames_mesh( def add_data__extruded_bars_mesh( - data_dict: list[dict[str, object]], mdl: Model) -> None: + data_dict: list[dict[str, object]], mdl: Model +) -> None: """ Adds a trace containing frame element extrusion mesh @@ -1070,7 +1102,6 @@ def add_data__extruded_bars_mesh( k_list: list[Optional[int]] = [] index = 0 for elm in line_elems: - assert isinstance(elm, element.TrussBar) if elm.visibility.hidden_when_extruded: continue @@ -1095,31 +1126,29 @@ def add_data__extruded_bars_mesh( loc0 = ( halfedge.vertex.coords[0] * z_vec + halfedge.vertex.coords[1] * y_vec - + side_a) + + side_a + ) loc1 = ( halfedge.vertex.coords[0] * z_vec + halfedge.vertex.coords[1] * y_vec - + side_b) + + side_b + ) loc2 = ( halfedge.nxt.vertex.coords[0] * z_vec + halfedge.nxt.vertex.coords[1] * y_vec - + side_b) + + side_b + ) loc3 = ( halfedge.nxt.vertex.coords[0] * z_vec + halfedge.nxt.vertex.coords[1] * y_vec - + side_a) - x_list.extend(( - loc0[0], loc1[0], loc2[0], loc3[0])) - y_list.extend(( - loc0[1], loc1[1], loc2[1], loc3[1])) - z_list.extend(( - loc0[2], loc1[2], loc2[2], loc3[2])) - i_list.extend(( - index + 0, index + 0)) - j_list.extend(( - index + 1, index + 2)) - k_list.extend(( - index + 2, index + 3)) + + side_a + ) + x_list.extend((loc0[0], loc1[0], loc2[0], loc3[0])) + y_list.extend((loc0[1], loc1[1], loc2[1], loc3[1])) + z_list.extend((loc0[2], loc1[2], loc2[2], loc3[2])) + i_list.extend((index + 0, index + 0)) + j_list.extend((index + 1, index + 2)) + k_list.extend((index + 2, index + 3)) index += 4 data_dict.append( { @@ -1138,19 +1167,20 @@ def add_data__extruded_bars_mesh( def show( - mdl: Model, - load_case: Optional[LoadCase] = None, - extrude: bool = False, - offsets: bool = True, - global_axes: bool = True, - parent_nodes: bool = True, - frame_axes: bool = False, - zerolength_axes: bool = False, - diaphragm_lines: bool = True, - tributary_area_boundaries: bool = True, - camera: Optional[dict[str, object]] = None, - to_html_file: Optional[str] = None, - to_figure: Optional[str] = None) -> None: + mdl: Model, + load_case: Optional[LoadCase] = None, + extrude: bool = False, + offsets: bool = True, + global_axes: bool = True, + parent_nodes: bool = True, + frame_axes: bool = False, + zerolength_axes: bool = False, + diaphragm_lines: bool = True, + tributary_area_boundaries: bool = True, + camera: Optional[dict[str, object]] = None, + to_html_file: Optional[str] = None, + to_figure: Optional[str] = None, +) -> None: """ Visualize the model diff --git a/src/osmg/ground_motion_utils.py b/src/osmg/ground_motion_utils.py index 31c475e3..12b43a40 100644 --- a/src/osmg/ground_motion_utils.py +++ b/src/osmg/ground_motion_utils.py @@ -37,14 +37,10 @@ def import_PEER(filename): elif i == 3: # Number of points npts = int( - re.sub( - r'NPTS=\s+', '', line.split(sep=', ')[0] - ) + re.sub(r'NPTS=\s+', '', line.split(sep=', ')[0]) ) # noqa: W605 # Time step - tmp = re.sub( - r'DT=\s+', '', line.split(sep=', ')[1] - ) + tmp = re.sub(r'DT=\s+', '', line.split(sep=', ')[1]) tmp = re.sub(r'\s* SEC', '', tmp) tmp = tmp.replace('SEC', '') # some files have no space d_t = float(tmp) diff --git a/src/osmg/load_case.py b/src/osmg/load_case.py index d6f42430..d5aabb18 100644 --- a/src/osmg/load_case.py +++ b/src/osmg/load_case.py @@ -83,7 +83,8 @@ class LineElementUDL: parent_load_case: LoadCase parent_line_element: Union[ - element.ElasticBeamColumn, element.DispBeamColumn] + element.ElasticBeamColumn, element.DispBeamColumn + ] val: nparr = field(default_factory=lambda: np.zeros(shape=3)) def __repr__(self): @@ -121,7 +122,8 @@ def add_glob(self, udl: nparr) -> None: # transformation. elm = self.parent_line_element assert isinstance( - elm, (element.ElasticBeamColumn, element.DispBeamColumn)) + elm, (element.ElasticBeamColumn, element.DispBeamColumn) + ) if elm.geomtransf.transf_type == "Corotational": elm_len = elm.clear_length() force = udl * elm_len / 2.00 @@ -212,12 +214,11 @@ def __post_init__(self): self.node_mass[node.uid] = PointLoadMass() for elm in self.parent_model.list_of_elements(): # only proceed for certain elements - if not isinstance(elm, ( - element.ElasticBeamColumn, element.DispBeamColumn)): + if not isinstance( + elm, (element.ElasticBeamColumn, element.DispBeamColumn) + ): continue - self.line_element_udl[elm.uid] = LineElementUDL( - self, elm - ) + self.line_element_udl[elm.uid] = LineElementUDL(self, elm) # initialize tributary area analysis for each level for lvlkey, lvl in self.parent_model.levels.items(): self.tributary_area_analysis[lvlkey] = TributaryAreaAnaysis( @@ -225,8 +226,8 @@ def __post_init__(self): ) def rigid_diaphragms( - self, level_uids: list[int], - gather_mass: bool = False) -> None: + self, level_uids: list[int], gather_mass: bool = False + ) -> None: """ Processes the geometry of the given levels and applies rigid diaphragm constraints. diff --git a/src/osmg/mesh.py b/src/osmg/mesh.py index 4745c785..801b1b35 100644 --- a/src/osmg/mesh.py +++ b/src/osmg/mesh.py @@ -253,7 +253,6 @@ def overlaps_or_crosses(self, other: Edge) -> bool: determinant = np.linalg.det(mat_a) if np.isclose(determinant, 0.00): - # there are infinite solutions # or there are no solutions # i.e., the edges are parallel. @@ -919,9 +918,8 @@ def subdivide_polygon(outside, holes, n_x, n_y, plot=False): def subdivide_hss_rect( - sec_h: float, sec_b: float, - sec_t: float, plot: bool = False) \ - -> list[shapely_Polygon]: + sec_h: float, sec_b: float, sec_t: float, plot: bool = False +) -> list[shapely_Polygon]: """ Used to define the fibers of steel HSS fiber sections. @@ -1001,9 +999,8 @@ def subdivide_hss_rect( def subdivide_hss_circ( - sec_d: float, sec_t: float, - plot: bool = False) \ - -> list[shapely_Polygon]: + sec_d: float, sec_t: float, plot: bool = False +) -> list[shapely_Polygon]: """ Used to define the fibers of steel HSS fiber sections. @@ -1019,16 +1016,16 @@ def subdivide_hss_circ( num_subdiv_t = 3 num_subdiv_circ = 12 - radius = sec_d/2.00 + radius = sec_d / 2.00 pieces = [] for i in range(num_subdiv_t): for j in range(num_subdiv_circ): - rr_i = radius - i * sec_t/num_subdiv_t - rr_j = radius - (i+1.0) * sec_t/num_subdiv_t + rr_i = radius - i * sec_t / num_subdiv_t + rr_j = radius - (i + 1.0) * sec_t / num_subdiv_t ang_i = (2.00 * np.pi) / num_subdiv_circ * j - ang_j = (2.00 * np.pi) / num_subdiv_circ * (j+1.00) + ang_j = (2.00 * np.pi) / num_subdiv_circ * (j + 1.00) pt1 = (rr_i * np.cos(ang_i), rr_i * np.sin(ang_i)) pt2 = (rr_i * np.cos(ang_j), rr_i * np.sin(ang_j)) pt3 = (rr_j * np.cos(ang_j), rr_j * np.sin(ang_j)) diff --git a/src/osmg/model.py b/src/osmg/model.py index 24ae99df..c0a5dd9b 100644 --- a/src/osmg/model.py +++ b/src/osmg/model.py @@ -40,9 +40,7 @@ nparr = npt.NDArray[np.float64] -def transfer_component( - other: Model, - component: ComponentAssembly) -> None: +def transfer_component(other: Model, component: ComponentAssembly) -> None: """ Transfers a single component assembly from one model to another, assuming the other model was generated with the @@ -122,12 +120,15 @@ class Model: elastic_sections: obj_collections.Collection[int, ElasticSection] = field( init=False ) - fiber_sections: obj_collections.Collection[ - int, FiberSection] = field(init=False) - uniaxial_materials: obj_collections.Collection[ - int, UniaxialMaterial] = field(init=False) - physical_materials: obj_collections.Collection[ - int, PhysicalMaterial] = field(init=False) + fiber_sections: obj_collections.Collection[int, FiberSection] = field( + init=False + ) + uniaxial_materials: obj_collections.Collection[int, UniaxialMaterial] = ( + field(init=False) + ) + physical_materials: obj_collections.Collection[int, PhysicalMaterial] = ( + field(init=False) + ) uid_generator: UIDGenerator = field(default_factory=UIDGenerator) settings: Settings = field(default_factory=Settings) @@ -309,8 +310,8 @@ def list_of_elements(self) -> list[element.Element]: return list(self.dict_of_elements().values()) def dict_of_specific_element( - self, element_class: Type[element.Element]) \ - -> dict[int, element.Element]: + self, element_class: Type[element.Element] + ) -> dict[int, element.Element]: """ Returns a dictionary of all element objects in the model of a particular element class. @@ -326,8 +327,8 @@ def dict_of_specific_element( return res def list_of_specific_element( - self, element_class: Type[element.Element]) \ - -> list[element.Element]: + self, element_class: Type[element.Element] + ) -> list[element.Element]: """ Returns a list of all element objects in the model of a particular element class. @@ -388,7 +389,8 @@ def initialize_empty_copy(self, name): return res def transfer_by_polygon_selection( - self, other: Model, coords: nparr) -> None: + self, other: Model, coords: nparr + ) -> None: """ Uses :func:`~transfer_component` to transfer all components of which the projection to the XY plane falls inside the specified diff --git a/src/osmg/obj_collections.py b/src/osmg/obj_collections.py index 07dc9143..f4917fe8 100644 --- a/src/osmg/obj_collections.py +++ b/src/osmg/obj_collections.py @@ -141,7 +141,8 @@ def retrieve_by_attr(self, attr: str, val: Any) -> Any: if res is None: raise ValueError( f'Item having the value "{val}" ' - f'in the attribute "{attr}" not found in collection.') + f'in the attribute "{attr}" not found in collection.' + ) return res def __srepr__(self): diff --git a/src/osmg/ops/element.py b/src/osmg/ops/element.py index cd3413fe..0ac90247 100644 --- a/src/osmg/ops/element.py +++ b/src/osmg/ops/element.py @@ -25,6 +25,7 @@ from .section import FiberSection from ..mesh import Mesh from ..graphics.visibility import ElementVisibility + if TYPE_CHECKING: from ..component_assembly import ComponentAssembly @@ -173,10 +174,7 @@ def ops_args(self): """ - elm_name = { - 'Linear': 'Truss', - 'Corotational': 'corotTruss' - } + elm_name = {'Linear': 'Truss', 'Corotational': 'corotTruss'} return [ elm_name[self.transf_type], @@ -190,7 +188,7 @@ def ops_args(self): '-cMass', self.cflag, '-doRayleigh', - self.rflag + self.rflag, ] def clear_length(self): @@ -205,10 +203,7 @@ def clear_length(self): return np.linalg.norm(p_i - p_j) def __repr__(self): - elm_name = { - 'Linear': 'Truss', - 'Corotational': 'corotTruss' - } + elm_name = {'Linear': 'Truss', 'Corotational': 'corotTruss'} res = "" res += f"{elm_name[self.transf_type]} element object\n" res += f"uid: {self.uid}\n" @@ -297,7 +292,9 @@ def ops_args(self): self.section.j_mod, self.section.i_y, self.section.i_x, - 4.00, 4.00, 2.00, + 4.00, + 4.00, + 2.00, k11_x, k33_x, k44_x, @@ -319,7 +316,9 @@ def ops_args(self): k11_y, k33_y, k44_y, - 4.00, 4.00, 2.00, + 4.00, + 4.00, + 2.00, self.geomtransf.uid, ] diff --git a/src/osmg/ops/section.py b/src/osmg/ops/section.py index 0253c007..04fb1bc7 100644 --- a/src/osmg/ops/section.py +++ b/src/osmg/ops/section.py @@ -199,8 +199,7 @@ def cut_into_tiny_little_pieces(self): return pieces - def copy_alter_material( - self, mat: UniaxialMaterial) -> SectionComponent: + def copy_alter_material(self, mat: UniaxialMaterial) -> SectionComponent: """ Make a shallow copy of a section component and replace the old material with the given one. @@ -288,8 +287,8 @@ def weight_per_length(self): return res * mult def copy_alter_material( - self, mat: UniaxialMaterial, - new_uid: int) -> FiberSection: + self, mat: UniaxialMaterial, new_uid: int + ) -> FiberSection: """ Returns a shallow copy of the section object in which all opensees_material objects have been replaced with the given diff --git a/src/osmg/ops/uniaxial_material.py b/src/osmg/ops/uniaxial_material.py index c4faa49b..3c0c7f3b 100644 --- a/src/osmg/ops/uniaxial_material.py +++ b/src/osmg/ops/uniaxial_material.py @@ -20,6 +20,7 @@ # pylint: disable=invalid-name + @dataclass class UniaxialMaterial: """ @@ -195,12 +196,7 @@ def ops_args(self): # # these are required and will always be there - args = [ - "Steel4", - self.uid, - self.Fy, - self.E0 - ] + args = ["Steel4", self.uid, self.Fy, self.E0] # optional arguments: if asym: @@ -210,11 +206,11 @@ def ops_args(self): if asym: args.extend([self.b_kc, self.R_0c, self.r_1c, self.r_2c]) if iso: - args.extend(['-iso', self.b_i, self.rho_i, - self.b_l, self.R_i, self.l_yp]) + args.extend( + ['-iso', self.b_i, self.rho_i, self.b_l, self.R_i, self.l_yp] + ) if asym: - args.extend([self.b_ic, self.rho_ic, - self.b_lc, self.R_ic]) + args.extend([self.b_ic, self.rho_ic, self.b_lc, self.R_ic]) if ultimate: args.extend(['-ult', self.f_u, self.R_u]) if asym: @@ -357,7 +353,7 @@ def ops_args(self): self.c_C, self.c_K, self.D_Plus, - self.D_Neg + self.D_Neg, ] @@ -613,7 +609,7 @@ def ops_args(self): '-min', self.min_strain, '-max', - self.max_strain + self.max_strain, ] return args diff --git a/src/osmg/postprocessing/basic_forces.py b/src/osmg/postprocessing/basic_forces.py index 3666c76f..a6eb2df3 100644 --- a/src/osmg/postprocessing/basic_forces.py +++ b/src/osmg/postprocessing/basic_forces.py @@ -62,8 +62,9 @@ def basic_forces( else: forces = anl.results[case_name].element_forces[elm.uid][step] if isinstance(elm, (ElasticBeamColumn, DispBeamColumn)): - w_x, w_y, w_z = anl.load_cases[ - case_name].line_element_udl[elm.uid].val + w_x, w_y, w_z = ( + anl.load_cases[case_name].line_element_udl[elm.uid].val + ) else: w_x, w_y, w_z = (0.00, 0.00, 0.00) diff --git a/src/osmg/preprocessing/self_weight_mass.py b/src/osmg/preprocessing/self_weight_mass.py index 55656f12..46cca918 100644 --- a/src/osmg/preprocessing/self_weight_mass.py +++ b/src/osmg/preprocessing/self_weight_mass.py @@ -25,9 +25,9 @@ def self_weight(mdl, lcase, factor=1.00): """ for elm in mdl.list_of_elements(): - if isinstance( - elm, (element.ElasticBeamColumn, element.DispBeamColumn)): + elm, (element.ElasticBeamColumn, element.DispBeamColumn) + ): weight_per_length = elm.section.weight_per_length() # apply weight as UDL if elm.visibility.skip_opensees_definition: @@ -69,9 +69,9 @@ def self_mass(mdl, lcase): g_const = common.G_CONST_SI for elm in mdl.list_of_elements(): - if isinstance( - elm, (element.ElasticBeamColumn, element.DispBeamColumn)): + elm, (element.ElasticBeamColumn, element.DispBeamColumn) + ): weight_per_length = elm.section.weight_per_length() elif isinstance(elm, element.TrussBar): weight_per_length = elm.weight_per_length diff --git a/src/osmg/preprocessing/split_component.py b/src/osmg/preprocessing/split_component.py index 257b7a31..e536a326 100644 --- a/src/osmg/preprocessing/split_component.py +++ b/src/osmg/preprocessing/split_component.py @@ -31,8 +31,8 @@ def split_component( - component: ComponentAssembly, point: nparr) \ - -> tuple[Node, nparr]: + component: ComponentAssembly, point: nparr +) -> tuple[Node, nparr]: """ Splits a beam-functioning component assembly to accomodate for a node required to connect another component assembly. @@ -49,8 +49,12 @@ def split_component( elms = [] elms.extend( - [elm for elm in component.elements.values() - if isinstance(elm, (ElasticBeamColumn, DispBeamColumn))]) + [ + elm + for elm in component.elements.values() + if isinstance(elm, (ElasticBeamColumn, DispBeamColumn)) + ] + ) distances = np.zeros(len(elms)) for i, elm in enumerate(elms): p_i = np.array(elm.nodes[0].coords) + elm.geomtransf.offset_i @@ -132,8 +136,7 @@ def split_component( assert isinstance(closest_elm.integration, Lobatto) beam_integration = Lobatto( uid=( - component.parent_collection - .parent.parent_model.uid_generator.new( + component.parent_collection.parent.parent_model.uid_generator.new( "beam integration" ) ), @@ -144,8 +147,7 @@ def split_component( elm_i = DispBeamColumn( # type: ignore component, ( - component.parent_collection.parent - .parent_model.uid_generator.new( + component.parent_collection.parent.parent_model.uid_generator.new( "element" ) ), @@ -163,8 +165,7 @@ def split_component( transf_j = GeomTransf( prev_gtransf.transf_type, ( - component.parent_collection - .parent.parent_model.uid_generator.new( + component.parent_collection.parent.parent_model.uid_generator.new( "transformation" ) ), @@ -179,8 +180,7 @@ def split_component( elm_j = ElasticBeamColumn( component, ( - component.parent_collection - .parent.parent_model.uid_generator.new( + component.parent_collection.parent.parent_model.uid_generator.new( "element" ) ), @@ -193,8 +193,7 @@ def split_component( assert isinstance(closest_elm.integration, Lobatto) beam_integration = Lobatto( uid=( - component.parent_collection - .parent.parent_model.uid_generator.new( + component.parent_collection.parent.parent_model.uid_generator.new( "beam integration" ) ), @@ -205,8 +204,7 @@ def split_component( elm_j = DispBeamColumn( # type: ignore component, ( - component.parent_collection - .parent.parent_model.uid_generator.new( + component.parent_collection.parent.parent_model.uid_generator.new( "element" ) ), diff --git a/src/osmg/preprocessing/tributary_area_analysis.py b/src/osmg/preprocessing/tributary_area_analysis.py index b52727a6..2043cdc5 100644 --- a/src/osmg/preprocessing/tributary_area_analysis.py +++ b/src/osmg/preprocessing/tributary_area_analysis.py @@ -200,15 +200,19 @@ def run( } for comp in horizontal_elements: - line_elements = [ - elm for elm in comp.elements.values() + elm + for elm in comp.elements.values() if isinstance( - elm, (ElasticBeamColumn, DispBeamColumn, TwoNodeLink))] + elm, (ElasticBeamColumn, DispBeamColumn, TwoNodeLink) + ) + ] zerolength_elements = [ - elm for elm in comp.elements.values() - if isinstance(elm, ZeroLength)] + elm + for elm in comp.elements.values() + if isinstance(elm, ZeroLength) + ] for zelm in zerolength_elements: zn_map[zelm.nodes[1].uid] = zelm.nodes[0].uid @@ -316,7 +320,7 @@ def run( if index == len(all_edges_list): # we are done. continue - remaining_edges = all_edges_list[(index + 1)::] + remaining_edges = all_edges_list[(index + 1) : :] for other_edge in remaining_edges: # check if the two edges overlap or cross each other if considered_edge.overlaps_or_crosses(other_edge): @@ -517,9 +521,14 @@ def is_in_some_subloop(halfedge, loops): for node in loaded_elm.nodes: lcase.node_loads[node.uid].add( np.array( - [0.00, 0.00, - -load_val * cmult / 2.00, - 0.00, 0.00, 0.00] + [ + 0.00, + 0.00, + -load_val * cmult / 2.00, + 0.00, + 0.00, + 0.00, + ] ) ) if not load.massless: diff --git a/src/osmg/solver.py b/src/osmg/solver.py index 14ace3c7..2ac5fe89 100644 --- a/src/osmg/solver.py +++ b/src/osmg/solver.py @@ -450,10 +450,7 @@ def define_material(mat, defined_materials): area = piece.area z_loc = piece.centroid.x y_loc = piece.centroid.y - ops.fiber( - y_loc, z_loc, area, part.ops_material.uid - ) - + ops.fiber(y_loc, z_loc, area, part.ops_material.uid) ops.beamIntegration(*elm.integration.ops_args()) ops.geomTransf(*elm.geomtransf.ops_args()) @@ -932,7 +929,8 @@ def _read_frame_element_forces_modal(self, case_name, elems): # have been applied. if np.linalg.norm(udl) > common.EPSILON: self.warning.issue( - "Loads were present in a modal load case. Ignoring them." + "Loads were present in a modal load case. Ignoring" + " them." ) udl = np.zeros(3) @@ -1982,13 +1980,13 @@ def run( num_modes = damping["num_modes"] # num_modes = num_modeshapes damping_ratio = damping["ratio"] - self.log("Running eigenvalue analysis" f" with {num_modes} modes") + self.log(f"Running eigenvalue analysis with {num_modes} modes") ops.eigen(num_modes) # ops.systemSize() self.log("Eigenvalue analysis finished") assert isinstance(damping_ratio, float) ops.modalDampingQ(damping_ratio) - self.log(f"{damping_ratio*100.00:.2f}% " "modal damping defined") + self.log(f"{damping_ratio*100.00:.2f}% modal damping defined") if damping_type == "modal+stiffness": self.log("Using modal+stiffness damping") @@ -2011,7 +2009,7 @@ def run( assert isinstance(num_modes, int) damping_ratio = damping["ratio_modal"] assert isinstance(damping_ratio, float) - self.log("Running eigenvalue analysis" f" with {num_modes} modes") + self.log(f"Running eigenvalue analysis with {num_modes} modes") omega_squareds = np.array(ops.eigen(num_modes)) self.log("Eigenvalue analysis finished") damping_vals = ( @@ -2051,7 +2049,6 @@ def run( 1.0e-11, 1e-12, ) - tols = [1.0e-8] * len(scale) algorithms = ( ("KrylovNewton",), ("KrylovNewton", "initial", "initial"), @@ -2127,7 +2124,9 @@ def run( if pbar is not None: pbar.set_postfix( { - 'time': f'{curr_time:.4f}/{target_timestamp:.2f} [{testiter}]' + 'time': ( + f'{curr_time:.4f}/{target_timestamp:.2f} [{testiter}]' + ) } ) pbar.update(curr_time - prev_time)