def plot_shear_moment_torque(model: OP2Geom, gpforce: RealGridPointForcesArray, coord: CORD2R, itime: int=0, nplanes: int=11, show: bool=True): nids, nid_cd, xyz_cid0, icd_transform, eids, element_centroids_cid0 = smt_setup(model) element_centroids_coord = coord.transform_node_to_local_array(element_centroids_cid0) idir = 0 x = element_centroids_coord[idir] xmin = x.min() xmax = x.max() dx = xmax - xmin assert abs(dx) > 0., f'dx={dx} xmin={xmin} xmax={xmax}' stations = np.linspace(0., dx, num=nplanes, endpoint=True) force_sum, moment_sum, new_coords, nelems, nnodes = gpforce.shear_moment_diagram( nids, xyz_cid0, nid_cd, icd_transform, eids, element_centroids_cid0, stations, model.coords, coord, iaxis_march=None, itime=itime, debug=False, log=model.log) plot_smt(stations, force_sum, moment_sum, nelems, nnodes, show=show)
def test_gpforce_01(self): nids = np.array([1, 2, 3]) xyz_cid0 = np.array([ [1., 1., 1.], [4., 2., 5.], [3., 3., 3.], ]) data_code = { 'nonlinear_factor': None, 'sort_bits': [0, 0, 0], 'analysis_code': 1, 'is_msc': True, 'format_code': 1, 'table_code': 1, 'data_names': 'cat', 'device_code': 1, #'tcode' : 1, } is_sort1 = True isubcase = 1 dt = 0.0 gpforce = RealGridPointForcesArray(data_code, is_sort1, isubcase, dt) gpforce.ntimes = 1 gpforce.ntotal = 3 gpforce._ntotals = [3] gpforce.build() gpforce.data[0, :, :] = np.array([ [ 3., 7., 11., 0., 0., 0., ], # fx, fy, fz, mx, my, mz [ 3., 7., 11., 0., 0., 0., ], [ 3., 7., 11., 0., 0., 0., ], ]) gpforce.node_element[0, :, :] = np.array([ [1, 1], [2, 1], [3, 1], ]) op2 = OP2() summation_point = [0., 0., 0.] icd_transform = None nid_cd = np.array([ [1, 0], [2, 0], [3, 0], ]) from pyNastran.bdf.bdf import CORD2R coord_out = CORD2R(cid=0, origin=None, zaxis=None, xzplane=None) coords = {0: coord_out} #eids = [1] #nids = [1] #gpforce.extract_interface_loads( #nids, eids, coord_out, coords, nid_cd, #icd_transform, #xyz_cid0, #summation_point, #itime=0, #debug=True, #logger=op2.log) #print('------------') #eids = [1] #nids = [2] #gpforce.extract_interface_loads( #nids, eids, coord_out, coords, nid_cd, #icd_transform, #xyz_cid0, #summation_point, #itime=0, #debug=True, #logger=op2.log) print('------------') eids = [1] nids = [1, 2] gpforce.extract_interface_loads(nids, eids, coord_out, coords, nid_cd, icd_transform, xyz_cid0, summation_point, itime=0, debug=True, logger=op2.log)
def plot_shear_moment_torque(self, model_name, gpforce: RealGridPointForcesArray, p1, p2, p3, zaxis, method: str = 'Z-Axis Projection', cid_p1: int = 0, cid_p2: int = 0, cid_p3: int = 0, cid_zaxis: int = 0, nplanes: int = 20, plane_color=None, plane_opacity=0.5, csv_filename=None, show=True, stop_on_failure=False): """ Creates a shear moment torque plot for the active plot result Parameters ---------- model_name : str the name of the model p1: (3,) float ndarray defines the starting point for the shear, moment, torque plot p3: (3,) float ndarray defines the end point for the shear, moment, torque plot p2: (3,) float ndarray defines the XZ plane for the shears/moments zaxis: (3,) float ndarray the direction of the z-axis cid_p1 / cid_p2 / cid_p3 the coordinate systems for p1, p2, and p3 method : str 'CORD2R' : typical CORD2R 'Z-Axis Projection' : project p2 on the z-axis """ log = self.gui.log if plane_color is None: plane_color = PURPLE_FLOAT assert len(plane_color) == 3, plane_color model = self.gui.models[model_name] nids, nid_cd, icd_transform, xyz_cid0 = get_nid_cd_xyz_cid0(model) #xyz1, xyz2, xyz3, i, k, origin, xzplane, dim_max, stations try: xyz1, xyz2, xyz3, i, k, coord_out, iaxis_march, dim_max, stations = setup_coord_from_plane( model, xyz_cid0, p1, p2, p3, zaxis, method=method, cid_p1=cid_p1, cid_p2=cid_p2, cid_p3=cid_p3, cid_zaxis=cid_zaxis, nplanes=nplanes, ) except ValueError as verror: model.log.error(str(verror)) if stop_on_failure: raise return coord = coord_out #try: ## i/j/k vector is nan #coord = CORD2R(1, rid=0, origin=origin, zaxis=zaxis, xzplane=xzplane, #comment='') #except: #log.error('The coordinate system is invalid; check your cutting plane.') #if stop_on_failure: #raise #return None, None # the plane actor defines the plane of the output results, # not the plane of the march direction # xyz1: origin # xyz2: xzplane unused_plane_actor, unused_prop = self.create_plane_actor( xyz1, xyz2, coord, i, k, dim_max, plane_color, plane_opacity, ) #if 0: #point_actor = self.gui.create_point_actor_from_points( #[xyz1, xyz3], point_size=8, actor_name='smt_points') #prop = point_actor.GetProperty() #prop.SetColor(*plane_color) #prop.SetOpacity(plane_opacity) # 0=transparent, 1=solid #point_actor.VisibilityOn() self.gui.rend.Render() self.gui.Render() eids, element_centroids_cid0 = get_element_centroids(model) force_sum, moment_sum, new_coords, nelems, nnodes = gpforce.shear_moment_diagram( nids, xyz_cid0, nid_cd, icd_transform, eids, element_centroids_cid0, stations, model.coords, coord, iaxis_march=iaxis_march, itime=0, debug=False, log=log) plot_smt(stations, force_sum, moment_sum, nelems, nnodes, show=show) return force_sum, moment_sum