# Change parameter function inputs

**URL:** <https://pybamm.discourse.group/t/change-parameter-function-inputs/133>\
**Category:** Parameters\
**Created:** [29 January 2025 17:33 UTC](https://pybamm.discourse.group/t/change-parameter-function-inputs/133 "2025-01-29T17:33:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![derek](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@derek](https://pybamm.discourse.group/u/derek)\
**Post date:** [29 January 2025 17:33 UTC](https://pybamm.discourse.group/t/change-parameter-function-inputs/133/1 "2025-01-29T17:33:49Z")

</div>

I am currently creating a routine for parameter estimation based on experimental data. It would be helpful for me if it was possible to customize the inputs in parameter functions to align with the inputs to my parameter estimation routine.

Please let me know if there is currently a way to go about this, thank you!

---

<div class="post-metadata">

**Author:** ![DrSOKane](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@DrSOKane](https://pybamm.discourse.group/u/DrSOKane)\
**Post date:** [29 January 2025 20:47 UTC](https://pybamm.discourse.group/t/change-parameter-function-inputs/133/2 "2025-01-29T20:47:41Z")

</div>

Hi Derek, [this notebook](https://docs.pybamm.org/en/latest/source/examples/notebooks/models/compare-ecker-data.html) contains a simple example.

My PhD student wrote [a much more detailed example](https://zenodo.org/records/13400193), but it is not been tested by anyone else so far!

---

<div class="post-metadata">

**Author:** ![derek](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@derek](https://pybamm.discourse.group/u/derek)\
**Post date:** [18 February 2025 03:33 UTC](https://pybamm.discourse.group/t/change-parameter-function-inputs/133/3 "2025-02-18T03:33:57Z")

</div>

Thank you @DrSOKane

I am not sure if this is exactly what I am looking for.

For example, I used a hard coded work around by editing the children in the parameter functions file:

```py
 def j0(self, c_e, c_s_surf, T, lithiation=None):
        """Dimensional exchange-current density [A.m-2]"""
        tol = pybamm.settings.tolerances["j0__c_e"]
        c_e = pybamm.maximum(c_e, tol)
        tol = pybamm.settings.tolerances["j0__c_s"]
        c_s_surf = pybamm.maximum(
            pybamm.minimum(c_s_surf, (1 - tol) * self.c_max), tol * self.c_max
        )
        domain, Domain = self.domain_Domain
        if lithiation is None:
            lithiation = ""
        else:
            lithiation = lithiation + " "
        inputs = {
            "Electrolyte concentration [mol.m-3]": c_e,
            f"{Domain} particle surface concentration [mol.m-3]": c_s_surf,
            f"{self.phase_prefactor}Maximum {domain} particle "
            "surface concentration [mol.m-3]": self.c_max,
            "Temperature [K]": T,
        }
        return pybamm.FunctionParameter(
            f"{self.phase_prefactor}{Domain} electrode {lithiation}"
            "exchange-current density [A.m-2]",
            inputs,
        )

```

was edited to:

```auto
 def j0(self, c_e, c_s_surf, T, lithiation=None):
        """Dimensional exchange-current density [A.m-2]"""
        tol = pybamm.settings.tolerances["j0__c_e"]
        c_e = pybamm.maximum(c_e, tol)
        tol = pybamm.settings.tolerances["j0__c_s"]
        c_s_surf = pybamm.maximum(
            pybamm.minimum(c_s_surf, (1 - tol) * self.c_max), tol * self.c_max
        )
        domain, Domain = self.domain_Domain
        if lithiation is None:
            lithiation = ""
        else:
            lithiation = lithiation + " "
        inputs = {
            "Current [A]": pybamm.electrical_parameters.current_with_time,
        }      
         return pybamm.FunctionParameter(
            f"{self.phase_prefactor}{Domain} electrode {lithiation}"
            "exchange-current density [A.m-2]",
            inputs,
        )

```

Then my custom function for exchange current density in the parameter set could just be a function of Current. I was wondering if there was a more official way to go about changing the function inputs to parameter functions

---

<div class="post-metadata">

**Author:** ![DrSOKane](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@DrSOKane](https://pybamm.discourse.group/u/DrSOKane)\
**Post date:** [18 February 2025 13:26 UTC](https://pybamm.discourse.group/t/change-parameter-function-inputs/133/4 "2025-02-18T13:26:43Z")

</div>

Have you heard of [PyBOP](https://github.com/pybop-team/PyBOP)? It may support what you’re trying to do.

---

<div class="post-metadata">

**Author:** ![derek](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@derek](https://pybamm.discourse.group/u/derek)\
**Post date:** [18 February 2025 20:29 UTC](https://pybamm.discourse.group/t/change-parameter-function-inputs/133/5 "2025-02-18T20:29:57Z")

</div>

Thanks for this resource. I have looked into it a little bit today. This package is performing parameter estimation in a similar way that I want.

For some context, we have created an HMC routine that builds out GPs. We treat PyBamm as a black box model, where we supply it the GPs, which ideally could be a function of any input, to replace some battery model parameters, as well as the experimental current. PyBamm will return a Voltage which could be compared to experimental data to build out these functions in an optimizer. The end results being functions tailored to the battery.

I believe PyBOP replaces too much of the functionality we have already built into our process. Thank you for your time.

---

<div class="post-metadata">

**Author:** ![valentinsulzer](https://yyz2.discourse-cdn.com/free1/user_avatar/pybamm.discourse.group/valentinsulzer/32/9_2.png) [@valentinsulzer](https://pybamm.discourse.group/u/valentinsulzer)\
**Post date:** [19 February 2025 14:43 UTC](https://pybamm.discourse.group/t/change-parameter-function-inputs/133/6 "2025-02-19T14:43:01Z")

</div>

You can rename or scale any of the parameters. For example, let’s say pybamm has parameters “a” and “b”, but you want parameter “c” instead of “a” and “d” instead of “b”, where “d” is twice the value of “b”. Then you can do:

```auto
parameter_values = {"a": pybamm.InputParameter("c"), "b": pybamm.InputParameter("d")/2}

```

and at solve time you just specify c and d

```auto
sim.solve(inputs={"c": 1, "d": 2})

```
