def test_material_invalid(): """Test the initialization of EnergyMaterial objects with invalid properties.""" concrete = EnergyMaterial('Concrete', 0.2, 0.5, 800, 1200) with pytest.raises(TypeError): concrete.identifier = ['test_identifier'] with pytest.raises(AssertionError): concrete.thickness = -1 with pytest.raises(AssertionError): concrete.conductivity = -1 with pytest.raises(AssertionError): concrete.density = -1 with pytest.raises(AssertionError): concrete.specific_heat = -1 with pytest.raises(AssertionError): concrete.roughness = 'Medium' with pytest.raises(AssertionError): concrete.thermal_absorptance = 2 with pytest.raises(AssertionError): concrete.solar_absorptance = 2 with pytest.raises(AssertionError): concrete.visible_absorptance = 2 with pytest.raises(AssertionError): concrete.resistivity = -1 with pytest.raises(AssertionError): concrete.u_value = -1 with pytest.raises(AssertionError): concrete.r_value = -1
def test_material_init(): """Test the initialization of EnergyMaterial objects and basic properties.""" concrete = EnergyMaterial('Concrete', 0.2, 0.5, 800, 1200, 'MediumSmooth', 0.95, 0.75, 0.8) str(concrete) # test the string representation of the material concrete_dup = concrete.duplicate() assert concrete.identifier == concrete_dup.identifier == 'Concrete' assert concrete.thickness == concrete_dup.thickness == 0.2 assert concrete.conductivity == concrete_dup.conductivity == 0.5 assert concrete.density == concrete_dup.density == 800 assert concrete.specific_heat == concrete_dup.specific_heat == 1200 assert concrete.roughness == concrete_dup.roughness == 'MediumSmooth' assert concrete.thermal_absorptance == concrete_dup.thermal_absorptance == 0.95 assert concrete.solar_absorptance == concrete_dup.solar_absorptance == 0.75 assert concrete.visible_absorptance == concrete_dup.visible_absorptance == 0.8 assert concrete.resistivity == 1 / 0.5 assert concrete.u_value == pytest.approx(2.5, rel=1e-2) assert concrete.r_value == pytest.approx(0.4, rel=1e-2) assert concrete.mass_area_density == pytest.approx(160, rel=1e-2) assert concrete.area_heat_capacity == pytest.approx(192000, rel=1e-2) concrete.r_value = 0.5 assert concrete.conductivity != concrete_dup.conductivity assert concrete.r_value == 0.5 assert concrete.conductivity == pytest.approx(0.4, rel=1e-2)