예제 #1
0
def get_cantilever_model():
    model = Model()

    mat = model.add_feature('material', uid='dummy')
    mat.set('E', 1)
    mat.set('G', 1)
    mat.set('rho', 1)

    cs = model.add_feature('cross_section', uid='dummy')
    cs.set('A', 1)
    cs.set('Iy', 1)
    cs.set('Iz', 1)
    cs.set('J', 1)

    beam = model.add_feature('beam')
    beam.add('node', [0, 0, 0], uid='root')
    beam.add('node', [1, 0, 0], uid='tip')
    beam.set('nelem', 10)
    beam.add('material', {'from': 'root', 'to': 'tip', 'uid': 'dummy'})
    beam.add('cross_section', {'from': 'root', 'to': 'tip', 'uid': 'dummy'})
    beam.add('orientation', {'from': 'root', 'to': 'tip', 'up': [0, 0, 1]})
    beam.add('point_load', {'at': 'tip', 'load': [0, 0, -1, 0, 0, 0]})

    model.set_feature('bc').add('fix', {'node': 'root', 'fix': ['all']})
    model.set_feature('post_proc')
    return model
예제 #2
0
def test_README_model():

    # =======================================================
    # KEEP SAME AS ON README PAGE
    # =======================================================

    from framat import Model

    model = Model()

    mat = model.add_feature('material', uid='dummy')
    mat.set('E', 1)
    mat.set('G', 1)
    mat.set('rho', 1)

    cs = model.add_feature('cross_section', uid='dummy')
    cs.set('A', 1)
    cs.set('Iy', 1)
    cs.set('Iz', 1)
    cs.set('J', 1)

    beam = model.add_feature('beam')
    beam.add('node', [0, 0, 0], uid='root')
    beam.add('node', [1, 0, 0], uid='corner')
    beam.add('node', [1, 1, 0], uid='tip')
    beam.set('nelem', 10)
    beam.add('material', {'from': 'root', 'to': 'tip', 'uid': 'dummy'})
    beam.add('cross_section', {'from': 'root', 'to': 'tip', 'uid': 'dummy'})
    beam.add('orientation', {'from': 'root', 'to': 'tip', 'up': [0, 0, 1]})
    beam.add('point_load', {'at': 'corner', 'load': [0, 0, -1, 0, 0, 0]})

    bc = model.set_feature('bc')
    bc.add('fix', {'node': 'root', 'fix': ['all']})

    pp = model.set_feature('post_proc')
    pp.add('plot', ['undeformed', 'deformed', 'nodes'])

    model.run()
def get_horseshoe_model(load_case):
    model = Model()

    mat = model.add_feature('material', uid='dummy')
    mat.set('E', 1)
    mat.set('G', 1)
    mat.set('rho', 1)

    cs = model.add_feature('cross_section', uid='dummy')
    cs.set('A', 1)
    cs.set('Iy', 1)
    cs.set('Iz', 1)
    cs.set('J', 1)

    beam = model.add_feature('beam')
    beam.add('node', [0.0, 0, 0], uid='a')
    beam.add('node', [1.5, 0, 0], uid='b')
    beam.add('node', [1.5, 3, 0], uid='c')
    beam.add('node', [0.0, 3, 0], uid='d')
    # beam.set('nelem', 20)
    beam.set('nelem', 100)
    beam.add('material', {'from': 'a', 'to': 'd', 'uid': 'dummy'})
    beam.add('cross_section', {'from': 'a', 'to': 'd', 'uid': 'dummy'})
    beam.add('orientation', {'from': 'a', 'to': 'd', 'up': [0, 0, 1]})

    bc = model.set_feature('bc')
    bc.add('fix', {'node': 'a', 'fix': ['all']})
    bc.add('fix', {'node': 'd', 'fix': ['all']})

    if load_case == 1:
        beam.add('distr_load', {'from': 'a', 'to': 'b', 'load': [0, 0, -2, 0, 0, 0]})
        beam.add('distr_load', {'from': 'c', 'to': 'd', 'load': [0, 0, -2, 0, 0, 0]})
        beam.add('distr_load', {'from': 'b', 'to': 'c', 'load': [0, 0, 1, 0, 0, 0]})
    else:
        beam.add('point_load', {'at': 'b', 'load': [+0.1, +0.2, +0.3, 0, 0, 0]})
        beam.add('point_load', {'at': 'c', 'load': [-0.1, -0.2, -0.3, 0, 0, 0]})

    model.set_feature('post_proc')
    return model
예제 #4
0
def test_x():
    model = Model()

    mat = model.add_feature('material', uid='dummy')
    mat.set('E', 1)
    mat.set('G', 1)
    mat.set('rho', 1)

    cs = model.add_feature('cross_section', uid='dummy')
    cs.set('A', 1)
    cs.set('Iy', 1)
    cs.set('Iz', 1)
    cs.set('J', 1)

    beam = model.add_feature('beam')
    beam.add('node', [0.0, 0, 0], uid='root1')
    beam.add('node', [0.5, 0, 0], uid='mid1')
    beam.add('node', [1.0, 0, 0], uid='tip1')
    beam.set('nelem', 10)
    beam.add('material', {'from': 'root1', 'to': 'tip1', 'uid': 'dummy'})
    beam.add('cross_section', {'from': 'root1', 'to': 'tip1', 'uid': 'dummy'})
    beam.add('orientation', {'from': 'root1', 'to': 'tip1', 'up': [0, 0, 1]})
    beam.add('point_load', {'at': 'tip1', 'load': [0, 0, -1, 0, 0, 0]})

    beam = model.add_feature('beam')
    beam.add('node', [0.0, 0, 1], uid='root2')
    beam.add('node', [0.5, 0, 1], uid='mid2')
    beam.add('node', [1.0, 0, 1], uid='tip2')
    beam.set('nelem', 40)
    beam.add('material', {'from': 'root2', 'to': 'tip2', 'uid': 'dummy'})
    beam.add('cross_section', {'from': 'root2', 'to': 'tip2', 'uid': 'dummy'})
    beam.add('orientation', {'from': 'root2', 'to': 'tip2', 'up': [0, 0, 1]})
    beam.add('point_load', {'at': 'tip2', 'load': [0, 0, -1, 0, 0, 0]})

    bc = model.set_feature('bc')
    bc.add('fix', {'node': 'root1', 'fix': ['all']})
    bc.add('fix', {'node': 'root2', 'fix': ['all']})

    r = model.run()
예제 #5
0
def test_helix():
    Model.example('helix').run()
예제 #6
0
def test_cantilever():
    Model.example().run()
    Model.example('cantilever').run()
예제 #7
0
def test_non_existent():
    with pytest.raises(ValueError):
        Model.example('MODEL_DOES_NOT_EXIST')
예제 #8
0
# The Model object is used to set up the entire structure model, and to run a
# beam analysis
from framat import Model

# Create a new instance of the Model object
model = Model()

# ===== MATERIAL =====
# Create a material definition which can be referenced when creating beams.
# Note that you can add as many materials as you want. Just provide a different
# UID (unique identifier) for each new material. Below we define the Young's
# modulus, the shear modulus and the density.
mat = model.add_feature('material', uid='dummy')
mat.set('E', 1)
mat.set('G', 1)
mat.set('rho', 1)

# ===== CROSS SECTION =====
# Besides material data, we also need cross section geometry, or more
# specifically, the cross section area, the second moments of area, and the
# torsional constant.
cs = model.add_feature('cross_section', uid='dummy')
cs.set('A', 1)
cs.set('Iy', 1)
cs.set('Iz', 1)
cs.set('J', 1)

# ===== BEAM =====
# Next, let's add a beam! We define the geometry using "named nodes", that is,
# we provide the coordinates of some "support nodes" which can be referred to
# with their UIDs.
예제 #9
0
def test_builtin_cantilever():
    model = Model.example()
    model.run()
예제 #10
0
from framat import Model

m = Model.example('helix')
# m = Model.example()

# beam = m.add_feature('beam')
# beam.add('node', {'uid': 'a', 'coord': [0, 1, 1]})
# beam.add('node', {'uid': 'b', 'coord': [0, -1, 2]})
# beam.add('node', {'uid': 'c', 'coord': [0, 2, 2]})
# beam.add('node', {'uid': 'd', 'coord': [2, 2, 2]})
# beam.set('nelem', 40)
# beam.add('material', {'from': 'a', 'to': 'd', 'uid': 'dummy'})
# beam.add('cross_section', {'from': 'a', 'to': 'd', 'uid': 'dummy'})
# beam.add('orientation', {'from': 'a', 'to': 'd', 'up': [0, 0, 1]})
# beam.add('point_load', {'at': 'b', 'load': [0, 0, -1, 0, 0, 0]})

# m.get('beam')[0].set('nelem', 50)

# b = m.get('beam')[0]
# m.get('bc').add('fix', {'node': 'tip', 'fix': ['all']})

pp = m.set_feature('post_proc')
pp.set('plot_settings', {'linewidth': 2, 'markersize': 4})
pp.add('plot', ('undeformed', 'deformed', 'nodes', 'node_uids'))
pp.add('plot', ('undeformed', 'deformed', 'node_uids'))

r = m.run()