Skip to content

Parameter constraints: Q1 < Q2 < Q3 or C1 < C2 or ... #11

Description

@Up2nothing

Is your feature request related to a problem? Please describe.
I'm sometimes frustrated when fitting a large amount of EIS data that the RQ subcircuits get swapped by the fitting algorithm. If I have two semi-circles in my EIS data the program can't always say which RQ subcircuit should model which semi-circle. It is difficult to put bounds on the admittance of the CPE element that are suitable for all the different EIS measurements.
By keeping the bounds of the CPE element large, the fit is more often successful, but the two subcircuits are free to "swap places". By restricting the bounds of the admittance I can keep the subcircuits correlated to a specific semi-circle but the fit sometimes is limited by these bounds and therefore fails to find an optimal solution.

Describe the solution you'd like
A way to link specific circuit elements in the model to specific arcs in the EIS data.
For example, if my EIS data often has 2 visible semi-circles I can model say with 3 resisters and 2 CPE elements: R(RQ)(RQ). I would like it if one semicircle is always modeled by the same RQ pair. This way when fitting many spectra and evaluating the circuit parameters, the name (and value) of a specific element always refers to the same semi-circle in my EIS data.

Describe a possible implementation of this solution
Diving into the code of pyimpspec I believe that the fitting is baced on lmfit. Searching the docs of lmfit I found a way that parameters can be constrained in respect to each other lmfit: using-inequality-constraints. Based on the above example with two RQ subcircuits the requierment would be Q1 ≤ Q2. This is equivalent to Q2 = Q1 + δ and δ ≥ 0, see stackoverflow. This shouldn't slow the fitting proccess because the admittance becomes more or less fixed and the variable parameter becomes δ.
Not being completly involved in the whole architecture of myimpspec I am nit sure how easy this is to implement. My guess is that the Element class would need to be extended with _expr (expression) and the ParameterDefinition class as well. How this is treaded and passed onto lmfit via the method _to_lmfit in fitting.py is for me, however, not clear.

Additional infos
I was not sure if I should post here or in DearEIS, but since the sorce code was under pyimpspec I thought it approprient to ask here. I do think it would be nice though if this also was available in the gui and API of DearEIS.

I will see if I can get a working samle setup and will share it here if I am successful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions