Consumer electronics, wearable and personal health devices, power networks, microgrids, and hybrid electric vehicles (HEVs) are some of the many applications of lithium-ion batteries. Their optimal design and management are important for safe and profitable operations. The use of accurate mathematical models can help in achieving the best performance. This article provides a detailed description of a finite volume method (FVM) for a pseudo-two-dimensional (P2D) Li-ion battery model suitable for the development of model-based advanced battery management systems. The objectives of this work are to provide: (i) a detailed description of the model formulation, (ii) a parametrizable Matlab framework for battery design, simulation, and control of Li-ion cells or battery packs, (iii) a validation of the proposed numerical implementation with respect to the COMSOL MultiPhysics commercial software and the Newman's DUALFOIL code, and (iv) some demonstrative simulations involving thermal dynamics, a hybrid charge-discharge cycle emulating the throttle of an HEV, a model predictive control of state of charge, and a battery pack simulation. The increasing demand for portable devices (e.g., smartphones) and hybrid electric vehicles (HEVs) calls for the design and management of storage devices of high power density and reduced size and weight. During the many decades of research, different chemistries of batteries have been developed, such as Nickel Cadmium (NiCd), Nickel Metal Hydride (NiMH), Lead Acid and Lithium ion (Li-ion) and Lithium ion Polymer (Li-Poly) (e.g., see Refs. 1-4). Among electrochemical accumulators, Li-ion batteries provide one of the best tradeoff in terms of power density, low weight, cell voltage, and low self-discharge. 5 Mathematical models can support the design of new batteries as well as the development of new advanced battery management systems (ABMS). [6][7][8] According to the literature, mathematical models for Li-ion battery dynamics fall within two main categories: Equivalent Circuit Models (ECMs) and Electrochemical Models (EMs). ECMs use only electrical components to model the dynamic behavior of the battery. ECMs include (i) the R int model where only a resistance and a voltage source are used to model the battery, (ii) the RC model (introduced by the company SAFT 9 ) where capacitor dynamics have been added to the R int model, 10 and (iii) the Thevenin model, which is an extension of the RC model (e.g., see Refs. 11, 12 and references therein). In contrast, EMs explicitly represent the chemical processes that take place in the battery. While ECMs have the advantage of simplicity, EMs are more accurate due to their ability to describe detailed physical phenomena. 13 The most widely used EM in the literature is the porous electrode theory-based pseudo-two-dimensional (P2D) model, 14 which is described by a set of tightly coupled and highly nonlinear partial differential-algebraic equations (PDAEs). In order to exploit the model for simulation and design purposes, the set of PDAEs are reformu...