コード例 #1
0
ファイル: simulation.py プロジェクト: yushun9897/PyBaMM
    def plot(self, output_variables=None, quick_plot_vars=None, **kwargs):
        """
        A method to quickly plot the outputs of the simulation. Creates a
        :class:`pybamm.QuickPlot` object (with keyword arguments 'kwargs') and
        then calls :meth:`pybamm.QuickPlot.dynamic_plot`.

        Parameters
        ----------
        output_variables: list, optional
            A list of the variables to plot.
        quick_plot_vars: list, optional
            A list of the variables to plot. Deprecated, use output_variables instead.
        **kwargs
            Additional keyword arguments passed to
            :meth:`pybamm.QuickPlot.dynamic_plot`.
            For a list of all possible keyword arguments see :class:`pybamm.QuickPlot`.
        """

        if quick_plot_vars is not None:
            raise NotImplementedError(
                "'quick_plot_vars' has been deprecated. Use 'output_variables' instead."
            )

        if self._solution is None:
            raise ValueError(
                "Model has not been solved, please solve the model before plotting."
            )

        if output_variables is None:
            output_variables = self.output_variables

        self.quick_plot = pybamm.dynamic_plot(
            self._solution, output_variables=output_variables, **kwargs)
コード例 #2
0
ファイル: batch_study.py プロジェクト: masoodtamaddon/PyBaMM
 def plot(self, output_variables=None, **kwargs):
     """
     For more information on the parameters used in the plot,
     See :meth:`pybamm.Simulation.plot`
     """
     self.quick_plot = pybamm.dynamic_plot(
         self.sims, output_variables=output_variables, **kwargs)
     return self.quick_plot
コード例 #3
0
    def plot(self, output_variables=None, **kwargs):
        """
        A method to quickly plot the outputs of the solution. Creates a
        :class:`pybamm.QuickPlot` object (with keyword arguments 'kwargs') and
        then calls :meth:`pybamm.QuickPlot.dynamic_plot`.

        Parameters
        ----------
        output_variables: list, optional
            A list of the variables to plot.
        **kwargs
            Additional keyword arguments passed to
            :meth:`pybamm.QuickPlot.dynamic_plot`.
            For a list of all possible keyword arguments see :class:`pybamm.QuickPlot`.
        """
        return pybamm.dynamic_plot(self, output_variables=output_variables, **kwargs)
コード例 #4
0
ファイル: simulation.py プロジェクト: tobykirk/PyBaMM
    def plot(self, quick_plot_vars=None, testing=False):
        """
        A method to quickly plot the outputs of the simulation.

        Parameters
        ----------
        quick_plot_vars: list, optional
            A list of the variables to plot.
        testing, bool, optional
            If False the plot will not be displayed
        """

        if self._solution is None:
            raise ValueError(
                "Model has not been solved, please solve the model before plotting."
            )

        if quick_plot_vars is None:
            quick_plot_vars = self.quick_plot_vars

        self.quick_plot = pybamm.dynamic_plot(
            self._solution, output_variables=quick_plot_vars, testing=testing
        )
コード例 #5
0
    if model.name == "user":
        # add the user supplied parameters
        param.update(
            {
                "Negative electrode surface area to volume ratio [m-1]":
                170000,
                "Positive electrode surface area to volume ratio [m-1]":
                200000,
            },
            check_already_exists=False,
        )

    sim = pybamm.Simulation(model, parameter_values=param)
    solution = sim.solve(t_eval)
    solutions.append(solution)

# plot solutions
pybamm.dynamic_plot(
    solutions,
    [
        "Negative particle surface concentration [mol.m-3]",
        "Positive particle surface concentration [mol.m-3]",
        "Negative electrode interfacial current density [A.m-2]",
        "Positive electrode interfacial current density [A.m-2]",
        "Negative electrode potential [V]",
        "Electrolyte potential [V]",
        "Positive electrode potential [V]",
        "Terminal voltage [V]",
    ],
)
コード例 #6
0
ファイル: calendar_ageing.py プロジェクト: yonas-y/PyBaMM
    seconds = minutes * 60

    t_eval = np.linspace(0, seconds, 100)

    sim.solve(t_eval=t_eval, solver=solver)
    sims.append(sim)
pb.dynamic_plot(
    sims,
    [
        "Terminal voltage [V]",
        "Negative particle surface concentration",
        "X-averaged negative particle surface concentration",
        "Electrolyte concentration [mol.m-3]",
        "Total negative electrode sei thickness [m]",
        "X-averaged total negative electrode sei thickness [m]",
        "X-averaged total negative electrode sei thickness",
        "X-averaged negative electrode sei concentration [mol.m-3]",
        "Loss of lithium to negative electrode sei [mol]",
        [
            "Negative electrode sei interfacial current density [A.m-2]",
            "Negative electrode interfacial current density [A.m-2]",
        ],
        [
            "X-averaged negative electrode sei interfacial current density [A.m-2]",
            "X-averaged negative electrode interfacial current density [A.m-2]",
        ],
        "Sum of x-averaged negative electrode interfacial current densities",
        "X-averaged electrolyte concentration",
    ],
)
コード例 #7
0
#
# Compare lead-acid battery models
#
import pybamm

pybamm.set_logging_level("INFO")

# load models
models = [
    pybamm.lead_acid.LOQS(),
    pybamm.lead_acid.FOQS(),
    pybamm.lead_acid.Composite(),
    pybamm.lead_acid.Full(),
]

# create and run simulations
sims = []
for model in models:
    model.convert_to_format = None
    sim = pybamm.Simulation(model)
    sim.solve([0, 3600 * 17])
    sims.append(sim)

# plot
pybamm.dynamic_plot(sims)
コード例 #8
0
    @property
    def default_solver(self):
        return pybamm.CasadiAlgebraicSolver()


if __name__ == "__main__":
    pybamm.set_logging_level("INFO")

    true_model = RHTModel()
    true_model.name = "True RHT"
    parameter_values = true_model.default_parameter_values
    parameter_values["T_inf"] = 45
    sim_true = pybamm.Simulation(true_model, parameter_values=parameter_values)

    base_model = RHTModel()
    base_model.name = "Base RHT"
    parameter_values = base_model.default_parameter_values
    parameter_values["T_inf"] = 45
    parameter_values["beta"] = 1
    sim_base = pybamm.Simulation(base_model, parameter_values=parameter_values)

    t_eval = np.array([0, 1])
    sims = []
    for sim in [sim_true, sim_base]:
        sim.solve(t_eval)
        sims.append(sim)

    pybamm.dynamic_plot(sims, ["Temperature", "beta", "beta_decoupled"],
                        spatial_unit="m")
コード例 #9
0
param = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Chen2020)
param = set_thermal_parameters(param, 20, 2.85e6, temperature)

mesh_factors = [1, 2, 4, 8]
solutions = []

var = pybamm.standard_spatial_vars

for factor in mesh_factors:
    var_pts = {
        var.x_n: 20 * factor,
        var.x_s: 20 * factor,
        var.x_p: 20 * factor,
        var.r_n: 30 * factor,
        var.r_p: 30 * factor,
        var.y: 10,
        var.z: 10,
    }
    sim = pybamm.Simulation(
        model,
        parameter_values=param,
        var_pts=var_pts,
        C_rate=Crate,
    )
    sim.model.name
    sim.solve([0, 3600])
    sim.solution.model.name += " x{} mesh".format(factor)
    solutions.append(sim.solution)

pybamm.dynamic_plot(solutions)
コード例 #10
0
    years = 30
    days = years * 365
    hours = days * 24
    minutes = hours * 60
    seconds = minutes * 60

    t_eval = np.linspace(0, seconds, 100)

    sim.solve(t_eval=t_eval, solver=solver)
    sims.append(sim)
pb.dynamic_plot(
    sims,
    [
        "Terminal voltage [V]",
        "Negative particle surface concentration",
        "X-averaged negative particle surface concentration",
        "Electrolyte concentration [mol.m-3]",
        "Total negative electrode SEI thickness [m]",
        "X-averaged total negative electrode SEI thickness [m]",
        "X-averaged total negative electrode SEI thickness",
        "X-averaged negative electrode SEI concentration [mol.m-3]",
        "Loss of lithium to negative electrode SEI [mol]",
        "Sum of x-averaged negative electrode interfacial current densities",
        "Loss of lithium inventory [%]",
        [
            "Total lithium lost [mol]",
            "Loss of lithium to negative electrode SEI [mol]"
        ],
    ],
)