Ejemplo n.º 1
0
def test_piping():
    P1 = nearest_pipe(Di=0.021)
    assert_close1d(P1, (1, 0.02664, 0.0334, 0.0033799999999999998))
    P2 = nearest_pipe(Do=.273, schedule='5S')
    assert_close1d(P2, (10, 0.26630000000000004, 0.2731, 0.0034))

    ans_str = nearest_pipe(Do=0.5, schedule='80')
    ans_int = nearest_pipe(Do=0.5, schedule=80)
    ans_float = nearest_pipe(Do=0.5, schedule=80.0)
    ans_expect = (20, 0.45562, 0.508, 0.02619)
    assert_close1d(ans_str, ans_expect)
    assert_close1d(ans_str, ans_int)
    assert_close1d(ans_str, ans_float)
Ejemplo n.º 2
0
def calculate(doc_original):
    doc = deepcopy(doc_original)
    treeUnitConvert(doc, doc['units'], SI_UNITS)
    doc['errors'] = []

    calculation_option = doc['input']['calculation_option']['_val']

    try:
        if (calculation_option == 'NPS'):
            NPS = parseFloat(doc['input']['NPS']['_val'])
            Schedule = doc['input']['Schedule']['_val']
            nps, di, do, t = nearest_pipe(NPS=NPS, schedule=Schedule)
        if (calculation_option == 'Di'):
            Di = parseFloat(doc['input']['Di']['_val'])
            Schedule = doc['input']['Schedule']['_val']
            nps, di, do, t = nearest_pipe(Di=Di, schedule=Schedule)
        if (calculation_option == 'Do'):
            Do = parseFloat(doc['input']['Do']['_val'])
            Schedule = doc['input']['Schedule']['_val']
            nps, di, do, t = nearest_pipe(Do=Do, schedule=Schedule)
    except Exception as e:
        doc['errors'].append(str(e))
        nps = math.nan
        di = math.nan
        do = math.nan
        t = math.nan

    doc['result'].update({'NPS': {'_val': str(roundit(nps))}})
    doc['result'].update({'Di': {'_val': str(roundit(di)), '_dim': 'length'}})
    doc['result'].update({'Do': {'_val': str(roundit(do)), '_dim': 'length'}})
    doc['result'].update({'t': {'_val': str(roundit(t)), '_dim': 'length'}})

    treeUnitConvert(doc, SI_UNITS, doc['units'], autoRoundOff=True)
    doc_original['result'].update(doc['result'])
    doc_original['errors'] = doc['errors']
    return True
Ejemplo n.º 3
0
def calculate(doc_original):
    doc = deepcopy(doc_original)
    treeUnitConvert(doc, doc['units'], SI_UNITS)

    K_pipe = 0
    K_fittings = 0
    K_entry = 0
    K_exit = 0
    K_fixed = 0
    K_LbyD = 0
    K_total = 0
    LbyD_total = 0
    deltaP_fixed = 0
    deltaP_total = 0

    size_definition = doc['input']['pipe']['size_definition']['_val']
    if (size_definition == "NPS"):
        nps = float(doc['input']['pipe']['NPS']['_val'])
        schedule = doc['input']['pipe']['schedule']['_val']
        NPS, Di, Do, t = nearest_pipe(NPS=nps, schedule=schedule)
    else:
        Di = float(doc['input']['pipe']['Dia_inner']['_val'])
        NPS = math.nan
        Do = math.nan
        t = math.nan

    doc['result'].update({'Di': {'_val': str(Di), '_dim': 'length_mili'}})
    doc['result'].update({'Do': {'_val': str(Do), '_dim': 'length_mili'}})
    doc['result'].update({'t': {'_val': str(t), '_dim': 'length_mili'}})

    area = math.pi * pow(Di / 2, 2)
    Q = float(doc['input']['fluidData']['Q']['_val'])
    V = roundit(Q / area)
    doc['result'].update({'V': {'_val': str(V), '_dim': 'speed'}})

    mu = float(doc['input']['fluidData']['mu']['_val'])
    rho = float(doc['input']['fluidData']['rho']['_val'])
    Re = roundit(Reynolds(V=V, D=Di, rho=rho, mu=mu))
    doc['result'].update({'Re': {'_val': str(Re)}})

    Hdyn = roundit(rho * pow(V, 2) / 2)
    doc['result'].update({'Hdyn': {'_val': str(Hdyn), '_dim': 'length'}})

    #K calculation for straigth pipe
    roughness_basis = doc['input']['pipe']['roughness_basis']['_val']
    if (roughness_basis == "Material"):
        material = doc['input']['pipe']['material']['_val']
        roughness = get_roughness(material)
    else:
        roughness = float(doc['input']['pipe']['roughness']['_val'])

    eD = roughness / Di

    doc['result'].update({'eD': {'_val': str(eD)}})
    fd = roundit(friction_factor(Re=Re, eD=eD, Method="Moody"))
    doc['result'].update({'fd_Moody': {'_val': str(fd)}})

    length = float(doc['input']['pipe']['length']['_val'])
    K_pipe = roundit(K_from_f(fd=fd, L=length, D=Di))
    doc['result'].update({'K_pipe': {'_val': str(K_pipe)}})
    deltaP_pipe = roundit(dP_from_K(K_pipe, rho, V))
    doc['result'].update(
        {'deltaP_pipe': {
            '_val': str(deltaP_pipe),
            '_dim': 'pressure'
        }})

    #calculating pressure drop for entrance

    entry_type = doc['input']['entrance']['entry_type']['_val']
    print('entry type is')
    print(entry_type)
    if entry_type == 'none':
        K_entry = 0
    elif entry_type == 'Sharp':
        K_entry = fluids.fittings.entrance_sharp()
    elif entry_type == 'Rounded':
        Rc = float(doc['input']['entrance']['Rc']['_val'])
        K_entry = fluids.fittings.entrance_rounded(Di, Rc)
    elif entry_type == 'Angled':
        angle_radians = float(doc['input']['entrance']['angle']['_val'])
        angle = angle_radians * 57.2958
        K_entry = fluids.fittings.entrance_angled(angle)
    elif entry_type == 'Projecting':
        wall_thickness = float(
            doc['input']['entrance']['wall_thickness']['_val'])
        K_entry = fluids.fittings.entrance_distance(Di, wall_thickness)

    K_entry = roundit(K_entry)
    doc['result'].update({'K_entry': {'_val': str(K_entry)}})
    deltaP_entry = roundit(dP_from_K(K_entry, rho, V))
    doc['result'].update(
        {'deltaP_entry': {
            '_val': str(deltaP_entry),
            '_dim': 'pressure'
        }})

    #calculating pressure drop for exit
    exit_type = doc['input']['exit']['exit_type']['_val']
    print('exit_type')
    print(exit_type)
    if (exit_type == 'Normal'):
        K_exit = exit_normal()
    else:
        K_exit = 0

    K_exit = roundit(K_exit)
    doc['result'].update({'K_exit': {'_val': str(K_exit)}})
    deltaP_exit = roundit(dP_from_K(K_exit, rho, V))
    doc['result'].update(
        {'deltaP_exit': {
            '_val': str(deltaP_exit),
            '_dim': 'pressure'
        }})

    #calculating pressure drop for fittings
    fittings_list = doc['input']['fittings']
    for fitting in fittings_list:
        name = get_hooper_list()[fitting['index']]
        Di_inch = Di * 39.3701
        K_fitting = Hooper2K(Di_inch, Re, name=name)
        K_fittings += K_fitting * fitting['quantity']

    K_fittings = roundit(K_fittings)
    doc['result'].update({'K_fittings': {'_val': str(K_fittings)}})
    deltaP_fittings = dP_from_K(K_fittings, rho, V)
    deltaP_fittings = roundit(deltaP_fittings)
    doc['result'].update({
        'deltaP_fittings': {
            '_val': str(deltaP_fittings),
            '_dim': 'pressure'
        }
    })

    #calculating pressure drop for sharp contractions
    deltaP_contractions_sharp = 0
    contractions_sharp = doc['input']['contractions_sharp']['_list']
    for contraction in contractions_sharp:
        D1 = contraction['D1']
        D2 = contraction['D2']
        A2 = 3.1416 * (D2**2) / 4
        V2 = Q / A2
        K_contraction = fluids.fittings.contraction_sharp(D1, D2)
        deltaP = dP_from_K(K_contraction, rho, V2)
        deltaP_contractions_sharp += deltaP

    deltaP_contractions_sharp = roundit(deltaP_contractions_sharp)
    doc['result'].update({
        'deltaP_contractions_sharp': {
            '_val': str(deltaP_contractions_sharp),
            '_dim': 'pressure'
        }
    })

    #calculating pressure drop for rounded contractions
    deltaP_contractions_rounded = 0
    contractions_rounded = doc['input']['contractions_rounded']['_list']
    for contraction in contractions_rounded:
        D1 = contraction['D1']
        D2 = contraction['D2']
        Rc = contraction['Rc']
        A2 = 3.1416 * (D2**2) / 4
        V2 = Q / A2
        K_contraction = fluids.fittings.contraction_round(D1, D2, Rc)
        deltaP = dP_from_K(K_contraction, rho, V2)
        deltaP_contractions_rounded += deltaP

    deltaP_contractions_rounded = roundit(deltaP_contractions_rounded)
    doc['result'].update({
        'deltaP_contractions_rounded': {
            '_val': str(deltaP_contractions_rounded),
            '_dim': 'pressure'
        }
    })

    #calculating pressure drop for conical contractions
    deltaP_contractions_conical = 0
    contractions_conical = doc['input']['contractions_conical']['_list']
    for contraction in contractions_conical:
        D1 = contraction['D1']
        D2 = contraction['D2']
        L = contraction['L']
        A2 = 3.1416 * (D2**2) / 4
        V2 = Q / A2
        K_contraction = fluids.fittings.contraction_conical(D1, D2, fd=fd, l=L)
        deltaP = dP_from_K(K_contraction, rho, V2)
        deltaP_contractions_conical += deltaP

    deltaP_contractions_conical = roundit(deltaP_contractions_conical)
    doc['result'].update({
        'deltaP_contractions_conical': {
            '_val': str(deltaP_contractions_conical),
            '_dim': 'pressure'
        }
    })

    #calculating pressure drop for pipe reducers contractions
    deltaP_contractions_reducer = 0
    contractions_reducer = doc['input']['contractions_reducer']['_list']
    for contraction in contractions_reducer:
        reducer_size = contraction['reducer_size']
        D1, D2, L = reducer_dimensions(reducer_size)
        A2 = 3.1416 * (D2**2) / 4
        V2 = Q / A2
        K_contraction = fluids.fittings.contraction_conical(D1, D2, fd=fd, l=L)
        deltaP = dP_from_K(K_contraction, rho, V2)
        deltaP_contractions_reducer += deltaP

    deltaP_contractions_reducer = roundit(deltaP_contractions_reducer)
    doc['result'].update({
        'deltaP_contractions_reducer': {
            '_val': str(deltaP_contractions_reducer),
            '_dim': 'pressure'
        }
    })

    # calculating total pressure drop in all contractions
    deltaP_contractions = deltaP_contractions_sharp + deltaP_contractions_rounded + deltaP_contractions_conical + deltaP_contractions_reducer
    deltaP_contractions = roundit(deltaP_contractions)
    doc['result'].update({
        'deltaP_contractions': {
            '_val': str(deltaP_contractions),
            '_dim': 'pressure'
        }
    })

    #calculating pressure drop for sharp expansions
    deltaP_expansions_sharp = 0
    expansions_sharp = doc['input']['expansions_sharp']['_list']
    for contraction in expansions_sharp:
        D1 = contraction['D1']
        D2 = contraction['D2']
        A1 = 3.1416 * (D1**2) / 4
        V1 = Q / A1
        K_contraction = fluids.fittings.diffuser_sharp(D1, D2)
        deltaP = dP_from_K(K_contraction, rho, V1)
        deltaP_expansions_sharp += deltaP

    deltaP_expansions_sharp = roundit(deltaP_expansions_sharp)
    doc['result'].update({
        'deltaP_expansions_sharp': {
            '_val': str(deltaP_expansions_sharp),
            '_dim': 'pressure'
        }
    })

    #calculating pressure drop for conical expansions
    deltaP_expansions_conical = 0
    expansions_conical = doc['input']['expansions_conical']['_list']
    for contraction in expansions_conical:
        D1 = contraction['D1']
        D2 = contraction['D2']
        L = contraction['L']
        A1 = 3.1416 * (D1**2) / 4
        V1 = Q / A1
        K_contraction = fluids.fittings.diffuser_conical(D1, D2, fd=fd, l=L)
        deltaP = dP_from_K(K_contraction, rho, V1)
        deltaP_expansions_conical += deltaP

    deltaP_expansions_conical = roundit(deltaP_expansions_conical)
    doc['result'].update({
        'deltaP_expansions_conical': {
            '_val': str(deltaP_expansions_conical),
            '_dim': 'pressure'
        }
    })

    #calculating pressure drop for pipe reducer expansions
    deltaP_expansions_reducer = 0
    expansions_reducer = doc['input']['expansions_reducer']['_list']
    for contraction in expansions_reducer:
        reducer_size = contraction['reducer_size']
        D2, D1, L = reducer_dimensions(reducer_size)
        A1 = 3.1416 * (D1**2) / 4
        V1 = Q / A1
        K_contraction = fluids.fittings.diffuser_conical(D1, D2, fd=fd, l=L)
        deltaP = dP_from_K(K_contraction, rho, V1)
        deltaP_expansions_reducer += deltaP

    deltaP_expansions_reducer = roundit(deltaP_expansions_reducer)
    doc['result'].update({
        'deltaP_expansions_reducer': {
            '_val': str(deltaP_expansions_reducer),
            '_dim': 'pressure'
        }
    })

    # calculating total pressure drop in all expansions
    deltaP_expansions = deltaP_expansions_sharp + deltaP_expansions_conical + deltaP_expansions_reducer
    doc['result'].update(
        {'deltaP_expansions': {
            '_val': deltaP_expansions,
            '_dim': 'pressure'
        }})

    fixed_K_loss = doc['input']['fixed_K_losses']['_list']
    for loss in fixed_K_loss:
        K_fixed += loss['K'] * loss['quantity']
    deltaP_fixed_K = dP_from_K(K_fixed, rho, V)

    fixed_LbyD_loss = doc['input']['fixed_LbyD_losses']['_list']
    for loss in fixed_LbyD_loss:
        L_D = loss['LbyD']
        K_LbyD += K_from_L_equiv(L_D=L_D, fd=fd) * loss['quantity']
    deltaP_fixed_LbyD = dP_from_K(K_LbyD, rho, V)

    fixed_deltaP_loss = doc['input']['fixed_deltaP_losses']['_list']
    for loss in fixed_deltaP_loss:
        deltaP_fixed += loss['deltaP'] * loss['quantity']
    deltaP_fixed_deltaP = deltaP_fixed

    deltaP_fixed_all = deltaP_fixed_K + deltaP_fixed_LbyD + deltaP_fixed_deltaP

    deltaP_fixed_all = roundit(deltaP_fixed_all)
    doc['result'].update({
        'deltaP_fixed_all': {
            '_val': str(deltaP_fixed_all),
            '_dim': 'pressure'
        }
    })

    deltaP_total = deltaP_pipe + deltaP_entry + deltaP_exit + deltaP_fittings + deltaP_contractions + deltaP_expansions + deltaP_fixed_all
    deltaP_total = roundit(deltaP_total)
    doc['result'].update(
        {'deltaP_total': {
            '_val': str(deltaP_total),
            '_dim': 'pressure'
        }})

    #    doc_original['input'].update(doc['input'])
    doc_original['result'].update(doc['result'])
    treeUnitConvert(doc, SI_UNITS, doc['units'], autoRoundOff=True)
    return True
Ejemplo n.º 4
0
def test_gauge():

    g1s = gauge_from_t(.5, False, 'BWG'), gauge_from_t(0.005588, True)
    assert_close1d(g1s, (0.2, 5))
    g2s = gauge_from_t(0.5165, False,
                       'AWG'), gauge_from_t(0.00462026, True, 'AWG')
    assert_close1d(g2s, (0.2, 5))
    g3s = gauge_from_t(.4305, False,
                       'SWG'), gauge_from_t(0.0052578, True, 'SWG')
    assert_close1d(g3s, (0.2, 5))
    g4s = gauge_from_t(.005, False,
                       'MWG'), gauge_from_t(0.0003556, True, 'MWG')
    assert_close1d(g4s, (0.2, 5))
    g5s = gauge_from_t(.432, False,
                       'BSWG'), gauge_from_t(0.0053848, True, 'BSWG')
    assert_close1d(g5s, (0.2, 5))
    g6s = gauge_from_t(0.227, False,
                       'SSWG'), gauge_from_t(0.0051816, True, 'SSWG')
    assert_close1d(g6s, (1, 5))

    with pytest.raises(Exception):
        gauge_from_t(.5, False, 'FAIL')  # Not in schedule
    with pytest.raises(Exception):
        gauge_from_t(0.02)  # Too large

    g1 = gauge_from_t(0.002)  # not in index; gauge 14, 2 mm
    g2 = gauge_from_t(
        0.00185)  # not in index, gauge 15, within tol (10% default)
    # Limits between them are 0.0018288 and 0.0021082 m.
    g3 = gauge_from_t(0.00002)
    assert_close1d([g1, g2, g3], [14, 15, 0.004])

    t1s = t_from_gauge(.2, False, 'BWG'), t_from_gauge(5, True)
    assert_close1d(t1s, (0.5, 0.005588))

    t2s = t_from_gauge(.2, False, 'AWG'), t_from_gauge(5, True, 'AWG')
    assert_close1d(t2s, (0.5165, 0.00462026))

    t3s = t_from_gauge(.2, False, 'SWG'), t_from_gauge(5, True, 'SWG')
    assert_close1d(t3s, (0.4305, 0.0052578))

    t4s = t_from_gauge(.2, False, 'MWG'), t_from_gauge(5, True, 'MWG')
    assert_close1d(t4s, (0.005, 0.0003556))

    t5s = t_from_gauge(.2, False, 'BSWG'), t_from_gauge(5, True, 'BSWG')
    assert_close1d(t5s, (0.432, 0.0053848))

    t6s = t_from_gauge(1, False, 'SSWG'), t_from_gauge(5, True, 'SSWG')
    assert_close1d(t6s, (0.227, 0.0051816))

    with pytest.raises(Exception):
        t_from_gauge(17.5, schedule='FAIL')
    with pytest.raises(Exception):
        t_from_gauge(17.5, schedule='MWG')

    # Test schedule is implemented
    NPS, Di, Do, t = nearest_pipe(Do=.273, schedule='80D1527')
    assert NPS == 10
    assert_close1d((Di, Do, t), (0.2429256, 0.27305, 0.015062200000000001))

    # initially accidentally implemented this using the mm's given in the standard
    # however the IPS ones are authoritative.
    NPS, Di, Do, t = nearest_pipe(NPS=8, schedule='ABSD2680')
    assert NPS == 8
    assert_close1d((0.19685, 0.239014, 0.021082), (Di, Do, t), rtol=1e-12)

    # initially accidentally implemented this using the mm's given in the standard
    # however the IPS ones are authoritative.
    NPS, Di, Do, t = nearest_pipe(NPS=27, schedule='PS115F679')
    assert NPS == 27
    assert_close1d((0.6591046, 0.7100062, 0.025450800000000003), (Di, Do, t),
                   rtol=1e-12)

    NPS, Di, Do, t = nearest_pipe(NPS=27, schedule='PS75F679')
    assert NPS == 27
    assert_close1d((0.665607, 0.7100062, 0.0221996), (Di, Do, t), rtol=1e-12)

    NPS, Di, Do, t = nearest_pipe(NPS=27, schedule='PS46F679')
    assert NPS == 27
    assert_close1d((0.6721602, 0.7100062, 0.018923), (Di, Do, t), rtol=1e-12)

    from fluids.piping import NPS120_D1785
    assert_close(NPS120_D1785[0], 0.5)
    assert_close(NPS120_D1785[-1], 12)

    # initially accidentally implemented this using the mm's given in the standard
    # however the IPS ones are authoritative.
    NPS, Di, Do, t = nearest_pipe(NPS=6, schedule='PVCD2665')
    assert_close1d((0.154051, 0.168275, 0.007112), (Di, Do, t), rtol=1e-12)

    # initially accidentally implemented this using the mm's given in the standard
    # however the IPS ones are authoritative.
    NPS, Di, Do, t = nearest_pipe(NPS=6, schedule='80D1785')
    assert_close1d((0.1463294, 0.168275, 0.0109728), (Di, Do, t), rtol=1e-12)

    # initially accidentally implemented this using the mm's given in the standard
    # however the IPS ones are authoritative.
    NPS, Di, Do, t = nearest_pipe(NPS=6, schedule='DR21D2241')
    assert_close1d((0.15222219999999997, 0.168275, 0.008026400000000001),
                   (Di, Do, t),
                   rtol=1e-12)

    # initially accidentally implemented this using the mm's given in the standard
    # however the IPS ones are authoritative.
    NPS, Di, Do, t = nearest_pipe(NPS=1, schedule='DR21D2241CTS')
    assert_close1d((0.025527, 0.028575, 0.001524), (Di, Do, t), rtol=1e-12)

    # initially accidentally implemented this using the mm's given in the standard
    # however the IPS ones are authoritative.
    NPS, Di, Do, t = nearest_pipe(NPS=10, schedule='DR325D2241PIP')
    assert_close1d((0.2431288, 0.25908, 0.0079756), (Di, Do, t), rtol=1e-12)

    # Test schedule with DN
    NPS, Di, Do, t = nearest_pipe(NPS=100, schedule='S40F441SI')
    assert_close1d((0.10226, 0.1143, 0.006019999999999999), (Di, Do, t),
                   rtol=1e-12)
Ejemplo n.º 5
0
def calculate(doc_original):
    doc = deepcopy(doc_original)
    treeUnitConvert(doc, doc['units'], SI_UNITS)
    doc['errors'] = []

    calculation_option = doc['input']['calculation_option']['_val']
    '''

    '''

    try:
        if (calculation_option == 'NPS'):
            NPS = parseFloat(doc['input']['NPS']['_val'])
            Schedule = doc['input']['Schedule']['_val']
            NPS, d, D, tn = nearest_pipe(NPS=NPS, schedule=Schedule)
        if (calculation_option == 'd'):
            d = parseFloat(doc['input']['d']['_val'])
            Schedule = doc['input']['Schedule']['_val']
            NPS, d, D, tn = nearest_pipe(Di=d, schedule=Schedule)
        if (calculation_option == 'D'):
            D = parseFloat(doc['input']['D']['_val'])
            Schedule = doc['input']['Schedule']['_val']
            NPS, d, D, tn = nearest_pipe(Do=D, schedule=Schedule)
    except Exception as e:
        doc['errors'].append(str(e))
        NPS = math.nan
        d = math.nan
        D = math.nan
        tn = math.nan

    P = parseFloat(doc['input']['P']['_val'])
    Tdesign = parseFloat(doc['input']['Tdesign']['_val'])
    materialSpec = doc['input']['materialSpec']['_val']
    weldType = doc['input']['weldType']['_val']
    W = parseFloat(doc['input']['W']['_val'])
    ca = parseFloat(doc['input']['ca']['_val'])
    h = parseFloat(doc['input']['h']['_val'])
    ut = parseFloat(doc['input']['ut']['_val'])

    t_ut = tn * ut / 100  # thickness lost due to undertolerance
    T = tn - t_ut  # guaranteed thickness available as a minimum

    c = ca + h  # get sum total of all corrosion and threading allowance

    S = getS(materialSpec, Tdesign)
    Y = getY(materialSpec, Tdesign)
    E = getE(weldType)
    t = t_pressure(P, D, S, E, W, Y)  # pressure design thickness
    tm = t + c  # min required thickness
    if (T >= tm):
        acceptability = "OK"
    else:
        acceptability = "Not OK"

    doc['result'].update({'NPS': {'_val': str(roundit(NPS))}})
    doc['result'].update({'d': {'_val': str(roundit(d)), '_dim': 'length'}})
    doc['result'].update({'D': {'_val': str(roundit(D)), '_dim': 'length'}})
    doc['result'].update({'tn': {'_val': str(roundit(tn)), '_dim': 'length'}})
    doc['result'].update(
        {'t_ut': {
            '_val': str(roundit(t_ut)),
            '_dim': 'length'
        }})
    doc['result'].update({'T': {'_val': str(roundit(T)), '_dim': 'length'}})
    doc['result'].update({'S': {'_val': str(roundit(S)), '_dim': 'pressure'}})
    doc['result'].update({'Y': {'_val': str(roundit(Y))}})
    doc['result'].update({'E': {'_val': str(E)}})
    doc['result'].update({'t': {'_val': str(roundit(t)), '_dim': 'length'}})
    doc['result'].update({'c': {'_val': str(roundit(c)), '_dim': 'length'}})
    doc['result'].update({'tm': {'_val': str(roundit(tm)), '_dim': 'length'}})
    doc['result'].update({'acceptability': {'_val': acceptability}})

    treeUnitConvert(doc, SI_UNITS, doc['units'], autoRoundOff=True)
    doc_original['result'].update(doc['result'])
    doc_original['errors'] = doc['errors']
    return True