Пример #1
0
def getS(materialSpec, T):
    data_file = "ASME_B31_3_table_A_1.csv"
    try:
        THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
        data_file_path = os.path.join(THIS_FOLDER, data_file)
        stress_df = pd.read_csv(data_file_path)
        stress_df = stress_df.set_index('MatlSpec')
        matl_stress = stress_df.loc[materialSpec]
        matl_stress = matl_stress.drop(['Tmin', 'Su', 'Sy'])
        temperature_values = matl_stress.index.tolist()
        stress_values = matl_stress.values

        for index, val in enumerate(temperature_values):
            temperature_values[index] = float(val)

        # convert K to F
        T_C = T - 273
        T_F = T_C * 9 / 5 + 32
        S_ksi = linarray_interp(temperature_values, stress_values, T_F)
        S = S_ksi * 6894757.2932
        #S = 137896000

    except Exception as e:
        #        raise e
        raise Exception('S could not be determined')

    return S
Пример #2
0
def getAllowableStress(materialSpec, T):
    data_file = "ASME_VIII_table_1A.csv"

    try:
        THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
        data_file_path = os.path.join(THIS_FOLDER, data_file)
        stress_df = pd.read_csv(data_file_path)
        stress_df = stress_df.set_index('MatlSpec')
        matl_stress = stress_df.loc[materialSpec]
        matl_stress = matl_stress.drop(
            ['Density', 'St', 'Sy', 'Tmax', 'Chart'])
        temperature_values = matl_stress.index.tolist()
        stress_values = matl_stress.values

        for index, val in enumerate(temperature_values):
            temperature_values[index] = float(val)

        # convert K to F
        T_C = T - 273.15
        S_MPa = linarray_interp(temperature_values, stress_values, T_C)
        S = S_MPa * 1e6

    except Exception as e:
        #        raise e
        raise Exception('S could not be determined')

    return S
Пример #3
0
def Z_NelsonObert_reduced(Pr, Tr):
    '''
    This function returns compressibility factors using Nelson Obert Generalised Compressibility Charts

    Arguments and Units
    -------------------
    Pr : Reduced Pressure (= P/Pcritical)
    Tr : Reduced Temperature (= T/Tcritical)
    '''

    if ((Pr <= 0.09) and (Tr <= 2)):
        nelobdata = nelobdatalow
    else:
        nelobdata = nelobdatahigh

    ncurves = len(nelobdata)

    #try:

    lindex = 0
    for i in range(0, ncurves):
        if (nelobdata[i][0] > Tr):
            lindex = i - 1
            break

    tr_lower = nelobdata[lindex][0]
    tr_lower_curve = nelobdata[lindex][1]
    tr_higher = nelobdata[lindex + 1][0]
    tr_higher_curve = nelobdata[lindex + 1][1]

    x, y = zip(*tr_lower_curve)
    Z_lower = linarray_interp(x, y, Pr)

    x, y = zip(*tr_higher_curve)
    Z_higher = linarray_interp(x, y, Pr)

    x = [tr_lower, tr_higher]
    y = [Z_lower, Z_higher]
    Z = linarray_interp(x, y, Tr)

    #except:
    #    Z = None
    return Z
Пример #4
0
def flameDistortion(Uinf_by_Uj):
    data_file = "flamedistortion.csv"
    try:
        THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
        data_file_path = os.path.join(THIS_FOLDER, data_file)
        distortion_df = pd.read_csv(data_file_path)
        distortion_df = distortion_df.set_index('Sno')
        x_array = distortion_df['X1'].tolist()
        print(x_array)
        y_array = distortion_df['delY_by_L'].tolist()
        print(y_array)
        Sdy_by_L = linarray_interp(x_array, y_array, Uinf_by_Uj)

        x_array = distortion_df['X2'].tolist()
        y_array = distortion_df['delX_by_L'].tolist()
        Sdx_by_L = linarray_interp(x_array, y_array, Uinf_by_Uj)

    except Exception as e:
        raise e
        raise Exception('S could not be determined')

    return Sdy_by_L, Sdx_by_L
Пример #5
0
def getY(materialSpec, T):
    Material = "Other_ductile_metals"
    Ferritic_steels = []
    Austenitic_steels = [
        "A312-TP316L", "A358-Gr316L", "A312-TP304", "A358-Gr304"
    ]
    Other_ductile_metals = [
        "A106-B", "A333-6", "A671-CC65", "A335-P5", "A691-5CR"
    ]
    Cast_irons = []

    if materialSpec in Ferritic_steels:
        Material = "Ferritic_steel"
    elif materialSpec in Austenitic_steels:
        Material = "Austenitic_steel"
    elif materialSpec in Other_ductile_metals:
        Material = "Other_ductile_metals"
    elif materialSpec in Cast_irons:
        Material = "Cast_iron"
    else:
        raise Exception(
            "Y lookup from ASME B31.3 table 304.1.1 failed. Check material specification input"
        )

    data_file = "ASME_B31_3_table_304_1_1.csv"
    THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
    data_file_path = os.path.join(THIS_FOLDER, data_file)
    Ycoeff_df = pd.read_csv(data_file_path)
    Ycoeff_df = Ycoeff_df.set_index("Material")
    Y_series = Ycoeff_df.loc[Material]
    temperature_values = Y_series.index.tolist()
    for index, val in enumerate(temperature_values):
        temperature_values[index] = float(val)

    Y_values = Y_series.values

    T_C = T - 273.15
    if (T_C < 482):
        T_C = 482

    if (T_C > 621):
        T_C = 621

    Y = linarray_interp(temperature_values, Y_values, T_C)
    return Y
Пример #6
0
def getTd(temperature, time, cell_range):
    if (temperature > 25):
        Td = 1
        return Td

    if (cell_range == 'L'):
        data_file = 'L_cell_deration.csv'
        time_values = [60, 300]
        if time < 60:
            time = 60
        if time > 300:
            time = 300

        index_lower, index_higher = getindex(time_values, time)
        time_lower = time_values[index_lower]
        time_higher = time_values[index_higher]
    elif (cell_range == 'H'):
        data_file = 'H_cell_deration.csv'
        time_values = [1, 30, 300]
        if time < 1:
            time = 1
        if time > 300:
            time = 300
        index_lower, index_higher = getindex(time_values, time)
        time_lower = time_values[index_lower]
        time_higher = time_values[index_higher]
    elif (cell_range == 'M'):
        data_file = 'M_cell_deration.csv'
        time_values = [15, 60, 300]
        if time < 15:
            time = 15
        if time > 300:
            time = 300
        index_lower, index_higher = getindex(time_values, time)
        time_lower = time_values[index_lower]
        time_higher = time_values[index_higher]
    else:
        raise Exception('Failed to calculate Td. Invalid choice of cell range')
    '''
    data_file = "T_derate.csv"
    time_values = [10, 30, 60, 180, 300]
    '''
    T_lower = "T_" + str(time_values[index_lower])
    C_lower = "C_" + str(time_values[index_lower])

    T_higher = "T_" + str(time_values[index_higher])
    C_higher = "C_" + str(time_values[index_higher])
    try:
        THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
        data_file_path = os.path.join(THIS_FOLDER, data_file)
        rates_df = pd.read_csv(data_file_path)
        rates_df = rates_df.set_index('S_No')
        T_lower_values = rates_df[T_lower].tolist()
        C_lower_values = rates_df[C_lower].tolist()
        deration_lower = linarray_interp(T_lower_values, C_lower_values,
                                         temperature)

        T_higher_values = rates_df[T_higher].tolist()
        C_higher_values = rates_df[C_higher].tolist()
        deration_higher = linarray_interp(T_higher_values, C_higher_values,
                                          temperature)

        deration = linear_interp(time, time_lower, deration_lower, time_higher,
                                 deration_higher)

    except Exception as e:
        raise e
        raise Exception('Td could not be calculated')

    Td = (1 / deration)

    return Td