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
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')
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)
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)
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')
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'] == ''
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')
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')
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')
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')