Repository: RemDelaporteMathurin/h-transport-materials

Issue:
Operations between ArrheniusProperty objects
Users should be able to multiply, divide ArrheniusProperty objects


```python
diff = Diffusivity(...)
solubility = Solubility(...)
permeability = diff * solubility
``` 

Discussion:

Patch:
diff --git a/h_transport_materials/property.py b/h_transport_materials/property.py
index aac6200..566854d 100644
--- a/h_transport_materials/property.py
+++ b/h_transport_materials/property.py
@@ -205,6 +205,43 @@ class ArrheniusProperty(Property):
         """
         return val
 
+    def __mul__(self, other):
+        """returns the result of self * other (an ArrheniusProperty)"""
+        if isinstance(other, (int, float)):
+            product = self.__class__(
+                pre_exp=other * self.pre_exp,
+                act_energy=self.act_energy,
+            )
+            return product
+        elif not isinstance(other, ArrheniusProperty):
+            raise TypeError(
+                "ArrheniusProperty can only be multiplied by ArrheniusProperty, int or float"
+            )
+        classes = [self.__class__, other.__class__]
+        if Diffusivity in classes and Solubility in classes:
+            product_class = Permeability
+        else:
+            product_class = ArrheniusProperty
+
+        product = product_class(
+            pre_exp=self.pre_exp * other.pre_exp,
+            act_energy=self.act_energy + other.act_energy,
+        )
+        return product
+
+    def __rmul__(self, other):
+        """returns the result of other * self (an ArrheniusProperty)"""
+        if isinstance(other, (int, float)):
+            product = self.__class__(
+                pre_exp=other * self.pre_exp,
+                act_energy=self.act_energy,
+            )
+            return product
+        else:
+            raise TypeError(
+                "ArrheniusProperty can only be multiplied by ArrheniusProperty, int or float"
+            )
+
     @property
     def units(self):
         # check if data_y is set


Test patch:
diff --git a/tests/test_arhenius_property.py b/tests/test_arhenius_property.py
index cfd89a9..41c5ef5 100644
--- a/tests/test_arhenius_property.py
+++ b/tests/test_arhenius_property.py
@@ -165,3 +165,53 @@ def test_no_units_preexp_raises_warning():
 def test_no_units_act_energy_raises_warning():
     with pytest.warns(UserWarning, match="no units were given with activation energy"):
         htm.ArrheniusProperty(0.1 * htm.ureg.m**2 * htm.ureg.s**-1, act_energy=0.1)
+
+
+def test_multiply_properties():
+    """Checks that two arrhenius props can be multiplied"""
+    prop1 = htm.ArrheniusProperty(
+        0.1 * htm.ureg.m**2 * htm.ureg.s**-1,
+        act_energy=0.2 * htm.ureg.eV * htm.ureg.particle**-1,
+    )
+    prop2 = htm.ArrheniusProperty(
+        0.5 * htm.ureg.m**2,
+        act_energy=0.3 * htm.ureg.eV * htm.ureg.particle**-1,
+    )
+
+    product = prop1 * prop2
+
+    assert isinstance(product, htm.ArrheniusProperty)
+    assert product.pre_exp == prop1.pre_exp * prop2.pre_exp
+    assert product.act_energy == prop1.act_energy + prop2.act_energy
+
+
+@pytest.mark.parametrize("factor", [2, 1.0, 2.0, -3, -3.0])
+def test_multiply_property_by_number(factor):
+    """Checks that an arrhenius prop can be multiplied by a number"""
+    prop1 = htm.ArrheniusProperty(
+        0.1 * htm.ureg.m**2 * htm.ureg.s**-1,
+        act_energy=0.2 * htm.ureg.eV * htm.ureg.particle**-1,
+    )
+
+    for product in [prop1 * factor, factor * prop1]:
+        assert isinstance(product, htm.ArrheniusProperty)
+        assert product.pre_exp == prop1.pre_exp * factor
+        assert product.act_energy == prop1.act_energy
+
+
+@pytest.mark.parametrize("factor", ["foo", [1, 2]])
+def test_multiply_property_by_str(factor):
+    """Checks that an arrhenius prop cannot be multiplied by non valid factors"""
+    prop1 = htm.ArrheniusProperty(
+        0.1 * htm.ureg.m**2 * htm.ureg.s**-1,
+        act_energy=0.2 * htm.ureg.eV * htm.ureg.particle**-1,
+    )
+
+    error_msg = (
+        "ArrheniusProperty can only be multiplied by ArrheniusProperty, int or float"
+    )
+    with pytest.raises(TypeError, match=error_msg):
+        factor * prop1
+
+    with pytest.raises(TypeError, match=error_msg):
+        prop1 * factor
diff --git a/tests/test_permeability.py b/tests/test_permeability.py
index b3e9927..d4571c9 100644
--- a/tests/test_permeability.py
+++ b/tests/test_permeability.py
@@ -45,3 +45,19 @@ def test_users_have_to_give_units_data_y():
 def test_without_units_but_law():
     prop = htm.Permeability(1, 0, law="sievert")
     assert prop.pre_exp.units == prop.units
+
+
+def test_prod_diff_sol_is_perm():
+    """Checks that the product of Diffusivity and Solubility is permeability"""
+    prop1 = htm.Diffusivity(
+        D_0=0.1 * htm.ureg.m**2 * htm.ureg.s**-1,
+        E_D=0.2 * htm.ureg.eV * htm.ureg.particle**-1,
+    )
+    prop2 = htm.Solubility(
+        S_0=0.5 * htm.ureg.mol * htm.ureg.m**-3 * htm.ureg.Pa**-0.5,
+        E_S=0.3 * htm.ureg.eV * htm.ureg.particle**-1,
+    )
+
+    product = prop1 * prop2
+
+    assert isinstance(product, htm.Permeability)