def modal(geom_file, num_modes, path): # add shell elements from mesh --------------------------------------------- with open(geom_file, 'rb') as fh: geom_data = json.load(fh) mesh = Mesh.from_data(geom_data['mesh']) s = structure.Structure() s.add_nodes_elements_from_mesh(mesh, element_type='ShellElement') # add displacements -------------------------------------------------------- pts = geom_data['pts'] nkeys = [] for pt in pts: nkeys.append(s.check_node_exists(pt)) s.add_set(name='support_nodes', type='NODE', selection=nkeys) supppots = FixedDisplacement(name='supports', nodes='support_nodes') s.add_displacement(supppots) # add materials and sections ----------------------------------------------- E35 = 35 * 10**9 concrete = ElasticIsotropic(name='MAT_CONCRETE', E=E35, v=0.2, p=2400) s.add_material(concrete) section = ShellSection(name='SEC_CONCRETE', t=0.020) s.add_section(section) prop = ElementProperties(type='SHELL', material='MAT_CONCRETE', section='SEC_CONCRETE', elsets=['ELSET_ALL']) s.add_element_properties(prop) # add modal step ----------------------------------------------------------- step = ModalStep(name='modal_analysis', displacements=['supports'], num_modes=num_modes) s.add_step(step) fnm = path + 'modal.inp' ansys.inp_generate(s, filename=fnm) # temp = path + '_Temp/' s.analyse(path=path, name='modal.inp', temp=None, software='ansys') return s
def harmonic(geom_file, freq_range, freq_steps, damping): # add shell elements from mesh --------------------------------------------- with open(geom_file, 'rb') as fh: geom_data = json.load(fh) mesh = Mesh.from_data(geom_data['mesh']) s = structure.Structure() s.add_nodes_elements_from_mesh(mesh, element_type='ShellElement') # add displacements -------------------------------------------------------- pts = geom_data['pts'] nkeys = [] for pt in pts: nkeys.append(s.check_node_exists(pt)) s.add_set(name='support_nodes', type='NODE', selection=nkeys) supppots = FixedDisplacement(name='supports', nodes='support_nodes') s.add_displacement(supppots) # add materials and sections ----------------------------------------------- E35 = 35 * 10**9 concrete = ElasticIsotropic(name='MAT_CONCRETE', E=E35, v=0.2, p=2400) s.add_material(concrete) section = ShellSection(name='SEC_CONCRETE', t=0.020) s.add_section(section) prop = ElementProperties(type='SHELL', material='MAT_CONCRETE', section='SEC_CONCRETE', elsets=['ELSET_ALL']) s.add_element_properties(prop) # add loads ---------------------------------------------------------------- f_pts = geom_data['f_pts'] nodes = [s.check_node_exists(pt) for pt in f_pts] s.add_set(name='load_nodes', type='NODE', selection=nodes) load = PointLoad(name='hload', nodes='load_nodes', x=0, y=0, z=1, xx=0, yy=0, zz=0) s.add_load(load) # add modal step ----------------------------------------------------------- step = HarmonicStep(name='harmonic_analysis', displacements=['supports'], loads=['hload'], freq_range=freq_range, freq_steps=freq_steps, damping=damping) s.add_step(step) fnm = path + 'harmonic.inp' ansys.inp_generate(s, filename=fnm) # temp = path+'_Temp/' s.analyse(path=path, name='harmonic.inp', temp=None, software='ansys') return s
def harmonic(mesh, pts, lpts, freq_range, freq_steps, damping, path, filename): # add shell elements from mesh --------------------------------------------- s = structure.Structure() s.add_nodes_elements_from_mesh(mesh, element_type='ShellElement') # add displacements -------------------------------------------------------- nkeys = [] for pt in pts: nkeys.append(s.check_node_exists(pt)) s.add_set(name='support_nodes', type='NODE', selection=nkeys) supports = PinnedDisplacement(name='supports', nodes='support_nodes') s.add_displacement(supports) # add materials and sections ----------------------------------------------- E35 = 35 * 10**9 concrete = ElasticIsotropic(name='MAT_CONCRETE', E=E35, v=0.2, p=2400) s.add_material(concrete) section = ShellSection(name='SEC_CONCRETE', t=0.050) s.add_section(section) prop = ElementProperties(material='MAT_CONCRETE', section='SEC_CONCRETE', elsets=['ELSET_ALL']) s.add_element_properties(prop) # add loads ---------------------------------------------------------------- nkeys = [] for lpt in lpts: nkeys.append(s.check_node_exists(lpt)) load = HarmonicPointLoad(name='harmonic_load', nodes=nkeys, z=-1) s.add_load(load) # add modal step ----------------------------------------------------------- step = HarmonicStep(name='harmonic_analysis', displacements=['supports'], loads=['harmonic_load'], freq_range=freq_range, freq_steps=freq_steps, damping=damping) s.add_step(step) fnm = path + filename ansys.inp_generate(s, filename=fnm, output_path=path) s.analyse(path=path, name=filename, fields=None, software='ansys') return s
(max_ - min_)) + minthick mesh.set_face_attribute(fkey, 'thick', thick) def assign_structure_property_to_mesh_faces(mesh, name, value): for fkey in mesh.faces(): mesh.set_face_attribute(fkey, name, value) if __name__ == '__main__': filename = 'example_From_mesh' path = os.path.dirname(os.path.abspath(__file__)) + '/' mesh = Mesh.from_obj('../data/quadmesh_planar.obj') minthick = .002 maxthick = .01 load = (0, 0, -2000) E35 = 35 * 10**9 v = 0.2 p = 2400 pin_all_boundary_vertices(mesh) applly_uniform_point_load(mesh, load) create_variable_thick_shell(mesh, minthick, maxthick) assign_structure_property_to_mesh_faces(mesh, 'E', E35) assign_structure_property_to_mesh_faces(mesh, 'v', v) assign_structure_property_to_mesh_faces(mesh, 'p', p) s = Structure.from_mesh(mesh) fnm = path + filename ansys.inp_generate(s, filename=fnm, out_path=path) print s