Modelling of Hybrid Electric Vehicle Components in Modelica. And Comparison with Simulink THESIS

Similar documents
MathWorks Technology Session at GE Physical System Modeling with Simulink / Simscape

Software-Entwicklungswerkzeuge

Software-Entwicklungswerkzeuge. Modelica Overview. Contents. 1. Modelica Introduction. 2. Modelica Users View. 3. Modelica Libraries

Modeling Technical Systems [ ] Mag MA MA Schweiger Gerald TU Graz Spring 2017

Physical Modelling with Simscape

Introduction to Physical Modelling Rory Adams Senior Application Engineer

MapleSim User's Guide

Introduction to Control Systems Design

Master Class: Diseño de Sistemas Mecatrónicos

Sensor Accuracy in Vehicle Safety

This is the published version of a paper presented at IEEE PES General Meeting 2013.

Hardware-in-the-Loop and Real-Time Testing Techniques

Vom Konzept zum Modell physikalischer Systeme Smarter Modellieren mit Simscape

Modelica. Language, Libraries, Tools, Workshop and EU-Project RealSim

Scicos/Modelica for modeling and simulation

ESI ITI Academy. Courses and Contents

Anticipatory Shifting Optimization of a Transmission Control Unit for an Automatic Transmission through Advanced Driver Assistance Systems

Design optimisation of industrial robots using the Modelica multi-physics modeling language

Rotational3D Efficient modelling of 3D effects in rotational mechanics

Developing a Robot Model using System-Level Design

Plant modeling: A First Step to Early Verification of Control Systems

Modern techniques bring system-level modeling to the automation industry

2015 The MathWorks, Inc. 1

A Modelica Power System Library for Phasor Time-Domain Simulation

Real-Time HIL/RCP Laboratory. Study, design and test power electronics control algorithms using both OPAL-RT and Lab-Volt solutions.

Multi-Physics RecurDyn Style Interoperability

From versatile analysis methods to interactive simulation with a motion platform based on SimulationX and FMI

INTEROPERABILITY WITH FMI TOOLS AND SOFTWARE COMPONENTS. Johan Åkesson

Equation-Based Modeling with Modelica Principles and Future Challenges

How Simscape Supports Innovation for Cyber-Physical Systems

Training Systems for Power Electronics

Topology Optimization of Engine Structure of a Scooter Engine using OptiStruct

Proceedings of the 4th International Modelica Conference, Hamburg, March 7-8, 2005, Gerhard Schmitz (editor)

SIMulation Workbench and HIL testing at Ford Motor Company

Model Library Mechanics

Recent Approaches of CAD / CAE Product Development. Tools, Innovations, Collaborative Engineering.

Model-Based Dynamic Optimization with OpenModelica and CasADi

Modeling and Simulation of Electromechanical Systems

FMI WORKSHOP. INCOSE International Workshop, Los Angeles, CA, Contents. Introduction

SimulationX The Powerful Simulation Software Package for the Future

Model Based Systems Engineering Engine Control: from concept to validation. Jan Smolders Technical Account Manager

Importing Models from Physical Modeling. Tools Using the FMI Standard

Simscape User s Guide. R2014a

Variable Structure Modeling for Vehicle Refrigeration Applications

Using RecurDyn. Contents

Decoupling Test Cases from Real and Virtual Test Systems with ASAM HIL API

Modeling, Simulation and Analysis of Integrated Building Energy and Control Systems. Michael Wetter. October 8, 2009

ENGINEERING. Apply online: CAREER OPPORTUNITY

Quick Start Training Guide

LMS Virtual.Lab Noise and Vibration

Ben Zandi, Ph.D. TES International LLC

LabVIEW FPGA in Hardware-in-the-Loop Simulation Applications

Multidisciplinary Analysis and Optimization

Parag Choudhary Engineering Architect

Power Density. Digital Control. Improvements and. Techniques Enabling. Power Management Capabilities. Technical Paper 004

Exhibition themes. Save the date

Design Verification of Hydraulic Performance. for a Centrifugal Pump using. Computational Fluid Dynamics (CFD)

POTENTIAL AND BENEFITS OF FUNCTIONAL MOCK-UP INTERFACE - FMI FOR VIRTUAL VEHICLE INTEGRATION

Real-Time Simulation of Simscape Models

Activation Inheritance in Modelica

Vision of Building Simulation

Recent Approaches of CAD / CAE Product Development. Tools, Innovations, Collaborative Engineering.

Mathieu Dutré - Application Specialist MBSE. Analysis and optimization of physical models for HIL simulation

Parallel Execution of Functional Mock-up Units in Buildings Modeling

Engineering 1000 Chapter 6: Abstraction and Modeling

Real-Time Execution in LabVIEWTM

Project Planning. Module 4: Practice Exercises. Academic Services Unit PREPARED BY. August 2012

1 Although other ways of exporting like using the 2 s 1

Optimized Thermal Systems, Inc.

Industrial Training Zone (ITZ) eseries Courses

Model-Based Development of Multi-Disciplinary Systems Challenges and Opportunities

Electrical Systems Technology

Architecture-driven development of Climate Control Software LMS Imagine.Lab Embedded Software Designer Siemens DF PL

Applications of Program analysis in Model-Based Design

Computer Simulation And Modeling

FMI Kit for Simulink version by Dassault Systèmes

HIL. Hardware-in-the-loop system for Automotive ECU testing and validation

Real Time Simulation of Complex Automatic Transmission Models. Marius Băţăuş, Andrei Maciac, Mircea Oprean, Nicolae Vasiliu

What s New with the MATLAB and Simulink Product Families. Marta Wilczkowiak & Coorous Mohtadi Application Engineering Group

HARDWARE OF SUPERVISORY CONTROL & DATA ACQUISITION SYSTEM

Modeling and Simulation in Scilab/Scicos with ScicosLab 4.4

Integrated Simulation and Hardware-test Environment for Microcontroller Development

Simulation-based development of automotive control software with Modelica

Running OPAL-RT s ehs on National Instruments crio: Sub-microsecond power-electronic simulation

Speed Control of A DC Motor Through Temperature Variation Using NI ELVIS LabVIEW

Freely Available for Academic Use!!! March 2012

Extending the IPG CarMaker by FMI Compliant Units

Paul Goossens Product Director

SDM for Systems Simulation Challenges and Solution Approach for Process and Data Management

Nonlinear Kinematics and Compliance Simulation of Automobiles

Micro physical simulation system of electric power systems

Numerical Simulation of Dynamic Systems XXIV

LMS Virtual.Lab The Unified Environment for Functional Performance Engineering

SIMPACK - A Tool for Off-Line and Real- Time Simulation

Program: Advanced Certificate Program

Accurate Thermo-Fluid Simulation in Real Time Environments. Silvia Poles, Alberto Deponti, EnginSoft S.p.A. Frank Rhodes, Mentor Graphics

30 th Anniversary Event. New features in Opera By: Kevin Ward. OPTIMIZER Automatically selects and manages multiple goalseeking

Matlab Simulink Simscape

Introduction to C omputational F luid Dynamics. D. Murrin

STATIC FINITE ELEMENT ANALYSIS AND VALIDATION OF N1 TYPE VEHICLE CHASSIS MEMBERS FOR BENDING PERFORMANCE

Transcription:

Modelling of Hybrid Electric Vehicle Components in Modelica And Comparison with Simulink THESIS Presented in Partial Fulfillment of the Requirements for the Degree Master of Science in the Graduate School of The Ohio State University By Avinash Divecha Graduate Program in Mechanical Engineering The Ohio State University 2016 Thesis Committee: Dr. Giorgio Rizzoni, Advisor Dr. Marcello Canova

Copyright by Avinash Divecha 2016

ABSTRACT Automobiles affect growth of humanity. Vehicles affect everything from economy to our environment. One of the advancements to ensure the energy consumed by vehicles is sustainable are Hybrid-electric vehicles. Hybrid-electric vehicles cover various domains under its umbrella. They are a combination of different systems including Electrical, Mechanical, Chemical, and Thermal. One of the tools used to model the dynamics of Hybrid-electric vehicles is MATLAB/Simulink which is a general purpose modelling tool. The language of Modelica and its simulation environments allows multi-domain modeling while modeling from the physical perspective. The focus of this thesis was to model components of Hybrid electric vehicles in a Modelica based simulation environment, in the process learning the advantages and disadvantages of using the Modelica language and the tools which act as the front ends for the language. A model was created to simulate the electrical dynamics of a battery cell and pack. A model of an electric drive was taken from a commercial library and its dynamics were observed by integrating the model of the battery pack along with the electric drive. The models created using Dymola simulated in Dymola and were exported to Simulink to compare results and simulation times. The differences in creating a model in Simulink and a Modelica Simulation environment were examined and noted along with the benefits and shortcomings of the different modeling methodologies. ii

DEDICATION To My parents Shailesh and Vibha, Who have molded me into the person I am today and provided for everything I have needed. My brother Yash, Who has always been there for me. All my teachers, Who have taken great efforts to aid my development. And my friends, Who have made this world an enjoyable place to be in. Without you all, none of this would be possible. iii

ACKNOWLEDGEMENTS I am grateful to my advisor, Dr. Giorgio Rizzoni who has not only guided me on academic topics and how to conduct research, but also on how live a balanced life, and how to play golf. I would like to express my gratitude to the researchers at The Center for Automotive Research, especially Dr. Qadeer Ahmed, who has helped shaped the outcome of this project, and Dr. Stephanie Stockar, who was not a part of this project but has had an immense influence on me and my research. I would like to thank all the students who have helped me with my difficulties and helped further my knowledge, especially Bharatkumar Hegde, who has always made himself available for discussions which have provided me with insight. I would also like to thank Cummins for funding this research and the entire team there whose questions and feedback were essential to the direction of this project. iv

VITA May 2013...B.E. Mechanical Engineering, K. J. Somaiya College of Engineering, University of Mumbai August 2013 to June 2014...Graduate Engineer Trainee, Godrej and Boyce Mfg. Pvt. Ltd., Mumbai, India Jan 2015 to April 2015...Undergraduate Teaching Assistant, Department of Mechanical Engineering, The Ohio State University March 2015 to May 2015...Student Research Associate, Department of Mechanical Engineering, The Ohio State University May 2015 to Present...Graduate Research Associate, Department of Mechanical Engineering, The Ohio State University FIELDS OF STUDY Major Field: Mechanical Engineering v

TABLE OF CONTENTS ABSTRACT... ii DEDICATION... iii ACKNOWLEDGEMENTS... iv VITA... v TABLE OF CONTENTS... vi LIST OF FIGURES... viii CHAPTER 1: INTRODUCTION... 1 1.1 Motivation... 1 1.2 Simulation Environments... 4 CHAPTER 2: LITERATURE REVIEW... 7 2.1 HEV Component Modelling Review... 7 2.2 Battery Modeling and Comparison of Methods... 12 CHAPTER 3: THE MODELICA LANGUAGE... 13 3.1 Introduction to Modelica... 13 3.2 Acausality in Modelica... 18 3.3 Tools running Modelica... 20 3.4 Comparison of Modelica Simulation Environments... 28 3.5 Dymola... 30 CHAPTER 4: BATTERY MODELING IN MODELICA... 32 4.1 Overview of Battery Modelling... 32 4.2 0 th order Battery Model... 33 4.3 1 st Order Battery Model... 45 4.4 1 st Order Battery Pack Model... 49 4.5 Exporting Battery Models to Simulink... 57 CHAPTER 5: ELECTRIC DRIVES MODELING IN MODELICA... 64 vi

5.1 Overview of Electric Drives... 64 5.2 Electric Machine Model... 67 5.3 Inverter Model... 68 5.4 Simulating the Electric Drive... 69 CHAPTER 6: COMPARISON OF MODELICA AND SIMULINK MODELS... 75 6.1 Overview of comparison between Modelica and Simulink... 75 6.2 Modeling Approach... 76 6.3 Data Collection and Plotting... 79 6.4 Acausal Modeling... 80 CHAPTER 7: CONCLUSION... 84 REFERENCES... 86 vii

LIST OF FIGURES Figure 1- Fuel Economy Prediction of Hybrid Vehicles [3]... 2 Figure 2 Equations and Schematic of Equivalent Circuit Model... 8 Figure 3 Simulink Model for Battery Cell Level Calculations... 8 Figure 4 Simulink Model for Lumped Battery Pack... 9 Figure 5 Overview of Simulink Model for Interconnected Battery Pack... 10 Figure 6 Diagram for Inverter... 11 Figure 7 Integrator and Derivative blocks with code in Modelica... 19 Figure 8- Equivalent Circuit Model for ECM Battery Modeling... 33 Figure 9- Model of Capacity Calculator... 34 Figure 10- Model of SOC Calculator... 34 Figure 11- Model of Open Circuit Voltage (E0) Calculator... 35 Figure 12- Model of Resistance R0 Calculator... 36 Figure 13- Model of 0 th Order Parameter Calculator... 37 Figure 14-0 th Order Battery Model... 38 viii

Figure 15-0 th Order Battery Model Simulator... 39 Figure 16-0 th Order Battery Model Simulation Results... 40 Figure 17-0 th Order Battery Cell Parallel Simulator... 41 Figure 18-0 th Order Battery Cell Parallel Simulation Results... 42 Figure 19-0 th Order Battery Cell Series Simulator... 43 Figure 20-0 th Order Battery Cell Series Simulation Results... 44 Figure 21- Model of 1 st Order Parameter Calculator... 45 Figure 22-1 st Order Battery Model... 46 Figure 23-1 st Order Battery Model Simulator... 47 Figure 24-1 st Order Battery Model Simulation Results... 48 Figure 25- Battery Pack PS Configuration... 49 Figure 26- Battery Pack Modelica Text... 50 Figure 27- Battery Pack Simulator... 51 Figure 28- Battery Pack Simulator... 52 Figure 29- Battery Pack 1P2S (Series) Configuration Results... 53 ix

Figure 30- Battery Pack 2P1S (Parallel) Configuration Results... 53 Figure 31- Battery Pack 2P2S Configuration Results... 54 Figure 32- Battery Pack (Cell to Pack) Model... 56 Figure 33- Comparison of Cell to Pack and Interconnected cell battery... 57 Figure 34- DymolaBlock in Simulink Library Browser... 58 Figure 35- Battery Simulator model for export to Simulink... 59 Figure 36- Interface for DymolaBlock in Simulink... 60 Figure 37- Compiled DymolaBlock for Battery Simulator in Simulink... 61 Figure 38- Simulink model with Battery Simulator DymolaBlock... 61 Figure 39- Table of comparison of Simulink and DymolaBlock... 62 Figure 40- PMSM operated in Brushless DC mode... 65 Figure 41- Parameters for PMSM operated in Brushless DC mode... 66 Figure 42- Permanent Magnet Synchronous Motor model... 67 Figure 43- Three Phase DC to AC converter... 69 Figure 44- Simulation of Electric Drive... 70 x

Figure 45- Inverter 3 Phase output current... 71 Figure 46- Inverter 3 Phase output current with requested torque... 72 Figure 47- PMSM operated in Brushless DC mode with 1 st order battery... 73 Figure 48- Simulation of Electric Drive with 1 st order battery model... 74 Figure 49- Results of 1 st Order Battery Model in Modelica & Simulink... 76 Figure 50- Difference in Simulink and Modelica Modeling Approach... 77 Figure 51- Modeling Approach in Simulink... 78 Figure 52- Modeling Approach in Modelica... 78 Figure 53- Data Collection in Simulink and Modelica... 79 Figure 54- Changing causality of Battery Simulation in a Modelica tool... 81 Figure 55- Result for Battery model simulation with Potential load... 82 xi

CHAPTER 1: INTRODUCTION 1.1 Motivation The automotive industry has had a major impact on the way we live and conduct business since its inception. However, a large percentage of automobiles are dependent on fossil fuels. In 2011, The United States had approximately 265 million registered vehicles which is about 830 vehicles per 1000 people in the U.S. [1]. A large percentage of these vehicles are powered by non-renewable sources of energy like liquid fossil fuels. Due to various reasons including but not limited to the cost, unsustainability of fossil fuels, and their impact on our environment, it is imperative that we look at other methods like electricity to power our vehicles. While the first practical electric vehicle was made over a 100 years ago, it was around 1990 when the interest in electric vehicles was renewed due to new state and federal regulations and concerns about the future availability and impact of fossil fuels [2]. 1

Figure 1- Fuel Economy Prediction of Hybrid Vehicles [3] Two of the most important aspects of the electric vehicle are its cost and fuel economy. Reducing vehicle price and increasing fuel economy are essential to making the vehicle available to the masses. For achieving both of these goals, it is necessary that the vehicle is designed well. Computer models and simulations have been used for a long time to recreate and examine the behavior of various events that take place in the real world. They help going over different scenarios that may be time consuming, expensive or sometimes impossible in real life. They are used in fields ranging from physics to economics to engineering. Modeling the dynamics of the vehicles and their components is important since it helps study how the component will work. It allows designers to compare results with 2

varying parameters. It is cheaper and quicker to perform tests on a simulator rather than a prototype. Hence, modelling reduces the time and the cost of the design process. There are various tools that have been developed to enable modelling and simulation of dynamic systems. Initially modelers were burdened with converting their models into systems of ordinary differential equations (ODEs) and the writing code to integrate those differential equations in order to run simulations. Eventually, a wide range of integrators were developed as independent software units and modelers were able to focus on the formulation of differential equations and use off-the-shelf integrators for simulation [4]. Most of the tools that have been developed, were either general purpose tools like System Build, SIMULINK, etc. which are not restricted to one domain but may require time to formulate the models for a particular purpose or domain-oriented tools like Spice, Saber, ADAMS, etc. which have numerical methods and interfaces which are optimized for a particular domain but restrict the modeler from creating multi-domain models. Some tools like the Dymola modeling language (Elmqvist, 1978) were developed for modelers to develop models from a physical perspective rather than a mathematical one. The Modelica language is a multi-domain, general-purpose language that builds on non-causal modeling with true ordinary differential and algebraic equations (DAEs) and the use of object-oriented constructs to facilitate reuse of modeling knowledge [5]. 3

The objective of this thesis is to explore the language of Modelica by modeling components of Hybrid Electric Vehicles such as Battery and Electric Drives, compare the results to those obtained by modeling the systems in Simulink and to list the strengths and weaknesses of the Modelica language as compared to MATLAB/Simulink. 1.2 Simulation Environments There are various software that may be used to simulate dynamic systems. There are various tools which may be used to build models of components to simulate a vehicle. Depending on the requirements and capabilities of a simulation environment, one may use a multi-domain modelling environment like Simulink or specific purpose tools like AVL Cruise, CarSim, GT-Suite, etc. Simulink, which is developed by MathWorks, is a block diagram environment for multi-domain simulation and Model-Based Design. It provides a graphical editor, customizable block libraries, and solvers for simulating dynamic systems. Its integration with MATLAB enables users to incorporate MATLAB algorithms into models and export simulation results to MATLAB for further analysis. There are many tools developed by companies for public or private use which use models created in MATLAB/Simulink for modeling dynamic systems. One of the earliest publically available vehicle simulation tools is ADVISOR (ADvanced VehIcle SimulatOR), which was developed at the National Renewable Energy 4

Laboratory (NREL) in 1994 to allow system-level analysis and trade-off studies of advanced vehicles [6]. ADVISOR was created using MATLAB/Simulink and was ideally suited for doing parametric studies to map out the design space of potential high fuel economy vehicles. GT-Suite is one of the current simulators with capabilities aimed at a variety of automotive engineering applications and beyond. It is maintained by Gamma Technologies and contains many different simulations technologies, one of which is a vehicle powertrain simulator called GT-Drive, which has the capability to incorporate models from other GT- Suite tools [7]. The general system models are created based on the various libraries which are available with it, some of which are the Flow library, Thermal library, Mechanical library, and Electric & Electromagnetic library. CarSim is a simulation environment developed by the Mechanical Simulation Corporation and according to its description at https://www.carsim.com/products/carsim, provides detailed, and efficient methods for simulating the performance of passenger vehicles and light-duty trucks. Some of its uses include analyzing vehicle dynamics, developing active controllers, and calculating a car s performance. CarSim, along with other tools tike BikeSim, and TruckSim built by the Mechanical Simulation Corporation use VehicleSim Technology which was first introduced in 1990. It has the capability to run with custom programs like MATLAB, Visual Basic, and C++. It supports Hardware in the Loop (HIL) testing on major real-time platforms. 5

AVL Simulation Technologies have a systematic netting of single simulation results to integrated, multidimensional simulation platforms. The various tools developed by AVL include AVL BOOST for Virtual Engine Simulation, AVL CRUISE for Vehicle System and Driveline Simulation, and AVL CRUISE M for Multi-disciplinary System Simulation. These tools can be combined with 3 rd party tools, and testing and analysis methods for verification of testing data, and reduction of test efforts. 6

CHAPTER 2: LITERATURE REVIEW 2.1 HEV Component Modelling Review A battery pack and electric drive model can be combined together to create an electric vehicle simulator. Work has been done previously at the Center for Automotive Research at The Ohio State University to build an electric vehicle simulator model comprising of models of the battery and the electric drive with different levels of fidelity [8]. To compare the results of the models created in a Modelica simulation environment and in Simulink, the models are built to have the same dynamics as the Simulink models built previously. While the models built previously focus on the electrical, thermal and aging dynamics, we concentrate on just the electrical dynamics which requires a set of parameters and initial conditions but can operate with the other subsystems. The battery pack can be modeled at a cell level, interconnected cell level or a pack level. 7

The cell voltage calculations are done using an equivalent circuit model. The equations used and the arrangement of the components which make the circuit are shown in Figure 2. V E R I V cell 0 0 dvrc I VRC dt C RC dv dt RC IR 1 I C RC Figure 2 Equations and Schematic of Equivalent Circuit Model These equations for the cell level calculations are modeled in Simulink using the basic Simulink library blocks as shown in Figure 3. Figure 3 Simulink Model for Battery Cell Level Calculations 8

The cell level model can be converted to a battery pack either by creating a lumped pack as shown in Figure 4 or by creating interconnected cells [9] as shown in Figure 5. Figure 4 Simulink Model for Lumped Battery Pack 9

Figure 5 Overview of Simulink Model for Interconnected Battery Pack The electric drive model mainly consists two physical components which are the electric machine and the inverter. The inverter consists of switches and diodes arranged as shown in Figure 6. The switches receive commands such that the output is a 3-Phase alternating current. 10

Figure 6 Diagram for Inverter The inverter can be modeled using either and efficiency based model, Ideal switch based 3-phase model or a 3-phase inverter model based on components like IGBT, MOSFET, etc. The electric machine in case of electric drives can be modeled using three main methods which are using an efficiency map and neglecting dynamics of the machine, considering the electrical dynamics of the machine in the dq-axis, and considering all three phases of the current using the dq-axis. 11

2.2 Battery Modeling and Comparison of Methods Battery models created in two different ways, i.e. using block diagrams in Simulink and modeling the plant in Dymola have been studied and compared [10] with the simulations having the Dymola model imported to Simulink running much faster than the model created using Simulink blocks. One of the aims of this project is to delve deeper into this comparison by creating our own models in a Modelica simulation environment and comparing the output to an equivalent model created using Simulink block. In that process, comparing not only the simulation times and errors but also the differences in the modelling capabilities and techniques, drawbacks and advantages of each method and the tools available to perform these actions. 12

CHAPTER 3: THE MODELICA LANGUAGE 3.1 Introduction to Modelica The Dymola modelling language was created as a part of his Ph.D. thesis by Hilding Elmqvist in 1978 [11]. The aim was to enable model developers to look at modeling from a physical perspective rather than taking a mathematical approach. After Dymola, many other tools emerged, building on this approach. The problem with these various tools was that they focused on different domains and models built using one tool could not be used by other tools. The effort to unify various languages was started by Hilding Elmqvist in 1996 and this was done by developing the Modelica modeling language. While there have been other undertakings similar to Modelica before and after, they have been focused mainly on the electrical domain while Modelica attempts to be domain neutral. The aim of Modelica was to have one modeling language that caters to various domains without limiting those models to one particular tool. To enable this, developers 13

who had worked on other object-oriented tools like Allan, Dymola, Omola, etc. were brought together to contribute using their knowledge which spanned through multiple domains and create the specification for the Modelica language. Modelica allows modelers to build their models using DAEs to describe the systems instead of converting them to ODEs. This capability was incorporated after the development of the DAE index reduction algorithm by Pantelides [12]. Modelica also allows discrete variables to be modeled along with continuous variables and simulate them at the same time in the same component or system. A particular variable does not need to be solved for manually. The Modelica tools decide that automatically using the available information. The Modelica name is a trademark of the Modelica association, a non-profit organization, which is also responsible for publication of the Modelica language specification. If one can demonstrate the need for functionality not already present in the Modelica language, then the Modelica Association can be contacted to add that functionality. The current Modelica specification can be found at the Modelica Association website https://www.modelica.org/. The Modelica language allows the modeler to reuse and exchange models and model libraries. It allows the user to step away from writing equations at the component level and work at a higher level using components that are made already. 14

The design approach of the language builds on non-causal modeling where equations do not specify a certain direction of data flow. The direction is decided by the tool once the complete model is built and depends on the known and unknown variables. Once the model is built, the compiler compiles the Modelica code into some intermediate code (generally C), which is compiled into machine code and solved with a numerical ODE or DAE solver. Using the graphical user interface (GUI) of the tools that run the Modelica language, models can be created by dragging, dropping and connecting components without having to delve into the code. All the tools based on the Modelica language come with the standard Modelica library from the Modelica Association which contains components from various domains including mechanical, electrical, thermal, fluid, etc. Following are some of the packages and components/models that are available with the standard Modelica Library: 1. Electrical Analog Transformer Gyrator 15

Synchronous Induction Machines Permanent Magnet Motor Electrical Excited Motor Reluctance Rotor Magnet Asynchronous Induction Machines Slip Ring Motor DC Machines Permanent Magnet Motor Series Excited 2. Mechanics Translational Mass Spring Damper Brake Rotational Inertia Disc Spring Clutch 16

Planetary Gearbox Multi-body Rotor Rolling Wheel Rolling Wheel Set 3. Fluid Closed Tank Open Tank Pump Controlled Pump Compressible Valve Linear Valve Heat Transfer Pressure Loss 4. Thermal Heat Capacitor Thermal Conductor Thermal Resistor Convection 17

There are many free and commercial libraries available. They are either developed by the Modelica Association, users of Modelica or by developers for commercial purposes. The libraries from the Modelica Association and most free libraries can be used in commercial products according to The Modelica License. A collection of the free and commercial libraries can be found at https://www.modelica.org/libraries. 3.2 Acausality in Modelica The definition and explanation of Causality in modelling is given by Michael Tiller in [4] as Causality is the cause and effect relationship between components in a complete physical system. In general, it is not possible to determine the causality of individual component. For example, does the voltage drop across a resistor result from a current going through a resistor or is it the current that results in the voltage drop? It is only once a complete system of components has been constructed that the causality can be determined. When an equation is written in MATLAB or blocks are arranged in Simulink, a certain direction of data flow is assigned. An equation written as V = I * R; in MATLAB to simulate the dynamics of resistor has the current (I) and resistance (R) as the inputs for that equation and the voltage (V) as the output. This defines the causality for the equation since we assume I and R to be the cause of V. Similarly, when we model this equation in Simulink, we are defining the causality of the model. 18

The acausal modelling approach builds on the idea that the causality of the individual component is not known and hence equations should not be treated as assignments. When an equation is written in the Modelica text, a certain direction of data flow is not specified. The equation V = I * R can be used as V := I * R, I := V / R or R := V / I depending on which values are known and which value needs to be calculated. Figure 7 Integrator and Derivative blocks with code in Modelica Acausality in modelling first order dynamics in Modelica can be seen by comparing the integrator and derivative blocks and the code used to model them as shown in Figure 7. We see from the figure that in both the blocks, the der term is used to find the time derivative of a variable. The difference is that in the derivative block, the derivative of the input is equated to the output while in the integrator block the derivative of the output is 19

equated to the input which is another way of saying that the output is an integral of the input. This acausal approach allows for reusability of the models developed and the effort required to change the causality of the model is very little compared to the effort required in Simulink where the system must be remodeled with the equations altered to suit the desired causality. 3.3 Tools running Modelica The Modelica language requires a modeling and simulation environment to solve the actual problems. The tool is required to define the model using a GUI such that editing the graphical model will result in a textual description of the model in the Modelica language format. The tool must use sophisticated symbolic transformation techniques to translate the Modelica model into a form which can be simulated efficiently in an appropriate simulation environment. It must also simulate the translated model using standard numerical integration methods and visualize the result. There are various commercial and free modeling and simulation environments/tools for Modelica. Following are the names and descriptions of the 20

commercial and free simulation environments as available from the Modelica tools website https://www.modelica.org/tools Commercial Modelica Simulation Environments: 1. By CyDesign Labs (formerly deltatheta): CyModelica is a powerful, best of breed, and extensible Modelica compiler and execution environment in the cloud. CyModelica is on track to provide full compliance with the Modelica language specification and Modelica Standard Libraries by early 2013. CyModelica is incorporated into CyDesign Studio, an integrated platform for model-based design optimization. CyModelica is also available as a standalone OEM Modelica compiler and simulation engine accessible through a comprehensive Web Services API. CyModelica supersedes Modelica SDK, an embeddable Modelica library previously offered by deltatheta. Vertex is a workstation-based engineering system simulation tool coupling the power and flexibility of Modelica modelling to CAD, spreadsheets and control system design software, bridging the gap between engineering design and simulation. Converge is the first and only dedicated version control and history analysis tool for Modelica models. Designed purely for comparing revisions of Modelica models, Converge is a workstation-based standalone tool that enables full model lifecycle management. 21

2. By Dassault Systèmes: Dymola has a Modelica translator which is able to perform all necessary symbolic transformations for large systems (> 100 000 equations) as well as for real time applications. A graphical editor for model editing and browsing, as well as a simulation environment are included. Convenient interfaces to MATLAB and the popular block diagram simulator Simulink exist. For example, a Modelica model can be transformed into a SIMULINK S-function C mex-file which can be simulated in SIMULINK as an input/output block. 3. By ESI ITI GmbH: SimulationX is a graphically-interactive tool for the holistic modeling, simulation and analysis of multi-domain systems from 1D to 3D. Multi-level customizing options and SimulationX s capability to adjust the model s complexity by mouseclick allow modeling in every step of the design process. Ready-to-use model libraries, e.g., for mechanics, multi-body systems, power transmission, hydraulics, pneumatics, thermodynamics, and electric drives are written in Modelica language. Libraries are extendable by Modelica-based modeling using the SimulationX TypeDesigner. A comprehensive API supports the integration into any CAE, CFD, CAD or database tool environment. Versatile interfaces offer plenty of opportunities for exporting models in terms of Simulink S-function and C-Code for HiL, RCP and other real-time applications. Different features (tracing, 22

performance analyzer, switchable model complexity) support users in achieving real-time-capabilities. 4. By Maplesoft: MapleSim is a high-performance multi-domain modeling and simulation tool. Systems are described in a compact and intuitive component diagram using nextgeneration physical modeling techniques, making them easier to build and understand. Model equations are automatically generated and simplified, yielding concise models and high-speed simulations of sophisticated systems. Many components in MapleSim are from the Modelica Standard Library, and all MapleSim models and components can be exported to Modelica. In the near future, MapleSim will be able to access third-party Modelica libraries. Users will be able to directly import any Modelica components or libraries and seamlessly incorporate them into MapleSim models. 5. By Siemens PLM Software: LMS Imagine.Lab Amesim is a complete 1D simulation suite to model and analyze multi-domain systems and predict their performances. It provides a large variety of validated model libraries (mechanical, hydraulic, electric, thermal, control) and application oriented tools (specialized libraries, pre and post processing tools, customization features, ). The LMS Imagine.Lab Amesim platform and its dedicated solutions cover numerous application fields to address the customer s 23

specific needs for the design of powertrain transmissions, thermal management systems, vehicle systems dynamics, fluid systems, internal combustion engines, aircraft ground loads, flight controls or electrical and electromechanical systems. LMS Imagine.Lab AMESim is now able to deal with Modelica. For instance, Modelica models can be created and modified in a text editor dedicated to the Modelica language, and imported into the LMS Imagine.Lab AMESim environment so as to be linked to other model and to be simulated in the simulation environment. 6. By Suzhou Tongyuan MWorks is a Modelica-based visual modeling and simulation platform for multidomain engineering systems. It provides visual modeling studio, effective Modelica compiler and symbolic analyzer, as well as powerful postprocessors of curves, schema and 3D animation. Engineering tools, such as experiment design and multi-object optimization, are included in MWorks. MWorks supports the interfaces with CAD, FEM, Matlab/Simulink and FMI. In particular, it can import general CAD files and FEM modal data into 3D animation postprocessor, including stl, sat, hsf, 3ds, dxf and MNF formats. It is also convenient to customize and expand MWorks through C/C++ interfaces, COM components and Python scripts. 7. By Wolfram: 24

Wolfram SystemModeler is a high-fidelity modeling environment that uses versatile symbolic components and computation to drive design efficiency and innovation. It integrates with the Wolfram technology platform to enable modeling, simulation, and analysis (of many types), all together achieving the first fully agile design optimization loop. Many of today's tools are limited in their fidelity by their foundations: using block-diagrams that poorly represent key components or producing models just for simulation and not engineering analysis. Moreover, computation is numeric-only or not integrated at all. It is the SystemModeler approach of versatile symbolic components backed by the ultimate computation environment that enables an all-in-one integrated workflow. That gets you the power to model reality at high fidelity-driving insight, innovation, and results. Free Modelica Simulation Environments: 8. JModelica.org: JModelica.org is an extensible Modelica-based open source platform for optimization, simulation and analysis of complex dynamic systems. The main objective of the project is to offer an industrially viable open source platform for optimization of Modelica models, and a flexible platform serving as a virtual lab for algorithm development and research. At the core of the JModelica.org platform are compilers for Modelica and Optimica, which is 25

an extension of Modelica dedicated to formulation of dynamic optimization problems. JModelica.org also features a Python integration for scripting and custom application development, code generation to C and XML, numerical algorithms for solving dynamic optimization problems, an interface to the state of the art optimization algorithm Ipopt, and an Eclipse plugin based on the JModelica.org compilers. The JModlica.org platform is available under the GPL open source license. Part of the software is also available under the less restrictive CPL license. In addition, commercial licenses are available from Modelon AB. 9. Modelicac: Modelicac is a compiler for a subset of the Modelica language including parts of the "equation" subset that can express relations between Real variables. Modelicac is included into the Scilab distribution (although it is an independent executable) and is used by Scicos (Scilab's block-oriented editor and simulator) to handle hybrid model simulations. The following features are supported by Modelicac: Declaration of "Real" scalar variables and (statically fixed-size) arrays; Aggregation of components is supported (but inheritance is not) Modifications of parameters are supported; Declaration of equations (equalities, "for" equations, "when" equations) 26

"if" equations are not supported, however it is possible to write "if" expressions in equations. That subset of the Modelica language allows one to write most of the continuous basic models encountered in various physical domains such as electricity, hydraulics, etc. A few examples provided as Scicos demonstrations come with the Scilab distribution. Control (by way of discrete variables, algorithms, blocks, etc.) is not handled by Modelicac, however it is handled by Scicos (in fact, it is Scicos's original purpose). Hence hybrid models can be simulated under the Scicos environment in a rather transparent way: Scicos calls Modelicac on the continuous part of the model and simulates directly the remaining (discrete) part. Scilab, Scicos and Modelicac are free software: one can use them for educational purposes but also into industrial applications. 10. OpenModelica: OpenModelica is an open source Modelica environment developed and supported by Linköping University and the Open Source Modelica Consortium (OSMC) - a growing group of companies, universities, institutes and individuals. The goal of the project is to create a complete Modelica modeling, compilation and simulation environment based on free software 27

distributed in source code and executable form intended for research, teaching, and industrial usage. OpenModelica is freely available for use. It can be combined with open source software according to the OSMC-GPL license. Moreover, it can also be integrated with proprietary software according to the OSMC-EPL. The current OpenModelica release supports most of the Modelica language, including equations, algorithms, eventhandling, functions, and packages. Also included are a Modelica Eclipse plugin for advanced developers, and an electronic notebook interface for teaching (see DrModelica). Improving the compiler, a general solver interface, enhanced graphics, and Modelica-UML integration in Eclipse are examples of ongoing development activities. We invite all interested developers, researchers, and students to participate in the project. 3.4 Comparison of Modelica Simulation Environments For the purpose of the project, we had to decide on one Modelica simulation environment that would allow us to explore the capabilities and shortcomings of the Modelica language. The shortlisted the tools that would satisfy the following criteria: Compatibility with Simulink to transfer models created in a Modelica Simulation Environment 28

Availability of Hybrid Electric Vehicle component libraries Following are the Simulink capabilities of the tools as found on MathWorks Third- Party Products & Services website http://www.mathworks.com/products/connections 1. Dymola Dymola can translate a physical model to a S-function, MATLAB code, or a MEX-file which can be used as a block in Simulink Algebraic loops are automatically solved Approximate state event handling suitable real time simulation is supported 2. AMESim: Interface enables you to couple an LMS AMESim plant model with a Simulink control system model Can export from AMESim into Simulink and also into Simulink Coder, do a co-simulation between AMESim and Simulink, or import from Simulink into AMESim AMESim also offers a scripting facility with MATLAB to perform complex 3. MapleSim: and automated pre- and post-processing or to build customized graphical interfaces 29

While there was no detail available about MapleSim on the MathWorks site, according to the description on Maplesoft s website, there are add-ons available for Simulink S-function code generation Most of the commercial libraries developed by third-party developers are built for use in Dymola. 3.5 Dymola Dymola was chosen as the Modelica Simulation Environment since the models created in Dymola can be exported to Simulink and since most commercial libraries are developed for Dymola, creating our models on that allows for greater possibility of adding components to complete a Hybrid Electric vehicle model in the future. The Dymola Modeling Language was designed by Hilding Elmqvist as a part of his Ph.D. dissertation at Lund University in Sweden. At that time, the language was purely alphanumerical and formed the basis of the Modelica modeling language. The first version of the GUI that would allow users to describe a physical system using graphical objects was developed in 1981. After a hiatus of 7 years, Elmqvist created Dynasim AB to further develop Dymola. 30

The language of Dymola underwent a major revision in 1996, which resulted in a new language that we know as Modelica. Considering that the name Dymola was now available, the GUI assumed the name Dymola. Dynasim AB was acquired by Dassault Systèmes in 2006 and it began integrating Dymola with CATIA. Dymola is now available independently or alongside CATIA. The advantages of using Dymola are: Integration with CATIA V6 allows real-time 3D animation and import of CAD files Capability to interface Dymola SIMULIA tools Abaqus, isight, and Fiper for co-simulation purposes Interfacing with Simulink allows exporting of models using S-Functions or as MEX files Wide range of libraries are available from third-party developers for Dymola 31

CHAPTER 4: BATTERY MODELING IN MODELICA 4.1 Overview of Battery Modelling The battery pack is one of the most important components of an electric vehicle. It is important that the characteristics of the battery be modeled correctly to study the way it reacts to the various other components of the vehicle and vice versa. While there are plenty of ways to model a battery including modeling the electrochemical dynamics at the cell level, for the purpose of this study, we focus on 0 th and 1 st order dynamics of individual battery cells and then converting them into battery packs. We use an equivalent circuit model for cell voltage approximation as shown in Figure 8 below: 32

Figure 8- Equivalent Circuit Model for ECM Battery Modeling 4.2 0 th order Battery Model The 0 th order model only considers the low frequency dynamics of resistance R0. We create models of various components which put together form the model of the battery cell. These are classes made up of base components available in the standard library available with all Modelica Simulation Environments. One of the first things modeled was the capacity calculator as shown below: 33

Figure 9- Model of Capacity Calculator The capacity of a battery is representative of the maximum amount of energy that can be extracted from the battery. It is dependent on the temperature of the battery. The capacity calculator was modeled using a look-up table with the temperature as the input and the capacity as the output. Figure 10- Model of SOC Calculator 34

The state of charge (SOC) of the battery gives us an idea of the portion of the battery capacity that is remaining to be extracted. While there are various methods to estimate the SOC of a battery, for the purpose of this model we use current integration or Coulomb counting which depends on the capacity of the battery and the current supplied by the battery. The SOC calculator divides the current flowing through the battery by the instantaneous capacity it receives from the capacity calculator and integrates the result to calculate the SOC of the battery cell. The initial SOC is declared as a variable parameter which can be changed before the simulation begins. Figure 11- Model of Open Circuit Voltage (E0) Calculator The open circuit voltage (OCV) of a battery is the difference in the electrical potential between the two terminals of the battery when it is not connected to any circuit. It is calculated from the value of the state of charge of the battery using the OCV vs. SOC curve from data about the battery. 35

Figure 12- Model of Resistance R0 Calculator The resistance of the battery depends on the temperature of the battery cell and the SOC. This data is passed through a 2 dimensional look-up table to get the instantaneous resistance of the battery. This table changes depending on whether the battery is being charged or discharged, which is accounted for by inserting a switch which changes the value of the output depending on the sign of the value of the current. 36

Figure 13- Model of 0 th Order Parameter Calculator The parameter calculator is modeled by combining the models of the capacity, SOC, OCV and R0 calculators. The input for this model is the temperature of the battery and the current flowing through the battery. The values of capacity and SOC are outputs of this block, though they are not required outside this model. The outputs of open circuit voltage and resistance will be used to assign values to the voltage and resistor blocks. 37

Figure 14-0 th Order Battery Model The 0 th order battery model is created using SignalVoltage and VariableResistor blocks available in the standard Modelica library along with the parameter calculator block which was modeled as shown above. The heat port permits the model to read the temperature of the battery and can be used for adding thermal dynamics in the future. 38

Figure 15-0 th Order Battery Model Simulator The 0 th order battery model is then connected in a circuit with a current load and simulated. The results of the simulation are shown below in Figure 16: 39

Figure 16-0 th Order Battery Model Simulation Results The negative current signifies current flowing into the battery or charging and the positive current signifies discharging. We see that as the battery is being charged, the SOC of the battery increases and along with it, the OCV of the battery cell increases. However the increase in the value of OCV is much smaller than the value of the voltage across the resistance due to which the dynamics of the change in OCV are not clearly visible in the plot of the battery voltage. 40

To simulate two cells in parallel, we copy and paste the battery cell in the simulator model shown in Figure 15 and connect the cells as they would be connected in a physical circuit as shown below. Figure 17-0 th Order Battery Cell Parallel Simulator The results of connecting the two battery cells in parallel are shown below and compared to the results obtained from the single cell simulator with the results of the simulation with the cells in parallel show in blue and those of the single cell shown in red. 41

Figure 18-0 th Order Battery Cell Parallel Simulation Results From the results of the simulation with the 2 cells in parallel, we see that the increase/decrease in the SOC is halved compared to the simulation with the single cell. This is representative of the fact that the current flowing through each cell is half of the current that was flowing through the cell during the single cell simulation. The battery voltage reduces while charging and increases while discharging as compared to the single 42

cell. This is due to the decrease in the overall resistance of the cell combined which is brought about by connecting the cells in parallel. To simulate the results of connecting 2 battery cells in series, we place two battery cells in the model and connect them as follows: Figure 19-0 th Order Battery Cell Series Simulator 43

Figure 20-0 th Order Battery Cell Series Simulation Results From Figure 20 above, we see that the curve followed by the SOC and E0 for each cell in series is same as those followed by that of the single cell battery simulated in Figure 15 since the current flowing through each cell would be the same. The overall voltage across the 2 battery cells in series is double that of the single cell. 44

4.3 1 st Order Battery Model The 1 st order battery model is created by modeling the equivalent circuit model shown in Figure 8 and considering values of R0, R1 and C1. All the other values of R and C are considered to be zero. To calculate the values of R1 and C1, we create models of R1 and C1 calculators with look-up tables similar to the R0 calculator found in Figure 12. These are then added to the parameter calculator show in Figure 13 to get the new model as shown below: Figure 21- Model of 1 st Order Parameter Calculator Using the parameter calculator and 1 st order equivalent circuit arrangement, we model the 1 st order battery model as follows: 45

Figure 22-1 st Order Battery Model Making modifications to the 0 th order model developed previously to add the resistor and capacitor in parallel, to the pre-existing capacitor is quite easy and quick to do, especially when compared to the time and effort that would be required to make the same changes for a model in Simulink. The first order battery model is simulated using a simulator as shown below. 46

Figure 23-1 st Order Battery Model Simulator The 1 st order battery model simulator shown in Figure 23 looks essentially the same as that shown in Figure 15, except the battery cell that can be seen has been modified and not has 1 st order dynamics. 47

Figure 24-1 st Order Battery Model Simulation Results From Figure 24 we see that the dynamics of the battery voltage have changes substantially compared to the 0 th order results due to the dynamics of the additional resistance and the capacitance. 48

4.4 1 st Order Battery Pack Model A battery pack can be made up of multiple cells connected in different combinations of cells in series and parallel. For the purpose of this study, we consider the pack made up of cells in the PS configuration as shown below in Figure 25. Figure 25- Battery Pack PS Configuration For modeling the battery pack with Modelica, we move away from the graphical interface and look at manipulating the Modelica code. We take advantage of the fact that since Modelica is an Object Oriented Programming (OOP) language, every model is a class and we can create arrays of any component. The number of cells in series and parallel are declared as parameters so that they can be edited easily before the simulation. Since the 49

connections are a type of class in the Modelica language, even the connections between the battery cells can be made by writing code. This reduces the effort on the modelers end in connecting each component. Figure 26- Battery Pack Modelica Text From the code shown in Figure 26 above, we see that we can declare the number of elements of the battery cell in an array depending on the number of cells you would like in series and parallel. They elements of the array can be connected using for loops. The initial value of the SOC for the entire battery pack is declared as a parameter as well, similar to the case of the single cell. 50

The simulator for the battery pack can be seen below in Figure 27. Figure 27- Battery Pack Simulator Without the battery pack, we were able to simulate multiple cells but effort had to be taken to create multiple instances of the model/class of the battery cell and they had to be connected together. This effort is eliminated by writing the code for the battery pack. This is particularly helpful when the number of cells to be simulated is greater. 51

Figure 28- Battery Pack Simulator On providing a current load similar to the one shown in Figure 24, we get the following results for the simulations where the configuration of the battery cells in the pack are 1P2S (Series), 2P1S (Parallel) and 2P2S (2 columns of 2 cells connected in series are connected in parallel). The results show the curves followed by the pack voltage and the individual cell voltage in each simulation. 52

6.72 PackVoltage 6.68 6.64 6.60 0 1000 2000 3000 4000 5000 3.36 BattVoltage 3.34 3.32 3.30 0 1000 2000 3000 4000 5000 Figure 29- Battery Pack 1P2S (Series) Configuration Results 3.33 PackVoltage 3.32 3.31 3.30 3.29 0 1000 2000 3000 4000 5000 3.33 BattVoltage 3.32 3.31 3.30 3.29 0 1000 2000 3000 4000 5000 Figure 30- Battery Pack 2P1S (Parallel) Configuration Results 53

6.66 PackVoltage 6.64 6.62 6.60 6.58 0 1000 2000 3000 4000 5000 3.33 BattVoltage 3.32 3.31 3.30 3.29 0 1000 2000 3000 4000 5000 Figure 31- Battery Pack 2P2S Configuration Results From Figure 29, we can see that when the cells are kept in series, the profile of the curve followed by the individual cell is same as that followed by the cell in Figure 24. Since there are 2 cells arranged in series, the potential difference across the pack is double that of the individual cell. When the cells are connected in parallel, we see in Figure 30 that the dynamics of the voltage across the individual cells change compared to those in Figure 24. The potential across the individual battery cells and the battery pack are the same and we know that the voltage between the two same points must be the same. 54

On connecting the individual cells in the 2P2S configuration which would have two columns, each with 2 cells connected in series, being connected in parallel. The results of simulating that configuration are shown in Figure 31, where the voltage across a single cell is the same as that found in Figure 30 however the pack voltage is double due to the cells being connected in series as well. While this method of designing a battery pack can help us create a model with interconnected cells and can be useful to study how cells would behave when connected together, as the number of cells increase, the computational effort increases since the number of equations for each cell get multiplied by the total number of cells. Due to this, when we need to model a battery pack in conjunction with other models, we manipulate the value of the voltage, capacitance and the resistances so that the computation time and effort is the same as simulating a single cell. The equations used to manipulate the model are: V V N R C pack cell series pack pack R C cell cell N N N N i i / N series parallel parallel series cell pack parallel This is modeled as: 55

pin_p gain4 k=1/parallelcolumns gain3 k=parallelcolumns/seriesrows gain2 k=seriesrows/parallelcolumns gain1 k=seriesrows/parallelcolumns gain C1 R1 R0 E0 SOC Cap i temperaturesensor1 T degc HeatPort k=seriesrows pin_n Figure 32- Battery Pack (Cell to Pack) Model We see below that this model gives us a voltage profile for the cell to pack model which is equal to that obtained by simulating the interconnected cells. 56

3 Current 2 1 0-1 -2-3 0 1000 2000 3000 4000 5000 PackVoltage(2P2S) Interconnected PackVoltage(2P2S) Cell to Pack 6.64 6.62 6.60 6.58 0 1000 2000 3000 4000 5000 Figure 33- Comparison of Cell to Pack and Interconnected cell battery 4.5 Exporting Battery Models to Simulink There are various tools which allow a model created in a Modelica simulation environment to be exported to Simulink like the FMI Toolbox for MATLAB/Simulink developed by Modelon. Dymola 2016 FD01 has two interfaces which can be used to export a model created in Dymola to Simulink. These are the DymolaBlock and the FMU Blocks which can be made available in the Simulink Library. 57

Figure 34- DymolaBlock in Simulink Library Browser The DymolaBlock block is a shield around an S-function MEX block, i.e. the interface to the C-code generated by Dymola for the Modelica model. The FMI block allows the user to import a Functional Mockup Unit (FMU) file which can be exported from Dymola. The Functional Mockup Interface (FMI), according to its website https://www.fmi-standard.org/ is a tool independent standard to support both model exchange and co-simulation of dynamic models using a combination of xml-files and compiled C-code. To export a model created in a Modelica simulation environment, some changes need to be made to the model before exporting it. Since a Simulink block must have inputs and outputs, we need to modify the model according to the variables known and unknown. In Figure 35 we see the model of the Battery Simulator modified to make the battery 58

temperature and the current flowing through the battery as the inputs, and the battery voltage as the output. Figure 35- Battery Simulator model for export to Simulink The simulator model can then be imported into Simulink using the DymolaBlock block from the Simulink Library. The interface to import a model using DymolaBlock can be seen below in Figure 36. 59

Figure 36- Interface for DymolaBlock in Simulink Once the file to be imported is selected and the path is entered, the block is compiled to create a Simulink block with the respective inputs and outputs as shown in Figure 37. 60

Figure 37- Compiled DymolaBlock for Battery Simulator in Simulink The compiled DymolaBlock is then given inputs of the battery temperature and the current and the battery voltage is recorded as shown below in Figure 38. Figure 38- Simulink model with Battery Simulator DymolaBlock 61

The Simulink model of the Battery simulator shown in Figure 38 is simulated and the output of the battery voltage is compared to the output voltage of a model of the battery cell made in Simulink using the basic equations of a 1 st order battery pack. The results of the simulation times and the RMS error in the voltage of the DymolaBlock output compared to the output of the Simulink model is shown below in Figure 39. Figure 39- Table of comparison of Simulink and DymolaBlock All the simulations for the results show above in Figure 39 were 5000s long simulations run in Simulink using the ODE45 (Dormand-Prince) solver on an Intel i7 2GHz processor with 8GB RAM. From the comparison we see that while the simulation time of the model created completely in Simulink is not much more than the model with the DymolaBlock, the difference in the simulation time becomes much larger when a battery pack of 3P3S configuration is simulated. The model using the DymolaBlock is able to run much faster because it already has the Dymola model compiled into an S-function and can run much faster. The RMS error in the value of the voltage obtained using the DymolaBlock as 62

compared to the model made in Simulink over the entire simulation time is almost negligible so it would be safe to conclude that the outputs are almost identical. 63

CHAPTER 5: ELECTRIC DRIVES MODELING IN MODELICA 5.1 Overview of Electric Drives Electric vehicles can be designed using various configurations. Some of the most common configurations are pure electric, series hybrid and parallel hybrid. In a purely electric vehicle, the wheels are powered by motors which are connected to a battery. The series hybrid has a machine connected to a battery and the battery can be charged using an internal combustion engine. In a parallel hybrid, the torque required at the wheels is produced by both, the engine and the motor and coupled together. In all of these configurations, the few components that are constant are the motor/generator, battery, and the inverter that is used to connect the two. For the purpose of this study, we will look at these three components. While we have developed a model for the battery, it is important to acknowledge the availability of the various models and their fidelities that have been created by other developers over the years and are available, some for free and some for which a library must be bought. For the electric drives model, we use components models by other developers. 64

perunitref duration=1 blcontroller threephasedcac AC DC batteryideal hallsensor ground timetable torque Y tau offset=0 smpm Figure 40- PMSM operated in Brushless DC mode The figure above shows the model for simulating a PMSM in brushless DC mode which is a part of the Smart Electric Drives library that can be bought for use in Dymola. This library is developed and maintained by the Mobility Department at AIT Austrian Institute of Technology GmbH. 65

Figure 41- Parameters for PMSM operated in Brushless DC mode We can change the values of various parameters for the simulation which allow us to model different scenarios with different physical and electrical characteristics. 66

5.2 Electric Machine Model The electric motor/generator can be used to deliver the requested torque or to charge the battery by performing regenerative braking. For this we use the Permanent Magnet Synchronous Machine (PMSM) that is available for free in the standard Modelica library. Figure 42- Permanent Magnet Synchronous Motor model 67

From Figure 42 we see that the model available with the standard library is a high fidelity model which models the mechanical, electrical dynamics of the motor and accounts for variations in dynamics with variation in the thermal conditions as well. 5.3 Inverter Model The inverter comprises of the 3 phase DC to AC converter and the controller that gives the signals to the gates of the DC to AC converter. The DCAC converter is modelled using switches and ideal diodes as follows: 68

psupply vsupply u nsupply vdc pload Figure 43- Three Phase DC to AC converter 5.4 Simulating the Electric Drive We simulate the electric drive by giving the requested torque values to see the dynamics of the motor and the battery. 69

Figure 44- Simulation of Electric Drive In the simulation, the time from zero to one second signifies the PMSM reaching the nominal speed and after that the load is applied which results in the fluctuating torque generated by the electrical machine. 70

200 Three Phase Output Current - Pin 1 100 0-100 -200 0 2 4 6 8 10 12 14 16 18 20 200 Three Phase Output Current - Pin 2 100 0-100 -200 0 2 4 6 8 10 12 14 16 18 20 200 Three Phase Output Current - Pin 3 100 0-100 -200 0 2 4 6 8 10 12 14 16 18 20 Figure 45- Inverter 3 Phase output current Figure 45 shows the 3 phase output current which goes from the DC to AC converter to the electric machine. While the dynamics of the current is not clearly visible in this figure, we can take a closer look at it in Figure 46 where we see the dynamics of the current at the pins of the 3 phase output as the requested torque increases. 71

100 Three Phase Output Current - Pin 1 0-100 1.0 1.1 1.2 1.3 1.4 1.5 100 Three Phase Output Current - Pin 2 0-100 1.0 1.1 1.2 1.3 1.4 1.5 100 Three Phase Output Current - Pin 3 0-100 1.0 1.1 1.2 1.3 1.4 1.5 100 Requested Torque 50 0 1.0 1.1 1.2 1.3 1.4 1.5 Figure 46- Inverter 3 Phase output current with requested torque In the figure above, we can see that the value of the current increases to cope with the increase in the requested torque and that the 3 current profiles are at a phase angle of 120 degrees with each other. 72

Figure 47- PMSM operated in Brushless DC mode with 1 st order battery In the figure above, we replace the ideal battery with the 1 st order battery model we developed as shown in Chapter 3. It is extremely convenient to switch the two battery models. 73