def test_issue_155(self): """ Langmuir.max_motive raises ValueError There's a case where the `Langmuir.max_motive` method will raise a `ValueError`. Specifically when `self.critical_point_current_density() == self.calc_saturation_point_current_density()`. This condition is tested to ensure the `ValueError` is not raised. See: https://github.com/jrsmith3/tec/issues/155 """ em_params = { 'barrier': 1.0, 'emissivity': 0.0, 'position': 0.0, 'richardson': 10.0, 'temp': 300.0, 'voltage': 0.0 } co_params = { 'barrier': 1.0, 'emissivity': 0.0, 'position': 1.0, 'richardson': 10.0, 'temp': 300.0, 'voltage': 0.0 } em = Metal.from_dict(em_params) co = Metal.from_dict(co_params) l = Langmuir(em, co) try: l.max_motive() except ValueError: self.fail("Issue #155 not resolved")
def test_issue_155(self): """ Langmuir.max_motive raises ValueError There's a case where the `Langmuir.max_motive` method will raise a `ValueError`. Specifically when `self.critical_point_current_density() == self.calc_saturation_point_current_density()`. This condition is tested to ensure the `ValueError` is not raised. See: https://github.com/jrsmith3/tec/issues/155 """ em_params = {'barrier': 1.0, 'emissivity': 0.0, 'position': 0.0, 'richardson': 10.0, 'temp': 300.0, 'voltage': 0.0} co_params = {'barrier': 1.0, 'emissivity': 0.0, 'position': 1.0, 'richardson': 10.0, 'temp': 300.0, 'voltage': 0.0} em = Metal.from_dict(em_params) co = Metal.from_dict(co_params) l = Langmuir(em, co) try: l.max_motive() except ValueError: self.fail("Issue #155 not resolved")
def test_additional_arbitrary_args(self): """ Langmuir can be instantiated with additional arbitrary args """ try: el = Langmuir(em, co, not_an_arg="nope sure not") except TypeError: self.fail("Instantiation failed with additional arbitrary args")
class Base(unittest.TestCase): """ Base class for tests This class is intended to be subclassed so that I don't have to rewrite the same `setUp` method for each class containing tests. """ def setUp(self): """ Create new Langmuir object for every test """ if em.position > co.position: raise ValueError("Initialization em.position > co.position.") self.t = Langmuir(em, co) self.em = em self.co = co # Create `Langmuir` objects for each regime: accelerating, # space charge limited, and retarding. saturation_point_voltage = self.t.saturation_point_voltage() critical_point_voltage = self.t.critical_point_voltage() # accelerating mode: accelerating_voltage = saturation_point_voltage - units.Quantity( 1., "V") co_accelerating = Metal(**co_params) co_accelerating.voltage = accelerating_voltage self.t_accel = Langmuir(em, co_accelerating) # space charge limited mode: scl_voltage = (saturation_point_voltage + critical_point_voltage) / 2 co_scl = Metal(**co_params) co_scl.voltage = scl_voltage self.t_scl = Langmuir(em, co_scl) # retarding mode: retarding_voltage = critical_point_voltage + units.Quantity(1., "V") co_retarding = Metal(**co_params) co_retarding.voltage = retarding_voltage self.t_ret = Langmuir(em, co_retarding)
class Base(unittest.TestCase): """ Base class for tests This class is intended to be subclassed so that I don't have to rewrite the same `setUp` method for each class containing tests. """ def setUp(self): """ Create new Langmuir object for every test """ if em.position > co.position: raise ValueError("Initialization em.position > co.position.") self.t = Langmuir(em, co) self.em = em self.co = co # Create `Langmuir` objects for each regime: accelerating, # space charge limited, and retarding. saturation_point_voltage = self.t.saturation_point_voltage() critical_point_voltage = self.t.critical_point_voltage() # accelerating mode: accelerating_voltage = saturation_point_voltage - units.Quantity(1., "V") co_accelerating = Metal(**co_params) co_accelerating.voltage = accelerating_voltage self.t_accel = Langmuir(em, co_accelerating) # space charge limited mode: scl_voltage = (saturation_point_voltage + critical_point_voltage) / 2 co_scl = Metal(**co_params) co_scl.voltage = scl_voltage self.t_scl = Langmuir(em, co_scl) # retarding mode: retarding_voltage = critical_point_voltage + units.Quantity(1., "V") co_retarding = Metal(**co_params) co_retarding.voltage = retarding_voltage self.t_ret = Langmuir(em, co_retarding)
def setUp(self): """ Create new Langmuir object for every test """ if em.position > co.position: raise ValueError("Initialization em.position > co.position.") self.t = Langmuir(em, co) self.em = em self.co = co # Create `Langmuir` objects for each regime: accelerating, # space charge limited, and retarding. saturation_point_voltage = self.t.saturation_point_voltage() critical_point_voltage = self.t.critical_point_voltage() # accelerating mode: accelerating_voltage = saturation_point_voltage - units.Quantity( 1., "V") co_accelerating = Metal(**co_params) co_accelerating.voltage = accelerating_voltage self.t_accel = Langmuir(em, co_accelerating) # space charge limited mode: scl_voltage = (saturation_point_voltage + critical_point_voltage) / 2 co_scl = Metal(**co_params) co_scl.voltage = scl_voltage self.t_scl = Langmuir(em, co_scl) # retarding mode: retarding_voltage = critical_point_voltage + units.Quantity(1., "V") co_retarding = Metal(**co_params) co_retarding.voltage = retarding_voltage self.t_ret = Langmuir(em, co_retarding)
def setUp(self): """ Create new Langmuir object for every test """ if em.position > co.position: raise ValueError("Initialization em.position > co.position.") self.t = Langmuir(em, co) self.em = em self.co = co # Create `Langmuir` objects for each regime: accelerating, # space charge limited, and retarding. saturation_point_voltage = self.t.saturation_point_voltage() critical_point_voltage = self.t.critical_point_voltage() # accelerating mode: accelerating_voltage = saturation_point_voltage - units.Quantity(1., "V") co_accelerating = Metal(**co_params) co_accelerating.voltage = accelerating_voltage self.t_accel = Langmuir(em, co_accelerating) # space charge limited mode: scl_voltage = (saturation_point_voltage + critical_point_voltage) / 2 co_scl = Metal(**co_params) co_scl.voltage = scl_voltage self.t_scl = Langmuir(em, co_scl) # retarding mode: retarding_voltage = critical_point_voltage + units.Quantity(1., "V") co_retarding = Metal(**co_params) co_retarding.voltage = retarding_voltage self.t_ret = Langmuir(em, co_retarding)