Example #1
0
def test_rdpostop2():
    post = op2.rdpostop2("tests/nas2cam_extseout/inboard.op2", 1, 1, 1, 1)

    dof = post["mats"]["ougv1"][0]["dof"]
    lam = post["mats"]["ougv1"][0]["lambda"]
    ougv1 = post["mats"]["ougv1"][0]["ougv1"]

    o4 = op4.load("tests/nas2cam_extseout/inboard.op4")
    mug1 = o4["mug1"][0]
    tug1 = nastran.rddtipch("tests/nas2cam_extseout/inboard.pch")
    tef1 = nastran.rddtipch("tests/nas2cam_extseout/inboard.pch", "TEF1")
    tes1 = nastran.rddtipch("tests/nas2cam_extseout/inboard.pch", "TES1")

    # ougv1, oef1, oes1 ... they don't have the constraint modes
    # or the resflex modes! How can they be useful? Anyway, this
    # checks the values present:

    # mug1 has 24 b-set ... get first 3 modes (rest are resflex):
    modes = mug1[:, 24:27]

    pv = locate.mat_intersect(tug1, dof)[0]
    assert np.allclose(modes[pv], ougv1)

    assert np.allclose(o4["mef1"][0][:, 24:27], post["mats"]["oef1"][0][0])
    assert np.all(post["mats"]["oef1"][0][1][:, 0] == tef1[:, 0])
    assert np.all(post["mats"]["oef1"][0][1][:, 1] == 34)

    pv = np.ones(15, bool)
    pv[5:7] = False
    pv[11:15] = False
    pv = np.hstack((pv, pv, pv))

    assert np.allclose(o4["mes1"][0][:, 24:27], post["mats"]["oes1"][0][0][pv])
    assert np.all(post["mats"]["oes1"][0][1][pv, 0] == tes1[:, 0])
    assert np.all(post["mats"]["oes1"][0][1][:, 1] == 34)

    with op2.OP2("tests/nas2cam_extseout/inboard.op2") as o2:
        o2._rowsCutoff = 0
        fpos = o2.dbnames["OUGV1"][0][0][0]
        o2._fileh.seek(fpos)
        name, trailer, dbtype = o2.rdop2nt()
        oug = o2._rdop2ougv1("OUGV1")

    assert np.all(oug["ougv1"] == ougv1)
    assert np.all(oug["dof"] == dof)
    assert np.all(oug["lambda"] == lam)
Example #2
0
def test_rddtipch():
    d = nastran.rddtipch("tests/nas2cam_csuper/fake_dtipch.pch", "TEF1")
    dof = [
        (10, 8),
        (97, 8),
        (3140051, 8),
        (3000108, 77),
        (3000113, 77),
        (3000299, 77),
        (3000310, 77),
        (3000330, 77),
    ]
    n = 0
    for i in dof:
        n += i[1]
    sbe = np.empty((n, 2), dtype=np.int64)
    n = 0
    for i in dof:
        sbe[n : n + i[1], 0] = i[0]
        sbe[n : n + i[1], 1] = np.arange(1, i[1] + 1)
        n += i[1]
    assert np.all(d == sbe)
Example #3
0
def test_cglf_moment_signs():
    pth = os.path.dirname(inspect.getfile(cb))
    pth = os.path.join(pth, "..")
    pth = os.path.join(pth, "tests")
    pth = os.path.join(pth, "cla_test_data")

    se = 101
    uset, coords = nastran.bulk2uset(os.path.join(pth, "outboard.asm"))
    dct = op4.read(os.path.join(pth, "outboard.op4"))
    maa = dct["mxx"]
    kaa = dct["kxx"]
    atm = dct["mug1"]
    ltm = dct["mef1"]
    pch = os.path.join(pth, "outboard.pch")
    atm_labels = [
        "Grid {:4d}-{:1d}".format(grid, dof) for grid, dof in nastran.rddtipch(pch)
    ]
    ltm_labels = [
        "CBAR {:4d}-{:1d}".format(cbar, arg)
        for cbar, arg in nastran.rddtipch(pch, "tef1")
    ]

    nb = uset.shape[0]
    nq = maa.shape[0] - nb
    bset = np.arange(nb)
    qset = np.arange(nq) + nb
    ref = [600.0, 150.0, 150.0]
    g = 9806.65

    # use addgrid to get coordinate transformations from lv to sc:
    cid = [1, 0, 0]
    A = [0, 0, 0]
    # define sc in terms of lv coords:
    # (all drawn out by hand)
    BC = [
        [[0, 0, 1.0], [1.0, 0, 0]],  # lv x is up
        [[0, 0, -1.0], [0, 1.0, 0]],  # lv y is up
        [[-1.0, 0, 0.0], [0, 0, 1.0]],  # lv z is up
        [[0, 0, -1.0], [-1.0, 0, 0]],  # lv x is down
        [[0, 0, 1.0], [0, -1.0, 0]],  # lv y is down
        [[0, -1.0, 0], [0, 0, -1.0]],  # lv z is down
    ]
    Ts = []
    nets = []
    rb = n2p.rbgeom_uset(uset, ref)
    rbcglfa = []
    for bc in BC:
        CI = n2p.mkusetcoordinfo([cid, A, *bc], None, {})
        T = CI[2:]
        Ts.append(T)
        net = cb.mk_net_drms(maa, kaa, bset, uset=uset, ref=ref, g=g, sccoord=T)
        nets.append(net)
        rba = net.cglfa[:, :24] @ rb
        rbcglfa.append(rba)
        # sc rows:
        assert np.all(np.sign(rba[1, [1, 5]]) == np.sign(rba[3, [1, 5]]))
        assert np.all(np.sign(rba[2, [2, 4]]) == np.sign(rba[4, [2, 4]]))
        # lv rows:
        assert np.all(np.sign(rba[6, [1, 5]]) == np.sign(rba[8, [1, 5]]))
        assert np.all(np.sign(rba[7, [2, 4]]) == np.sign(rba[9, [2, 4]]))

    wh_sc = nets[0].weight_sc * nets[0].height_sc
    wh_lv = nets[0].weight_lv * nets[0].height_lv
    n = nets[0].cgatm_sc.shape[1]
    # x is down:
    cgdrm = np.vstack(
        (
            # 5 s/c rows
            nets[0].cgatm_sc[:3],
            -nets[0].ifltma_sc[5] / wh_sc,
            nets[0].ifltma_sc[4] / wh_sc,
            # 5 l/v rows
            nets[0].cgatm_lv[:3],
            -nets[0].ifltma_lv[5] / wh_lv,
            nets[0].ifltma_lv[4] / wh_lv,
            # 4 RSS rows ... filled in during data recovery
            np.zeros((4, n)),
        )
    )
    assert np.allclose(cgdrm, nets[0].cglfa)
Example #4
0
    from pyyeti import op2, n2p, nastran, op4, cb
    from pyyeti.pp import PP

    se = 101
    uset, coords = nastran.bulk2uset("outboard.asm")
    dct = op4.read("outboard.op4")
    maa = dct["mxx"]
    kaa = dct["kxx"]
    atm = dct["mug1"]
    #    ltm = dct['mef1']
    pch = "outboard.pch"

    def getlabels(lbl, id_dof):
        return ["{} {:4d}-{:1d}".format(lbl, g, i) for g, i in id_dof]

    atm_labels = getlabels("Grid", nastran.rddtipch(pch, "tug1"))
    #    ltm_labels = getlabels('CBAR', nastran.rddtipch(pch, 'tef1'))
    iflabels = getlabels("Grid", uset[:, :2].astype(int))

    # setup CLA parameters:
    mission = "Micro Space Station"

    nb = uset.shape[0]
    nq = maa.shape[0] - nb
    bset = np.arange(nb)
    qset = np.arange(nq) + nb
    ref = [600.0, 150.0, 150.0]
    g = 9806.65
    net = cb.mk_net_drms(maa, kaa, bset, uset=uset, ref=ref, g=g)

    # run cbcheck: