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

Plotting issue with notebooks #340

Open
kratman opened this issue Oct 24, 2024 · 5 comments
Open

Plotting issue with notebooks #340

kratman opened this issue Oct 24, 2024 · 5 comments
Assignees

Comments

@kratman
Copy link
Contributor

kratman commented Oct 24, 2024

There is a plotting issue that might be an issue for some users. When I run lp.plot_output(output) I get the graphs correctly. The problem comes at the second run. I change some parameters, the simulation runs fine but after that the plots do not show anymore. The only solution I found is to restart the kernel and import the libraries from scratch. Is it an issue with liionpack or with jupyter notebook, visual studio code?

@kratman
Copy link
Contributor Author

kratman commented Oct 24, 2024

@hectormara This is the new ticket for your discussion

@kratman
Copy link
Contributor Author

kratman commented Oct 24, 2024

Can you share some information about your setup?

  1. Were you using the develop branch or the version from pip? Release v0.3.11 has a bug which was fixed on develop, but not yet released as v0.3.12
  2. Are you running windows, linux, or Mac?
  3. Can you share which notebook you were using when you saw the issue?

@kratman kratman self-assigned this Oct 24, 2024
@hectormara
Copy link

hectormara commented Oct 25, 2024

Thank you. I was using liionpack 0.3.10 from pip under windows.

The code is this:

    import liionpack as lp
    import pybamm
    
    # Generate the netlist
    netlist = lp.setup_circuit(Np=4, Ns=3, Rb=1e-3, Rc=1e-2)
    # Define some additional variables to output
    output_variables = [
    'X-averaged negative particle surface concentration [mol.m-3]',
    'X-averaged positive particle surface concentration [mol.m-3]',
    ]
    
    amperes = input("Enter the current: ")
    
    
    # Cycling experiment, using PyBaMM
    experiment = pybamm.Experiment([
    "Charge at " + amperes + " A for 30 minutes",
    "Rest for 15 minutes",
    "Discharge at 5 A for 30 minutes",
    "Rest for 30 minutes"],
    period="10 seconds")
    # PyBaMM battery parameters
    
    parameter_values = pybamm.ParameterValues("Chen2020")
    
    # Solve the pack problem
    output = lp.solve(netlist=netlist,
    parameter_values=parameter_values,
    experiment=experiment,
    output_variables=output_variables,
    initial_soc=0.5)
    # Display the results
    lp.plot_output(output)

@hectormara
Copy link

The same happens with the function lp.compare_solution_output.
Any suggestions?

@hectormara
Copy link

There is a quick workaround. After the "plot_output" function write plt.show(). At the beginning write
`import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.clear()
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants