diff --git a/CHANGELOG.md b/CHANGELOG.md index cd7f64d..26e6194 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog of galpynostatic +## v0.2.2 (2023-12-27) + +### Bug fixes + +- Change the name of the `bmx_fc` metric to `umbem`, which is the name of the metric in the cited PhD thesis. +- Replace the `test_metric` to use `pytest.mark.parametrize` and have a test for each value insted of the dataframe all togheter. + ## v0.2.1 (2023-12-26) ### Bug fixes diff --git a/tests/test_data/metric_dataset.csv b/tests/test_data/metric_dataset.csv deleted file mode 100644 index 2e66896..0000000 --- a/tests/test_data/metric_dataset.csv +++ /dev/null @@ -1,33 +0,0 @@ -Material,d,dcoeff,ref_soc,ref_tau -Ternarios,10.0,7.8e-11,0.10196677515247746,12820.51282051282 -Ternarios,8.0,3.3241540277189356e-10,0.5997431392906016,1925.301880307796 -Ternarios,3.5,1.7320508075688788e-11,0.25863966970279745,7072.5407975729095 -LCO,7.5,1.0000000000000007e-09,0.7780047426132527,562.4999999999997 -LCO,2.775,3.872983346207416e-10,0.9172202087372949,198.82928253592334 -LCO,0.5,1.0000000000000007e-09,0.986812793891686,2.4999999999999982 -LCO,3.0,8.246211251235334e-11,0.802634701248963,1091.4103126634968 -LCO,0.1,1.3400000000000008e-11,0.9941796203962906,7.462686567164176 -LMO,0.2,9.04000000000002e-11,0.9925539063791815,4.424778761061938 -LMO,3.5,1.5000000000000005e-12,0.022497538851677282,81666.66666666664 -LMO,0.3,2.970000000000002e-12,0.9537254339018952,303.03030303030283 -LMO,3.5,1.5700000000000004e-07,0.9271879576217682,0.7802547770700634 -LMO,10.0,9.999999999999982e-09,0.7852809938829575,100.00000000000017 -LFP,0.1,1.070000000000003e-12,0.9835689994291361,93.45794392523341 -LFP,0.2,1.4866068747318485e-14,0.076590908765472,26906.91175985254 -LFP,0.35,8.726167543658563e-12,0.9727943667689891,140.38236074096764 -LFP,0.3,9.872385729903416e-15,0.02304824990184765,91163.37475286279 -LFP,0.1999999999999999,3.640054944640265e-14,0.1845359128112399,10988.845115895094 -LFP,0.3,4.547416849157347e-12,0.9666987310405498,197.91455893619548 -LFP,0.8,9.142866071424249e-16,,6999993.164072487 -LTO,0.45,4.000000000000005e-12,0.9256629216326868,506.2499999999995 -LTO,0.935,4.690415759823438e-13,0.10693479836617928,18638.53962559832 -LTO,0.2,1.0300000000000013e-13,0.5259378104904399,3883.4951456310637 -LTO,3.0,5.1200000000000144e-14,,1757812.4999999953 -LTO,0.09,1.0399999999999992e-13,0.8992216859296965,778.8461538461545 -LTO,0.935,9.999999999999983e-12,0.8705756914162891,874.2250000000016 -Grafito,25.166666666666668,1.0000000000000019e-11,,633361.1111111101 -Grafito,15.0,1.430314650697529e-10,0.06459947750849444,15730.804399596487 -Grafito,10.0,4.690415759823433e-10,0.5345677449174814,2132.0071635561026 -Grafito,25.166666666666668,7.599999999999993e-11,0.006432536491576099,83336.98830409367 -Grafito,25.166666666666668,4.399999999999999e-06,0.49349763109967465,1.4394570707070713 -Grafito,50.5,9.999999999999994e-08,0.0,255.0250000000002 diff --git a/tests/test_metric.py b/tests/test_metric.py index f2053ed..fcc2e10 100644 --- a/tests/test_metric.py +++ b/tests/test_metric.py @@ -17,8 +17,6 @@ import numpy as np -import pandas as pd - import pytest # ============================================================================= @@ -26,31 +24,65 @@ # ============================================================================= -def test_fom(data_path): - """Test the Figure of Merit for fast-charging of Xia et al.""" - df = pd.read_csv(data_path / "metric_dataset.csv") - - for d, dcoeff, ref in zip(df["d"], df["dcoeff"], df["ref_tau"]): +@pytest.mark.parametrize( + ("d", "dcoeff", "ref"), + [ + (10.0, 7.8e-11, [0.101967, 12820.512821]), + (8.0, 3.324154e-10, [0.599743, 1925.301896]), + (3.5, 1.732051e-11, [0.258640, 7072.540012]), + (7.5, 1.0e-09, [0.778005, 562.5]), + (2.775, 3.872983e-10, [0.917220, 198.8293]), + (0.5, 1.0e-09, [0.986813, 2.5]), + (3.0, 8.246211e-11, [0.802635, 1091.410346]), + (0.1, 1.34e-11, [0.99418, 7.462687]), + (0.2, 9.04e-11, [0.992554, 4.424779]), + (3.5, 1.5e-12, [0.022498, 81666.666667]), + (0.3, 2.97e-12, [0.953725, 303.030303]), + (3.5, 1.57e-07, [0.927188, 0.780255]), + (10.0, 1.0e-08, [0.785281, 100.0]), + (0.1, 1.07e-12, [0.983569, 93.457944]), + (0.2, 1.486607e-14, [0.076591, 26906.909493]), + (0.35, 8.726168e-12, [0.972794, 140.382353]), + (0.3, 9.872386e-15, [0.023048, 91163.372259]), + (0.2, 3.640055e-14, [0.184536, 10988.84494877138]), + (0.3, 4.547417e-12, [0.966699, 197.914552]), + (0.45, 4.0e-12, [0.925663, 506.25]), + (0.935, 4.690416e-13, [0.106935, 18638.538671]), + (0.2, 1.03e-13, [0.525938, 3883.495146]), + (0.09, 1.04e-13, [0.899222, 778.846154]), + (0.935, 1.0e-11, [0.870576, 874.225000]), + (15.0, 1.430315e-10, [0.064599, 15730.800558]), + (10.0, 4.690416e-10, [0.534568, 2132.007054]), + (25.166667, 7.6e-11, [0.006433, 83336.990512]), + (25.166667, 4.4e-06, [0.493498, 1.439457]), + (50.5, 1.0e-07, [0.0, 255.025]), + ], +) +class TestMetric: + """Test the different metrics for benchmarking FC materials.""" + + def test_fom(self, d, dcoeff, ref): + """Test the Figure of Merit for fast-charging of Xia et al.""" value = galpynostatic.metric.fom(1e-4 * d, dcoeff) - np.testing.assert_almost_equal(value, ref, 6) + np.testing.assert_almost_equal(value, ref[1], 6) + def test_umbem(self, d, dcoeff, ref): + """Test the UMBEM metric without fitting the model.""" + greg = galpynostatic.model.GalvanostaticRegressor(d=1e-4 * d) + greg._validate_geometry() + greg._map = galpynostatic.datasets.map.MapSpline(greg.dataset) + greg.dcoeff_, greg.k0_ = dcoeff, 1e-7 + greg.dcoeff_err_ = None + + value = galpynostatic.metric.umbem(greg) -@pytest.mark.parametrize(("fit"), [(True), (False)]) -def test_umbem(fit, data_path): - """Test the Benchmarking Materials for eXtreme fast-charging metric.""" - df = pd.read_csv(data_path / "metric_dataset.csv") + np.testing.assert_almost_equal(value, ref[0], 6) - for d, dcoeff, ref in zip(df["d"], df["dcoeff"], df["ref_soc"]): - if fit: - greg = {"d": 1e-4 * d, "dcoeff_": dcoeff, "k0_": 1e-7} - else: - greg = galpynostatic.model.GalvanostaticRegressor(d=1e-4 * d) - greg._validate_geometry() - greg._map = galpynostatic.datasets.map.MapSpline(greg.dataset) - greg.dcoeff_, greg.k0_ = dcoeff, 1e-7 - greg.dcoeff_err_ = None + def test_umbem_fit(self, d, dcoeff, ref): + """Test the UMBEM metric using the fit argument.""" + greg = {"d": 1e-4 * d, "dcoeff_": dcoeff, "k0_": 1e-7} value = galpynostatic.metric.umbem(greg) - np.testing.assert_almost_equal(value, ref, 6) + np.testing.assert_almost_equal(value, ref[0], 6)