liionpack icon indicating copy to clipboard operation
liionpack copied to clipboard

Plotting issue with notebooks

Open kratman opened this issue 1 year ago • 5 comments

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 avatar Oct 24 '24 12:10 kratman

@hectormara This is the new ticket for your discussion

kratman avatar Oct 24 '24 13:10 kratman

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 avatar Oct 24 '24 13:10 kratman

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 avatar Oct 25 '24 09:10 hectormara

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

hectormara avatar Nov 13 '24 17:11 hectormara

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() `

hectormara avatar Nov 15 '24 15:11 hectormara