Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to quick_plot due to different shapes between model and empirical data #524

Closed
absichtengrg opened this issue Oct 1, 2024 · 1 comment · Fixed by #527
Closed
Labels
bug Something isn't working

Comments

@absichtengrg
Copy link

Python Version

3.12.4

Describe the bug

After getting the initial and estimated parameters using
optim = pybop.XNES( cost, sigma0=[1e-3, 1e-3, 1e-3, 20, 20], max_unchanged_iterations=30, max_iterations=100, ) x, final_cost = optim.run() print("Initial parameters:", optim.x0) print("Estimated parameters:", x),
I used:
pybop.quick_plot(problem, problem_inputs=x, title="Optimised Comparison");

and it gives an error:
`---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[54], line 1
----> 1 pybop.quick_plot(problem, problem_inputs=x, title="Optimised Comparison")

File ~\anaconda3\Lib\site-packages\pybop\plotting\plot_problem.py:77, in quick_plot(problem, problem_inputs, show, **layout_kwargs)
73 plot_dict.traces.append(target_trace)
75 if isinstance(problem, FittingProblem):
76 # Compute the standard deviation as proxy for uncertainty
---> 77 plot_dict.sigma = np.std(model_output[i] - target_output[i])
79 # Convert x and upper and lower limits into lists to create a filled trace
80 x = xaxis_data.tolist()

ValueError: operands could not be broadcast together with shapes (471,) (436603,)`

Which I am thinking is the size of my experimental dataset that is different from the created model.

Steps to reproduce the behaviour

Using experimental dataset:
`file_loc = "15Ah_Rectangular_7A5_10cycles.csv"
df = pd.read_csv(file_loc, index_col=None, na_values=["NA"])
df = df.drop_duplicates(subset=["Time"], keep="first")

dataset = pybop.Dataset(
{
"Time [s]": df["Time"].to_numpy(),
"Current function [A]": df["Current"].to_numpy(),
"Voltage [V]": df["Voltage"].to_numpy(),
}
)`

In the ECM HPPC example.

Relevant log output

No response

@absichtengrg absichtengrg added the bug Something isn't working label Oct 1, 2024
@BradyPlanden
Copy link
Member

Hi @absichtengrg,

In this case the identified parameters are causing the predicted model to hit an event in the PyBaMM solver. I suspect that a voltage limit is triggered and as such the simulation is stopped before completion. Given the length of the data you are trying to fit, this is somewhat to be expected. Thevenin identification works best with shorter time series data, both for robustness and performance. I would recommend splitting the dataset you have into smaller sections and trying to identify from each. In addition, you can adjust the max_unchange_iterations to avoid stopping the process prematurely. Finally, adjusting the upper and lower voltage limits can help with convergence when identifying parameters close to the limits.

Thanks for exposing this sharp point in the codebase, the error is not very descriptive and should be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants