Example #1
0
def test_cbcoordchk2():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    se = 101
    maa = nas["maa"][se]
    kaa = nas["kaa"][se]
    pv = np.any(maa, axis=0)
    pv = np.ix_(pv, pv)
    kaa = kaa[pv]

    uset = nas["uset"][se]
    b = n2p.mksetpv(uset, "a", "b")
    b = np.nonzero(b)[0]

    chk0 = cb.cbcoordchk(kaa, b, b[-6:], verbose=False)
    rbmodes0 = chk0.rbmodes[b]

    # maa = cb.cbreorder(maa, b, last=True)
    kaa = cb.cbreorder(kaa, b, last=True)
    b += kaa.shape[0] - len(b)
    bref = b[-6:]

    chk1 = cb.cbcoordchk(kaa, b, bref, verbose=False)
    rbmodes1 = chk1.rbmodes[b]

    assert np.allclose(chk1.coords, chk0.coords)
    assert np.allclose(rbmodes1, rbmodes0)
    assert np.allclose(chk1.maxerr, chk0.maxerr)
    assert chk0.refpoint_chk == chk1.refpoint_chk == "pass"
    assert abs(chk0.maxerr).max() < 1e-5

    # a case where the refpoint_chk should be 'fail':
    chk2 = cb.cbcoordchk(kaa, b, [25, 26, 27, 31, 32, 33], verbose=False)
    assert chk2.refpoint_chk == "fail"
Example #2
0
def test_cbcheck_reorder():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    se = 101
    maa = nas["maa"][se]
    kaa = nas["kaa"][se]
    pv = np.any(maa, axis=0)
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]

    uset = nas["uset"][se]
    bset = n2p.mksetpv(uset, "p", "b")
    usetb = nas["uset"][se].iloc[bset]
    b = np.nonzero(n2p.mksetpv(uset, "a", "b"))[0]

    maa = cb.cbreorder(maa, b, last=True)
    kaa = cb.cbreorder(kaa, b, last=True)
    b += maa.shape[0] - len(b)

    # write to a string:
    with StringIO() as f:
        out = cb.cbcheck(f, maa, kaa, b, b[:6], usetb, em_filt=2)
        s = f.getvalue()
    s = s.splitlines()
    with open("tests/nas2cam_csuper/yeti_outputs/cbcheck_yeti_101.out") as f:
        sy = f.read().splitlines()

    assert s[0] == "Mass matrix is symmetric."
    assert s[1] == "Mass matrix is positive definite."
    assert s[2] == "Stiffness matrix is symmetric."
    compare_cbcheck_output(s, sy)
Example #3
0
def test_cbcheck_indeterminate_rb_norm2():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    se = 102
    maa = nas["maa"][se]
    kaa = nas["kaa"][se]
    pv = np.any(maa, axis=0)
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]

    uset = nas["uset"][se]
    bset = n2p.mksetpv(uset, "p", "b")
    usetb = nas["uset"][se].iloc[bset]
    b = n2p.mksetpv(uset, "a", "b")
    q = ~b
    b = np.nonzero(b)[0]

    bref = n2p.mkdofpv(usetb, "b", [[3, 12356], [19, 3]])[0]

    # write to a string:
    with StringIO() as f:
        out = cb.cbcheck(f, maa, kaa, b, bref, usetb, em_filt=2, rb_norm=True)
        s = f.getvalue()
    s = s.splitlines()

    with open("tests/nas2cam_csuper/yeti_outputs/cbcheck_yeti_102_rbnorm.out") as f:
        sy = f.read().splitlines()

    assert s[0] == "Mass matrix is symmetric."
    assert s[1] == "Warning: mass matrix is not positive definite."
    assert s[2] == "Warning: stiffness matrix is not symmetric."

    compare_cbcheck_output(s, sy)
Example #4
0
def test_calcAM():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    maa = nas["maa"][101]
    kaa = nas["kaa"][101]
    uset = nas["uset"][101]
    b = n2p.mksetpv(uset, "a", "b")
    q = ~b
    b = np.nonzero(b)[0]

    freq = np.arange(1.0, 80.0, 1.0)

    pv = np.any(maa, axis=0)
    q = q[pv]
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]
    baa = np.zeros_like(maa)
    baa[q, q] = 2 * 0.05 * np.sqrt(kaa[q, q])

    nb = len(b)
    bdrm = np.zeros((nb, maa.shape[0]))
    bdrm[:nb, :nb] = np.eye(nb)
    AM1 = frclim.calcAM((maa, baa, kaa, b), freq)
    AM2 = frclim.calcAM((maa, baa, kaa, bdrm), freq)
    assert np.allclose(AM1, AM2)
Example #5
0
def test_bigend():
    # most files are little-endian ... test a big-endian file:
    nas = op2.rdnas2cam("tests/nas2cam/bigend_nas2cam")
    # 1st 3 rows of the GM matrix should have 1/3 in x, y, z
    # positions: [[ 1/3,   0,   0, 0, 0, 0, 1/3,   0,   0, ...],
    #             [   0, 1/3,   0, 0, 0, 0,   0, 1/3,   0, ...],
    #             [   0,   0, 1/3, 0, 0, 0,   0,   0, 1/3, ...]]
    # - there are 18 columns (3 grids being averaged)
    # use broadcasting to get the 1/3 values out:
    rows = [[0], [1], [2]]
    cols = ytools.mkpattvec([0, 6, 12], 3, 1)
    gmvals = nas["gm"][0][rows, cols]
    assert np.allclose(gmvals, 1 / 3)
Example #6
0
def test_cbcheck_determinate():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    se = 101
    maa = nas["maa"][se]
    kaa = nas["kaa"][se]
    pv = np.any(maa, axis=0)
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]

    uset = nas["uset"][se]
    bset = n2p.mksetpv(uset, "p", "b")
    usetb = nas["uset"][se].iloc[bset]
    b = n2p.mksetpv(uset, "a", "b")

    q = ~b
    b = np.nonzero(b)[0]
    q = np.nonzero(q)[0]

    center = np.mean(usetb.iloc[::6, 1:], axis=0)
    rb = n2p.rbgeom_uset(usetb, center.values)

    # transform to single pt on centerline:
    # [b, q]_old = T*[b, q]_new
    #            = [[rb, 0], [0, I]] * [b, q]_new
    T = np.zeros((len(b) + len(q), 6 + len(q)))
    T[:len(b), :6] = rb
    T[len(b):, 6:] = np.eye(len(q))

    kaa = T.T @ kaa @ T
    maa = T.T @ maa @ T
    b = np.arange(6)

    # write to a string:
    with StringIO() as f:
        out = cb.cbcheck(f, maa, kaa, b, b[:6], em_filt=2)
        s = f.getvalue()

    s = s.splitlines()
    with open("tests/nas2cam_csuper/yeti_outputs/cbcheck_yeti_101_single.out"
              ) as f:
        sy = f.read().splitlines()

    assert s[0] == "Mass matrix is symmetric."
    assert s[1] == "Mass matrix is positive definite."
    assert s[2] == "Warning: stiffness matrix is not symmetric."

    j = [10]
    jy = [10]
    assert comptable(s, sy, j, jy, label="KBB =", skip=1)
    compare_cbcheck_output(s, sy)
Example #7
0
def test_cbcheck_unit_convert():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    se = 101
    maa = nas["maa"][se]
    kaa = nas["kaa"][se]
    pv = np.any(maa, axis=0)
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]

    uset = nas["uset"][se]
    bset = n2p.mksetpv(uset, "p", "b")
    usetb = nas["uset"][se].iloc[bset]
    b = n2p.mksetpv(uset, "a", "b")

    q = ~b
    b = np.nonzero(b)[0]
    q = np.nonzero(q)[0]

    # write to a string:
    with StringIO() as f:
        out = cb.cbcheck(
            f,
            maa,
            kaa,
            b,
            b[:6],
            uset=usetb,
            em_filt=2,
            conv=[1 / 25.4, 0.005710147154735817],
            uref=[600, 150, 150],
            rb_norm=False,
        )
        s = f.getvalue()

    s = s.splitlines()
    with open("tests/nas2cam_csuper/yeti_outputs/cbcheck_yeti_101_unitconv.out"
              ) as f:
        sy = f.read().splitlines()

    assert s[0] == "Mass matrix is symmetric."
    assert s[1] == "Mass matrix is positive definite."
    assert s[2] == "Stiffness matrix is symmetric."
    compare_cbcheck_output(s, sy)
Example #8
0
def test_n2c_csuper():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    # nas.keys()
    # dict_keys(['rfmodes', 'fgravh', 'lambda', 'phg', 'dnids', 'nrb',
    # 'maps', 'kaa', 'cstm', 'maa', 'fgravg', 'uset', 'selist', 'upids',
    # 'cstm2'])
    m = matlab.loadmat("tests/nas2cam_csuper/nas2cam.mat")
    # In [41]: m['nas'].dtype.names
    # Out[41]:
    # ('cstm',
    #  'dnids',
    #  'fgravg',
    #  'fgravh',
    #  'kaa',
    #  'lambda',
    #  'maa',
    #  'maps',
    #  'nrb',
    #  'phg',
    #  'rfmodes',
    #  'selist',
    #  'upids',
    #  'uset')
    runcomp(nas, m)
Example #9
0
def test_wtextseout():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    se = 101
    maa = nas["maa"][se]
    kaa = nas["kaa"][se]
    pv = np.any(maa, axis=0)
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]

    uset = nas["uset"][se]
    bset = n2p.mksetpv(uset, "p", "b")
    usetb = nas["uset"][se].iloc[bset]
    b = n2p.mksetpv(uset, "a", "b")
    q = ~b
    b = np.nonzero(b)[0]
    baa = np.zeros_like(maa)
    baa[q, q] = 2 * 0.05 * np.sqrt(kaa[q, q])
    name = "_wtextseout_test_"
    pre = "tests/nas2cam_csuper/yeti_outputs/se101y"
    try:
        nastran.wtextseout(
            name,
            se=101,
            maa=maa,
            kaa=kaa,
            baa=baa,
            bset=b,
            uset=usetb,
            spoint1=9900101,
        )
        names, mats, f, t = op4.load(name + ".op4", into="list")
        namesy, matsy, fy, ty = op4.load(pre + ".op4", into="list")
        assert names == namesy
        assert f == fy
        assert t == ty
        for i, (m, my) in enumerate(zip(mats, matsy)):
            assert np.allclose(m, my)
        lst = (".asm", ".pch")
        for ext in lst:
            with open(name + ext) as f:
                s = f.read()
            with open(pre + ext) as f:
                sy = f.read()
            assert s.replace(name.upper(), "SE101") == sy
    finally:
        for ext in (".asm", ".pch", ".op4"):
            if os.path.exists(name + ext):
                os.remove(name + ext)

    # test the additional writing of matrices:
    mug1 = np.arange(12).reshape(3, 4)
    mef1 = 10 * mug1
    try:
        nastran.wtextseout(
            name,
            se=101,
            maa=maa,
            kaa=kaa,
            baa=baa,
            bset=b,
            uset=usetb,
            spoint1=9900101,
            mug1=mug1,
            mef1=mef1,
        )
        names, mats, f, t = op4.load(name + ".op4", into="list")
        namesy, matsy, fy, ty = op4.load(pre + ".op4", into="list")
        assert names == namesy
        for i, (m, my) in enumerate(zip(mats, matsy)):
            if names[i] in ("mug1", "mef1"):
                assert np.allclose(m, eval(names[i]))
            else:
                assert f[i] == fy[i]
                assert t[i] == ty[i]
                assert np.allclose(m, my)
        lst = (".asm", ".pch")
        for ext in lst:
            with open(name + ext) as f:
                s = f.read()
            with open(pre + ext) as f:
                sy = f.read()
            assert s.replace(name.upper(), "SE101") == sy

    finally:
        for ext in (".asm", ".pch", ".op4", ".baa_dmig"):
            if os.path.exists(name + ext):
                os.remove(name + ext)
Example #10
0
def test_n2c_extseout():
    nas = op2.rdnas2cam("tests/nas2cam_extseout/nas2cam")
    m = matlab.loadmat("tests/nas2cam_extseout/nas2cam.mat")
    runcomp(nas, m)
Example #11
0
def test_rbmultchk():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    se = 101
    maa = nas["maa"][se]
    kaa = nas["kaa"][se]
    pv = np.any(maa, axis=0)
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]

    uset = nas["uset"][se]
    bset = n2p.mksetpv(uset, "p", "b")
    usetb = nas["uset"][se].iloc[bset]
    b = n2p.mksetpv(uset, "a", "b")
    q = ~b
    b = np.nonzero(b)[0]

    grids = [[11, 123456], [45, 123456], [60, 123456]]
    drm101, dof101 = n2p.formtran(nas, 101, grids)

    # write and read a file:
    f = tempfile.NamedTemporaryFile(delete=False)
    name = f.name
    f.close()

    rb = n2p.rbgeom_uset(usetb)
    cb.rbmultchk(name, drm101, "DRM101", rb)
    with open(name) as f:
        sfile = f.read()
    os.remove(name)

    # test rbscale and unit scale:
    with StringIO() as f:
        cb.rbmultchk(f, 0.00259 * drm101, "DRM101", 100 * rb)
        s = f.getvalue()

    pos = s.find(" which is: ")
    pos2 = s[pos:].find("\n")
    assert math.isclose(float(s[pos + 10 : pos + pos2]), 100)
    s = s.splitlines()
    table, nj1 = gettable(s, 15, 0, "Absolute Maximums", 3)
    sbe = np.array(
        [
            [600, 300, 300, 0.00259],
            [600, 300, 300, 0.00259],
            [600, 300, 300, 0.00259],
            [150, -930, 150, 0.00259],
            [600, 300, 300, 0.00259],
            [150, -930, 150, 0.00259],
        ]
    )

    assert np.allclose(table[:, 1:5], sbe)

    # write to a string:
    with StringIO() as f:
        cb.rbmultchk(f, drm101, "DRM101", rb)
        s = f.getvalue()
    assert sfile == s

    # add q-set rows to rb:
    nq = np.count_nonzero(q)
    rb2 = np.vstack((rb, np.zeros((nq, 6))))
    with StringIO() as f:
        cb.rbmultchk(f, drm101, "DRM101", rb2)
        s2 = f.getvalue()
    assert s2 == s

    # check results when b-set are last:
    drm101_last = np.hstack((drm101[:, q], drm101[:, b]))
    with StringIO() as f:
        cb.rbmultchk(f, drm101_last, "DRM101", rb, bset="last")
        s2 = f.getvalue()
    assert s2 == s

    # check results when b-set are last ... using pv:
    with StringIO() as f:
        bsetpv = np.zeros((len(b) + nq), bool)
        bsetpv[-len(b) :] = True
        cb.rbmultchk(f, drm101_last, "DRM101", rb, bset=bsetpv)
        s2 = f.getvalue()
    assert s2 == s

    with StringIO() as f:
        assert_raises(
            ValueError, cb.rbmultchk, f, drm101, "asdf", rb, bset="bad string"
        )

    # trim q-set columns out of drm:
    labels = [str(i[0]) + "  " + str(i[1]) for i in dof101]
    with StringIO() as f:
        cb.rbmultchk(
            f,
            drm101[:, b],
            "DRM101",
            rb,
            drm2=drm101[:, b],
            prtnullrows=True,
            labels=labels,
        )
        s2 = f.getvalue()

    # row 16 is now all zeros ... not comparable
    drm2 = drm101.copy()
    drm2[15] = 0
    with StringIO() as f:
        cb.rbmultchk(f, drm2, "DRM101", rb, drm2=drm2, prtnullrows=True, labels=labels)
        s3 = f.getvalue()
    assert s2 == s3

    s = s.splitlines()
    with open("tests/nas2cam_csuper/yeti_outputs/rbmultchk_yeti_101.out") as f:
        sy = f.read().splitlines()

    j = [2]
    jy = [2]
    assert comptable(s, sy, j, jy, label="Extreme ", skip=3, col=11)
    assert comptable(s, sy, j, jy, label=" Row ", skip=2, col=68)
    assert comptable(s, sy, j, jy, label=" Row ", skip=2)
    assert comptable(s, sy, j, jy, label=" Row ", skip=2)
Example #12
0
def test_cbtf():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    maa = nas["maa"][102]
    kaa = nas["kaa"][102]
    uset = nas["uset"][102]
    b = n2p.mksetpv(uset, "a", "b")
    q = ~b
    b = np.nonzero(b)[0]

    rb = n2p.rbgeom_uset(uset.iloc[b], 3)
    freq = np.arange(1.0, 80.0, 1.0)
    a = rb[:, :1]
    a2 = a.dot(np.ones((1, len(freq))))
    a3 = rb[:, 0]

    pv = np.any(maa, axis=0)
    q = q[pv]
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]
    baa1 = np.zeros_like(maa)
    baa1[q, q] = 2 * 0.05 * np.sqrt(kaa[q, q])
    baa2 = 0.1 * np.random.randn(*maa.shape)
    baa2 = baa2.dot(baa2.T)

    bb = np.ix_(b, b)

    for baa in [baa1, baa2]:
        for delq in [False, True]:
            if delq:
                m = maa[bb]
                c = baa[bb]
                k = kaa[bb]
            else:
                m = maa
                c = baa
                k = kaa

            tf = cb.cbtf(m, c, k, a, freq, b)
            tf2 = cb.cbtf(m, c, k, a2, freq, b)
            save = {}
            tf3 = cb.cbtf(m, c, k, a3, freq, b, save)
            tf4 = cb.cbtf(m, c, k, a2, freq, b, save)

            assert np.all(freq == tf.freq)
            assert np.all(freq == tf2.freq)
            assert np.all(freq == tf3.freq)
            assert np.all(freq == tf4.freq)

            assert np.allclose(tf.frc, tf2.frc)
            assert np.allclose(tf.a, tf2.a)
            assert np.allclose(tf.d, tf2.d)
            assert np.allclose(tf.v, tf2.v)

            assert np.allclose(tf.frc, tf3.frc)
            assert np.allclose(tf.a, tf3.a)
            assert np.allclose(tf.d, tf3.d)
            assert np.allclose(tf.v, tf3.v)

            assert np.allclose(tf.frc, tf4.frc)
            assert np.allclose(tf.a, tf4.a)
            assert np.allclose(tf.d, tf4.d)
            assert np.allclose(tf.v, tf4.v)

            # confirm proper solution:
            O = 2 * np.pi * freq
            velo = 1j * O * tf.d
            acce = 1j * O * velo
            f = m.dot(acce) + c.dot(velo) + k.dot(tf.d)
            assert np.allclose(acce, tf.a)
            assert np.allclose(velo, tf.v)
            assert np.allclose(f[b], tf.frc)
            if not delq:
                assert np.allclose(f[q], 0)

    assert_raises(ValueError, cb.cbtf, maa, baa1, kaa, a2[:, :3], freq, b)

    assert_raises(ValueError, cb.cbtf, maa, baa1, kaa, a2[:3, :], freq, b)
Example #13
0
def test_cbcheck_determinate():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    se = 101
    maa = nas["maa"][se]
    kaa = nas["kaa"][se]
    pv = np.any(maa, axis=0)
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]

    uset = nas["uset"][se]
    bset = n2p.mksetpv(uset, "p", "b")
    usetb = nas["uset"][se].iloc[bset]
    b = n2p.mksetpv(uset, "a", "b")

    q = ~b
    b = np.nonzero(b)[0]
    q = np.nonzero(q)[0]

    center = np.mean(usetb.iloc[::6, 1:], axis=0)
    rb = n2p.rbgeom_uset(usetb, center.values)

    # transform to single pt on centerline:
    # [b, q]_old = T*[b, q]_new
    #            = [[rb, 0], [0, I]] * [b, q]_new
    T = np.zeros((len(b) + len(q), 6 + len(q)))
    T[: len(b), :6] = rb
    T[len(b) :, 6:] = np.eye(len(q))

    kaa = T.T @ kaa @ T
    maa = T.T @ maa @ T
    b = np.arange(6)

    # write to a string:
    with StringIO() as f:
        out = cb.cbcheck(f, maa, kaa, b, b[:6], em_filt=2)
        s = f.getvalue()

    s = s.splitlines()
    with open("tests/nas2cam_csuper/yeti_outputs/cbcheck_yeti_101_single.out") as f:
        sy = f.read().splitlines()

    assert s[0] == "Mass matrix is symmetric."
    assert s[1] == "Mass matrix is positive definite."
    assert s[2] == "Warning: stiffness matrix is not symmetric."

    j = [10]
    jy = [10]
    assert comptable(s, sy, j, jy, label="KBB =", skip=1)
    compare_cbcheck_output(s, sy)

    # check with no em filter:
    with StringIO() as f:
        out2 = cb.cbcheck(f, maa, kaa, b, b[:6])
        s2 = f.getvalue()
    s2 = s2.splitlines()

    s_unique = [i for i in s if i not in s2]
    # ['Printing only the modes with at least 2.0% effective mass.',
    #  'The sum includes all modes.']

    s2_unique = [i for i in s2 if i not in s]
    # ['     5          7.025        0.00    0.00    0.00    0.00    0.88    0.00',
    #  '     6          7.025        0.00    0.00    0.00    0.00    0.00    0.00',
    #  '     7         10.913        0.00    0.00    0.00    0.00    0.00    1.52',
    #  '    11         25.135        0.00    0.00    0.00    0.00    0.00    0.42',
    #  '    12         25.140        1.03    0.00    0.00    0.00    0.00    0.00',
    #  '    13         42.173        0.00    0.00    0.00    0.51    0.00    0.00',
    #  '    14         42.193        0.00    0.00    1.04    0.00    1.02    0.00',
    #  '    16         46.895        0.00    0.00    0.00    0.00    0.00    0.00',
    #  '    17         69.173        0.00    0.13    0.00    0.00    0.00    0.99']

    assert len(s2) > len(s)
    assert len(s_unique) == 2
    assert len(s2_unique) == 9
Example #14
0
def test_cbcheck_indeterminate():
    nas = op2.rdnas2cam("tests/nas2cam_csuper/nas2cam")
    se = 101
    maa = nas["maa"][se]
    kaa = nas["kaa"][se]
    pv = np.any(maa, axis=0)
    pv = np.ix_(pv, pv)
    maa = maa[pv]
    kaa = kaa[pv]

    uset = nas["uset"][se]
    bset = n2p.mksetpv(uset, "p", "b")
    usetb = nas["uset"][se].iloc[bset]
    b = n2p.mksetpv(uset, "a", "b")
    q = ~b
    b = np.nonzero(b)[0]

    # write and read a file:
    f = tempfile.NamedTemporaryFile(delete=False)
    name = f.name
    f.close()
    # m, k, bset, rbs, rbg, rbe, usetconv = cb.cbcheck(
    out = cb.cbcheck(name, maa, kaa, b, b[:6], uset, em_filt=2)
    with open(name) as f:
        sfile = f.read()
    os.remove(name)
    assert (out.m == maa).all()
    assert (out.k == kaa).all()
    assert out.uset.equals(usetb)

    rbg = n2p.rbgeom_uset(out.uset)
    assert np.allclose(rbg, out.rbg)
    rbg_s = np.vstack((la.solve(rbg[:6].T, rbg.T).T, np.zeros((q[q].size, 6))))
    assert abs(out.rbs - rbg_s).max() < 1e-5
    assert abs(out.rbe - rbg_s).max() < 1e-5

    # write to a string:
    with StringIO() as f:
        out = cb.cbcheck(f, maa, kaa, b, b[:6], usetb, em_filt=2)
        s = f.getvalue()

    assert sfile == s
    s = s.splitlines()

    with open("tests/nas2cam_csuper/yeti_outputs/cbcheck_yeti_101.out") as f:
        sy = f.read().splitlines()

    assert s[0] == "Mass matrix is symmetric."
    assert s[1] == "Mass matrix is positive definite."
    assert s[2] == "Stiffness matrix is symmetric."

    compare_cbcheck_output(s, sy)

    with StringIO() as f:
        out = cb.cbcheck(f, maa, kaa, b, b[:6], usetb, em_filt=2, conv="e2m")
        out2 = cb.cbcheck(f, out.m, out.k, b, b[:6], out.uset, em_filt=2, conv="m2e")
        assert np.allclose(out2.uset, usetb)
        assert np.allclose(maa, out2.m)
        assert np.allclose(kaa, out2.k)

    # check for error catches:
    with StringIO() as f:
        assert_raises(
            ValueError, cb.cbcheck, f, maa, kaa, b, b[:6], usetb.iloc[:-6], em_filt=2
        )