dgpost.transform.circuit_utils.circuit_parser
- dgpost.transform.circuit_utils.circuit_parser.parse_circuit(circ: str) Tuple[list[dict], Callable[[dict, ndarray], ndarray]]
Extended Backus–Naur form (EBNF) parser for a circuit string.
Implements an extended Backus–Naur form (EBNF) to parse a string containing a description of a circuit.
- The syntax of the EBNF is given by:
circuit = element | element-circuit
element = component | parallel
parallel = p(circuit {,circuit})
component = a circuit component defined in
circuit_components
So to put elements in series connect them through ‘-’ Parallel elements are created by p(…,… ,…)
To use a component in the circuit string use its symbol. The symbol can be followed by a digit to differentiate similar components. Already implemented circuit elements are located in
dgpost.transform.circuit_utils.circuit_components.py
.From this a function is generated and which evaluates the impedance of the circuit.
- Parameters:
circ – String describing a circuit
- Returns:
param_info – list of used parameter. For more information about parameters look in
circuit_components
calculate
- dgpost.transform.circuit_utils.circuit_parser.fit_routine(opt_func: Callable[[list], float], fit_guess: list[float], bounds: list[tuple], repeat: int = 1)
Fitting routine which uses scipy least_squares and minimize.
Least_squares is a good fitting method but will get stuck in local minima. For this reason, the Nelder-Mead-Simplex algorithm is used to get out of these local minima. The fitting routine is inspired by Relaxis 3 fitting procedure. More information about it can be found on page 188 of revision 1.25 of Relaxis User Manual. https://www.rhd-instruments.de/download/manuals/relaxis_manual.pdf
Open issue is estimate the errors of the parameters. For further information look: - https://github.com/andsor/notebooks/blob/master/src/nelder-mead.md - https://math.stackexchange.com/questions/2447382/nelder-mead-function-fit-error-estimation-via-surface-fit - https://stats.stackexchange.com/questions/424073/calculate-the-uncertainty-of-a-mle
- Parameters:
opt_func – function that gets minimized
fit_guess – initial guess for minimization
bounds – bounds of the fitting parameters
repeat – how many times the least squares and minimize step gets repeated
- Returns:
opt_result – the result of the optimization from the last step of Nelder-Mead.
- Return type:
scipy.optimize.OptimizeResult