def test_load(self):
        """Make sure the material loads from the YAML file w/o throwing errors."""
        # Action
        aisi316L_sheet = load('AISI_316L', 'sheet', 'annealed')
        aisi316L_am_renishaw = load('AISI_316L', 'additive, Renishaw',
                                    'as-built')
        aisi316L_am_eos = load('AISI_316L', 'additive, EOS', 'as-built')

        # Verificaiton
        self.assertEqual(type(aisi316L_sheet), Material)
        self.assertEqual(type(aisi316L_am_renishaw), Material)
        self.assertEqual(type(aisi316L_am_eos), Material)
        # TODO automate checking this
        print('\n' + str(aisi316L_sheet) + '\n')
        print('\n' + str(aisi316L_am_renishaw) + '\n')
        print('\n' + str(aisi316L_am_eos) + '\n')
    def test_load(self):
        """Make sure the material loads from the YAML file w/o throwing errors."""
        # Action
        ti64_bar = load('Ti-6Al-4V_ELI', 'bar', 'annealed')
        ti64_am_renishaw = load('Ti-6Al-4V_ELI', 'additive, Renishaw',
                                'annealed')
        ti64_am_eos = load('Ti-6Al-4V_ELI', 'additive, EOS', 'annealed')

        # Verificaiton
        self.assertEqual(type(ti64_bar), Material)
        self.assertEqual(type(ti64_am_renishaw), Material)
        self.assertEqual(type(ti64_am_eos), Material)
        # TODO automate checking this
        print('\n' + str(ti64_bar) + '\n')
        print('\n' + str(ti64_am_renishaw) + '\n')
        print('\n' + str(ti64_am_eos) + '\n')
    def test_load(self):
        """Make sure the material loads from the YAML file w/o throwing errors."""
        # Action
        in718_bar = load('In718', 'bar', 'solution treated and aged')
        in718_am_renishaw = load('In718', 'additive, Renishaw',
                                 'solution treated and aged')
        in718_am_eos = load('In718', 'additive, EOS',
                            'solution treated and aged')

        # Verificaiton
        self.assertEqual(type(in718_bar), Material)
        self.assertEqual(type(in718_am_renishaw), Material)
        self.assertEqual(type(in718_am_eos), Material)
        # TODO automate checking this
        print('\n' + str(in718_bar) + '\n')
        print('\n' + str(in718_am_renishaw) + '\n')
        print('\n' + str(in718_am_eos) + '\n')
예제 #4
0
def main():
    al6061 = materials.load('Al_6061', 'extruded, thickness > 1 inch', 'T6')

    axes = plot_utils.plot_property_vs_state(
        al6061.properties['youngs_modulus'], 'thermal', 'temperature')
    plot_utils.decorate_temperature_axis(axes, (50, 800), 'aviation')
    plt.title('Stiffness of {:s} vs. temperature'.format(al6061.name))
    plt.grid()
    def test_load(self):
        """Make sure the material loads from the YAML file w/o throwing errors."""
        # Action
        al6061 = load('Al_6061', 'extruded, thickness > 1 inch', 'T6')

        # Verificaiton
        self.assertEqual(type(al6061), Material)
        # TODO automate checking this
        print('\n' + str(al6061) + '\n')
    def test_load(self):
        """Make sure the material loads from the YAML file w/o throwing errors."""
        # Action
        aisi304 = load('AISI_304', 'sheet and strip', 'annealed')

        # Verificaiton
        self.assertEqual(type(aisi304), Material)
        # TODO automate checking this
        print('\n' + str(aisi304) + '\n')
    def test_load(self):
        """Make sure the material loads from the YAML file w/o throwing errors."""
        # Action
        aisi4130 = load('AISI_4130', 'tubing', 'normalized, HT-95')

        # Verificaiton
        self.assertEqual(type(aisi4130), Material)
        # TODO automate checking this
        print('\n' + str(aisi4130) + '\n')
    def test_load(self):
        """Make sure the material loads from the YAML file w/o throwing errors."""
        # Action
        d6ac = load('D6AC', 'bar, forging, tubing', 'tempered to 220 ksi')

        # Verificaiton
        self.assertEqual(type(d6ac), Material)
        # TODO automate checking this
        print('\n' + str(d6ac) + '\n')
    def test_load(self):
        """Make sure the material loads from the YAML file w/o throwing errors."""
        # Action
        alsi10mg_am_renishaw = load('AlSi10Mg', 'additive, Renishaw',
                                    'stress relieved')

        # Verificaiton
        self.assertEqual(type(alsi10mg_am_renishaw), Material)
        # TODO automate checking this
        print('\n' + str(alsi10mg_am_renishaw) + '\n')
    def test_al6061_T6_extruded(self):
        # Action
        al6061 = load('Al_6061', 'extruded, thickness > 1 inch', 'T6')

        # Verification
        self.assertEqual(al6061.category, 'metal')
        self.assertEqual(
            al6061.properties['solidus_temperature'].query_value(), 855.)
        self.assertEqual(al6061.properties['youngs_modulus'].units, 'GPa')
        result = al6061.properties['youngs_modulus'].query_value(
            {'temperature': 294})
        self.assertAlmostEqual(result, 68.3, delta=0.5)
        print('\n' + str(al6061) + '\n')
예제 #11
0
def main():
    al6061 = materials.load('Al_6061', 'extruded, thickness > 1 inch', 'T6')

    temperature = np.linspace(80, 580)  # [units: kelvin]
    modulus = al6061['youngs_modulus'].query_value(
        {'temperature': temperature})

    plt.plot(temperature, modulus, label=al6061.name)
    plt.plot(al6061['solidus_temperature'].query_value(),
             0,
             color='C0',
             marker='x')
    plt.legend()
    plt.grid(True)
    x_units = al6061['youngs_modulus']['thermal'].state_vars_units[
        'temperature']
    plt.xlabel('Temperature [{:s}]'.format(x_units))
    y_units = al6061['youngs_modulus'].units
    plt.ylabel('Youngs Modulus $E$ [{:s}]'.format(y_units))

    plt.figure()
    for exp_time in [0.5, 10, 100, 1000,
                     10000]:  # exposure time [units: hour].
        uts = al6061['strength_tensile_ultimate'].query_value({
            'temperature':
            temperature,
            'exposure time':
            exp_time
        })

        plt.plot(temperature,
                 uts,
                 label=al6061.name + ', {:.0f} hr exposure'.format(exp_time))
    plt.legend()
    plt.grid(True)
    x_units = al6061['strength_tensile_ultimate']['thermal'].state_vars_units[
        'temperature']
    plt.xlabel('Temperature [{:s}]'.format(x_units))
    y_units = al6061['strength_tensile_ultimate'].units
    plt.ylabel(
        'Ultimate Tensile Strength $\\sigma_{{ut}}$ [{:s}]'.format(y_units))
def main():
    # Load copper properties from the data file
    copper = materials.load('copper', 'wire', 'annealed')

    # Print a summary of the available properties for copper
    print(copper)

    # Query the heat capacity
    cp_300 = copper['heat_capacity'].query_value({'temperature': 300})
    print('Heat capacity of copper at 300 K = {:.1f} {:s}'.format(
        cp_300, copper['heat_capacity'].units))

    # Query the resistivity at several temperatures
    temp = np.linspace(100, 600, 6)
    rho = copper['electrical_resistivity'].query_value({'temperature': temp})
    print('Electrical resistivity of copper:')
    print('temperature: ' + str(temp) + ' K')
    print('resistivity: ' + str(rho) + copper['electrical_resistivity'].units)

    # Make plots
    plt.figure(figsize=(6, 8))
    ax1 = plt.subplot(2, 1, 1)
    plot_utils.plot_property_vs_state(copper['electrical_resistivity'],
                                      'thermal',
                                      'temperature',
                                      axes=ax1)
    ax2 = plt.subplot(2, 1, 2, sharex=ax1)
    plot_utils.plot_property_vs_state(copper['heat_capacity'],
                                      'thermal',
                                      'temperature',
                                      axes=ax2)

    plt.suptitle('Electrical resistivity and heat capacity of pure copper')
    plt.tight_layout()
    plt.subplots_adjust(top=0.90)
    plt.show()
def main():
    aisi304 = materials.load('AISI_304', 'sheet and strip', 'annealed')

    fig, axes = plt.subplots(nrows=2,
                             ncols=2,
                             sharex='col',
                             sharey='row',
                             figsize=(10, 6))

    dose = np.logspace(19.5, 22)
    temperatures = np.array([300, 300 + 273, 600 + 273, 700 + 273, 1023])
    colors = plt.cm.hot(np.linspace(0, 0.5, len(temperatures)))
    for (temp, color) in zip(temperatures, colors):
        yts = aisi304['strength_tensile_yield'].query_value(
            {
                'temperature': temp,
                'neutron dose': dose
            }, 'radiation')
        elong = aisi304['elongation'].query_value(
            {
                'temperature': temp,
                'neutron dose': dose
            }, 'radiation')
        axes[0, 0].semilogx(dose,
                            yts,
                            label='$T={:.0f}$ K'.format(temp),
                            color=color)
        axes[1, 0].semilogx(dose,
                            elong,
                            label='$T={:.0f}$ K'.format(temp),
                            color=color)
    xunits = aisi304['strength_tensile_yield']['radiation'].state_vars_units[
        'neutron dose']
    yunits = aisi304['strength_tensile_yield'].units
    axes[0, 0].set_ylabel('Yield tensile strength [{:s}]'.format(yunits))
    axes[0, 0].set_ylim([0, 1100.])

    yunits = aisi304['elongation'].units
    axes[1, 0].set_xlabel('Neutron dose [{:s}]'.format(xunits))
    axes[1, 0].set_ylabel('Elongation [{:s}]'.format(yunits))
    axes[1, 0].set_ylim([0, 50.])
    axes[1, 0].legend()

    doses = np.array([1e20, 5e20, 1e21])
    temperature = np.linspace(300, 1000)
    yts = aisi304['strength_tensile_yield'].query_value(
        {'temperature': temperature}, 'thermal')
    elong = aisi304['elongation'].query_value({'temperature': temperature},
                                              'thermal')
    axes[0, 1].plot(temperature, yts, label='unirradiated', color='black')
    axes[1, 1].plot(temperature, elong, label='unirradiated', color='black')

    colors = plt.cm.viridis(np.linspace(0, 0.75, len(doses)))
    for (dose, color) in zip(doses, colors):
        yts = aisi304['strength_tensile_yield'].query_value(
            {
                'temperature': temperature,
                'neutron dose': dose
            }, 'radiation')
        elong = aisi304['elongation'].query_value(
            {
                'temperature': temperature,
                'neutron dose': dose
            }, 'radiation')
        axes[0, 1].plot(temperature,
                        yts,
                        label='dose={:.1e} cm^-2'.format(dose),
                        color=color)
        axes[1, 1].plot(temperature,
                        elong,
                        label='dose={:.1e} cm^-2'.format(dose),
                        color=color)
    axes[0, 1].legend()
    xunits = aisi304['strength_tensile_yield']['radiation'].state_vars_units[
        'temperature']
    axes[1, 1].set_xlabel('Temperature [{:s}]'.format(xunits))

    plt.suptitle('Effects of radiation on the strength and ductility of {:s}'.
                 format(aisi304.name) +
                 '\nin {:s} condition'.format(aisi304.condition))
    plt.tight_layout()
    plt.subplots_adjust(top=0.90, hspace=0.05, wspace=0.05)

    plt.show()
 def test_bogus(self):
     """Asking for a bogus material should raise an error."""
     with self.assertRaises(ValueError) as context:
         load('bogus', 'a', 'b')
     self.assertTrue('Available materials' in str(context.exception))