예제 #1
0
def test_temperature_overstress_harsh_environment(temperature_active,
                                                  environment_active_id):
    """overstressed() should return True when hot spot temperature is within 15C of rated temperature in a harsh environment and False otherwise."""
    ATTRIBUTES['current_operating'] = 0.18
    ATTRIBUTES['current_rated'] = 0.5
    ATTRIBUTES['voltage_rated'] = 20.0
    ATTRIBUTES['voltage_ac_operating'] = 0.005
    ATTRIBUTES['voltage_dc_operating'] = 6.0
    ATTRIBUTES['temperature_rated_max'] = 125.0
    ATTRIBUTES['temperature_active'] = temperature_active
    ATTRIBUTES['environment_active_id'] = environment_active_id

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes = Inductor.calculate_hot_spot_temperature(**_attributes)
    _attributes = Component.do_check_overstress(**_attributes)

    assert isinstance(_attributes, dict)
    if temperature_active == 28.7:
        assert not _attributes['overstress']
        assert _attributes['reason'] == ''
    elif temperature_active == 118.2:
        assert _attributes['overstress']
        assert _attributes['reason'] == ('1. Operating temperature within '
                                         '15.0C of maximum rated '
                                         'temperature.\n')
예제 #2
0
def test_calculate_mil_hdbk_217f_part_stress_missing_environment():
    """calculate_mil_hdbk_217f_part_stress() should return a zero active hazard rate and a non-empty message when the active environment ID is missing."""
    ATTRIBUTES['subcategory_id'] = 1
    ATTRIBUTES['hazard_rate_method_id'] = 2
    ATTRIBUTES['environment_active_id'] = 41
    ATTRIBUTES['insulation_id'] = 3
    ATTRIBUTES['construction_id'] = 2
    ATTRIBUTES['temperature_active'] = 32.0
    ATTRIBUTES['temperature_rated_max'] = 85.0
    ATTRIBUTES['quality_id'] = 2
    ATTRIBUTES['temperature_active'] = 32.0
    ATTRIBUTES['power_operating'] = 0.15
    ATTRIBUTES['temperature_case'] = 45.0
    ATTRIBUTES['theta_jc'] = 70.0
    ATTRIBUTES['voltage_rated'] = 5.0
    ATTRIBUTES['voltage_ac_operating'] = 0.05
    ATTRIBUTES['voltage_dc_operating'] = 3.3

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes, _msg = Semiconductor.calculate_217f_part_stress(**_attributes)

    assert isinstance(_attributes, dict)
    assert _msg == (
        'RAMSTK WARNING: piE is 0.0 when calculating semiconductor, '
        'hardware ID: 6 and active environment ID: 41.\n')
    assert pytest.approx(_attributes['voltage_ratio'], 0.67)
    assert _attributes['temperature_junction'] == 55.5
    assert _attributes['lambda_b'] == 0.0034
    assert _attributes['piQ'] == 1.0
    assert _attributes['piE'] == 0.0
    assert _attributes['piC'] == 2.0
    assert pytest.approx(_attributes['piT'], 2.6196648)
    assert pytest.approx(_attributes['piS'], 0.3778868)
    assert _attributes['hazard_rate_active'] == 0.0
예제 #3
0
def test_calculate_mil_hdbk_217f_part_stress():
    """calculate_mil_hdbk_217f_part_stress() should return a dictionary of updated values on success."""
    ATTRIBUTES['subcategory_id'] = 1
    ATTRIBUTES['hazard_rate_method_id'] = 2
    ATTRIBUTES['environment_active_id'] = 4
    ATTRIBUTES['insulation_id'] = 3
    ATTRIBUTES['construction_id'] = 2
    ATTRIBUTES['temperature_active'] = 32.0
    ATTRIBUTES['temperature_rated_max'] = 85.0
    ATTRIBUTES['quality_id'] = 2
    ATTRIBUTES['temperature_active'] = 32.0
    ATTRIBUTES['power_operating'] = 0.15
    ATTRIBUTES['temperature_case'] = 45.0
    ATTRIBUTES['theta_jc'] = 70.0
    ATTRIBUTES['voltage_rated'] = 5.0
    ATTRIBUTES['voltage_ac_operating'] = 0.05
    ATTRIBUTES['voltage_dc_operating'] = 3.3

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes, _msg = Semiconductor.calculate_217f_part_stress(**_attributes)

    assert isinstance(_attributes, dict)
    assert _msg == ''
    assert pytest.approx(_attributes['voltage_ratio'], 0.67)
    assert _attributes['temperature_junction'] == 55.5
    assert _attributes['lambda_b'] == 0.0034
    assert _attributes['piQ'] == 1.0
    assert _attributes['piE'] == 9.0
    assert _attributes['piC'] == 2.0
    assert pytest.approx(_attributes['piT'], 2.6196648)
    assert pytest.approx(_attributes['piS'], 0.3778868)
    assert pytest.approx(_attributes['hazard_rate_active'], 0.01781886)
예제 #4
0
def test_calculate_mil_hdbk_217f_part_stress():
    """calculate_mil_hdbk_217f_part_stress() should return a dictionary of updated values on success."""
    ATTRIBUTES['hazard_rate_method_id'] = 2
    ATTRIBUTES['environment_active_id'] = 4
    ATTRIBUTES['subcategory_id'] = 10
    ATTRIBUTES['insulation_id'] = 3
    ATTRIBUTES['construction_id'] = 2
    ATTRIBUTES['temperature_active'] = 32.0
    ATTRIBUTES['temperature_rated_max'] = 85.0
    ATTRIBUTES['quality_id'] = 2
    ATTRIBUTES['power_rated'] = 5.0
    ATTRIBUTES['power_operating'] = 1.5
    ATTRIBUTES['voltage_rated'] = 250.0
    ATTRIBUTES['voltage_ac_operating'] = 0.05
    ATTRIBUTES['voltage_dc_operating'] = 15.0
    ATTRIBUTES['resistance'] = 3.3E4
    ATTRIBUTES['n_elements'] = 4

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes, _msg = Resistor.calculate_217f_part_stress(**_attributes)

    assert isinstance(_attributes, dict)
    assert _msg == ''
    assert _attributes['power_ratio'] == 0.3
    assert pytest.approx(_attributes['voltage_ratio'], 0.8901438)
    assert pytest.approx(_attributes['lambda_b'], 4.2888845)
    assert _attributes['piQ'] == 5.0
    assert _attributes['piE'] == 8.0
    assert _attributes['piC'] == 1.0
    assert _attributes['piV'] == 1.1
    assert _attributes['piR'] == 1.1
    assert _attributes['piTAPS'] == 1.112
    assert pytest.approx(_attributes['hazard_rate_active'], 293.7851584)
예제 #5
0
def test_calculate_mil_217f_part_stress(category_id):
    """calculate() should return a dictionary of updated values on success when calculating 217F part stress."""
    ATTRIBUTES['hazard_rate_method_id'] = 2
    ATTRIBUTES['environment_active_id'] = 4
    ATTRIBUTES['environment_dormant_id'] = 3
    ATTRIBUTES['category_id'] = category_id

    if category_id == 10:
        for subcategory_id in [1, 2, 3, 4]:
            ATTRIBUTES['subcategory_id'] = subcategory_id
            _attributes, _msg = Component.calculate(**ATTRIBUTES)
    else:
        _attributes, _msg = Component.calculate(**ATTRIBUTES)

    assert isinstance(_attributes, dict)
    if category_id < 9:
        assert _msg == ''
예제 #6
0
def test_voltage_overstress_mild_environment(power_rated,
                                             environment_active_id):
    """overstressed() should return True when voltage ratio > 0.9 in a mild environment and False otherwise."""
    ATTRIBUTES['power_operating'] = 0.47
    ATTRIBUTES['temperature_rated_max'] = 150.0
    ATTRIBUTES['temperature_active'] = 48.7
    ATTRIBUTES['power_rated'] = power_rated
    ATTRIBUTES['environment_active_id'] = environment_active_id

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes = Component.do_check_overstress(**_attributes)

    assert isinstance(_attributes, dict)
    if power_rated == 1.0:
        assert not _attributes['overstress']
        assert _attributes['reason'] == ''
    elif power_rated == 0.5:
        assert _attributes['overstress']
        assert _attributes['reason'] == ('1. Operating power > 90% rated '
                                         'power in mild environment.\n')
예제 #7
0
def test_temperature_overstress_harsh_environment(temperature_junction,
                                                  environment_active_id):
    """overstressed() should return True when junction temperature is >125C in a harsh environment and False otherwise."""
    ATTRIBUTES['power_operating'] = 0.18
    ATTRIBUTES['power_rated'] = 0.5
    ATTRIBUTES['temperature_rated_max'] = 125.0
    ATTRIBUTES['temperature_junction'] = temperature_junction
    ATTRIBUTES['environment_active_id'] = environment_active_id

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes = Component.do_check_overstress(**_attributes)

    assert isinstance(_attributes, dict)
    if temperature_junction == 128.2:
        assert _attributes['overstress']
        assert _attributes['reason'] == ('1. Junction temperature > 125.0C '
                                         'in harsh environment.\n')
    elif temperature_junction == 28.7:
        assert not _attributes['overstress']
        assert _attributes['reason'] == ''
예제 #8
0
def test_voltage_overstress_harsh_environment(voltage_rated,
                                              environment_active_id):
    """overstressed() should return True when voltage ratio > 0.6 in a harsh environment and False otherwise."""
    ATTRIBUTES['voltage_ac_operating'] = 0.005
    ATTRIBUTES['voltage_dc_operating'] = 15.0
    ATTRIBUTES['temperature_rated_max'] = 125.0
    ATTRIBUTES['temperature_active'] = 48.7
    ATTRIBUTES['voltage_rated'] = voltage_rated
    ATTRIBUTES['environment_active_id'] = environment_active_id

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes = Component.do_check_overstress(**_attributes)

    assert isinstance(_attributes, dict)
    if voltage_rated == 40.0:
        assert not _attributes['overstress']
        assert _attributes['reason'] == ''
    elif voltage_rated == 20.0:
        assert _attributes['overstress']
        assert _attributes['reason'] == ('1. Operating voltage > 70% rated '
                                         'voltage in harsh environment.\n')
예제 #9
0
def test_over_voltage(voltage_rated, environment_active_id):
    """overstressed() should return True when voltage < 0.95 rated in a harsh environment and False otherwise."""
    ATTRIBUTES['current_operating'] = 0.005
    ATTRIBUTES['current_rated'] = 0.01
    ATTRIBUTES['voltage_ac_operating'] = 0.005
    ATTRIBUTES['voltage_dc_operating'] = 4.95
    ATTRIBUTES['voltage_rated'] = voltage_rated
    ATTRIBUTES['environment_active_id'] = environment_active_id
    ATTRIBUTES['temperature_junction'] = 89.4

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes = Component.do_check_overstress(**_attributes)

    assert isinstance(_attributes, dict)
    if voltage_rated == 5.0:
        assert not _attributes['overstress']
        assert _attributes['reason'] == ''
    elif voltage_rated == 3.3:
        assert _attributes['overstress']
        assert _attributes['reason'] == ('1. Operating voltage > 105% rated '
                                         'voltage.\n')
예제 #10
0
def test_calculate_zero_mult_adj():
    """calculate() should return an error message when the multiplicative adjustment factor is <= 0.0."""
    ATTRIBUTES['hazard_rate_method_id'] = 1
    ATTRIBUTES['environment_active_id'] = 4
    ATTRIBUTES['environment_dormant_id'] = 3
    ATTRIBUTES['category_id'] = 1
    ATTRIBUTES['mult_adj_factor'] = 0.0

    _attributes, _msg = Component.calculate(**ATTRIBUTES)

    assert isinstance(_attributes, dict)
    assert _msg == ("RAMSTK WARNING: Multiplicative adjustment factor is 0.0 "
                    "when calculating hardware item, hardware ID: 6.\n")
예제 #11
0
def test_temperature_overstress_harsh_environment(temperature_junction,
                                                  environment_active_id):
    """overstressed() should return True when hot spot temperature is within 15C of rated temperature in a harsh environment and False otherwise."""
    ATTRIBUTES['current_operating'] = 0.18
    ATTRIBUTES['current_rated'] = 0.5
    ATTRIBUTES['voltage_rated'] = 5.0
    ATTRIBUTES['voltage_ac_operating'] = 0.005
    ATTRIBUTES['voltage_dc_operating'] = 4.95
    ATTRIBUTES['temperature_rated_max'] = 125.0
    ATTRIBUTES['temperature_junction'] = temperature_junction
    ATTRIBUTES['environment_active_id'] = environment_active_id

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes = Component.do_check_overstress(**_attributes)

    assert isinstance(_attributes, dict)
    if temperature_junction == 28.7:
        assert not _attributes['overstress']
        assert _attributes['reason'] == ''
    elif temperature_junction == 138.0:
        assert _attributes['overstress']
        assert _attributes['reason'] == ('1. Junction temperature > '
                                         '125.000000C.\n')
예제 #12
0
def test_current_overstress_mild_environment(current_rated,
                                             environment_active_id):
    """overstressed() should return True when current ratio > 0.9 in a mild environment and False otherwise."""
    ATTRIBUTES['current_operating'] = 0.48
    ATTRIBUTES['current_rated'] = current_rated
    ATTRIBUTES['voltage_ac_operating'] = 0.02
    ATTRIBUTES['voltage_dc_operating'] = 6.0
    ATTRIBUTES['temperature_rated_max'] = 150.0
    ATTRIBUTES['temperature_active'] = 48.7
    ATTRIBUTES['voltage_rated'] = 15.0
    ATTRIBUTES['environment_active_id'] = environment_active_id

    _attributes = Component.do_calculate_stress_ratios(**ATTRIBUTES)
    _attributes = Inductor.calculate_hot_spot_temperature(**_attributes)
    _attributes = Component.do_check_overstress(**_attributes)

    assert isinstance(_attributes, dict)
    if current_rated == 1.0:
        assert not _attributes['overstress']
        assert _attributes['reason'] == ''
    elif current_rated == 0.5:
        assert _attributes['overstress']
        assert _attributes['reason'] == ('1. Operating current > 90% rated '
                                         'current in mild environment.\n')
예제 #13
0
def test_calculate_zero_quantity():
    """calculate() should return an error message when the quantity is < 1."""
    ATTRIBUTES['hazard_rate_method_id'] = 1
    ATTRIBUTES['environment_active_id'] = 4
    ATTRIBUTES['environment_dormant_id'] = 3
    ATTRIBUTES['category_id'] = 1
    ATTRIBUTES['mult_adj_factor'] = 1.0
    ATTRIBUTES['duty_cycle'] = 1.0
    ATTRIBUTES['quantity'] = 0

    _attributes, _msg = Component.calculate(**ATTRIBUTES)

    assert isinstance(_attributes, dict)
    assert _msg == ("RAMSTK WARNING: Quantity is less than 1 when calculating "
                    "hardware item, hardware ID: 6.\n")
예제 #14
0
def test_calculate_dormant_hazard_rate(category_id, subcategory_id,
                                       environment_active_id,
                                       environment_dormant_id):
    """calculate_dormant_hazard_rate() should return a dictionary of updated values on success."""
    ATTRIBUTES['hazard_rate_active'] = 1.005887691
    ATTRIBUTES['category_id'] = category_id
    ATTRIBUTES['subcategory_id'] = subcategory_id
    ATTRIBUTES['environment_active_id'] = environment_active_id
    ATTRIBUTES['environment_dormant_id'] = environment_dormant_id

    try:
        if category_id == 2:
            # [1, 2] = diodes, else transistors.
            if subcategory_id in [1, 2]:
                dormant_mult = (
                    DORMANT_MULT[category_id][environment_active_id]
                    [environment_dormant_id][0])
            elif subcategory_id in [3, 4, 5, 6, 7, 8, 9]:
                dormant_mult = (
                    DORMANT_MULT[category_id][environment_active_id]
                    [environment_dormant_id][1])
            else:
                dormant_mult = 0.0
        else:
            dormant_mult = DORMANT_MULT[category_id][environment_active_id][
                environment_dormant_id]
    except KeyError:
        dormant_mult = 0.0

    _attributes, _msg = Component.do_calculate_dormant_hazard_rate(
        **ATTRIBUTES)

    assert isinstance(_attributes, dict)
    try:
        assert _msg == ''
    except AssertionError:
        assert _msg == (
            "RAMSTK ERROR: Unknown active and/or dormant environment "
            "ID for hardware item.  Hardware ID: 6, active "
            "environment ID: {0:d}, and dormant environment ID: "
            "{1:d}.\n").format(environment_active_id, environment_dormant_id)

    assert _attributes['hazard_rate_dormant'] == (
        ATTRIBUTES['hazard_rate_active'] * dormant_mult)