#print(mdl.sections['shell'])

mdl.add(
    ElementProperties(name='ep',
                      material='concrete',
                      section='shell',
                      elset='mesh'))

#print(mdl.element_properties['ep'])

mdl.add(PinnedDisplacement(name='pinned', nodes='supports'))

#print(mdl.displacements['pinned'])

mdl.add([
    GravityLoad(name='gravity', elements='mesh'),
    PointLoad(name='loads', nodes='loads', z=-1000),
    AreaLoad(name='pressure', elements='area', z=7000),
])

#print(mdl.loads['loads'])
#print(mdl.loads['gravity'])
#print(mdl.loads['pressure'])

mdl.add([
    GeneralStep(name='bc', displacements='pinned'),
    GeneralStep(name='loads',
                loads=['gravity', 'loads', 'pressure'],
                factor=1.5),
    BucklingStep(name='buckling',
                 modes=3,
Пример #2
0
p = 2400
thickness = .02
matname = 'concrete'
concrete = ElasticIsotropic(name=matname, E=E, v=v, p=p)
s.add_material(concrete)
section = ShellSection(name='concrete_sec', t=thickness)
s.add_section(section)
prop = ElementProperties(name='floor',
                         material=matname,
                         section='concrete_sec',
                         elsets=['shell'])
s.add_element_properties(prop)

# add gravity load -------------------------------------------------------------

s.add_load(GravityLoad(name='load_gravity', elements=['shell']))

# add steps --------------------------------------------------------------------

step = GeneralStep(name='gravity_step',
                   nlgeom=False,
                   displacements=['supports'],
                   loads=['load_gravity'],
                   type='static')

s.add_steps([step])

s.steps_order = ['gravity_step']

# analyse ----------------------------------------------------------------------
Пример #3
0
               section='sec_tie',
               elset='elset_ties'),
    Properties(name='ep_concrete',
               material='mat_concrete',
               section='sec_solid',
               elset='elset_tets'),
])

# Displacements

mdl.add(RollerDisplacementY(name='disp_rollers', nodes='nset_supports'))

# Loads

mdl.add([
    GravityLoad(name='load_gravity', elements='elset_tets'),
    PointLoad(name='load_point', nodes='nset_load', z=-5),
])

# Steps

mdl.add([
    GeneralStep(name='step_bc', displacements=['disp_rollers']),
    GeneralStep(name='step_loads',
                loads=['load_gravity', 'load_point'],
                factor=1.35),
])
mdl.steps_order = ['step_bc', 'step_loads']

# Summary
Пример #4
0
    Properties(name='ep_ends',
               material='mat_steel',
               section='sec_ends',
               elset='elset_ends'),
])

# Displacements

mdl.add([
    RollerDisplacementY(name='disp_top', nodes='nset_top'),
    RollerDisplacementY(name='disp_bot', nodes='nset_bot'),
])

# Loads

mdl.add(GravityLoad(name='load_gravity', elements='elset_mesh'))

mesh = mesh_from_guid(Mesh(), rs.ObjectsByLayer('elset_mesh')[0])
point_loads = {}
for key in mesh.vertices():
    xyz = mesh.vertex_coordinates(key)
    pt = rs.ProjectPointToSurface([xyz],
                                  rs.ObjectsByLayer('surface')[0],
                                  [0, 0, 1])[0]
    pz = mesh.vertex_area(key) * distance_point_point(xyz, pt) * 2400 * 9.81
    point_loads[mdl.check_node_exists(xyz)] = {'z': -pz}
mdl.add(PointLoads(name='load_points', components=point_loads))

# Steps

displacements = ['disp_top', 'disp_bot']
Пример #5
0
    'w_l2': {'pos': -0.045, 'spacing': 0.100, 'material': 'mat_rebar', 'dia': 0.010, 'angle': 90},
    'w_l1': {'pos': -0.055, 'spacing': 0.100, 'material': 'mat_rebar', 'dia': 0.010, 'angle': 0}}

mdl.add_element_properties([
    Properties(name='ep_plinth', material='mat_concrete', section='sec_plinth', 
               elsets='elset_plinth', reinforcement=reb_plinth),
    Properties(name='ep_wall', material='mat_concrete', section='sec_wall',
               elsets='elset_wall', reinforcement=reb_wall)])

# Displacements

mdl.add_displacement(FixedDisplacement(name='disp_fixed', nodes='nset_fixed'))

# Loads

mdl.add_load(GravityLoad(name='load_gravity', elements=['elset_wall', 'elset_plinth']))
components = {}
for guid in rs.ObjectsByLayer('nset_loads'):
    px, py, pz = rs.ObjectName(guid).split(' ')
    components[mdl.check_node_exists(rs.PointCoordinates(guid))] = {'z': float(pz)*100}
mdl.add_load(PointLoads(name='load_points', components=components))
loads = ['load_gravity', 'load_points']

# Steps

mdl.add_steps([
    GeneralStep(name='step_bc', nlgeom=False, displacements=['disp_fixed']),
    GeneralStep(name='step_loads', nlgeom=False, loads=loads)])
mdl.steps_order = ['step_bc', 'step_loads']

# Summary
Пример #6
0
# Properties

mdl.add(
    Properties(name='ep_shell',
               material='mat_elastic',
               section='sec_shell',
               elset='mesh'))

# Displacements

mdl.add(PinnedDisplacement(name='disp_pin', nodes='supports'))

# Loads

mdl.add(GravityLoad(name='gravity', elements='all'))
mdl.add(PointLoad(name='load_points', nodes='lpts1', x=0, y=0, z=-1000))

# Steps

mdl.add([
    GeneralStep(name='step_bc', displacements=['disp_pin']),
    GeneralStep(name='step_load', loads=['gravity', 'load_points']),
])
mdl.steps_order = ['step_bc', 'step_load']

# Summary

mdl.summary()

# Run
Пример #7
0
mdl.add([
    Properties(name='ep_circ',
               material='mat_elastic',
               section='sec_circ',
               elset='elset_beams'),
    Properties(name='ep_shell',
               material='mat_elastic',
               section='sec_shell',
               elset='elset_shell'),
])

# Add loads

mdl.add([
    PointLoad(name='load_point', nodes='nset_top', x=10000, z=-10000),
    GravityLoad(name='load_gravity', elements='elset_beams'),
])

# print('load_point components: ', mdl.loads['load_point'].components)

# Add displacements

mdl.add(PinnedDisplacement(name='disp_pinned', nodes='nset_base'))

# print('disp_pinned components: ', mdl.displacements['disp_pinned'].components)

# Add steps

mdl.add([
    GeneralStep(name='step_bc', displacements=['disp_pinned']),
    GeneralStep(name='step_loads', loads=['load_point', 'load_gravity']),
Пример #8
0
mdl.add_element_properties([
    Properties(name='ep_concrete', material='mat_concrete', section='sec_concrete', elsets='elset_concrete'),
    Properties(name='ep_steel', material='mat_steel', section='sec_ties', elsets='elset_ties')])

# Displacements

mdl.add_displacements([
    RollerDisplacementXY(name='disp_roller', nodes='nset_corners'),
    PinnedDisplacement(name='disp_pinned', nodes='nset_corner1'),
    GeneralDisplacement(name='disp_xdof', nodes='nset_corner2', x=0)])
    
# Loads

mesh = mesh_from_guid(Mesh(), rs.ObjectsByLayer('load_mesh')[0])
mdl.add_loads([
    GravityLoad(name='load_gravity', elements='elset_concrete'),
    PrestressLoad(name='load_prestress', elements='elset_ties', sxx=50*10**6),
    TributaryLoad(mdl, name='load_tributary', mesh=mesh, z=-2000)])

# Steps

mdl.add_steps([
    GeneralStep(name='step_bc', displacements=['disp_roller', 'disp_pinned', 'disp_xdof']),
    GeneralStep(name='step_prestress', loads=['load_prestress']),
    GeneralStep(name='step_loads', loads=['load_gravity', 'load_tributary'], factor=1.1)])
mdl.steps_order = ['step_bc', 'step_prestress', 'step_loads']

# Summary

mdl.summary()
Пример #9
0
    Properties(name='ep_joints',
               material='mat_bamboo',
               section='sec_joints',
               elsets=s3)
])

# Displacements

mdl.add_displacements([
    PinnedDisplacement(name='disp_bot', nodes='supports_bot'),
    RollerDisplacementZ(name='disp_top', nodes='supports_top')
])

# Loads

mdl.add_load(GravityLoad(name='load_gravity', elements=layers))

# Steps

mdl.add_steps([
    GeneralStep(name='step_bc', displacements=['disp_bot', 'disp_top']),
    GeneralStep(name='step_loads', loads=['load_gravity'])
])
mdl.steps_order = ['step_bc', 'step_loads']

# Summary

mdl.summary()

# Run (Abaqus)
Пример #10
0
               section='sec_ties',
               elset='elset_ties'),
])

# Displacements

mdl.add([
    RollerDisplacementXY(name='disp_edges', nodes='nset_edges'),
    PinnedDisplacement(name='disp_pinned', nodes='nset_corner1'),
    GeneralDisplacement(name='disp_xdof', nodes='nset_corner2', x=0),
])

# Loads

mdl.add([
    GravityLoad(name='load_gravity', elements='elset_floor'),
    PrestressLoad(name='load_prestress', elements='elset_ties',
                  sxx=10 * 10**6),
    TributaryLoad(mdl,
                  name='load_area',
                  mesh=mesh_from_bmesh(get_object_by_name('load_mesh')),
                  z=-2000),
])

# Steps

mdl.add([
    GeneralStep(name='step_bc',
                displacements=['disp_edges', 'disp_pinned', 'disp_xdof']),
    GeneralStep(name='step_loads',
                loads=['load_gravity', 'load_area'],
Пример #11
0
def compute_compas_fea(file_path, load_path, fea_engine='abaqus', recompute=True):
    """ Use abaqus (via compas_fea) to perform elastic FEA on the given frame
    under a given load case. If no load path is specified, elemental gravity
    will be assumbed to be applied.

    Parameters
    ----------
    file_path : string
        full path to the frame shape's json file.
    load_path : type
        full path to the load case's json file.

    Returns
    -------
    nD: dict
        Reactional nodal displacement
        key is the node id.
        value is
        (nodal_id, dx, dy, dz, theta_x, theta_y, theta_z).

    fR: dict
        Fixities reaction force, moment.
        key is the nodal id.
        value is [Fxyz, Mxyz] in the global axes.

    eR: dict
        Element-wise reaction force, moment (two ends).
        key is the element id.
        (Fxyz_1, Mxyz_1, Fxyz_2, Mxyz_2)

    """
    root_dir = os.path.dirname(os.path.abspath(__file__))
    temp_dir = os.path.join(root_dir, 'compas_fea-temp')
    if not os.path.exists(temp_dir):
        os.makedirs(temp_dir)

    file_json_name = file_path.split(os.sep)[-1]
    file_name = file_json_name.split('.')[0]
    print('compas_fea initing: file name {}'.format(file_name))
    if not recompute:
        nD, fR, eR = parse_abaqus_result_json(file_name, temp_dir)
        return nD, fR, eR

    with open(file_path, 'r') as f:
        json_data = json.loads(f.read())
    load_json_data = {}
    if load_path:
        with open(load_path, 'r') as f:
            load_json_data = json.loads(f.read())

    # init an empty structure
    mdl = Structure(name=file_name, path=os.path.join(temp_dir, ''))

    # nodes
    mdl.add_nodes(nodes=parse_frame_nodes(json_data))

    # elements
    elements = parse_elements(json_data)

    # align local axes with conmech
    sc = stiffness_checker(json_file_path=file_path, verbose=False)
    e_rot_mats = sc.get_element_local2global_rot_matrices()
    assert len(e_rot_mats) == len(elements)
    for e, mat in zip(elements, e_rot_mats):
        # compas_fea local axis convention is differrent to the one used in conmech:
        # in compas_fea
        # 'ex' axis represents the cross-section’s major axis
        # 'ey' is the cross-section’s minor axis
        # 'ez' is the axis along the element
        # TODO: this numpy array to list conversion
        # is essential to make compas_fea work...
        ez = list(mat[0][0:3]) # conmech longitude axis
        ex = list(mat[1][0:3]) # conmech cross sec major axis
        ey = list(mat[2][0:3]) # conmech cross sec minor axis

        mdl.add_element(nodes=e,
                        type='BeamElement',
                        axes={'ex': ex, 'ey': ey, 'ez': ez})
        # print(mdl.elements[mdl.check_element_exists(nodes=e)])

    assert_equal(mdl.element_count(), len(elements))

    # Sets
    # just convenient aliases for referring to a group of elements
    mdl.add_set(name='elset_all', type='element', selection=list(range(mdl.element_count())))

    mdl.add_set(name='nset_all', type='node', selection=list(range(mdl.node_count())))

    fixities = parse_fixties(json_data)
    mdl.add_set(name='nset_fix', type='node', selection=[f[0] for f in fixities])

    if load_json_data:
        pt_loads, include_sw = parse_load_case(load_json_data)
        # mdl.add_set(name='nset_pt_load', type='node', selection=[l[0] for l in pt_loads])
    else:
        pt_loads = []
        include_sw = True
    if pt_loads:
        mdl.add_set(name='nset_v_load_all', type='node', selection=[pl[0] for pl in pt_loads])

    # Materials
    # Young’s modulus E [in units of Pa]
    # Poisson’s ratio v and density p [kg per cubic metre].
    mat_json = json_data['material_properties']
    mat_name = 'mat_' + mat_json['material_name']
    E_scale = parse_pressure_scale_conversion(mat_json['youngs_modulus_unit'])
    p_scale = parse_density_scale_conversion(mat_json['density_unit'])
    mdl.add(ElasticIsotropic(name=mat_name,
                             E=E_scale * mat_json['youngs_modulus'],
                             v=mat_json['poisson_ratio'],
                             p=p_scale * mat_json['density']))

    # G_scale = parse_pressure_scale_conversion(mat_json['shear_modulus_unit'])
    # print('{}, {}'.format(mdl.materials['mat_' + mat_json['material_name']].G, G_scale * mat_json['shear_modulus']))
    # assert_almost_equal(mdl.materials['mat_' + mat_json['material_name']].G['G'], G_scale * mat_json['shear_modulus'])
    # print('-----------material')
    # print(mdl.materials[mat_name])

    # Sections
    # SI units should be used, this includes the use of metres m for cross-section dimensions, not millimetres mm.
    sec_name = 'sec_circ'
    mdl.add(CircularSection(name=sec_name, r=parse_circular_cross_sec_radius(json_data)))

    # print('-----------cross section')
    # print(mdl.sections[sec_name])

    # Properties, associate material & cross sec w/ element sets
    mdl.add(Properties(name='ep_all', material=mat_name, section=sec_name, elset='elset_all'))

    # Displacements
    # pin supports
    for i, fix in enumerate(fixities):
        f_dof = []
        for j in range(6):
            if fix[j+1] == 1:
                f_dof.append(0)
            else:
                f_dof.append(None)
        mdl.add(GeneralDisplacement(name='disp_fix_'+str(i), nodes=[fix[0]], x=f_dof[0], y=f_dof[1], z=f_dof[2], xx=f_dof[3], yy=f_dof[4], zz=f_dof[5]))
    # print('-----------fixities')
    # for i in range(len(fixities)):
    #     print(mdl.displacements['disp_fix_'+str(i)])

    # Loads
    if pt_loads:
        mdl.add([PointLoad(name='load_v_'+str(i), nodes=[pl[0]],
                           x=pl[1], y=pl[2], z=pl[3],
                           xx=pl[4], yy=pl[5], zz=pl[6])
                 for i, pl in enumerate(pt_loads)])
        if include_sw:
            mdl.add(GravityLoad(name='load_gravity', elements='elset_all'))
    else:
        mdl.add(GravityLoad(name='load_gravity', elements='elset_all'))
    # print('-----------loads')
    # print(mdl.loads['load_gravity'])
    # for i in range(len(pt_loads)):
    #     print(mdl.loads['load_v_'+str(i)])

    # Steps
    loads_names = []
    if pt_loads:
        loads_names.extend(['load_v_'+str(i) for i in range(len(pt_loads))])
    if include_sw:
        loads_names.append('load_gravity')
    mdl.add([
        GeneralStep(name='step_bc', displacements=['disp_fix_'+str(i) for i in range(len(fixities))]),
        GeneralStep(name='step_loads', loads=loads_names)
        ])

    # a boundary condition step such as 'step_bc' above, should always be applied as the first step to prevent rigid body motion
    mdl.steps_order = ['step_bc', 'step_loads']

    # Summary
    mdl.summary()

    # Run
    # node
    # 'u': nodal displacement: ux, uy, uz, um (magnitude)
    # 'ur': nodal rotation
    # 'rf': reaction force
    # 'cf': concentrated force (external load)
    # 'cm': concentrated moment (external load)

    # element
    # 's': beam stress (conmech cannot compute this at
    # version 0.1.1)
    # For beam, the following values are evaluated
    # at the "integration point" 'ip1' (middle point)
    # and pts along the axis: 'sp3, sp7, sp11, sp15'
    # sxx: axial
    # syy: hoop
    # sxy: torsion
    # smises: Von Mises
    # smaxp: max principal
    # sminp: min principal

    # 'sf': beam section force
    # sf1: axial
    # sf2: shear x
    # sf3: shear y
    if fea_engine == 'abaqus':
        mdl.analyse_and_extract(software='abaqus', fields=['u', 'ur', 'rf', 'rm', 'sf'], ndof=6, output=True)
        nD, fR, eR = parse_abaqus_result_json(file_name, temp_dir)
    elif fea_engine == 'opensees':
        mdl.analyse_and_extract(software='opensees', fields=['u'], exe=OPENSEES_PATH, ndof=6, output=True, save=True)
        raise NotImplementedError('opensees from compas_fea is not fully supported at this moment...')

        nD = {}
        fR = {}
        eR = {}
        # nD = mdl.get_nodal_results(step='step_load', field='ux', nodes='nset_all')
        print(mdl.results)
    else:
        raise NotImplementedError('FEA engine not supported!')

    return nD, fR, eR
Пример #12
0
    Properties(name='ep_stiff', material='mat_stiff', section='sec_stiff', elset='elset_stiff'),
    Properties(name='ep_ties', material='mat_steel', section='sec_ties', elset='elset_ties'),
])

# Displacements

mdl.add([
    RollerDisplacementXY(name='disp_edges', nodes='nset_edges'),
    PinnedDisplacement(name='disp_pinned', nodes='nset_corner1'),
    GeneralDisplacement(name='disp_xdof', nodes='nset_corner2', x=0),
])

# Loads

mdl.add([
    GravityLoad(name='load_gravity', elements=['elset_ribs', 'elset_vault']),
    PrestressLoad(name='load_prestress', elements='elset_ties', sxx=10*10**6),
    TributaryLoad(mdl, name='load_area', mesh=mesh_from_guid(Mesh(), rs.ObjectsByLayer('load_mesh')[0]), z=-2000),
])

# Steps

mdl.add([
    GeneralStep(name='step_bc', displacements=['disp_edges', 'disp_pinned', 'disp_xdof']),
    GeneralStep(name='step_loads', loads=['load_gravity', 'load_area'], factor={'load_gravity': 1.35, 'load_area': 1.50}),
])
mdl.steps_order = ['step_bc', 'step_loads']

# Summary

mdl.summary()
Пример #13
0
mdl.add(
    Properties(name='ep_beam',
               material='mat_elastic',
               section='sec_beam',
               elset='elset_lines'))

# Displacements

mdl.add([
    PinnedDisplacement(name='disp_left', nodes='nset_left'),
    PinnedDisplacement(name='disp_right', nodes='nset_right'),
])

# Loads

mdl.add(GravityLoad(name='load_gravity', elements='elset_lines'))

# Steps

mdl.add([
    GeneralStep(name='step_bc', displacements=['disp_left', 'disp_right']),
    GeneralStep(name='step_load', loads='load_gravity'),
])
mdl.steps_order = ['step_bc', 'step_load']

# Summary

mdl.summary()

# Run
Пример #14
0
# Sections

mdl.add(RectangularSection(name='bsec', b=0.1, h=.2))
mdl.add(Properties(name='ep_1', material='mat_1', section='bsec', elsets=['beams']))

mdl.add(ShellSection(name='ssec', t=.1))
mdl.add(Properties(name='ep_2', material='mat_2', section='ssec', elsets=['shell']))

# Displacements

mdl.add([FixedDisplacement(name='supports', nodes='supports')])

# Loads

mdl.add(GravityLoad(name='load_gravity', elements=['beams', 'shell']))

# Steps

mdl.add([
    GeneralStep(name='step_bc', displacements=['supports']),
    GeneralStep(name='step_load', loads=['load_gravity']),
])
mdl.steps_order = ['step_bc', 'step_load']

# Summary


mdl.analyse_and_extract(software='ansys', fields=['s'])

# rhino.plot_data(mdl, step='step_load', field='um', radius=0.1, colorbar_size=0.3)
Пример #15
0
               material='mat_steel',
               section='sec_stays',
               elsets='elset_stays')
])

# Displacements

mdl.add_displacement(PinnedDisplacement(name='disp_pinned', nodes='nset_pins'))

# Loads
# Note: GravityLoad doesnt activate for OpenSees

mdl.add_loads([
    PointLoad(name='load_pl_v', nodes='nset_load_v', z=-15500),
    PointLoad(name='load_pl_h', nodes='nset_load_h', x=5000),
    GravityLoad(name='load_gravity', elements=['elset_diag', 'elset_main'])
])

# Steps

mdl.add_steps([
    GeneralStep(name='step_bc', displacements=['disp_pinned']),
    GeneralStep(name='step_loads',
                loads=['load_pl_v', 'load_pl_h', 'load_gravity'],
                factor=1.5,
                increments=200)
])
mdl.steps_order = ['step_bc', 'step_loads']

# Summary
mdl.add(
    ElementProperties(name='property',
                      material='steel',
                      section='section',
                      elset='trusses'))

# print(mdl.element_properties['property'])

mdl.add(PinnedDisplacement(name='pinned', nodes='supports'))

# print(mdl.displacements['pinned'])

mdl.add([
    PointLoad(name='pointloads', nodes='loads', y=-50000),
    GravityLoad(name='gravity', elements='trusses', z=0, y=1),
])

# print(mdl.loads['pointloads'])
# print(mdl.loads['gravity'])

mdl.add([
    GeneralStep(name='bc', displacements='pinned'),
    GeneralStep(name='loads', loads=['pointloads', 'gravity'], factor=1.5),
])
mdl.steps_order = ['bc', 'loads']

# print(mdl.steps['bc'])
# print(mdl.steps['loads'])

mdl.summary()