Dirac structure KDS Kirchhoff Dirac structure PCH Port-Controlled Hamiltonian PH Port-Hamiltonian MPC Model Predictive Control KiBam Kinetic Battery Model MPPT Maximum Power Point Tracking PMSM Permanent Magnet Synchronous Machine MTPA Maximum

Thanks

This thesis is the result of three years work within the LCIS laboratory of Grenoble INP, Valence, France, with funding from the European project Arrowhead. During this important period of my life, I received a lot of help and support from many people to make this work fruitful. I take this opportunity to express my gratitude to all of them.

First of all, I wish to thank my supervisors, Mr. Laurent LEFEVRE, Ms. Ionela PRODAN and Mr. Denis GENON-CATALOT. Four years ago, Laurent gave me a chance to do a research internship at LCIS which was a huge challenge for me at that time. This continued with a PhD thesis. With his supervision and support, I did not feel any pressure, just the passion which motivated me to advance my works. To Ionela, my nearly direct supervisor, I will never forget the thousand of hours she spent discussing my works, correcting my papers and showing me how to work efficiently. I also thank to Denis for his great support on the industrial collaboration and constant communication with a friendly smile. To all of them, I truly appreciate their kindness and availability for answering my questions and provide help whenever I needed. Moreover, by sharing my social life with them through numerous friendly dinners and outdoor activities, I believe that they are also my friends with whom I feel free to express my opinion and emotion. Working with them has been my most valuable professional experience and founds my first steps in the research.

I wish to thank to the jury members who spent their time and effort to evaluate my thesis, Mr. Bernard MASCHKE, Mr. Damien FAILLE, Ms. Françoise COUENNE and Ms. Manuela SECHILARIU. I am grateful to the reviewers, Ms. Françoise COUENNE and Ms. Manuela SECHILARIU, for accepting to review my thesis, and for their insightful remarks which helped in improving the quality of the manuscript.

During these last years, I also had the chance to discuss with many people on different research topics. I thank to Ms. Trang VU, former PhD student at LCIS, for the fruitful discussions on the modelling method. I am thankful to Mr. Cédric CHOMEL, head of the electric R&D project at SODIMAS, France, for his scientific collaboration. I thank also to Mr. Thang PHAM, former researcher at LCIS, for his supervision during my first months in the laboratory. I thank to Mr. Florin STOICAN, associate professor at UPB, Romania, and visiting researcher at LCIS, for his kind discussions on various theoretical problems. I also thank to Ms. Chloé DESDOUITS, PhD student at Schneider Electric, for helping me on some practical informations.

Furthermore, I am grateful to the LCIS assistant team who helped me easily integrate to the research life of the laboratory. Firstly, Ms. Jennyfer DUBERVILLE and Ms. Carole SEYVET, the LCIS secretaries, were always available to get through the administrative issues, this giving me more time to focus on the research works. I also take this opportunity to thank everyone in the computing service, Mr. Cedric CARLOTTI and Mr. Karim Oumahma, for their important technical support. I am thankful to Mr. André LAGREZE, associate professor at LCIS, for organizing sportive activities which got me out of the office and allowed me to refresh.

A huge thanks to my international friends, Silviu, Lai, Huy, Thinh, Mehdi, Antoine, Ayoub, Khadija, Thanos, Igyso, Youness, Guillaume, through whom I update the news and with whom I share my research life. I also acknowledge the presence and help of the vietnamese families of Mr. Hieu, Mrs. Le, Mrs. Trang, Mrs. Tien as well as the vietnamese students Tin, Phuoc, Thong, Anh, Hung, Lap, Hai, Loc, Linh, Vuong. I will always remember our holidays celebrations, the birthday parties and the new member welcomes.

Finally, I want to dedicate my biggest thank to my family, my father, my mother and my brother, who always stood by my sides and made me stronger whenever I felt weak. I thank them for always believing in me and in all my decisions. i

Notations

DC microgrids

The capacity of a process to provide useful power (defined as the variation of the energy characterizing that process) has been one of the transforming elements of human society. Energy exists in a variety of forms, such as electrical, mechanical, chemical, thermal, or nuclear, and can be transformed from one form to another [EIA, 2017]. Energy sources are divided into two groups: renewable energy (e.g., solar energy, geothermal energy, wind energy, biomass) or nonrenewable energy (e.g., petroleum products, hydrocarbon gas liquids, natural gas, coal, nuclear energy). They are called the primary energy sources. However, to transport energy from one place to another we need the energy carriers, also called the secondary energy sources, e.g., the electricity and the hydrogen. In this thesis, we only discuss about the electricity carrier. The network of transmission lines, substations, transformers which delivers electricity from the energy sources to the energy consumers is called the electrical grid [Smartgrid.gov, 2017]. However, the conventional electrical grid are facing many challenges which can be outlined as follows.

• The increasing of the power demands causes the network power congestion when the available power from the energy sources is limited. This frequently leads to a "blackout" which spreads rapidly due to the lack of the communication between the grid and the control centers.

• Without the information about the available energy the customers can not make optimal decisions to reduce the electricity consumption during the expensive peak period.

• The conventional grid is not flexible enough to support the power fluctuation caused by the renewable energies.

• There are many regions where the energy consumers can not easily reach the global electrical grid, e.g., in the forest, in the desert.

The last challenge motivates the use of a local electrical grid, called a microgrid, which can work without the connection with the global electrical grid. What is a microgrid? The U.S. Department of Energy calls it "a group of interconnected customer loads and Distributed Energy Resources (DER) within clearly defined electrical boundaries that acts as a single controllable entity that can connect and disconnect from the grid (known as "islanding")" [Shireman, 2013] (see also Fig. 1.1.1). DERs are small power sources that can be aggregated to provide the power necessary to meet a regular demand [Haas, 2017]. Thus, the DER implies the distributed energy storage system and the distributed energy generation system, i.e., the renewable energy source. The distributed energy generation systems are integrated to the local system to reduce the impact on the environment of the fossil fuel resources. However, the electricity price of the external grid varies during a day. It may be expensive when the energy demand is high. Moreover, the power supplied by the distributed energy generation system is unstable. Consequently, the distributed energy storage system is used to store energy when it is available and cheap. Then, it is reused in the contrary case. In microgrids, all the components are connected to a common bus (transmission lines) through converters. There are two types of microgrids: AC (Alternative Current) and DC (Direct Current). A microgrid is called AC or DC if its components are connected to the AC or DC transmission lines, also called AC or DC bus. The microgrid topology which characterizes the power interconnections within the microgrid is defined by the topology of transmission lines. There are three types of microgrid topologies: radial, ring-main and meshed [START_REF] Bucher | Multiterminal HVDC networkswhat is the preferred topology[END_REF]. Each one of these topologies having their advantages and disadvantages. Note that the network Figure 1.1.1: A typical microgrid system [START_REF] Prodan | Fault tolerant predictive control design for reliable microgrid energy management under uncertainties[END_REF].

design is usually chosen according to a planning criteria, i.e., cost reliability, contingency and the like. The microgrids are an important innovation for the society due to the following reasons.

• Through microgrids, people in isolated regions can access to the electricity.

• The microgrid motivates the integration of renewable sources to the energy system. This reduces the bad impacts of the fossil fuel to our environment.

• Due to the declining cost of renewable sources and the rising cost of fossil fuels, the incorporation of the renewable energy into the local energy system (microgrid) will make attractive values for the small and medium enterprise.

• Microgrid controllers regulate and optimize operations of various DERs. This makes the DERs more manageable and thus, simplifies the global energy management.

• Through the islanding mode, the microgrid improves the energy reliability of the electrical grid for essential emergency response facilities (e.g., police stations, hospitals, military operations).

Since the microgrid is a complex system, there are many problems to be studied such as:

1. What is the suitable control architecture to deal with the computation and communication limits?

2. How are the microgrid components modelled such that necessary properties are taken into account, e.g., time scale, power transfer?

3. How is the microgrid controlled such that the energy dissipation or the energy cost is minimized?

4. How can we integrate various components with different physical characteristics to the microgrid?

5. What are the suitable topologies?

6. How can we integrate control algorithms to the physical microgrid?

7. What is the control algorithm which guarantees the power demand satisfaction when faults occur?

To answer to some of these questions a literature review on the existing modelling approaches, control methods and the architectures are presented in the following.

DC microgrids from a control theoretic perspective

The control algorithm plays an important role in the implementation of the microgrid. Embedding controllers in microgrids allow to manage loads and DERs in order to avoid blackouts, optimize operations of microgrid components and deal with the power fluctuation of the renewable source. The implementation of the microgrid in our modern life is an active subject in the industry community through various successful projects. A student team at Eindhoven University of Technology invents the first solar-powered family car [START_REF] Tu/E | Student team unveils world's first solar-powered family car[END_REF]. Tesla enterprise started to build "smart" roofs for houses which have PV panels and reduce to 0 the electricity spendings [Fehrenbacher, 2017]. Moreover, Schindler enterprise introduced the solar elevator in 2013 which can serve the passenger during a power outage [START_REF] Zemanta | Solar powered elevators on their way to the U.S[END_REF]. The energy efficiency in gridconnected elevator systems is also considered in the Arrowhead project [Arrowhead, 2017]. Currently, the solar-powered plane which aims at flying around the world without fuel is studied within the Solar Impulse project [Solar.Impulse, 2017].

The study of complex dynamical systems is a fundamental control issue. Microgrids are complex energy systems since they include many subsystems of different natures (e.g., mechanical, electrical, electronic, magnetic, thermodynamic, chemical), with different characteristics and time scales. The control decisions are expected to be derived and implemented in real-time. Feedback started to be used extensively to cope with uncertainties of the system and its environment.

The issues faced when dealing with such complex systems include:

• Modelling methods: they should explicitly describe the useful properties of the microgrid, e.g., suitable time scale, energy conservation [START_REF] Pham | Port-Hamiltonian model and load balancing for DC-microgrid lift systems[END_REF][START_REF] Schiffer | A survey on modeling of microgrids: from fundamental physics to phasors and voltage sources[END_REF].

• Reference profile generation: gives indications for the DERs to track while taking into account future predictions [Pham et al., 2015a, Pham et al., 2017].

• Efficient energy management: it optimizes some economy or technology criteria, e.g., electricity cost, computation time. Note that there are mathematically two types of criteria (objective functions): finite-dimensional cost [START_REF] Larsen | Distributed control of the power supply-demand balance[END_REF],Stegink et al., 2017] and continuous-time cost [START_REF] Parisio | Stochastic model predictive control for economic/environmental operation management of microgrids: an experimental case study[END_REF], Pham et al., 2017].

• Control architecture: it handles the structure of the control law and the communication topology for the microgrid.

• Constraint handling: it aims at formulating the constraints in the control design.

• Stability: this implies the reference tracking problems within the microgrid components and the power balance among them [START_REF] Alamir | Constrained control framework for a stand-alone hybrid[END_REF], Zonetti et al., 2015, Schiffer et al., 2016a, de Persis et al., 2016, de Persis and Monshizadeh, 2017]. The power balance in the DC microgrid corresponds to the DC bus voltage control in the fast time scale where the DC bus dynamics are considered.

• Robustness: this guarantees the planned microgrid operation despite disturbances.

• Fault tolerant control: aims at guaranteeing the load power satisfaction under unexpected events, e.g., when some of the generators fails to provide power to the other microgrid components [START_REF] Prodan | Fault tolerant predictive control design for reliable microgrid energy management under uncertainties[END_REF].

The above enumerated objectives require different modelling approaches (or models), control design methods and control architectures.

Modelling

As previously mentioned the microgrids are complex energy systems containing heterogeneous components distributed in space and time. This makes the modelling of the microgrid system a complicated task. There are different modelling methods employed in the literature, of course depending on the control objectives.

Fuzzy modelling is a system representation based on the fuzzy sets [START_REF] Takagi | Fuzzy identification of systems and its applications to modeling and control[END_REF]. The consequences are linear models which describe the system for different operating points. This method is used to forecast the renewable and load powers in the microgrids while taking into account the power uncertainty [START_REF] Sáez | Fuzzy prediction interval models for forecasting renewable resources and loads in microgrids[END_REF]. The obtained model does not explicitly exhibit the underlying power-preserving structure of the microgrid.

Agent-based modelling can be defined as a three-tuple comprising of a set of agents (homogeneous or heterogeneous), an environment and the ability to negotiate and interact in a cooperative manner [Wooldridge, 2002]. An agent can be a physical entity, e.g., the distributed energy storage unit [START_REF] Lagorse | A multi-agent system for energy management of distributed power sources[END_REF], or a virtual entity, e.g., a piece of software which provides the electricity price or stores data [START_REF] Dimeas | Operation of a multiagent system for microgrid control[END_REF]. It has a partial representation of the environment, e.g., in the power system, an agent may only know the voltage of its own bus. This characteristic allows the agent-based control of complex system with a little data exchange and computation demands. An agent communicates with other agents and autonomously makes decisions. Agent-based modelling for the microgrid are studied in numerous works such as [START_REF] Dimeas | Operation of a multiagent system for microgrid control[END_REF], Krause et al., 2006, Weidlich and Veit, 2008, Jimeno et al., 2010, Lagorse et al., 2010]. However, the microgrid model obtained by this approach does not explicitly take into account the dynamics of the individual components. Thus, the system properties are not fully considered.

Differential equations-based modelling describes the system through a set of differential equations [Khalil, 2002]. It allows an explicit representation of the system dynamics which are derived from the physical constitutive equations and balance equations such as Newton's law, Ohm's law, Kirchhoff's law, Lenz's law etc. The obtained model captures the system natural property [Paire, 2010, Alamir et al., 2014, Lefort et al., 2013, Prodan et al., 2015, Parisio et al., 2016, dos Santos et al., 2016]. However, this system description does not explicitly exhibit the underlying power-preserving structure and the energy conservation.

Port-Hamiltonian modelling describes a system as a combination of power-preserving interconnections, energy storages, resistive elements and the external environment [Duindam et al., 2009, van der Schaft andJeltsema, 2014]. The interconnection is expressed by algebraic relations of conjugate variable pairs (whose product is a power), e.g., the Kirchhoff's laws for the currents and the voltages in an electrical circuit. The energy storages and the resistive elements represent the subsystems where the energy is stored and dissipated, respectively. The external environment represents control actions, other systems or energy sources. The system model may be graphically described by a Bond Graph. From this graph, the system dynamics may be automatically derived as a set of algebraic and differential equations. Usually, they reduce to the differential equations written in a specific form. In [START_REF] Zonetti | Modeling and control of HVDC transmission systems from theory to practice and back[END_REF], Benedito et al., 2017], this approach is used to model the transmission lines and/or the system of converters in DC microgrids. Similar approach have been applied for the AC microgrid in [START_REF] Stegink | A unifying energy-based approach to stability of power grids with market dynamics[END_REF][START_REF] Schiffer | A survey on modeling of microgrids: from fundamental physics to phasors and voltage sources[END_REF]. However, none of previous works consider the slow time scale models for the distributed energy resources (DERs). This will be one of the contributions of the present thesis.

Control approach

The main objective in the load balancing for microgrid systems is to generate the real-time power references which need to be tracked by the local component controls in the faster time scale. Note that microgrid components are strongly nonlinear and must satisfy various constraints, e.g., the battery charge limits, the maximal power supplied by the external grid. To deal with the presented objective and the nonlinearity, different control approaches used in the literature are presented in the following.

Passivity-based methods exploit a physical system property which is the energy balance [START_REF] Ortega | Putting energy back in control[END_REF]. By choosing the suitable desired stored and dissipated energies of the closed-loop system we derive the control law through the matching equation. The passivity-based control is efficient to deal with the passive nonlinear system since it makes use of the stored energy in the system as the Lyapunov function. This method is used for the stabilization of the transmission lines and of the system of converters in AC microgrid [Schiffer et al., 2016a, de Persis et al., 2016, de Persis and Monshizadeh, 2017] and in High Voltage Direct Current grid [START_REF] Zonetti | Modeling and control of HVDC transmission systems from theory to practice and back[END_REF]. However, this method is not suitable for the non-passive and/or constrained systems.

Gradient-based methods formulate the constrained optimization problem of the controller as a virtual dynamical system such that the steady state of the virtual dynamics corresponds to the solution of the optimal control problem [START_REF] Feijer | Stability of primaldual gradient dynamics and applications to network optimization[END_REF]]. This virtual system is derived using the Karush-Kuhn-Tucker conditions (see also Section 5 Chapter 5 in [Boyd and Vandenberghe, 2004]). The presented method allows to take into account constraints and optimization cost in the control design. It is used to optimize the power distribution within the microgrid [START_REF] Stegink | A unifying energy-based approach to stability of power grids with market dynamics[END_REF], Li et al., 2016, Benedito et al., 2017]. However, the previous works do not take into account the electrical storage system dynamics, the renewable and load power prediction which are essential for the microgrid energy management.

Constrained optimization-based control formulates the control law as the solution of an optimization problem. A popular method of this approach is the dynamic programming based on the Bellman's principle (principle of optimality), i.e., an optimal policy has the property that what ever the initial state and initial decisions are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision [Bellman, 1957, Liberzon, 2011]. This control method is used to find the DERs power profiles in the microgrid [START_REF] Costa | A stochastic dynamic programming model for optimal use of local energy resources in a market environment[END_REF], Handschin et al., 2006, Bilbao et al., 2014]. However, since the control law at a given instant depends on laws at the previous instants, previous control laws must be kept during the computation process. This makes the computation complex. The reference power profiles for the DER can be also found off-line (before the system operation) [START_REF] Lifshitz | Optimal control of a capacitor-type energy storage system[END_REF], Pham et al., 2015a, Touretzky and Baldea, 2016]. However, this methods is not robust in real-time control.

Another type of the optimization-based control is the Model Predictive Control (MPC) [START_REF] Rawlings | Model Predictive Control: Theory and Design[END_REF]. It finds the optimal open-loop control sequence at each time instant and applies the first control action as the system input. For the reference tracking objective in the tracking MPC, optimization costs usually penalize the discrepancies between the actual and reference signals. If it is not the case, i.e. the cost function penalizes an economic cost such as the dissipated energy or the electricity cost, we call it the economic MPC [START_REF] Ellis | Economic Model Predictive Control[END_REF]. This MPC type is used to generate the reference profiles for controllers in faster time scales. In [START_REF] Prodan | A model predictive control framework for reliable microgrid energy management[END_REF], Desdouits et al., 2015, Parisio et al., 2016, dos Santos et al., 2016], the economic MPC is used to generate on-line the power reference profiles for the DERs. This will be the main focus of the present thesis.

Robust optimization formulates an uncertainty-affected optimization problem as a deterministic program whose solutions are feasible for all allowable realization of the data [START_REF] Bertsimas | Robust discrete optimization and network flows[END_REF]. This method is used to generate the reference power profiles for the microgrid components with the model parameter uncertainties in [START_REF] Battistelli | Optimal energy management of small electric energy systems including v2g facilities and renewable energy sources[END_REF]. This method can be used with the MPC to improve it robustness. However, since we have not systematically considered uncertainties for microgrids in this thesis yet, using the robust optimization method may make control algorithms more complex.

To improve the efficiency of the microgrid control, different control strategies are studied in the literature which will be discussed in the next subsection.

Control architecture

From the presented modelling and control problems of the microgrid, we can distinguish several control strategies (centralized/distributed/decentralized/-hierarchical/multi-layer) motivated by the two following reasons [Scattolini, 2009]:

-numerical complexity of the multi-objective optimization problem, -communication limitations/geographical distribution among the heterogeneous components of the micogrid system.

In the centralized architecture, a single controller collects all system outputs and gives policies for all system control variables [START_REF] Becherif | Modeling and passivity-based control of hybrid sources: Fuel cell and supercapacitors[END_REF], Alamir et al., 2014]. However, it is usually difficult to control a complex system, such as the microgrid, using a centralized controller due to limited computation capacity and/or the restricted communication bandwidth. Thus, the decentralized architecture is employed where the control and controlled variables may be partitioned into disjoint sets from which local regulators are designed independently [START_REF] Zonetti | Modeling and control of HVDC transmission systems from theory to practice and back[END_REF],Schiffer et al., 2016a,de Persis et al., 2016]. In the distributed architecture, some information is exchanged among the local regulators [START_REF] Larsen | Distributed control of the power supply-demand balance[END_REF],Qi et al., 2013,Zhao and Dörfler, 2015, Li et al., 2016].

Low level regulator 1 Since the microgrid components are distributed in space (geographical distribution) and in time (multitime scale dynamics) and since different control objectives are considered, for the different time scales we consider a class of the distributed architecture, the hierarchical (or multi-layer) architecture [Scattolini, 2009, Christofides et al., 2013] (see also Fig. 1.2.1). At the higher level, the regulator output variables are used as the references for the lower level control or directly applied to the system (i.e., the system input). At the lower level, the regulators aim at tracking the given references from the higher level regulators while implementing their own objectives. Furthermore, there are different ways to determine the system models in the higher control level, e.g., the steady state of the global dynamics [START_REF] Backx | Integration of model predictive control and optimization of processes: Enabling technology for market driven process operation[END_REF], the slower dynamics with the steady state of the fast dynamics [START_REF] Picasso | An MPC approach to the design of two-layer hierarchical control systems[END_REF], Chen et al., 2012] or the entire multi-time scale dynamics [START_REF] Ellis | Integrating dynamic economic optimization and model predictive control for optimal operation of nonlinear process systems[END_REF].

The multi-layer control is applied to microgrid systems in [START_REF] Paire | A real-time sharing reference voltage for hybrid generation power system[END_REF], Lefort et al., 2013, Sechilariu et al., 2014, Touretzky and Baldea, 2016, Cominesi et al., 2017]. In [START_REF] Paire | A real-time sharing reference voltage for hybrid generation power system[END_REF], the high regulator generates the reference currents for the distributed energy storage system and for the external grid by using priority rules. In [Sechilariu et al., 2014, Touretzky andBaldea, 2016], the high level regulators generate the off-line reference power for the lower level regulators as the solution of an optimization problem which takes into account the long time scale model of the microgrid components. In [START_REF] Lefort | Hierarchical control method applied to energy management of a residential house[END_REF], Cominesi et al., 2017], optimization problems in the high level regulators are solved on-line and generate the on-line power reference for the lower regulators. In the presented works, the low level regulators aim at tracking the given references from the high level controls and balance the power in the microgrid. Usually, the microgrid models used in the high and low level controls are in different time scales, i.e., slow and fast. In many cases, a good reference tracking does not respect the power balance due to the differences of the predicted power profiles in these time scales, e.g., the predicted power profiles in the slow time scale are the average approximations of the power profiles in the fast time scale. Thus, the low level regulators are separated into two different control levels [START_REF] Paire | A real-time sharing reference voltage for hybrid generation power system[END_REF], Sechilariu et al., 2014], or the tracking objectives are relaxed [START_REF] Lefort | Hierarchical control method applied to energy management of a residential house[END_REF]. However, in the presented works, the power-preserving interconnection between the slow and fast dynamics is not considered.

Thesis orientation

The literature review presented above gives evidence that the microgrid control domain is vast and disparate. In this thesis we limit ourselves to several modelling and control objectives, related and originating from a particular architecture (a DC microgrid system). We will concentrate on a particular system made of an elevator, and its auxiliary components (storage nodes, power bus, capacitive and resistive elements, etc) in the context of Arrowhead project [Arrowhead, 2017].

The main objectives of the present work is to formulate a multi-layer optimization-based control for optimizing the energy distribution within DC microgrids based on their PH models. The novelty resides in the PH model whose properties will be considered in different aspects of the control design, e.g., time discretization model, model simplification.

Two PH formulations are considered for microgrids: hybrid input-output representation [START_REF] Pham | Port-Hamiltonian model and load balancing for DC-microgrid lift systems[END_REF] and PH system on graphs [START_REF] Pham | Power balancing in a DC microgrid elevator system through constrained optimization[END_REF]. The first formulation is a compact form for multiphysic microgrids while the second formulation is not compact but captures the topology of the electrical network.

Then, two discretization methods of PH systems are investigated. The first method uses a high order B-spline-based parameterization of the system flat output [Pham et al., 2015a]. Thus, the approximated trajectory respects the continuous-time system dynamics, but is not easy to be found. The second method uses the parameterization of all the system variables based on the first-order B-splines [Pham et al., 2015a, Pham et al., 2017]. The obtained discrete trajectory does not respect the continuous-time model but still preserves the energy balance and is easy to be found.

Using the obtained models, two multi-layer control schemes are investigated. In both of them, the higher level regulators generate the optimal reference profiles for the lower level regulators to track. Their differences reside in the model discretization methods and in the relations between the models used in two layers. In the first control design, the models used in two layers are the same [Pham et al., 2015a]. In the second control design, the models in the higher and lower layers correspond to the slow and fast parts of the system.

Contribution of the thesis

This thesis extends the microgrid model in [Paire, 2010] and considers a PH representation following the ideas in [van der Schaft and Jeltsema, 2014]. We concentrate first on the elevator system and dissipative energy minimization objective. Novel combination between differential flatness with B-splines parameterization and MPC are used to design a control scheme which includes the off-line reference profile generation and the on-line tracking control. Next, the global load balancing problem is solved using the economic MPC with a PH model of the microgrid in slow time scale.

More precisely, the main contributions of the thesis are summarized in the following:

• The model of the multi-source elevator dynamical system in [Paire, 2010] is developed and rewritten in the PH formulation. Especially, the well-known Permanent Magnet Synchronous Machine model in direct-quadrature coordinate is derived using the PH framework (coordinate transformation, model reduction based on PH formulation). The microgrid PH formulation is given in an appropriate form which can be easily generalized for general DC microgrids including converters and corresponding energy devices (e.g., energy storage device, distributed energy resource system, loads and the like).

• An energy-preserving time discretization method for PH system generalized from [START_REF] Stramigioli | Sampled data systems passivity and discrete Port-Hamiltonian systems[END_REF], Aoues, 2014] is proposed. The discrete system is described in the implicit form as a combination of discrete-time interconnection and discrete-time element models. We prove that the time-invariant coordinate transformation preserves the energy conservation property of the discrete-time PH system. This method is applied for the electro-mechanical elevator system and for the global DC microgrid under different discretization schemes. The schemes are validated over numerical simulations and compared with classical Euler discretization schemes. The results show that the accuracies of the first-order methods are improved by the energy-preserving method which eliminates numerical energy dissipations or sources.

• For minimizing the dissipated energy in the electro-mechanical elevator system during an elevator travel, an optimization-based control is studied. This represents the combination of an off-line reference profile generation and on-line tracking control. The reference profiles are formulated as the solution of a continuous-time optimization problem. By using the differential flatness and B-spline-based parameterization, this problem is approximated by a finite-dimensional optimization problem of the control points corresponding to the B-splines. The novelty resides in the appropriate constraints of the control points which guarantee the satisfaction of the continuous-time constraints. Extensive simulation results prove the efficiency of the studied method.

• Load balancing for the DC microgrid is investigated by using an economic MPC approach [START_REF] Ellis | Economic Model Predictive Control[END_REF] for a simplified microgrid model. The simplified model is derived by assuming that the fast dynamics of the supercapacitor, the converter and transmission lines are quickly stabilized. Then, this model is discretized by the studied energy-preserving time discretization model. By taking into account the discretized microgrid dynamics, the electro-mechanical elevator power profile, the renewable power profile and the electricity price profile, an economic MPC is formulated. The control method is validated through simulations with the numerical data given by the industrial partner SODIMAS, in France.

Organization of the manuscript

This thesis includes 6 chapters, including this introduction (see also Fig. 1.5.1).

• Chapter 2 first recalls some notions and definitions for Port-Hamiltonian (PH) systems. Next, we develop using PH formulations the dynamical models of the multi-source elevator system components and of the global system. Furthermore, the reference profiles, the system constraints and different control objectives are introduced.

• Chapter 3 presents the energy-preserving time discretization method for the PH system and its properties. Then, the presented method is used for discretizing the dynamics of the electro-mechanical elevator system and of the global microgrid system. The proposed discretization methods are validated through some numerical simulations.

• Chapter 4 presents an optimization-based control approach for minimizing the dissipated energy within the electro-mechanical elevator. Firstly, we describe some necessary tools like differential flatness, Bspline-based parameterization and MPC. Using their properties, we formulate the optimization problems for the off-line reference profile generation and the on-line reference tracking. The control method for EME system is validated through some numerical simulations with nominal/perturbation-affected cases and with the open-loop/closed-loop systems.

• Chapter 5 studies the load balancing for the DC microgrid system using economic MPC. Firstly, the simplified microgrid model is represented using the Port-Hamiltonian formulation on graphs. Then, the economic MPC is formulated using the presented microgrid model. Some simulations are implemented to validate the proposed control method.

• Chapter 6 completes the thesis with conclusions and discussions on future directions.

The presented organization of the thesis is graphically illustrated in Fig. 1.5.1. Each rectangle box represents a chapter including various processes denoted by ellipses. Each arrow describes the relation between two processes (or chapters), i.e., the process (or chapter) at the arrow end uses results (e.g., variables, models, methods, ideas) of the process (or chapter) at the arrow origin. Chapter 2 DC microgrid modelling

Introduction

Because of the diversity of microgrid dynamics, there are many control objectives that require different models. In this work, we concentrate on two main objectives: energy cost optimization and transmission lines stability. The first one aims to generate reference trajectories or set points. The second one aims to stabilize the dynamics to the given trajectories or set points. Consequently, the previously mentioned objectives correspond to different time scales 1 of the microgrid dynamics. The energy management problem (i.e., deals with the energy cost optimization while satisfying the load requirements) relates to the slow time scale dynamics. This includes the battery dynamics, the renewable power profile, electricity price profile and statistic rules of load during a day. The transmission lines stability problem relates to the fast time scale dynamics of the transmission lines and converter.

There are various works for microgrids which consider the above objectives within different time scales. For example, in [START_REF] Zhao | Distributed control and optimization in DC microgrids[END_REF], the authors propose a distributed control approach for regulating the voltages of the DC transmission lines. The studied system is a resistor network which connects voltage sources and passive current loads. Besides, the controller guarantees the optimal power sharing within the network. The authors of [START_REF] Zonetti | Modeling and control of HVDC transmission systems from theory to practice and back[END_REF] study the combination of DC transmission lines, AC/DC converters and three-phase electrical generators. The energy sources and loads are modelled as voltage sources. Their work presents to a decentralized controller for stabilizing the transmission line voltages. Similar work for AC microgrids to control the network frequency is investigated in [START_REF] Schiffer | Conditions for stability of droop-controlled inverter-based microgrids[END_REF]. Since the previous works consider the fast time scale dynamics of microgrids, the studied models for energy sources, loads and energy storage devices are simple. For longer time scale dynamics studies, [Lagorse et al., 2010,Xu and[START_REF] Xu | [END_REF] additionally consider the limited capacities of energy storage devices and maximal available power of renewable source. However, these informations can only be taken into account instantaneously since the authors do not consider the electricity storage models for the prediction. In [START_REF] Alamir | Constrained control framework for a stand-alone hybrid[END_REF], a fast electrical storage dynamics (i.e., a supercapacitor) is considered within the DC bus controller. However, without the slow time scale dynamics of energy storage and renewable power generator, the presented model can not be used for the energy cost optimization.

Furthermore, many works study the energy cost optimization [START_REF] Lefort | Hierarchical control method applied to energy management of a residential house[END_REF], Prodan et al., 2015, Desdouits et al., 2015, Lifshitz and Weiss, 2015, Parisio et al., 2016, dos Santos et al., 2016, Touretzky and Baldea, 2016]. The authors in [START_REF] Prodan | Fault tolerant predictive control design for reliable microgrid energy management under uncertainties[END_REF],Desdouits et al., 2015,Lifshitz and Weiss, 2015] use simple models for the battery and/or transmission lines which do not entirely capture the real dynamics. Some works use a first-order model for the electrical storage unit [START_REF] Prodan | Fault tolerant predictive control design for reliable microgrid energy management under uncertainties[END_REF],Desdouits et al., 2015,Parisio et al., 2016]. In fact, the electrical storage unit (e.g., a battery) may include many sub storage parts which are connected by resistive elements. Only some of these parts can directly supply the energy. For the slow time scale, the internal charge distribution between these parts can not be ignored. Thus, a first-order model for the electrical storage unit may give incorrect informations about the real available charge. Also, in these works, the transmission lines network dynamics are simply described by a power balance relation. This is not realistic for DC microgrids where each component is placed far from the others. Hence, the resistance of the transmission lines can not be neglected.

In general, the microgrid dynamics has at least two energetic properties which may be useful for studying the energy cost optimization: the energy balance and the underlying power-preserving structure. [Lefort 1 There are three time scales corresponding to the hour, the minute and the second. et al., 2013,Touretzky andBaldea, 2016] do not take explicitly into account these properties when developing the model of the microgrid system. Thus, they may be lost while studying the energy cost optimization through the model discretization and reduction:

11

• Generally, the energy cost optimization is a continuous-time optimization problem where the solution is the time profile of control variables (see Appendix C.2). Usually, it is infeasible to find its exact solution. Therefore, we may discretize the optimization problem to obtained the finite-dimensional optimization problem which is easier to solve (details of finite-dimensional optimization problem can be found in Appendix C.1). Moreover, its discretization requires the discrete-time model of the microgrid dynamics.

• Generally, the microgrid dynamics has different time scales. To reduce the computation complexity, the energy cost optimization usually uses the slow dynamics obtained by reducing the fast dynamics of the global model using singular perturbation approach [START_REF] Kokotović | Singular perturbations and order reduction in control theory-an overview[END_REF].

Since the considered DC microgrid in this work is a multi-sources elevator system (the scheme of this microgrid is given in Fig. 2. 1.1), it is worth to mentioning that there exists an additional control objective which requires a middle time scale dynamics. This time scale, which corresponds to the elevator cabin travel2 , is shorter than the time scale of battery operation and longer than the time scale of transmission lines operation.

The above mentioned issues motivate a multi-time scale model for the DC microgrid which explicitly describes the power exchange and the system energetic structure. A well-known candidate method for this objective is the Port-Hamiltonian formulation [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]. Therefore, in this chapter, we first introduce some basic definitions and notions of Port-Hamiltonian formulations and then concentrate on the modeling of the DC microgrid multi-source elevator system through a Port-Hamiltonian approach.

This chapter contains two main contributions as follows:

• The Port-Hamiltonian models are formulated for the components of the DC microgrid, for the electromechanical elevator system and for the global system. The microgrid components include converters (AC/DC and DC/DC), electricity storage devices (battery and supercapacitor), an electrical machine and a mechanical elevator. After deriving the dynamics, we consider their steady states which relate to the system order reduction in the slow time scale dynamics of the global system. Besides, the electro-mechanical elevator system includes the AC/DC converter, the Permanent Magnet Synchronous Machine (PMSM) and the mechanical elevator. Firstly, its Port-Hamiltonian model is expressed taking into account the three magnetic fluxes of the stator coils. Next, we use the Park transformation [START_REF] Nicklasson | Passivity-Based Control of a class of Blondel-Park transformable electric machines[END_REF] and a constraint elimination process to derive the reduced-order dynamics for electro-mechanical elevator. In this model, three original stator fluxes are replaced by two fluxes, called direct and quadrature (d-q) fluxes, respectively. Furthermore, we prove that the coordinates transformation and constraint elimination for electro-mechanical elevator preserve the Port-Hamiltonian form. It leads to the reduced Port-Hamiltonian model of PMSM which is used popularly in literature [START_REF] Petrović | Interconnection and damping assignment approach to control of pm synchronous motors[END_REF]. By considering the Park transformation and the constraint elimination for electro-mechanical elevator in the framework of Port-Hamiltonian formulation, we explicitly describe their underlying energetic meanings. Finally, the global DC microgrid dynamics are derived by parallel connecting the components to the DC transmission lines. The obtained dynamics are expressed as an input-state-output Port-Hamiltonian dynamical system and a power constraint of external port variables. Moreover, it includes different time scale dynamics which will be used for different control objectives.

• Based on the introduced model, constraints and cost functions are formulated for further solving the load balancing problem. The studied constraints include the kinematic limitations of elevator, the ranges of charge levels of electricity storage units, the limited power of battery, the limit values of control signals. They are determined by the passenger request and the manufacturer. These constraints are reformulated using the energetic state variables. Then, three control objectives corresponding to three time scales are presented: regulate the voltage of transmission lines, regulate the elevator cabin position, minimize the electricity cost in a day. Three corresponding controllers are ranged from low to high, respectively. The stability of a low closed-loop dynamics is described by an additional algebraic constraint in the higher control problem. Consequently, from the presented objectives, we can derive different control problems of the microgrid in a hierarchical way which require coherent combinations of the profile generation and the profile tracking.

The organization of this chapter is as follows. Section 2.2 recalls some notions on Bond Graph representations and basics definitions of Port-Hamiltonian systems. Section 2.3 presents the Port-Hamiltonian formulation of the energy sources, transmission lines and electricity storage units. Section 2.4 formulates the dynamics of the electro-mechanical elevator by a Port-Hamiltonian formalism. In Section 2.5, the global model of the DC microgrid is derived using the fast and slow time scale separation. Based on the presented model, Section 2.6 introduces the constraints and the cost functions for the microgrid control and energy management. Finally, the conclusions for this chapter are presented in Section 2.7. 2.2 From Bond Graphs to Port-Hamiltonian formulations

Supercapacitor

Bond Graphs

Bond Graph is a graphical energetic representation for physical dynamical systems [START_REF] Sueur | Bond-graph approach for structural analysis of mimo linear systems[END_REF], Karnopp and Rosenberg, 1975, Duindam et al., 2009]. Some advantages of the Bond Graph approach are:

• it focuses on energy as the fundamental concept to appropriately model physical systems;

• It is a multi-domain representation. The same concepts and mathematical representations are used for various physical elements as for example, mechanical, electrical, hydraulic, pneumatic, thermodynamical [START_REF] Couenne | Structured modeling for processes: A thermodynamical network theory[END_REF], chemical [Couenne et al., 2008a] and the like;

• It is a multi-scale representation. The physical elements can be decomposed hierarchically in smaller interconnected components.

Each edge is called a bond and represents the bi-directional flow of the power. They are characterized by a pair of conjugated variables named the effort, e, and the flow, f , whose product is the power. The edge orientation is represented by a stroke that forms a half-arrow with the line indicating the positive power direction. Besides, the Bond Graph representation uses the notion of causality indicating which side of a bond determines the instantaneous effort and which determines the instantaneous flow. It is a symmetric relationship, i.e., when one side causes the effort, the other side causes the flow. When formulating the dynamical equations which describe the system, causality defines, for each modelling element, which variable is dependent and which is independent. A causal stroke is added to one end of the power bond to indicate that the opposite end defines the effort.

The labelled nodes are elements that can be distinguished on the basis of their properties with respect to energy. They connect to the bonds through their ports. There are nine basic nodes categorized in five groups of energetic behaviours:

• Storage nodes represent one-port elements describing the stored energy and they are denoted by C or I, e.g., the capacitance, the inductance.

• Supply nodes represent effort and flow sources having one port and they are denoted by Se and Sf respectively, e.g., the voltage source, the velocity source.

• Reversible transformers represent two-ports elements which modify the effort/flow ratio while preserving the power flow and they are denoted by T F or GY, for transformers of gyrators respectively, such as ideal electric transformer, ideal electric motor, and the like.

• The junction nodes represent multi-ports elements that describe topological constraints such as parallel and series electrical circuits. Let (f 1 , e 1 ), . . . , (f n , e n ) ∈ R 2 be the flow and effort pairs at the n ports of the 0-junction. The constitutive equations of such a 0-junction are:

e 1 = e 2 = . . . = e n , f 1 + f 2 + . . . + f n = 0,
while for the 1-junction, the constitutive equations are:

f 1 = f 2 = .
. . = f n , e 1 + e 2 + . . . + e n = 0.

• The irreversible transformation nodes which represent energy-dissipating elements are denoted by R, e.g., ideal electric resistor, ideal friction, etc.

Note that some of these elements can be modified by an external signal without changing the node nature or affecting the power balance. It is called the modulation and just some of the mentioned elements can be modulated: the supply/demand, the reversible and irreversible transformation. Moreover, to describe a complex physical system, it is necessary to replace many nodes having similar characteristics by one node. Thus, a node in a Bond Graph can have multiple ports (multi-ports) which are connected by many bonds (multi-bonds), see Fig. 2.2.2. We present in Fig. 2.2.1 an illustrative example which describes the Bond Graph of a simple DC RC electrical circuit.

Port-Hamiltonian systems

This section introduces some basic definitions and notions related to PH systems [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF] which will be further used for modelling the DC microgrid elevator system.

The central elements of PH systems are Dirac structures (DS) which describe power-conserving interconnections. By considering a vector/flow linear space F with its dual/effort linear space F * = E, we define a symmetric bilinear form ., . on the space F × F * as:

(f 1 , e 1 ), (f 2 , e 2 ) = e 1 |f 2 + e 2 |f 1 , (2.2.1)
with (f 1 , e 1 ), (f 2 , e 2 ) ∈ F×F * , and e|f denotes the duality product (power product). Next, the corresponding DS is defined as follows.

Definition 2.2.1 (Dirac structure [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]). A (constant) DS on F×F * is a subspace D ⊂ F×F * such that D = D ⊥ , where ⊥ denotes the orthogonal complement with respect to the bilinear form , . In practice, many system dynamics include constraints (for instance, three phase synchronous machine which is considered within the DC microgrid elevator system). The elimination of these constraints results in a state-modulated DS. This motivates the following definition.

Definition 2.2.2 (Modulated DS [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]). Let X be a manifold for the energy storage, with its tangent space T x X and co-tangent space T *

x X. f ∈ F and e ∈ F * are the port variables of the additional ports. A modulated DS, D(x) is point-wise specified by a constant DS:

D ⊂ T x X × T * x X × F × F * , x ∈ X.
Moreover, a physical system may be constructed from some physical subsystems. Thus, the combination of systems leads to the composition of DSs.

Consider a Dirac structure D A on a product space F 1 × F 2 of two linear spaces F 1 and F 2 and another Dirac structure D B on a product space F 2 × F 3 with the additional linear space F 3 . The space F 2 is the space of shared flow variables, and F * 2 the space of shared effort variables. We define the feedback interconnection by:

f A = -f B , ∈ F 2 , e A = e B ∈ F * 2 , (2.2.2) with (f A , e A ) ∈ D A and (f B , e B ) ∈ D B .
Definition 2.2.3. Feedback composition of DS [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]: The feedback composition of DS D A and D B , denoted by D A ||D B , is defined as

D A ||D B = {(f 1 , e 1 , f 3 , e 3 ) ∈ F 1 × F * 1 × F 3 × F * 3 | ∃(f 2 , e 2 ) ∈ F 2 × F * 2 s.t (f 1 , e 1 , f 2 , e 2 ) ∈ D A and (-f 2 , e 2 , f 3 , e 3 ) ∈ D B }.
(2.2.

3)

The DS has some important properties such as:

• the power is conserved, i.e. for all (f , e) ∈ D, e|f = 0,

• the feedback composition of DSs is again a DS.

The DS admits several representations. One of them is the constrained input-output representation which is presented by the following proposition.

Proposition 2.2.4. Constrained input-output representation of DS [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]: Every DS, D ⊂ F × F * can be represented as

D = (f , e) ∈ F × F * |f = De + G D λ, G T D e = 0, λ ∈ V , (2.2.4)
with a skew-symmetric mapping D : F → F * , a linear mapping G D such that ImG D = {f |(f , 0) ∈ D} and a linear space V with the same dimension as F.

A PH system is constructed by connecting the DS with the energy storage, the energy dissipative element and the environment through corresponding ports. Therefore, the DS ports (f , e) from Definition (2.2.1) are partitioned into energy storage ports (f S , e S ), resistive ports (f R , e R ) and external ports (f E , e E ).

Definition 2.2.5 (PH system [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]). Consider a state-space X with its tangent space T x X, co-tangent space T *

x X, and a Hamiltonian H : X → R, defining the energy-storage. A PH system on X is defined by a DS,

D ⊂ T x X × T * x X × F R × F * R × F E × F * E , having energy storage port (f S (t), e S (t)) ∈ T x X × T * x X with f S (t) = -ẋ(t) and e S (t) = ∇H(x), a resistive structure: R R = {(f R (t), e R (t)) ∈ F R × F * R |r(f R (t), e R (t)) = 0, e R (t)|f R (t) ≤ 0 } , (2.2.5)
and the external ports (f E (t), e E (t)) ∈ F E × F * E . Generally, the PH dynamics are described by:

(-ẋ(t), ∇H(x), f R (t), e R (t), f E (t), e E (t)) ∈ D. (2.2.6)
Physically, the DS describes the system interconnection which is usually constant. However, in practice, a system dynamics may be described by a PH formulation associated with port variables constraints. These constraints may be reduced. The obtained dynamics can be cast in the PH formulation with a state-modulated interconnection matrix, although the original DS is constant. This means that in the constrained input-output representation of a state-modulated DS (2.2.4), the structure matrices D, G D depend on the state variables.

We here present a popular class of explicit PH system which is called the input-state-output PH system with direct feed-through. This system admits the following assumptions:

• The resistive structure R R defined by (2.2.5) is given by a linear relation

r(f R , e R ) = R R f R (t) + e R (t) = 0, (2.2.7)
where R R is symmetric and positive.

• The structure matrices D, G D in (2.2.4) have the following formulations:

G D = 0, D(x) =    -J(x) -G SR (x) -G(x) G T SR (x) 0 G RE (x) G T (x) -G T RE (x) M(x)    , (2.2.8)
where J(x), M(x) are skew-symmetric.

Then, the explicit formulation of a PH system is written as:

ẋ(t) = [J(x) -R(x)] ∇H(x) + [G(x) -P(x)] e E (t), f E (t) = [G(x) + P(x)] T ∇H(x) + [M(x) + S(x)] e E (t), (2.2.9)
where x(t), e E (t), f E (t) are the state, input and output vectors, respectively, J(x) describes the direct interconnection of the energy state variables, M(x) describes the direct interconnection of input variables. The resistive matrices R(x), P(x), S(x) are given by the following expressions:

R(x) = G SR (x)R R G T SR (x), P(x) = G SR (x)R R G RE (x), S(x) = G T RE (x)R R G RE (x).
(2.2.10)

Since R R is symmetric and positive, R(x), P(x), S(x) satisfy the following expression:

R(x) P(x) P T (x) S(x) ≥ 0.
Furthermore, if the system interconnection is switched between many topologies (many different DSs), some additional binary variables are considered and placed in the interconnection matrices (see Chapter 13 in [van der Schaft and Jeltsema, 2014]). Especially, in the electronic circuit, the mentioned variables indicate the transistors states, i.e., 0 and 1 correspond to the closed/open states, respectively. Moreover, in the case of converters, since these states are repeatedly changed with high frequencies, one replaces the binary variables by the continuous average ones [START_REF] Escobar | A Hamiltonian viewpoint in the modeling of switching power converters[END_REF]. They are defined by the ratio of the time duration, when the binary variable is 1, and the switching cycle duration. They are named the duty cycle and denoted by d(t). Therefore, when this additional variable takes the decision role, the control signal is not only the external port variable as in the Port-Controlled Hamiltonian (PCH) system3 (2.2.9). Thus, we will consider the general class of PH systems such as:

ẋ(t) = [J(x, d) -R(x, d)] ∇H(x) + [G(x, d) -P(x, d)] e E (t), f E (t) = [G(x, d) + P(x, d)] T ∇H(x) + [M(x, d) + S(x, d)] e E (t), (2.2.11)
In many cases, J(x, d) is an affine function of the duty cycle d(t) [START_REF] Escobar | A Hamiltonian viewpoint in the modeling of switching power converters[END_REF], R(x, d) is an nonlinear function of d(t), which usually appears with the ideal model of the converter (without dynamics). Both formulations (2.2.9) and (2.2.11) will be used throughout the manuscript to describe the dynamics of the microgrid components.

Energy-supplying system

The energy-supplying system of the DC microgrid (see also Fig. 2.1.1) includes all the elements which supply the energy to the load system such as:

-the electricity storage devices (e.g., batteries and/or supercapacitor) with their corresponding power converters;

-the external energy sources (e.g., three phase electrical grid) and their associated converters;

-the renewable energy sources (e.g., solar panels) and their associated converters;

-the transmission lines (DC bus).

Converters

The converters are necessary to connect the electrical devices to the DC bus. In the multi-sources elevator system we consider two types of converters: DC/DC and DC/AC. DC/DC converter: The DC/DC converter is modelled as an ideal Cuk circuit (see Fig. 2.3.1) which can provide an output voltage lesser or greater than the input voltage [van Dijk et al., 1995,Escobar et al., 1999]. It includes two inductors L b1 , L b2 (with the corresponding magnetic fluxes φ L b1 (t), φ L b2 (t)), two capacitors C b1 , C b2 (with the corresponding charges q C b1 (t), q C b2 (t)) and a pair of switches characterized by their timeaveraged models (with the duty cycle d b (t) ∈ (0, 1)) (the reader is referred to [van Dijk et al., 1995] for the time-averaged model). We investigate the converter which connects the battery and the DC bus. Moreover, from (2.2.11), the PH formulation for the converter dynamics is derived as in [START_REF] Escobar | A Hamiltonian viewpoint in the modeling of switching power converters[END_REF]:

   -ẋ cb (t) v bb (t) i b (t)    =    -J cb (d b ) -G cb -G cbt G T cb 0 0 G T cbt 0 0       ∇H cb (x cb ) -i bb (t) v b (t)    , (2.3.1)
where the state vector includes the magnetic flux of the inductors, L b1 , L b2 , and the charges of the capacitors, C b1 , C b2 , such as

x cb (t) = [φ L b1 (t) q C b1 (t) φ L b2 (t) q C b2 (t)] T ∈ R 4 . (2.3.2)
The voltage and current at the connection point between the converter and the DC bus are denoted by v b (t), i b (t) ∈ R, respectively. The voltage and current at the connection point between the converter and the battery are denoted by v bb (t), i bb (t) ∈ R, respectively. The Hamiltonian is the stored energy in the inductors and capacitors such that:

H cb (x cb ) = 1 2 x cb (t) T Q cb x cb (t), (2.3.3) with Q -1 cb = diag {L b1 , C b1 , L b2 , C b2 }.
Furthermore, the structure matrices J bc (d b ), G bc , G bi are given by the following expressions:

J cb (d b ) =      0 -d b (t) 0 0 d b (t) 0 1 -d b (t) 0 0 -1 + d b (t) 0 -1 0 0 1 0      , G cb =      0 0 0 1      , G cbt =      1 0 0 0      . (2.3.4)
From the presented model of the DC/DC converter, we can see that there is no dissipation matrix R(x, d), i.e., this (ideal) converter does not loose any energy. Therefore, at the steady state, the power-converting efficiency must be 1.

Next, from (2.3.1)-(2.3.4), we derive the converter ratio:

       v bb (t) v b (t) = - 1 -d b (t) d b (t) ∈ (-∞, 0), i bb (t) i b (t) = d b (t) 1 -d b (t)
∈ (0, +∞).

(2.3.5)

Similarly, the dynamics of the DC/DC converter associated to the supercapacitor are described by (2.3.6) with the duty cycle d s (t), the state variable x cs (t), the Hamiltonian H cs (x cs ), the input and output variables i ss (t), v ss (t), i s (t), v s (t) ∈ R, respectively. The interconnection matrices are denoted by J cs (d s ), G cs , G cst with the values given in (2. 3.4). Based on these ingredients, the dynamics of the supercapacitor unit are given as:

     ẋ cs (t) = J cs (d s )∇H cs (x cs ) + G cs [-i ss (t)] + G cst v s (t), v ss (t) = G T cs ∇H cs (x cs ), i s (t) = G T cst ∇H cs (x cs ), (2.3.6)
DC/AC converter: The DC/AC converter associated with the PMSM is illustrated in Fig. 2.3.2. It transforms the direct current (DC) to the three phase alternative current (AC) and vice versa. The converter circuit is modelled as three parallel pairs of ideal switches. They are characterized by three duty cycles ďl Fig. 2.3.2). Therefore, the relation of its port variables can be represented by:

(t) = [d a (t) d b (t) d c (t)] T ∈ [0, 1] 3 (see
i l (t) vl (t) = 0 -ďl (t) T ďl (t) 0 v l (t) ǐl (t) , (2.3.7)
where the phase voltages and currents are denoted by vl (t) ∈ R 3 and ǐl (t) ∈ R 3 , the corresponding DC bus voltage and current are denoted by i l (t) ∈ R, v l (t) ∈ R. From (2.3.7), we can see that the relation matrix of the converter input and output (2.3.7) is skew-symmetric which implies the power conservation property, i.e., i l (t)v l (t) + ǐl T (t) vl (t) = 0.

Energy sources

This section presents the models of the renewable source and external grid. Both of them can be modelled as current sources (i.e., they are controllable).

+ _ Renewable power source

Renewable energy:

In the present work we consider only the solar panels as renewable sources. In practice, a renewable source includes a grid of solar panels which supply electrical power depending on the solar radiance, panel temperature and device voltage, [START_REF] Kong | New approach on mathematical modeling of photovoltaic solar panel[END_REF]. To connect the panel to the microgrid, a DC/DC converter is used to control the delivered voltage. It is regulated to the value where the supplied power is maximal using the Maximum Power Point Tracking (MPPT) algorithm [START_REF] Femia | Distributed maximum power point tracking of photovoltaic arrays: Novel approach and system analysis[END_REF]. In this work, we assume that the regulator quickly stabilizes the supplied power to the maximal values. Furthermore, we neglect the temperature effect and consider an ideal converter (without energy dissipation). Therefore, the panel unit will be simply modelled as a power source P r (t) which only depends on the time as in Fig. 2.3.3. Hence, the voltage v r (t) and current i r (t) of the solar panel unit satisfy the following constraint: i r (t)v r (t) = -P r (t) < 0.

(2.3.8) + _ External grid External grid: The conventional energy source unit is the three phase electrical grid associated with an AC/DC converter. By this unit, the three phase alternative voltage is adapted to the voltage of the DC bus by modulating the three duty cycles of the AC/DC converter. Reference values of the delivered current to the DC bus are sent to the local controller of this converter. We assume that this controller steers the delivered current to this reference quickly. Therefore, the external grid is modelled as a current source i e (t) ∈ R with the corresponding voltage v e (t) ∈ R as in Fig. 2.3.4.

Transmission lines

The previous storage devices, energy source devices and electro-mechanical system are connected through the transmission lines (DC bus). The most simple model for these lines includes a capacitor which is connected in parallel with the power units [START_REF] Paire | A real-time sharing reference voltage for hybrid generation power system[END_REF]. However, it is not suitable for a large system where the connection lines should be taken into account. In the slow time scale, such a system can be modelled as a resistor network [START_REF] Zhao | Distributed control and optimization in DC microgrids[END_REF]. In the fast time scale, the line model includes capacitors and resistors4 (see Fig. The input current, output voltage and state vectors are denoted by:

i t (t) = [i tb (t) i ts (t) i tl (t) i te (t) i tr (t)] T ∈ R 5 , v t (t) = [v tb (t) v ts (t) v tl (t) v te (t) v tr (t)] T ∈ R 5 ,
x t (t) = [q t,1 (t) q t,2 (t) q t,3 (t) q t,4 (t) q t,5 (t)] T ∈ R 5 .

(2.3.9) Also, the current and voltage vectors of the lines resistors are denoted by:

i tR (t) = [i t,1 (t) i t,2 (t) i t,3 (t) i t,4 (t) i t,5 (t) i t,6 (t)] T ∈ R 6 , v tR (t) = [v t,1 (t) v t,2 (t) v t,3 (t) v t,4 (t) v t,5 (t) v t,6 (t)] T ∈ R 6 .
(2.3.10)

Their relations are described by the Ohm's law as: (2.3.11) where

v tR (t) + R tR i tR (t) = 0,
R tR = diag {R t,1 , R t,2 , R t,3 , R t,4 , R t,5 , R t,6 } ∈ R 6×6
represents the line resistors. Note that, R tR is symmetric and positive.

The Hamiltonian for the energy stored in the DC bus is chosen as: (2.3.12) where the weighting matrix (2.3.13) where the interconnection matrices G t , G tSR are given by:

H t (x t ) = 1 2 x t (t) T Q t x t (t),
Q t = diag {C b , C s , C l , C e , C r } -1 ∈ R 5×5
   -ẋt (t) v tR (t) v t (t)    =    0 -G tSR -G t G T tSR 0 0 G t 0 0       ∇H t (x t ) i tR (t) i t (t)    ,
G t = I 5 , G tSR =         -1 0 0 0 -1 -1 1 -1 0 0 0 0 0 1 1 0 0 1 0 0 0 -1 0 0 0 0 -1 1 0 0         . ( 2
i t (t) = R t v t (t).
The resistive matrix R t is also called the weighted Laplacian matrix of resistor network. In [van der Schaft, 2010], the properties of this matrix for the general resistor network is studied.

Proposition 2.3.1. Since the resistor network does not have the star topology (i.e., each end of each resistor is connected to a bus capacitor), the resistive matrix R t is semi-positive [van der Schaft, 2010, Zonetti et al., 2015].

Proof. If the resistor network has the star topology, the dynamics of transmission lines includes some constraints of resistor currents with the following form: (2.3.16) where A is an appropriate matrix. This is the current Kirchhoff's law for the resistor ends which are connected together but not to any capacitor. Thus, the dynamics (2.3.13) is not valid for the star topology of resistor network.

Ai tR (t) = 0,
In our case, by multiplying the two sides of the first equation in (2. 3.13) with the ones-vector, 1 T 5 , we obtain:

1 T 5 ẋt (t) -1 T 5 G tSR i tR (t) -1 T 5 G t i t (t) = 0.
(2.3.17)

In the previous equation, the first term indicates the total charge current of 5 bus capacitors. The third term of G t in (2. 3.14) indicates the total supplied current of the components. Since the resistors do not store the electricity, the first and third term must be equal. Thus, the second term must be zero such as:

1 T 5 G tSR i tR (t) = 0, ∀i tR (t) ∈ R 5 , ⇒ 1 T 5 G tSR = 0, ⇒ 1 T 5 G tSR R -1 tR G T tSR = 0, ⇒ 1 T 5 R t = 0.
(2. 3.18) Therefore, the resistive matrix R t is semi-positive. This concludes the proof.

To simplify the notation in the global DC microgrid dynamics, we partition the input matrix G tSR into five input matrices G tb , G ts , G tl , G te , G tr ∈ R 5×1 corresponding to the battery unit, supercapacitor unit, electro-mechanical elevator, external grid and renewable source, respectively, such that:

G tb G ts G tl G te G tr = G tSR .
(2.3.19)

Electrical storage unit

Generally, the dynamics of the electrical storage unit can be described by the formulation (2.2.9). In this work we consider particular types of electrical storage unit, that are, a lead-acid battery and a supercapacitor.

Lead-acid battery: An ideal battery model considers that the voltage is constant during the charging or discharging periods. This model can be useful only in case of low load and current (when compared to the battery's maximal capacity). For more general models we need to take into account some nonlinear effects which affects the available charge (see [START_REF] Jongerden | Which battery model is use? Software[END_REF]). There exist various electrical circuit models (see, for example, [START_REF] Durr | Dynamic model of a lead acid battery for use in a domestic fuel cell system[END_REF]) which describe the battery dynamics accurately, but they are too complex for an application to the real time optimal power balancing problem. The authors in [START_REF] Esperilla | A model for simulating a lead-acid battery using bond graphs[END_REF] proposed a Bond Graph battery model for which the parameters are difficult to identify. Thus, we need a simple enough model which can capture all the necessary properties of the system such as: the increase/decrease of voltage with charging/discharging current and state of charge, the increase/decrease in capacity with increasing charge or discharge rates, the recovery effect and the hysteresis by using an internal variable. There are at least two possible analytical models, the diffusion model, [START_REF] Rakhmatov | An analytical high-level battery model for use in energy management of portable electronic systems[END_REF] and the Kinetic Battery Model (KiBaM), [START_REF] Manwell | Lead acid battery storage model for hybrid energy systems[END_REF]. Although these models have been developed separately, the KiBaM model can be considered as a first order approximation of the diffusion model, [START_REF] Jongerden | Which battery model is use? Software[END_REF]. Hence, we consider the KiBaM model a good choice for our work, [START_REF] Lifshitz | Optimal energy management for grid-connected storage systems[END_REF]. Next, a PH formulation for the battery model will be developped (see also Fig. 2.3.6). As illustrated in Fig. 2.3.6, the battery model includes two electronic "wells" with the corresponding charges q b1 (t), q b2 (t), a bridge to connect them described by a coefficient k > 0, and a serial resistor R b . For simplicity, we assume that the battery voltage limits, E min , E max , are the same for both charging and discharging modes. Thus, the battery dynamics is represented by the following relations: (2.3.20) where b ∈ (0, 1) is a charge factor, q max is the maximal charge, i bb (t), v bb (t) ∈ R are the current and the voltage, respectively. By defining the state variable from the two charges of the battery x b (t) = [q b1 (t) q b2 (t)] T ∈ R 2 , we describe the Hamiltonian, which indicates the energy stored in the battery, as: (2.3.21) where the minimal battery voltage, Q b1 ∈ R 1×2 , and the inverts of battery charge capacity, Q b2 ∈ R 2×2 , are represented by:

               qb1 (t) = -k q b1 (t) b + k q b2 (t) 1 -b + i bb (t), qb2 (t) = k q b1 (t) b -k q b2 (t) 1 -b , i bb (t) = - E max -E min bq max R b q b1 (t) - E min R b + v bb (t) R b ,
H b (x b ) = Q b1 x b (t) + 1 2 x T b (t)Q b2 x b (t),
Q b1 = E min E min , Q b2 = diag E max -E min bq max , E max -E min (1 -b)q max .
(2. 3.22) The resistive current, i bR (t) ∈ R 2 , represents the electricity currents through the serial resistor, R b , and the bridge between two charges. The resistive voltage, v bR (t) ∈ R 2 , represents the voltages of the serial resistor, R b , and the bridge between two charges. The Ohm's laws for these resistive elements are given by:

v bR (t) + R bR i bR (t) = 0, (2.3.23)
with the resistive matrix of the resistive elements: (2.3.25) where the structure matrices are given by

R bR = diag {R bi , R b } ∈ R 2×2 , with R bi = E max -E min kq max . ( 2
  -ẋb (t) v bR (t) i bb (t)   =   0 -G bSR 0 G T bSR 0 G bRE 0 -G T bRE 0     ∇H b (x b ) i bR (t) v bb (t)   ,
G bSR = -1 1 1 0 ∈ R 2×2 , G bRE = 0 1 ∈ R 2×1 . (2.3.26)
From the previous model and numerical parameter values (determined using the data given by the industrial partner SODIMAS France), the battery has following important characteristics:

• R bi characterizes the battery internal current between the two charges (see also Fig. 2.3.6). Usually, R bi R b , i.e., the internal current is much smaller than the battery charging/discharging current through R b . Thus, in the fast time scale, the internal charge q b2 (t) mostly does not change.

• The battery charging mode corresponds to the positive sign of the output current, i bb (t) > 0. When

i bb (t) = 0, i.e., v bb (t) = -(G T bSE R -1 bR G bSE ) -1 (G bSE R -1 bR G T bSR )∇H b (x b ), (2.3.27)
the internal current is still non-zero to redistribute the charges q b1 (t), q b2 (t). From (2.3.24), (2.3.26)-(2.3.27), we can easily prove that the redistribution stops (i.e., ẋb (t) = 0) when the internal potentials are equal (i.e., ∂ q b1 H = ∂ q b2 H).

Supercapacitor: Supercapacitors are suitable for electrical power application. They have high performances in electrical power supplying [START_REF] Lai | High energy density double-layer capacitors for energy storage applications[END_REF]. They usually contain two parallel electrodes with an electrolyte without chemical reaction because of an added separator. A practical model for the supercapacitor can be found in [START_REF] Zubieta | Characterization of double-layer capacitors for power electronics applications[END_REF]]. Here we consider a simpler model which contains the serial connection of a capacitor, C s , with a resistor, R s . Thus the state variable is defined by the supercapacitor charge, x s (t) = q s (t) ∈ R. The Hamiltonian indicating the energy stored in the supercapacitor is expressed as:

H s (x s ) = 1 2 q 2 s (t) C s . (2.3.28)
Similarly with battery dynamics (2.3.25) the supercapacitor dynamical model is represented by: (2.3.29) where i sR (t), v sR (t) ∈ R are the current and voltage of the serial resistor, R s , satisfying the Ohm's law:

  -ẋs (t) v sR (t) i ss (t)   =   0 -G sSR 0 G T sSR 0 G sRE 0 -G T sRE 0     ∇H s (x s ) i sR (t) v ss (t)   ,
R s i sR (t) + v sR (t) = 0. (2.3.30)
The structure matrices G sSR , G sRE ∈ R in (2.3.29) are given as:

G sSR = 1, G sRE = 1. (2.3.31)

The electro-mechanical elevator

This section presents the PH formulations for the electro-mechanical elevator dynamics. Electro-mechanical elevator system represents the combination of the AC/DC converter, Permanent Magnet Synchronous Machine (PMSM) and mechanical elevator. In the literature, the d-q model of PMSM is usually derived using the Park transformation. Its PH formulation is presented in [START_REF] Nicklasson | Passivity-Based Control of a class of Blondel-Park transformable electric machines[END_REF], Petrović et al., 2001].

In this work, we first consider the PH formulation of the electro-mechanical elevator in the coordinates which include the three magnetic fluxes of machine stator coils. This is called original model. Then, the Park transformation is applied. Since there is still a flow constraint in the transformed model, we eliminate it to obtain the d-q PH model. Thus, two main contributions are provided here:

• the original model of the electro-mechanical elevator is represented in the PH formulation.

• the Park transformation is considered explicitly in the PH formulation.

Next, we first present the PH formulation for the original model of the electro-mechanical elevator. Then, we derive the d-q PH model using the Park transformation.

Original model

This component is a combination of the mechanical elevator, the PMSM and the three phase DC/AC converter (see Fig. 2.4.1). Physically, the original model of the subsystem considers three phase fluxes of the stator as the state variables.

Mechanical elevator: The mechanical elevator includes the cabin (including the passengers) and the counterweight with the corresponding masses m c , m p . They are connected together by a cable and hung on a pulley with the radius ρ. The friction is assumed to be negligible. The mechanical energy is the sum of kinetic and potential energies:

H m (p l , θ m ) = 1 2 p l (t) 2 I l -(m c -m p ) gρθ m (t), (2.4.1)
where θ m (t) is the pulley angle, g = 9.81m/s 2 is the gravity acceleration,

I l = [m c -m p ] ρ 2 is the mechanical inertia, and p l (t) = I l θm (t) is the mechanical momentum. Let x m (t) = [p l (t) θ m (t)
] ∈ R 2 denote the state vector for the mechanical elevator. From the kinematic relation and Newton's law, we obtain the following dynamics: where τ e (t) ∈ R is the magnetic torque of the PMSM and ω l (t) ∈ R is the rotor angular speed.

   -ṗl (t) -θ m (t) ω l (t)    =    0 -1 -1 1 0 0 1 0 0       ∂ p l H m (θ m , p l ) ∂ θm H m (θ m , p l ) τ e (t)    , (2.4.2) Mechanical system
Permanent Magnet Synchronous Machine: The PMSM includes a permanent magnet rotor and a threephases stator. The rotor flux is characterized by the magnet flux φ f . Its projections on three stator coils are denoted by Φ f abc (θ e ) ∈ R 3 , with the rotor angle θ e (t) ∈ R. The stator is modelled as a system of three symmetric coils with the inductance matrix L abc (θ e ) ∈ R 3×3 . It depends on the rotor angle since the air gap between the rotor and stator coils varies with time. (Details on the stator coils, Φ f abc (θ e ) and the inductance matrix L abc (θ e ), are provided in the Appendix A).

Hence, the PMSM magnetic energy stored in the stator is:

H e ( Φl , θ e ) = 1 2 Φl (t) -Φ f abc (θ e ) T L -1 abc (θ e ) Φl (t) -Φ f abc (θ e ) .
(2.4.3)

From the Kirchhoff's laws and Lenz's law, we obtain the interconnection structure of PMSM as: .4.4) where vl (t), ǐl (t) ∈ R are the voltage and current vectors of the stator at the connection point with the DC/AC converter. The model derivation of PMSM dynamics (2.4.4) is explained in detail in Appendix A.

             -Φl (t) -θe (t) i lR (t) -ǐl (t) 0 -τ e (t)              =             0 0 I 3 -I 3 1 3 0 0 0 0 0 0 -1 -I 3 0 0 0 0 0 I 3 0 0 0 0 0 -1 T 3 0 0 0 0 0 0 1 0 0 0 0                          ∂ Φl H e ( Φl , θ e ) ∂ θe H e ( Φl , θ e ) v lR (t) vl (t) v ln (t) ω l (t)              , ( 2
The resistive elements, which we assume that they are linear, correspond to the stator resistors characterized by the resistance R l for each phase. The Ohm's law is written as:

v lR (t) = -R l i lR (t).
(2.4.5)

Electro-mechanical elevator: The dynamics of electro-mechanical elevator are derived by connecting the PMSM dynamics (2.4.4) with the mechanical dynamics (2.4.2) through the mechanical port (τ e (t), ω l (t)) in (2.4.4) and with the DC/AC relation (2.3.7) through the electrical port ( ǐl (t), vl ) in (2. 4.4). Therefore, since the DC/AC converter does not store the energy, the Hamiltonian of electro-mechanical elevator is the total of the mechanical energy (2.4.1) and the magnetic energy (2.4.3):

H l ( Φl , x m ) = H e ( Φl , θ e ) + H m (x m ).
(2.4.6)

Let us define the global state variable vector xl (t) ∈ R 6 which includes the stator magnetic fluxes Φl (t), the rotor angle θ e (t), the mechanical momentum p l (t) and the pulley angle θ m (t):

xl (t) = [ Φl (t) T θ e (t) p l (t) θ m (t)] T ∈ R 6 .
(2.4.7)

By combining the DC/AC relation (2.3.7), the mechanical elevator dynamics (2.4.2) and the PMSM dynamics (2.4.4), we derive the implicit PH model for the electro-mechanical elevator as follows:

˙l x(t) = Jl ∇H l (x l ) + ǦlSR v lR (t) + ǦlSE ( ďl )v l (t) + ǦlSn v ln (t), (2.4.8a) i lR (t) = ǦT lSR ∇H l (x l ), (2.4.8b) i l (t) = ǦT lSE ( ďl )∇H l (x l ), (2.4.8c) 0 = ǦT lSn ∇H l (x l ), (2.4.8d) v lR (t) = -R l i lR (t).
(2.4.8e)

where the interconnection matrix Jl and the input matrices ǦlSR , ǦlSE ( ďl ), ǦlSn are described by the following expressions:

Jl =      0 0 0 0 0 0 1 0 0 -1 0 -1 0 0 1 0      ∈ R 6×6 , ǦlSR =      -I 3 0 0 0      ∈ R 6×3 , (2.4.9a) ǦlSE ( ďl ) =      ďl (t) 0 0 0      ∈ R 6×1 , ǦlSn =      -1 3 0 0 0      ∈ R 6×1 . (2.4.9b)
As we see in dynamics (2.4.8), there is still a constraint (2.4.8d) in the external port output. This is discarded in the next subsection where a reduced PH model is obtained.

Remark 2.4.1. From the Hamiltonians described by (2.4.1), (2.4.3) and (2.4.6), we see that the Hamiltonian H l (x l ) is convex but not positive definite. This means that it does not admit a minimum point. Equivalently, the electro-mechanical elevator does not have an equilibrium point corresponding to the zero input v l (t) = 0. The storage elements reside in the PMSM stator and mechanical elevator. The resistive element only resides in the PMSM stator. There are two external ports: the zero-flow source Sf representing the flow constraint (2.4.8d) and the electrical port (i l , v l ) connecting to the transmission lines. Note that the Dirac structure of the DC/AC converter is modulated by the duty cycle ďl (t). We can see that the Bond Graph describes different physical domains in the same theoretic formalism: magnetic, electric and mechanic.

Transmission lines

Reduced order model

In the following we present the d-q PH formulation for the electro-mechanical elevator (2.4.8) by using the Park transformation and a constraint reduction. Especially, these two processes are considered in the PH formulation. Since the Park transformation is time invariant, the transformed system is also a PH system. For the reduced model, a simple condition to preserve the PH form is fortunately satisfied. First, we define the Park matrix P(θ m ) ∈ R 3×3 as: .4.10) where p ∈ N denotes the number of pole pair in the machine stator,

P(θ m ) = 2 3       cos(α a (θ m )) cos(α b (θ m )) cos(α c (θ m )) -sin(α a (θ m )) -sin(α b (θ m )) -sin(α c (θ m )) 1 √ 2 1 √ 2 1 √ 2       , ( 2
α a (θ m ) = pθ m (t), α b (θ m ) = pθ m (t) - 2π 3 , α c (θ m ) = pθ m (t) + 2π 3
. The Park matrix is used to transform the PMSM flux vector Φl (t) in (A.0.4)

to Φ l (t) = P(θ m ) Φl (t). For the electro-mechanical elevator, the state vector includes not only the stator fluxes but also the mechanical momentum and rotor angle as in (2.4.7). Thus, we define the extended Park transformation as: .4.11) Note that, only the stator flux is transformed:

x l (t) = P(θ m ) 0 0 I 3 xl (t). ( 2
x l (t) = [Φ l (t) θ e (t) p l (t) θ m (t)] T ∈ R 6 .
(2.4.12)

The Jacobian matrix of the transformation (2.4.11) is given by:

W(x l ) ∂ xl x l =      P(θ m ) dP dθ m (θ m )Φ l (t) 0 0 1 0 0 0 I 2      . (2.4.13)
The transformed PH model is explained by the following proposition.

Proposition 2.4.2. Any time invariant transformation of the state-space of the electro-mechanical elevator system (2.4.8) preserves the PH form.

Proof. Let W(x l ) be the Jacobian matrix of a time invariant transformation of state-space x l (x l ). From the chain rules for the state vector and Hamiltonian, we obtain:

ẋl (t) = W(x l ) ˙l x(t), ∇H l (x l ) = W T (x l )∇H l (x l ).
(2.4.14)

By defining the structure matrices

J l (x l ) ∈ R 6×6 , R l (x l ) ∈ R 6×6 , G l,SE (x l , ďl ) ∈ R 6×1 , G l,Sn (x l ) ∈ R 6×1 as:          J l (x l ) = W(x l ) Jl W T (x l ), G lSR (x l ) = W(x l ) ǦlSR , G lSE (x l , ďl ) = W(x l ) ǦlSE ( ďl ), G lSn (x l ) = W(x l ) ǦlSn , (2.4.15)
we get the transformed dynamics of the electro-mechanical elevator:

                       ẋl (t) = J l (x l )∇H l (x l ) + G lSR (x l )v lR (t) +G lSE (x l , ďl )v l (t) + G lSn (x l )v ln (t), i lR (t) = G lSR T (x l )∇H l (x l ), i l (t) = G lSE T (x l , ďl )∇H l (x l ), 0 = G lSn T (x l )∇H l (x l ), v lR (t) = -R l i lR (t).
(2.4.16)

Since Jl is skew-symmetric, then J l (x l ) has the same property. Consequently, the time invariant transformation of state-space x l (x l ) preserves the PH form of the electro-mechanical elevator dynamics.

Remark 2.4.3. Note that, from the transformed system dynamics (2.4.16) there is still a flow constraint (fourth equation in (2.4.16)). Also, the structure matrix [J l (x l ) G lSR (x l ) G lSE (x l , ďl ) G lSn (x l )] is not full rank. This motivates model order reduction which preserves the PH formulation. In the following proposition we indicate a state-space projection to reduce the transformed dynamics (2.4.16).

Proposition 2.4.4. Let x l (t) ∈ R 4 be the reduced state variable of x l (t) by the state-space projection (2.4.17) with

x l (t) = G ⊥ x l (t),
G ⊥ = I 2 0 0 0 0 I 2 ∈ R 4×6 .
(2.4.18)

In the case of electro-mechanical elevator, the presented state-space projection has the following properties:

1. It satisfies the relations:

∇H l (x l ) = (G ⊥ ) T ∇H l (x l ), G ⊥ G lSn (x l ) = 0. (2.4.19)
2. It reduces electro-mechanical elevator PH dynamics (2.4.16) to PH dynamics.

Proof. We start by proving the first property. The first coordinate of the reduced state variable vector x l (t) defined by (2.4.17) is called the direct flux and denoted by φ ld (t). Similarly, the second coordinate is called the quadrature flux and denoted by φ lq (t). They describe the projections of the stator magnetic fluxes on two perpendicular axis associated with the rotor. Using these definitions and the reduction (2.4.17)-(2.4.18), the electrical, mechanical and electro-mechanical state vectors are given by:

x e (t) = φ ld (t) φ lq (t) ∈ R 2 , x m (t) = p l (t) θ m (t) ∈ R 2 , x l (t) = x e (t) x m (t) ∈ R 4 .
(2.4.20)

Moreover, the electro-mechanical elevator Hamiltonian defined by (2.4.1), (2.4.3) and (2.4.6) may be rewritten using the reduced state variables: (2.4.21) with the direct and quadrature inductances defined by: (2.4.22) where L 1 , L 2 , L 3 are the parameters of the original stator fluxes in (A.0.2). By some calculation from the mechanical energy (2.4.1), the electromagnetic energy (2.4.3), the electro-mechanical elevator energy (2.4.6), the Park transformation (2.4.10), the Jacobian (2.4.13) and the state-space projection (2.4.17)-(2.4.18) we derive (2. 4.19).

H l (x l ) = 1 2L d φ ld (t) - 3 2 φ f 2 + 1 2 φ lq (t) 2 L q + 1 2 p l (t) 2 I l -(m c -m p ) gρθ m (t),
L d = L 1 + 1.5L 2 -L 3 , L q = L 1 -1.5L 2 -L 3 ,
Next, we prove the second property stated in the Proposition. By multiplying the transformed dynamics (2.4.16) with G ⊥ , we get: (2.4.23) Thanks to the reduction (2.4.17) and the property (2. 4.19), we obtain the reduced electro-mechanical elevator dynamics as: (2.4.24) where the reduced structure matrices are given by:

                         G ⊥ ẋl (t) = G ⊥ J l (x l )∇H l (x l ) +G ⊥ G lSR (x l )v lR (t)+ +G ⊥ G lSE (x l , ďl )v l (t) +G ⊥ G lSn (x l )v ln (t), i lR (t) = G lSR T (x l )∇H l (x l ), i l (t) = G lSE T (x l , ďl )∇H l (x l ), 0 = G lSn T (x l )∇H l (x l ), v lR (t) = -R l i lR (t),
         ẋl (t) = J l (x l )∇H l (x l ) +G lR (x l )v lR (t) + G l ( ďl , x l )v l (t), i lR (t) = G T lR (x l )∇H l (x l ), i l (t) = G T l (d l , x l )∇H l (x l ), v lR (t) = -R l i lR (t),
     J l (x l ) = G ⊥ J l (x l )(G ⊥ ) T , G lR (x l ) = G ⊥ G lSR (x l ), G l ( ďl , x l ) = G ⊥ G lSE ( ďl , x l ).
(2.4.25)

From the previous calculation, we note that the input matrix G l ( ďl , x l ) depends on the pulley angle θ m (t). Therefore, we define the equivalent duty cycle vector denoted by d l (t) ∈ R 2 to simplify the input matrix G l ( ďl , x l ) in the form:

G l (d l ) = d l (t) 0 ∈ R 4×1 , (2.4.26) with d l (t) = 2 3    cos(pθ m ) cos(pθ m - 2π 3 ) cos(pθ m + 2π 3 ) -sin(pθ m ) -sin(pθ m - 2π 3 ) -sin(pθ m + 2π 3 )    ďl (t). (2.4.27)
From the presented reduced model in (2.4.24), we emphasize some characteristics of the electro-mechanical elevator dynamics related to the interconnection matrix and to the Hamiltonian:

1. The interconnection matrix J l (x l ) of the dynamics (2.4.24) depends on the state variable x l (t) and is not integrable.

2. The electro-mechanical elevator dynamics include the electrical and mechanical domains. From their details, we can partition the structure matrices as:

J l (x e ) = 0 J em (x e ) -J T em (x e ) J m , G lR (x l ) = G lRe (x m ) 0 , (2.4.28)
where

                 J m = 0 -1 1 0 , J em (x e ) = φ lq (t) 0 -φ ld (t) 0 , G lRe (x m ) = 2 3    cos(pθ m ) cos(pθ m - 2π 3 ) cos(pθ m + 2π 3 ) -sin(pθ m ) -sin(pθ m - 2π 3 ) -sin(pθ m + 2π 3 )    .
(2.4.29)

From (2.4.21), we note that the Hamiltonian is a quadratic function: .4.30) where the weight matrices are given by: .4.31) with the weight matrices corresponding to the electrical and mechanical domains:

H l (x l ) = Q l0 + x T l (t)Q l1 + 1 2 x T l (t)Q l2 x l (t). ( 2
Q l0 = 3 4 φ 2 f L d , Q l1 = Q l1e Q l1m , Q l2 = Q l2e 0 0 Q l2m , ( 2
                   Q l1e =    - 3 2 φ f L d 0    , Q l1m = 0 -(m c -m p )gρ , Q l2e =    1 L d 0 0 1 L q    , Q l2m =   1 I l 0 0 0   .
(2.4.32)

Transmission lines

Identification

The parameter values for the derived model can be measured directly on the actual system. However, the PMSM parameters can not be measured directly on the system. They are quite complex (intrusive and sensitive) and the obtained measured parameters' values may be different from the actual values in nominal operating conditions. Therefore, we will use identification methods to determine the parameters x by measured data of some physical quantities, called inputs and outputs of the system which are denoted by û(t), ŷ(t), respectively.

Let ȳ(t) be the output value which is derived from the data of the input û(t) and parameter x using the system dynamics: Ȳd = g(x, Ûd ), (2. 4.33) where Ȳd and Ûd are the discrete functions of output ȳ(t) and input û(t), respectively. The outputs ŷ(t) and ȳ(t) are used to construct the cost function V ( Ŷd , Ȳd ) with the discrete function Ŷd of ŷ(t). In this work, we penalize the cost the discrepancy between ŷ(t) and ȳ(t) such that:

V ( Ŷd , Ȳd ) = N i=1 (ȳ(i) -ŷ(i)) T (ȳ(i) -ŷ(i)) . (2.4.34)
Then, by replacing (2.4.33) in (2.4.34), we obtain a cost which depends on the parameters V ( Ŷd , x, Ûd ), or simply V (x). By minimizing this cost function wrt. the parameters x, we obtain their approximate values.

The electro-mechanical elevator dynamics described by (2.4.20)-(2.4.21), (2.4.24), (2.4.26) and (2.4.28) can be expressed in the following explicit form:

                               φld (t) = - R l L d φ ld (t) - 3 2 φ f + φ lq (t)p l (t) I l + v ld (t), φlq (t) = - R l L q φ lq (t) - 1 I l φ ld (t)p l (t) + v lq (t), ṗl (t) = 3 2 φ f L d φ lq (t) + L d -L q L d L q φ ld (t)φ lq (t) + Γ res , θm (t) = 1 I l p l (t).
(2. 4.35) In this model, there are seven parameters: I l , Γ res , p, R l , L d , L q , φ f . The mechanical parameters (I l , Γ res ) and the number of pole pairs (p) are assumed to be known (they may be identified separately). Practically, the remaining 4 parameters will be determined by identification methods using the currents and voltages values (given data) of the three phases ǐl (t), vl (t) and the angular velocity of the rotor ω l (t). However, in the d-q frame, the replacing voltage and current v l (t), i l (t) are determined by using the Park transformation described by (2.3.7), (2.4.27) and (3.3.1). Finally, the identification algorithms will make use of the following data:

v ld (t), v lq (t), i ld (t), i lq (t), ω l (t).
It is theoretically sufficient to use the two first electrical equations of (2.4.35) which relate to the magnetic fluxes, for the identification purpose. However, in the second equation of (2.4.35), the value of rotor mechanical momentum coefficient is too small. This produces poor results for the estimation of the rotor's flux in the case of experiments with short durations and zero initial value for the flux. Therefore, three first equations of (2.4.35) are used.

We investigate hereinafter two identification methods based on two identification models for the electromechanical elevator: direct dynamic identification model (DDIM) [Khatounian et al., 2006, Robert andGautier, 2013] and inverse dynamic identification model (IDIM) [START_REF] Khatounian | Parameters estimation of the actuator used in haptic interfaces: Comparison of two identification methods[END_REF],Zentai and Dabóczi, 2008, Robert and Gautier, 2013]. However, note that the mentioned choices of inputs and outputs have not been generalized for the PH system yet, i.e., they do not relate to the input and output at the external power port.

The Output Error method (OE) [START_REF] Robert | Global identification of mechanical and electrical parameters of synchronous motor driven joint with a fast CLOE method[END_REF]: In this method, let

ŷ(t) =   i l (t) ṗl (t) ω l (t)   , ȳ(t) =   īl (t) pl (t) ωl (t)   , û(t) = v l (t), x =     R l L d L q φ f    
denote the output data, the estimated outputs, the input data and the vector of parameters, respectively. Some numerical methods to find the argument xmin minimizing V (x) in (2.4.34) needs to be used such as the gradient method, the Newton method [START_REF] Robert | Global identification of mechanical and electrical parameters of synchronous motor driven joint with a fast CLOE method[END_REF]. We follow [START_REF] Khatounian | Parameters estimation of the actuator used in haptic interfaces: Comparison of two identification methods[END_REF], using the Levenberg-Marquardt algorithm to ensure a robust convergence even in the case of a bad initialization of x. This identification scheme is robust to noise in the measurements as well, but requires larger amount of computational effort than the method we present next.

The Least Square and Inverse model method (LSI) [START_REF] Zentai | Offline parameter estimation of permanent magnet synchronous machine by means of LS optimization[END_REF]:

In this method, let ŷ(t) = v l (t) ṗl (t) -Γ res , ȳ(t) = vl (t) pl (t) -Γ res , û(t) = i l (t) ω l (t) , x =     R l L d L q φ f    
denote the output data, the estimated outputs, the input data and the vector of parameters with Γ res = -∂ θm H l (x l ) = (m cm p )gρ. This choice allows to rewrite the system dynamics by the linear constraints of parameters: (2.4.36) where γ(û) is a suitable function derived from (2.4.35). Thus, the cost function V (x) in (2.4.34) is actually quadratic whose minimum is well-known. This method exhibits good results in the case without noise but unfortunately is rather sensitive to the noise disturbances in the current data. Therefore, to improve the obtained results, it is necessary to use it with a low-pass filter using these.

ȳ(t) = γ(û)x,
Simulation results: The "measured" data are obtained by simulation ran with the parameters values received from the PMSM manufacturer. The PMSM model proposed in (2. 4.24) was implemented in Matlab/Simulink 2016a. During the simulations, the input voltages, output currents and rotor speed are recorded to create data for identification (see also Fig. 2.4.4). Using these data, both identification algorithms are tested in terms of convergence and noise sensitivity. : numerical data of dq currents, i l (t), dq voltages, v l (t), rotor speed, ω l (t), and rotor angle, θ m (t).

Three experimental scenarios are implemented corresponding to the nominal case (without noise), noiseaffected data and the case with noise and a supplementary low-pass filter. We provide more details on the simulation data and configuration in [START_REF] Pham | An energy-based control model for autonomous lifts[END_REF]. The parameter values used in these experience are J = 0.1 kg.m 2 , Γ res = 5 N.m, p = 20, R s = 0.53 Ω, L d = 8.96 mH, L q = 11.23 mH, φ f = 0.05 W b. The sample time is h = 10 -5 s and the simulation duration is t = 0.5 s. The first experience (without noise) was also carried out with a shorter duration (t = 0.005 s) in order to emphasize the effect on the identification results. The amplitude of noises is 1 A for data of currents, and is 1 rad/s for data of rotor speed. From the obtained results in Tables 2.4.1-2.4.3 for the presented scenarios, some conclusions are deduced:

-The estimated values using the OE identification method are less sensitive to noise wrt the estimated values obtained using the LSI identification method;

-The estimated values of the direct inductance, L d , and the quadrature inductance, L q , are more accurate wrt the stator resistance, R l , and the rotor magnetic flux, φ f . -The longer the running time for the LSI method is, the best is the convergence. On the contrary, the convergence of the OE method is worse when the simulation time increases because the errors of the estimated output of the OE method increase.

The simulations show that, in our case, the LSI method associated with low-pass filter is better than the other identification methods since it ensures both, a robust convergence and small volume of computations. This results are similar to the results presented by [START_REF] Khatounian | Parameters estimation of the actuator used in haptic interfaces: Comparison of two identification methods[END_REF] in simulation (deterministic case without converter) and experimentally. The values of appropriate sample time and duration can be adapted according to the chosen current waveforms.

The global DC microgrid model

This section presents the global PH model of the DC microgrid elevator taking into account the PH models of the presented microgrid components and the microgrid power-preserving interconnection.

Bond graph for the multi-source elevator system

Global model

As previously mentioned, all the electrical power components are connected to the corresponding port of the DC bus. This connection is described by a simple power-preserving relation:

i t (t) v com (t) = 0 -I 5 I 5 0 v t (t) i com (t) , (2.5.1)
where i t (t), v t (t) ∈ R 5 are the currents and voltages at the connection ports of the DC bus defined by (2.3.9), and are the currents and voltages of the battery unit, supercapacitor unit, electro-mechanical elevator, external grid and renewable power source, respectively. Consequently, the global state variable, x(t), and Hamiltonian, H(x), gather the states and energy of the DC microgrid components such as:

i com (t) = [i b (t) i s (t) i l (t) i e (t) i r (t)] ∈ R 5 , v com (t) = [v b (t) v s (t) v l (t) v e (t) v r (t)] ∈ R 5 , (2.5.2)
x(t) = x T t (t) x T cb (t) x T cs (t) x T s (t) x T e (t) x T m (t) x T b (t) T ∈ R 20 , (2.5.3a) H(x) = H t (x t ) + H cb (x cb ) + H cs (x cs ) + H s (x s ) + H e (x e ) + H m (x m ) + H b (x b ). (2.5.3b)
Note that in (2.5.3) the subscripts denote the corresponding variables for the transmission lines, battery/supercapacitor converters, machine stator, battery, supercapacitor and mechanical elevator, respectively. The global flow and effort variables of the resistive elements are denoted by:

e R (t) = i T tR (t) i T bR (t) i T sR (t) v T lR (t) T ∈ R 11 , (2.5.4a) f R (t) = v T tR (t) v T bR (t) v T sR (t) i T lR (t) T ∈ R 11 , (2.5.4b)
and their relation is described by the Ohm's law:

f R (t) + R R e R (t) = 0, (2.5.5)
with R R ∈ R 12×12 denoting the resistive matrix given as:

R R = diag{R tR , R bR , R s , R -1 l I 3 }. ( 2
     f (t) = D(d, x)e(t), P r (t) = -i r (t)v r (t), f R (t) = -R R e R (t),
(2.5.7)

where the flow, f (t) ∈ R 34 , and the effort, e(t) ∈ R 34 , variables are given by:

f (t) =      -ẋ(t) f R (t) v e (t) v r (t)      , e(t) =      ∇H(x) e R (t) i e (t) i r (t)      , (2.5.8)
and the structure matrix, D(d, x) ∈ R 34×34 , is described by:

D(d, x) =      -J(d, x) -G SR (θ m ) -G e -G r G T SR (θ m ) 0 0 0 G T e 0 0 0 G T r 0 0 0      , (2.5.9)
which contains the structure matrices

J(d, x) ∈ R 20×20 , G T SR (x l ) ∈ R 20×12 , G r , G e ∈ R 20×1 described by: J(d, x) =              0 -G tb G T cbt -G ts G T cst 0 -G tl d T l (t) 0 0 G cbt G T tb J cb (d b ) 0 0 0 0 0 G cst G T ts 0 J cs (d s ) 0 0 0 0 0 0 0 0 0 0 0 d l (t)G T tl 0 0 0 0 J em (x e ) 0 0 0 0 0 -J T em (x e ) J m 0 0 0 0 0 0 0 0              , (2.5.10a) G SR (θ m ) =              G tSR 0 0 0 0 G cb G T bRE 0 0 0 0 G cs G T sRE 0 0 0 G sSR 0 0 0 0 G lRe (x m ) 0 0 0 0 0 G bSR 0 0              . (2.5.10b) G r = G tr 0 , G e = G te 0 , (2.5.10c)
From the above model (2.5.7)-(2.5.10c), we emphasize some of the DC microgrid characteristics:

1. The Hamiltonian H(x) is a quadratic function of the form:

H(x) = Q 0 + x(t)Q 1 + 1 2 x T (t)Q 2 x(t), (2.5.11) with Q 0 ∈ R, Q 1 ∈ R 20 and Q 2 ∈ R 20×2
is diagonal and non-negative. The minimum of Hamiltonian does not exist due to the linear potential energy. Usually, when the operation point (state) is determined, we change the coordinate to this point to obtain a new Hamiltonian which is usually useful for stabilizing the system.

2. Some external ports of the DC network connect to the renewable energy units which are modelled as DC power sources (see Eq. (2.3.8)). Therefore, we can not derive the input-state-output PH system, and the DC microgrid model is represented in the implicit form (2.5.7). However, this implicit form describes in detail the component models and their interconnection which will be useful for the global control objective.

3. The interconnection matrix J(d, x) in (2.5.10a) is an affine function of the state variables (see relations (2.4.29) and (2.5.10a)).

4. The interconnection matrix J(d, x) in (2.5.10a) is an affine function of each converter duty cycles 5 . This means that these variables do not change the global energy but the internal power distribution between the components.

5. The studied microgrid illustrated in Fig. 2.1.1 includes three physical domains: chemical (battery, supercapcitor), mechanical (machine rotor, mechanical elevator) and electrical (converter, transmission lines, machine stator). Based on the actual system, there are three time-scale dynamics corresponding to the electrical domain, the mechanical elevator and the supercapacitor and the battery, respectively. They will be considered with the corresponding objectives in the next subsection.

Control objectives

As mentioned in the introduction, there are many control objectives considered for the microgrid. In the present work we concentrate on the energy management objective under an optimization-based control framework. Based on the modelling formulation presented above, in this section, we present the general profiles, constraints and cost which will be used in the next chapters for the optimization-based control design. All the elements of the electrical system are characterized by certain profiles of reference. Load power profiles: In the dynamics (2. 4.24), the cabin mass, m c , is constant during the travel of the elevator. However, it changes when the elevator stops corresponding to the weight of the inside passengers. Furthermore, the start/stop instant and the cabin position are also modified many times in a day. For the elevator operation the cabin mass, m c , the start instant, t in , the stop instant, t f i and the cabin position, θ, are the control signals which are decided by the passenger and/or the elevator programmer.

Reference profiles

We denote by N t the number of elevator travels in a day. Then, the vector m c , t in , t f i , θ ∈ R Nt captures N t values of cabin mass, initial instant, final instant and final rotor angle of N t travels:

m c = [m c,1 . . . m c,Nt ] T , t in = [t in,1 . . . t in,Nt ] T , t f i = [t f i,1 . . . t f i,Nt ] T , θ = [θ 1 . . . θ Nt ] T .
(2.6.1)

These vectors with the duty cycles of the machine converter define the control variables and lead to a consumption power profile of the electro-mechanical elevator. In our work, m c , t in , t f i , θ are assumed to be decided by the passenger, i.e., they are fixed and unknown. Therefore, the long-term consumed electrical power is nearly fixed and admits a statistical rule. Taking into account the available statistical measurements of electricity consumption we consider the reference power of the consumer denoted by P l (t). However, the short-term load power is still modified by the minimization of the machine dissipated energy during each travel which will be presented in Chapter 4.

Renewable power profile: From the description of the renewable source in Subsection 2.3.2 we denote by P r (t) the power profile of the renewable source estimated from meteorological data.

Electricity price profile: Lastly, by using existing historical data of electricity market, we denote the predicted electricity price profile by price(t). Also, we assume that the selling and buying prices are the same. Fig. 2.6.1 depicts the evolution of the price on the electricity market in a day.

Constraints

Electro-mechanical elevator system: The operation constraints corresponding to the electro-mechanical elevator system are caused by physical limitations and passengers requirements. In fact, to avoid a high machine temperature which can destroy the machine and change its physical characteristics, the current amplitude needs to satisfy the following constraint (see [START_REF] Lemmens | PMSM drive current and voltage limiting as a constraint optimal control problem[END_REF] for details):

ǐl (t) 2 ≤ I l,max .
(2.6.2)

In the d-q frame, (2.6.2) is rewritten as:

   φ ld (t) - 3 2 φ f /L d φ lq (t)/L q    2 ≤ I l,max √ 2 .
(2.6.3)

Because of the machine design and the passenger's comfort requirements, the rotor speed and the rotor angle need to be less than a priori chosen values. The elevator speed limit is defined by:

ω l,min ≤ ω l (t) ≤ ω l,max , (2.6.4)
with ω l,min , ω l,max ∈ R denoting the minimal and maximal mechanical elevator momentum which is proportional to the machine speed. This comes from the limitation of the mechanical solidity, and it is given by the manufacturer.

The duty cycle ďl (t) ∈ R 3 has to be in the interval [0, 1] 3 . However, by using the Park transformation, we derive the corresponding non-linear constraint in the d-q coordinate:

d l (t) 2 ≤ 1 √ 2 .
(2.6.5)

Usually, there is also the constraint on the rotor position such as (2.6.6) where θ l,min , θ l,max ∈ R are respectively the minimal and maximal rotor angles of the pulley during a travel. θ l,min and θ l,max are the initial and final angles. Fortunately, the constraint (2.6.6) can be eliminated thanks to the constraints (4.3.6c), (4.3.8) and (2.6.7). It is clearly that the time integration of the rotor speed is the rotor angle, i.e.

θ l,min ≤ θ m (t) ≤ θ l,max ,
θ m (t) = θ 0 + t t0 ω l (t)dt.
(2.6.7)

If the elevator goes down, θ l,min = θ 0 , θ l,max = θ f , and ω l,min = 0. Thus, from (4.3.6c), (4.3.8) and (2.6.7), we obtain the following inequality:

⇒ 0 = t t0 ω l,min dt ≤ t t0 ω l (t)dt ≤ t f t0 ω l (t)dt = θ f -θ 0 = θ l,max -θ l,min , ⇒ 0 ≤ θ m (t) -θ l,min ≤ θ l,max -θ l,min , ⇒ (4.3.8).
Therefore, (4.3.6c), (4.3.8) and (2.6.7) are the sufficient condition for (4.3.8) when the elevator go down. Similarly, we have the same conclusion for the case the elevator goes up.

Battery unit: In general, an electrical storage unit has some limitations on the quantity of charged energy. Furthermore, the battery stored charge must be greater than half its capacity (kept in case of unexpected events):

0.5x b,max ≤ x b (t) ≤ x b,max , (2.6.8)
with x b,max ∈ R 2 . Also, the battery charge/ discharge current respects some limitation range given by the manufacturer: i b,min ≤ i bb (t) ≤ i b,max , (2.6.9)

with i b,min , i b,max ∈ R. The duty cycle needs to respect the following limitations:

0 ≤ d b (t) ≤ 1.
(2.6.10)

Supercapacitor unit: The supercapacitor has the advantage of high power level. However, its charge level is low and can be described by: s q s,max ≤ q s (t) ≤ q s,max , (2. 6.11) with the maximal supercapacitorcharge q s,max ∈ R and s ∈ [0, 1]. Similar with the battery unit, the duty cycle fo the supercapacitor is also limited as follows:

0 ≤ d s (t) ≤ 1.
(2.6.12)

External grid: The constraints of the external grid come from the limited available power P e (t) as in (2.6.13).

Since the DC bus voltage v e (t) in Fig. 2.3.4 is nearly constant, the limitation becomes a constraint on the current, i e (t), described as: i e,min ≤ i e (t) ≤ i e,max , (2. 6.13) with i e,min , i e,max ∈ R. A low limit current implies a low subscription cost. Thus, a way to minimize the electricity cost is by decreasing the peak power purchased from the external grid. However, in this work we aim at decreasing this cost by purchasing the electricity when it is cheap and reusing it when the electricity price is expensive.

Cost functions

In this section, we present the cost functions for the microgrid control and supervision. Due to the complexity of microgrid dynamics (multi-time scales, high dimension, nonlinearity), a centralized optimization problem is intractable. Thus, as also employed in the literature, the energy management for the microgrid is separated into two sub-problems with different time scales, objectives and control variables, that is, dissipated energy minimization and electricity cost minimization:

• The first objective is for the fast time scale (within a range of seconds-minutes), corresponding to the supercapacitor dynamics and mechanical elevator. It aims to minimize the dissipated energy within the microgrid during an elevator travel.

• The second objective is investigated for the slow time scale (within a range of minutes-hours) corresponding to the battery dynamics, renewable power, electricity price and passenger travel statistic. It aims to minimize the electricity cost by the external current i e (t) and the passenger requests given by m c , t in , t f i , θ defined in Section 2.6.1. Therefore, the cost function will be generally non-quadratic and time-varying.

Dissipated energy minimization:

The control for the elevator position is the combination of DC bus voltage control at a fast time scale and the microgrid component regulation at a slower time scale. The DC bus control needs to guarantee a constant reference for the DC bus voltage. However, as illustrated in Fig. 2.3.5, we see that each component has its own DC bus voltage due to the resistance of the transmission lines. Therefore, the bus stability aims to regulate the load voltage to a reference value in order to guarantee its normal operation. Moreover, the constant DC bus voltage also indicates the satisfaction of required load electrical power, i.e., the power balancing objective will be ensured. Some methods to control the DC bus voltage can be found in [START_REF] Alamir | Constrained control framework for a stand-alone hybrid[END_REF], Zhao and Dörfler, 2015, Zonetti et al., 2015] which is not the main objective of our work. Consequently, the bus voltage is quickly stabilized and can be represented by an additional constraint to the original microgrid dynamics given in (2.5.7)-(2.5.10c):

A 1 x(t) = b 1 ,
(2. 6.14) with

A 1 = [0 T 2 1 0 T 17 ] ∈ R 1×20 , b 1 = C t,3 v * l ∈ R, v *
l is the reference DC bus voltage and C t,3 is the corresponding bus capacitor.

Each component has its own objective, e.g., for a reliable system operation, the elevator must arrive to the requested building floor within a suitable time interval. Hence, the supercapacitor charge must be at the nominal value at the end of the elevator travel for the security of the next travel. These objectives are described by the following constraint:

A 2 x(t 1 ) = b 2 , (2.6.15)
where t 1 is the final instant of the elevator travel,

A 2 = 0 3×2 I 3 ∈ R 3×5 , b 2 x * s x * m T ∈ R 3 ,
with the reference values of supercapacitor charge, x * s ∈ R, of the machine speed and angle, x * m ∈ R 2 . This constraint can be simplified by removing the supercapacitor unit and replacing the electro-mechanical elevator with a statistic average power unit represented by P l (t) which is derived from the data of passenger mass m c , elevator start/stop instants t in , t f i , building floor required by the passenger θ. The simplified dynamics is used for the higher control level, i.e., electricity cost minimization.

The cost function penalizes the dissipated energy within the microgrid during the elevator travel: (2.6.16) where t 0 , t 1 are the initial and final instants of the elevator travel; f R (t), e R (t) ∈ R 11 are the resistive flow and effort vectors defined in (2.5.4), d(t) ∈ R 4 are the converter duty cycles of the components. For simplicity, we decompose this cost into two following costs:

V (d(t)) = - t1 t0 f T R (t)e R (t)dt,
V s (d b (t), d s (t)) = - t1 t0 f T R (t) I 9 0 0 0 e R (t)dt, (2.6.17a) V l (d l (t)) = - t1 t0 f T R (t) 0 0 0 I 2 e R (t)dt, (2.6.17b) where d s (t), d b (t) ∈ R, d l (t) ∈ R 2
are the converter duty cycles of the supercapacitor unit, of the battery unit and the electro-mechanical elevator, respectively. V l (d l (t)) will be considered in the controller of the electro-mechanical elevator in Chapter 4. The optimization problem corresponding to V s (d b (t), d s (t)) and its relation with the previous optimization will be considered in future works.

Electricity cost minimization: The electricity cost minimization for a day is meaningful since the electricity cost changes during a day. Therefore, the energy can be stored in the battery when it is cheap and reuse it when the electricity price is expensive. Thus, the electricity cost is described by the integration of the product of electricity price and purchased power from the external grid:

V e (i e ) = - 24h 0h price(t)i e (t)v e (t)dt,
(2. 6.18) where price(t) is the electricity price at the instant t; i e (t), v e (t) ∈ R are the external grid current and voltage, respectively.

Conclusions

This chapter introduced a Port Hamiltonian formulation for a DC microgrid elevator system. The model takes into account the nonlinear dynamics of the components controlled by the corresponding converters. The Park transformation for the Permanent Magnet Synchronous Machine is considered in a unified Port-Hamiltonian formalism. Then, the global dynamics of the DC microgrid is derived as an implicit Port-Hamiltonian dynamical system. Finally, the multilayer control problem is formulated within a constrained optimizationbased control framework which includes the system physical limitations, network operation and suitable cost functions. Further details on Port-Hamiltonian formulations applied for various works in energy systems can be found in [START_REF] Zonetti | Modeling and control of HVDC transmission systems from theory to practice and back[END_REF], Stegink et al., 2017[START_REF] Dòria-Cerezo | Passivity-based control of multi-terminal HVDC systems under control saturation constraints[END_REF][START_REF] Schiffer | A survey on modeling of microgrids: from fundamental physics to phasors and voltage sources[END_REF].

The next chapter will concentrate on the discretization method for the proposed Port Hamiltonian model formulation which will be later employed within the discrete-time load balancing problem of the microgrid system.

Chapter 3

Energy-preserving discretization

Introduction

For numerical simulation and practical control purposes, a discrete-time model derived from the continuoustime model is important. Since any discrete model is only an approximation of the continuous process from which is derived, the discretization method only aims at preserving some specific properties of the continuous model. Therefore, the continuous dynamics need to be formulated in an appropriate form, explicitly describing the system properties. In here we study the energy management for microgrids, hence the continuous dynamics should describe their stored energy and the power exchanges. These properties of the continuous systems are explicitly taken into account through the Port-Hamiltonian (PH) formulation [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]. In what follows, we present some existing methods based on this formulation to preserve the energy and/or the power exchange in the discretization process.

In the PH systems, the stored energy is represented by the Hamiltonian. The power exchange structure within the system is represented by a skew-symmetric matrix called the interconnection matrix (for more details, see in the appendix B.2). This matrix describes a Dirac structure (DS) and depends on the state coordinates. Moreover, when the interconnection matrix satisfies the integrability condition, there exists state coordinates where the interconnection matrix of the corresponding Hamiltionian system is constant (see Section B.2). Thanks to the skew-symmetric form of the interconnection matrix and the chain rule for the time derivative of the Hamiltonian, we can prove the energy conservation property along the state trajectory. Another important property of the Hamiltonian system is the symplecticity property defined in the appendix B (see Section B.1, Definition B.1.3), which considers the volume conservation along the state trajectories. More specifically, the symplecticity means that the volume defined by a set of initial states is equal to the volume defined by the corresponding set of state at the studied instant. This symplecticity is proved for Hamiltonian systems with canonical interconnection matrices as in [START_REF] Marsden | [END_REF]Ratiu, 1999, Hairer et al., 2006].

Some discretization methods for Hamiltonian systems are studied in [START_REF] Hairer | Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations[END_REF]. The authors aim at preserving the invariants (e.g., Hamiltonian, Casimirs) or the symplecticity property. The invariant conservation means that it is the same at each time step. The symplectic method only conserves the energy periodically, i.e., the energies at some fixed instants are the same. By preserving energy or by symplecticity, the energy levels at different time instants are kept near the continuous energy levels. Thus, the discrete state variables approximate well the continuous state variables even with long discrete-time step and long range simulation.

The open, lossless PH systems are obtained by adding external ports to the Hamiltonian system [van der Schaft and Jeltsema, 2014, [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]. If the external port variables are the control signals, the PH system is called a lossless Port-Controlled Hamiltonian (PCH) system. In this case, the DS is described by the interconnection and input matrices, which are called the structure matrices. Due to the energy supplied from the exterior, the Hamiltonian does not remain constant. Instead, we have an energy balance for the stored and the supplied energy at the external ports. There is no standard definition of symplecticity for PCH system. It can be defined by the conservation of DS, which is similar to the symplecticity in the Hamiltonian system, using a Poisson structure. This property is easy to test when the structure matrices are constant.

There are some works which tackle the energy balance and/or the symplecticity property preservation for the discrete-time model of lossless PCH systems [START_REF] Talasila | Discrete port-Hamiltonian systems[END_REF], Laila and Astolfi, 2006, Aoues, 2014]. In [START_REF] Talasila | Discrete port-Hamiltonian systems[END_REF], the authors propose a theoretical definition for the discrete-time PCH system which preserves the symplecticity. However, the proposed discrete-time model does not preserve the energy balance since the chain rule for the time derivation of the discrete Hamiltonian is not taken into account.

In [Laila andAstolfi, 2006, Aoues, 2014], the authors propose discretization schemes which aim at preserving the energy balance. The proposed algorithms also preserve the energy in the case of the closed Hamiltonian system. Generally, it is difficult to find a discretization method which preserves both the symplecticity and the energy balance. They can be nevertheless achieved in the case of linear lossless PCH system with a canonical interconnection matrix [START_REF] Aoues | Canonical interconnection of discrete linear port-Hamiltonian systems[END_REF].

By connecting the resistive elements to the lossless PCH system, we obtain the lossy PCH system [van der Schaft andJeltsema, 2014, Duindam et al., 2009]. In this case, the definition of symplecticity is similar to the one for the lossless PCH system. The energy balance is now defined by the zero sum of the energy flowing through the storage, resistive and external ports. The authors in [START_REF] Stramigioli | Sampled data systems passivity and discrete Port-Hamiltonian systems[END_REF], Aoues, 2014, Falaize and Hélie, 2017] propose some discretization methods which preserve the energy balance by taking into account the skew-symmetric form of the interconnection matrix. For their implementation the discrete-time flow/effort variables and the discrete-time interconnection matrix are considered. Also, they satisfy the discrete-time chain rule of the time derivation of the Hamiltonian and the hybrid input-output representation of DS of the continuous PCH system.

In our work, another class of open lossy PH system is studied where the control signals modulate the interconnection matrices (and consequently the DS) [START_REF] Escobar | A Hamiltonian viewpoint in the modeling of switching power converters[END_REF]. In here, some external port variables have to satisfy time-varying power constraints which comes from the integration of renewable sources. Since we consider the open-loop PH system, the control signals can vary arbitrarily and the DS is generally not constant. Consequently, the symplecticity for the discrete-time model is not possible. Thus, the proposed definition for the discrete-time PH system in [START_REF] Talasila | Discrete port-Hamiltonian systems[END_REF] can not be used directly. However, the energy balance conservation can still be obtained for the discrete-time model using the method presented in [START_REF] Stramigioli | Sampled data systems passivity and discrete Port-Hamiltonian systems[END_REF], Aoues, 2014, Falaize and Hélie, 2017]. In this particular work, we consider it for two non-linear subsystems of the DC microgrid, that is, the electro-mechanical elevator and the global multi-source elevator system.

This chapter presents two main contributions as follows.

• The time discretization method in [START_REF] Stramigioli | Sampled data systems passivity and discrete Port-Hamiltonian systems[END_REF], Aoues, 2014] is generalized for nonlinear lossy open PH systems with control-modulated structure matrices. The studied system includes the energy storage, the resistive element, the effort/flow source, the time-varying power source and the DS. The DS is described by a skew-sysmetric matrix which explicitly depends on the state and control variables. Therefore, the non-linearities lie in the state and control modulation of the structure matrices and in the time-varying power constraint of the external port. We define the discrete-time state, flow and effort variables which satisfy the discrete relation of the system elements as follows. The hybrid input-output representation of DS is preserved by keeping the skew-symmetric interconnection matrix.

The chain rule for the Hamiltonian time derivative is preserved by an appropriate choice of the discrete storage effort/flow variables. The discrete forms of the resistive elements and of the effort/flow sources are similar to the continuous ones. Also, the discretization of the time-varying power is represented by its average on a time step. Thanks to the presented discretization formulation, the discrete-time model preserves the energy balance. Moreover, we show that a time invariant coordinate transformation transforms an energy-preserving time discretization PH system to another one. This can be used to improve the accuracy of the discretization method.

• The presented method is validated through various simulations for the electro-mechanical elevator which is a lossy PCH system. Fortunately, since the Hamiltonian is quadratic, we can easily find a discretization scheme for the storage port variables which guarantees the chain rule for the Hamiltonian time derivation. As mentioned in the previous chapter, the electro-mechanical elevator dynamics is a combination of two time scale dynamics: electrical and mechanical parts. The electrical dynamics corresponds to the PMSM stator and is faster than the mechanical elevator dynamics. Therefore, to study the behavior of the electro-mechanical elevator dynamical model, we use small discretization time steps. This makes the numerical errors of the mechanical variables (i.e., elevator speed and position) insignificant. Also, for the studied discretization methods we implement and compare different schemes such as the explicit, implicit and midpoint rules for the interconnection matrix.

The presented method is applied for the multi-sources elevator system which is an open lossy PH system with a control-modulated structure. Similarly to the case of the electro-mechanical elevator, only the short time duration simulations are considered. It actually corresponds to the fast dynamics of the converters and DC bus. In this case, the midpoint rule within the energy-preserving method is used to compare with the first-order Euler methods. We find that its order is less than one obtained in the simulations for the electro-mechanical elevator. Besides, it does not create the energy sum error and results in high accuracies of the discrete state variables.

This chapter is organized as follows. Section 3.2 formally defines the energy-preserving discretization method. Section 3.3 presents the implementation of the proposed method for the electro-mechanical elevator which serves for the machine parameter identification. Section 3.4 considers the implementation of the same discretization method for the global multi-source elevator system in the fast time scale. Some conclusions and discussions are presented in Section 3.5.

Energy-preserving discretization

Time discretization concept

A time approximation method has three elements: approximation basis, weight vector, approximate function. Consider the time interval [t 0 , t f ], and the set G of all functions g : [t 0 , t f ] → R. The approximation basis is defined by choosing N independent functions λ i ∈ G with i ∈ {1, 2, . . . , N }, we have the approximation basis. We gather them in a vector Λ(t) = [λ 1 (t) . . . λ N (t)] T ∈ R N . Next, we represent the function g(t) in these basis by N real numbers g i with i ∈ {1, 2, . . . , N }, which we denote as the weights or coordinates of g(t). Similarly, we gather them in a vector g d = [g 1 (t) . . . g N (t)] ∈ R 1×N . The approximation of the function g(t) is denoted by g a (t) ∈ R and is defined as:

g a (t) = N i=1 g i λ i (t) = g d Λ(t). (3.2.1)
The approximation (3.2.1) is convergent if

lim N →∞ g a (t) = g(t), ∀t ∈ [t 0 , t f ]. (3.2.2)
Note that the approximation basis is chosen according to different criteria, e.g., the required accuracy, the available computation. However, to simplify the numerical computation we consider in (3.2.1) the first-order B-splines basis functions defined as:

λ i (t) = 1, if t 0 + (i -1)h ≤ t < t 0 + ih, 0, else , ∀i ∈ {1, 2, . . . , N }, (3.2.3)
where h = t ft 0 N is the time step. Note that, this choice is suitable for practical control. In fact, the real control signals are implemented at the beginning of each time step and kept constant until the next time step while waiting for the next control signals. The same situation happens for the feedback signals which are usually sampled with the same frequency. Therefore, in our work, the time discretization is defined as the time approximation with the first-order B-splines basis as in (3.2.1)- (3.2.3). The weights g d in (3.2.1) represent the discrete functions of g(t).

Using the above prerequisites the next subsection investigates the discrete functions of the state, flow and effort variables given in the PH Definition 2.2.5.

Energy-preserving discretization method

For the PH systems, the dynamical equations are described in terms of relations among sets of effort, flow and state variables. Thus, the time discretization of PH dynamics is defined as a set of algebraic equations which include discrete functions of the state, control, flow and effort variables. The main idea of the investigated method is to preserve the energy balance while maintaining unchanged the structure matrices describing the continuous time model.

First we define the discretized constitutive equations for the interconnection and for the DC microgrid elements (i.e., energy storage, static elements, time varying power source). The skew-symmetric form of the discrete-time interconnection matrix will guarantee power conservation within the interconnection. The chain rule for the discrete Hamiltonian time derivative and the average power for the time-varying power source will guarantee the energy conservation.

Discrete interconnection matrix: Let us recall the hybrid input-output representation of a PH system (see also Section 2.2.2 and [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]):

f (t) = D(x, u)e(t, u), (3.2.4)
where x(t) ∈ X ⊂ R n , u(t) ∈ U ⊂ R m are the state and control variables. The port variables are gathered in the flow and effort vectors as:

f (t) = f S (t) f R (t) f E (t) T , e(t) = e S (t) e R (t) e E (t, u) T . (3.2.5)
where f R (t), e R (t) are the flow and effort variables of the resistive element defined in (2.2.5), and f E (t), e E (t) are the flow and effort variables of the environment where some ports satisfy some time-varying constraints.

The flow and effort of the energy storage are described correspondingly by the time derivative of state variable f S (t) =ẋ(t), and the gradient vector of the Hamiltonian e S (t) = ∇H(x). Furthermore, in (3.2.4) the system interconnection is described by the skew-symmetric matrix D(x, u) given as:

D(x, u) =    -J(x, u) -G SR (x, u) -G(x, u) G T SR (x, u) 0 G RE (x, u) G T (x, u) -G T RE (x, u) M(x, u)    = -D T (x, u). (3.2.6)
Note that the control variables u(t) modulate the external effort. If the interconnection matrix D does not depend on the control signal u, the PH system defined by (3.2.4)-(3.2.6) is PCH system. Moreover, the skew-symmetric property of D(x, u) entails the internal power conservation of the system (3.2.4), i.e., e T (t)f (t) = 0.

The chain rule for the Hamiltonian, that is In fact, this represents, the passivity property with storage function H(x) and input/output pair e E (t), f E (t).

Ḣ(t) = ẋT (t)∇H(x), ( 3
Besides the state modulation, in the converter system the interconnection is switched between different topologies. For describing the topologies some binary variables are added in the interconnection matrices. However, since they are switched repeatedly with a high frequency, we replace the binary variables by their averages. More specifically, this average is the ratio of the time duration when the binary variable is 1 and the switching cycle duration (i.e., the sum of the duration when the binary variable is 1 and the duration when the binary variable is 0). Furthermore, they are also the control variables.

Hereinafter, the discretization of the interconnection matrix D(x, u) in (3.2.6) is derived which varies with the discrete time. Definition 3.2.1 (Discrete interconnection). Let D(x, u) be the interconnection matrix defined in (3.2.4) and (3.2.6). Its discretization D d over the time interval [t 0 , t f ] is an arranged set of N matrices D i with i ∈ {1, . . . , N } denoting the time step such that:

D i = D(g D (i, x d ), u i ), (3.2.10)
where g D is a chosen discretization map g D : {1, . . . , N } × X N → X and x d ∈ X N is the discrete function of x(t). Thus, the discretization of the Dirac structure (3.2.4) is described by: .2.11) The previous definition states that the discrete form of the interconnection matrix D(x, u) is obtained by replacing x and u with g D and u i , respectively. There are many possible choices for g D , e.g.,

f i = D(g D (i, x d ), u i )e i . ( 3
     g D (i, x d ) = x l,i , g D (i, x d ) = x i+1 , g D (i, x d ) =
x l,i + x i+1 2 .

(3.2.12)

The above discretization schemes are not computationally demanding and this will be proven through simulations for the electro-mechanical elevator and the microgrid system. We denote the discrete functions of effort and flow variables given in (3.2.5)

         -hf T S,i (x d )e S,i (x d ) = H(x i ) -H(x i-1 ), ∀i ∈ {1, . . . , N }, lim N →+∞ f S,i (x d ) = ẋ(t i ), ∀i ∈ {1, . . . , N }, lim N →+∞ e S,i (x d ) = ∇H(x i ), ∀i ∈ {1, . . . , N }. (3.2.14)
Generally, it is difficult to find all admissible choices for the discrete flow and effort vectors. However, we can characterize a class of these solutions. A popular discretization scheme for the storage flow vector is the left finite difference formula:

f S,i (i, x d ) = - x i -x i-1 h . (3.2.15)
Then, the corresponding discretization for the storage effort vector is given by the discrete derivative of the Hamiltonian: e S,i (i,

x d ) = DH(x i , x i-1 ). (3.2.16)
where the discrete derivative, Dg, of a function, g, is defined in the following definition.

Definition 3.2.3. (Discrete derivative [Gonzalez, 1996]) Let X be an open subset of R m . A discrete derivative for a smooth function g : X → R is a mapping Dg : X × X → R m with the following properties:

1. Directionality:

Dg(x 1 , x 2 ) T (x 1 -x 2 ) = g(x 1 ) -g(x 2 ) for any x 1 , x 2 ∈ X, 2. Consistency: Dg(x 1 , x 2 ) = ∇g x 1 + x 2 2 +O( x 1 -x 2 ) for all x 1 , x 2 ∈ X with x 1 -x 2 sufficiently small.
Proposition 3.2.4. The discretization scheme defined by (3.2.15) and (3.2.16) is admissible.

In the following, we present two examples for finding the discrete derivative of the Hamiltonian.

Example 3.2.5. (Midpoint rule for the discrete derivative of a quadratic Hamiltonian [START_REF] Hairer | Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations[END_REF]).

Let H(x) be a quadratic Hamiltonian:

H(x) = Q 0 + Q T 1 x + 1 2 x T Q 2 x, (3.2.17) where x ∈ X ⊂ R n , Q 0 ∈ R, Q 1 ∈ R n×1 , Q 2 ∈ R n×n such that Q 2 = Q T 2 ≥ 0.
The discretization for the storage effort vector defined by the midpoint rule is a discrete derivative of the Hamiltonian H(x) in (3.2.17):

e S,i (i, x d ) = Q 1 + Q 2 x i + x i-1 2 , ∀i ∈ {1, . . . , N }. (3.2.18)
Consequently, the discretization scheme defined by (3.2.15) and (3.2.18) is admissible thanks to Proposition 3.2.4. This method will be employed later in Section 3.3 and 3.4 for the simulations of the electro-mechanical elevator and of the microgrid system.

Example 3.2.6. (Discrete gradient [Aoues, 2014, Falaize andHélie, 2017]). Another method for finding the discrete derivative of the Hamiltonian is by using the discrete gradient. Consider that the discrete-time states x i-1 , x i are two opposite vertices of a hypercube in the state space X ∈ R n , where x i-1 is the origin and x i is the final state. We consider a path from x i-1 to x i including n sub-paths which are the edges of the hypercube. Thus, there are n! choices for this path. The path and the corresponding Hamiltonian evolution are described by the following graph:

x i-1 → . . . →         . . . x k,i-1 . . . x j,i-1 . . .         →         . . . x k,i . . . x j,i-1 . . .         →         . . . x k,i . . . x j,i . . .         → . . . → x i , x i-1 → . . . → . . . → x k,i-1 → x j,i-1 → . . . → . . . , H(x i-1 ) → . . . → . . . → H k (x k,i-1 ) → H j (x j,i-1 ) → . . . → H(x i ), (3.2.19)
where x k,i and x j,i are the k th and j th coordinates of the state vector at the instant i, x j,i-1 ∈ R n is the discrete state vector where only the j th coordinate is different from the j th coordinate of the discrete state vector on the left in the series (3.2.19), i.e., x k,i-1 . The discrete gradient of the Hamiltonian is denoted by ∇H(x i-1 , x i ) ∈ R n where the j th coordinate is defined by:

∇ j H(x i-1 , x i ) = H j (x j,i-1 ) -H k (x k,i-1 ) x j,i -x j,i-1 . (3.2.20)
From Proposition 6 in [Aoues, 2014], the mapping ∇H : R n × R n → R n defined by (3.2.20) is a discrete derivative. Therefore, using Proposition 3.2.4, the discretization scheme for the storage effort vector, e S (t), and (3.2.15) for the storage flow vector, f S (t), are admissible:

e S,i (i, x d ) = ∇H(x i-1 , x i ). (3.2.21)
Furthermore, if the Hamiltonian is quadratic as in (3.2.17) and the weight matrix Q 2 is diagonal, the discrete gradient of the Hamiltonian is rewritten as:

∇H(x i-1 , x i ) =      . . . H j (x j,i-1 ) -H k (x k,i-1 ) x j,i -x j,i-1 . . .      =        . . . Q 1,j x j,i + 1 2 Q 2,j,j x 2 j,i -Q 1,j x j,i-1 - 1 2 Q 2,j,j x 2 j,i-1 x j,i -x j,i-1 . . .        =      . . . Q 1,j + Q 2,j,j x j,i + x j,i-1 2 . . .      = Q 1 + Q 2 x i + x i-1 2 ,
where Q 1,j is the element at the j th row of matrix Q 1 , Q 2,j,j is the element at the j th row and j th column of matrix Q 2 . In this case, we see that the discrete gradient of the Hamiltonian satisfies the midpoint rule for the Hamiltonian gradient vector.

Besides the linear discretization scheme for the flow vector (3.2.15), an admissible choice may be nonlinear. For example, if all the coordinates of the state vector are different from zero, a discretization for the storage flow variable is given by:

f S,j,i (i, x d ) = - x 2 j,i -x 2 j,i-1 2hx j,i , j = 1, . . . , n, i = 1, . . . , N. (3.2.22)
Next, the discretization for the storage effort vector is obtained by rewriting (3.2.16) as:

e S,j,i (i, x d ) = x j,i x j,i + x j,i-1 DH j (x i-1 , x i ), j = 1, . . . , n, i = 1, . . . , N. (3.2.23)
where n ∈ N is the dimension of the state space X, f S,j,i , e S,j,i , x j,i , DH j are, respectively, the j th coordinates of the flow, effort, state and discrete derivative vectors at the instant t i . By multiplying the discrete time flow in (3.2.22) by the discrete time effort in (3.2.23), we can verify the energy conservation condition (3.2.14) as follows:

-hf S,i (x d ) T e S,i (x d ) = -h n j=1 f S,j,i (i, x d )e S,j,i (i, x d ) = -h n j=1 - x 2 j,i -x 2 j,i-1 2hx j,i x j,i x j,i + x j,i-1 DH j (x i-1 , x i ) = n j=1 (x j,i -x j,i-1 ) DH j (x i-1 , x i ) = H(x i ) -H(x i-1 ).
Generally, the nonlinear discretization schemes are not definite over the whole state space, e.g., the scheme (3.2.22) is not definite in {x ∈ X|∃j ∈ {1, . . . , n}, x j = 0}. Furthermore, they require a huge computation due to the complex derived algebraic equations for the discretization scheme. Moreover, these equations may have no solution. However, in some cases, to improve the accuracy of the discretization we must use nonlinear schemes. An example for the nonlinear flow discretization will be considered in Section 3.2.3. Discrete static elements: An element is called static if its port variables satisfy a static relation. From this definition, the static elements of the microgrid system are the static resistive element, the constant power source, the effort/flow sources, the fast time scale dynamics at its steady state. These static relations are defined for the discrete time model as in the following definition. Definition 3.2.7 (Discrete static elements). Let f (t), e(t) be the conjugate variables of the static ports with the static relation:

s(f , e) = 0, ∀t ∈ [t 0 , t f ]. (3.2.24)
Their discrete functions f d , e d are chosen such that:

s(f i , e i ) = 0, ∀i ∈ {1, . . . , N }. ( 3

.2.25)

Discrete time-varying power source: There are some ports where the product of the conjugate variables is not static, i.e., time-varying power source P (t) with:

f (t)e(t) = P (t), ∀t ∈ [t 0 , t f ], ( 3
f i e i = P i , with P i = 1 h (i+1)h ih P (t)dt, ∀i ∈ {1, . . . , N }. (3.2.27)
The previous definition of the discretization of time varying power source implies that the supplied energy of the discrete power during the interval [t i , t i-1 ] is equal to the supplied energy of the continuous power. Obviously, it requires the exact data for the supplied power which is not always available.

Discussions: The discrete-time dynamics of the PH system (3.2.4)-(3.2.6) are specified by the discretization schemes as in Definitions 3.2.1-3.2.8. We underline that the presented discretization method preserves the energy balance, i.e.,

H(x

i ) -H(x i-1 ) = f T R,i e R,i + f T E,i e E,i , ∀i ∈ {1, . . . , N }. (3.2.28)
Also, if the Hamiltonian is bounded from below, the discrete-time PH system is passive. However, the discretized energy may not be equal to the continuous one.

Remark 3.2.9. Note that the chosen discretization scheme needs to satisfy the convergence condition (Definition 4.1 in [START_REF] Hairer | Solving Ordinary Differential Equations I: Nonstiff Problems[END_REF]). If it is a linear multistep method, the necessary and sufficient conditions for the convergence are the stability and consistency (Theorem 4.2 in [START_REF] Hairer | Solving Ordinary Differential Equations I: Nonstiff Problems[END_REF]). However, since this is not the main goal of our work, we assume that these conditions are always respected.

Discrete-time Port-Hamiltonian system through coordinate transformation

In this subsection we consider the discrete-time PH system through the coordinate transformation. According to Proposition 2.4.2 every invertible time invariant transformation of the state space z = ϕ(x) preserves the PH formulation.

Let the Jacobian matrix of the state transformation be defined by:

W(x) ∂ x ϕ(x). (3.2.29)
For the simplicity, we denote by W(z) the representation of the Jacobian matrix by the transformed state W(ϕ -1 (z)) where ϕ -1 (z) implies the inverse state transformation. The transformed PH system is described by:

f z (t) = D z (z, u)e z (t, z, u), (3.2.30)
where z(t) ∈ ϕ(X), u(t) ∈ U are the state and control variables. The port variables are represented by the global flow and effort vectors as: (3.2.31) where the storage flow and effort vectors are given by f S,z (t) =ż(t), e S,z (t) = ∇H(z). The transformed interconnection matrix is given by:

f z (t) = f S,z (t) f R,z (t) f E,z (t) T , e z (t) = e S,z (t) e R,z (t) e E,z (t, u) T ,
D z (z, u) =    -W(z)J(z, u)W T (z) -W(z)G SR (z, u) -W(z)G(z, u) G T SR (z, u)W T (z) 0 G RE (z, u) G T (z, u)W T (z) -G T RE (z, u) M(z, u)    . (3.2.32)
Note that the relations of the port variables in two coordinates are described as follows: Thanks to the explicit description of the energy through the Hamiltonian in the PH formulation, the energy-preserving discretization method was developed. It is important to mention that, there exists a special property called Casimir for which a coordinate transformation of the PH formulation is necessary. Note that Casimir C(x) is a function which is constant along the state trajectory with any Hamiltonian (see in the Appendix B, Section B.2.2). The following example illustrates an energy-preserving discretization scheme which preserves Casimir by using a suitable coordinate transformation.

                             f S,z (t) = -ż(t) = -W(x) ẋ(t) = W(x)f S (t), e S (t) = ∇H(x) = W T (x)∇H(z) = W T (x)f S,z (t), f R,z (t) = f R (t), e R,z (t) = e R (t), f E,z (t) = f E (t), e E,z (t) = e E (t). ( 3
                                   x i = ϕ -1 (z i ), f S,i = W -1 (g D (i, z d ))f S,z,i , e S,i = W T (g D (i, z d ))e S,z,i , f R,i = f R,z,i , e R,i = e R,z,i , f E,i = f E,z,i , e E,i = e E,z,i , (3
Example 3.2.11. (Discretization scheme for preserving the Hamiltonian and the Casimir)

PH system and Casimir property: Consider a PH system given by: ẋ(t) = J(x)∇H(x), (3.2.35) where

x(t) = [x 1 (t) x 2 (t) x 3 (t)] T ∈ R 3
is the state vector, the interconnection matrix and the Hamiltonian are given by:

J(x) =    0 0 x 2 0 0 -x 1 -x 2 x 1 0    , H(x) = 1 2 x 1 - 1 2 2 + 1 2 x 2 2 + 1 2 x 2 3 = Q 0 + Q 1 x + 1 2 x T Q 2 x, (3.2.36) with Q 0 = 1 4 , Q 1 = - 1 2 0 0 , Q 2 = I 3 .
It is easy to verify that the Hamiltonian H(x) and the Casimir

C(x) = x 2 1 + x 2 2
2 are the invariants of the considered PH system. In what follows, we present 5 time discretization schemes for the system (3.2.35)-(3.2.36) including:

• 2 classical schemes: the explicit and implicit Euler schemes,

• 2 energy-preserving schemes called the mix scheme 1 and the mix scheme 2,

• an energy-preserving scheme which also preserves the Casimir.

We partition the time duration [0, T ] to N time subintervals with the time step h = T N . Let i ∈ {1, . . . , N } be the time index.

The explicit/implicit Euler schemes: They are respectively given by the following expressions:

1 h (x i -x i-1 ) =J(x i-1 )(Q 1 + Q 2 x i-1 ), (3.2.37a) 1 h (x i -x i-1 ) =J(x i )(Q 1 + Q 2 x i ). (3.2.37b)
The mix scheme 1 and the mix scheme 2: Since the Hamiltonian is quadratic with the diagonal weight matrix Q 2 , we can choose the midpoint rule for the discretization of the effort vector ∇H(x). Thus, they are given by the following expressions:

1 h (x i -x i-1 ) =J(x i-1 ) Q 1 + Q 2 x i-1 + x i 2 , (3.2.38a) 1 h (x i -x i-1 ) =J(x i ) Q 1 + Q 2 x i-1 + x i 2 . (3.2.38b)
The Casimir conservation scheme: Let z(t) = [z 1 (t) z 2 (t) z 3 (t)] T ∈ R 3 be the transformed state vector with

z 1 = x 1 , z 2 = x 3 x 2 , z 3 = C(x) = x 2 1 + x 2 2 2 .
Thus, the inverse state transformation is:

x 1 = z 1 , x 2 = 2z 3 -z 2 1 , x 3 = z 2 2z 3 -z 2 1 .
Note that we consider only the haftspace defined by x 2 > 0 where the transformation is feasible. The Jacobian matrix of this transformation is:

W(x) =      1 0 0 0 - x 3 x 2 2 1 x 2 x 1 x 2 0      =      1 0 0 0 - z 2 2z 3 -z 2 1 1 2z 3 -z 2 1 z 1 2z 3 -z 2 1 0      = W(z).
The transformed PH system is described by: 3.2.39) where the interconnection matrix and the Hamiltonian are, respectively:

ż(t) = J z ∇H(z), (
J z =    0 1 0 -1 0 0 0 0 0    , H(z) = 1 2 -z 2 1 z 2 2 + 2z 2 2 z 3 -z 1 + 2z 3 + 1 4 . (3.2.40)
An energy-preserving discretization for the transformed system (3.2.39)-(3.2.40) is described by:

1 h (z i -z i-1 ) = J z       - 1 2 (z 1,i + z 1,i-1 ) z 2 2,i - 1 2 (z 2,i + z 2,i-1 ) z 3,i - 1 2 z 2 1,i-1 z 2 2,i-1 + 1      
.

We note that the elements on the third line of the interconnection matrix J z are zeros. Therefore, C i -C i-1 = z 3,iz 3,i-1 = 0, ∀i. Thus, the C(z) is preserved along the discrete-time state trajectory. Using the inverse state transformation, we determine the Casimir preserving discretization scheme of the original system (3.2.35)-(3.2.36):

f i = J(x i-1 )e i , (3.

2.41)

with the discrete time flow vector:

f i = - 1 h      1 0 0 0 - x 3,i-1 x 2 2,i-1 1 x 2,i-1 x 1,i-1 x 2,i-1 0      -1        x 1,i -x 1,i-1 x 3,i x 2,i - x 3,i-1 x 2,i-1 x 2 1,i + x 2 2,i 2 - x 2 1,i-1 + x 2 2,i-1 2        , (3.2.42)
and the discrete time effort vector:

e i =      1 0 0 0 - x 3,i-1 x 2 2,i-1 1 x 2,i-1 x 1,i-1 x 2,i-1 0      T           - 1 2 (x 1,i + x 1,i-1 ) x 2 3,i x 2 2,i - 1 2 x 3,i x 2,i + x 3,i-1 x 2,i-1 x 2 1,i + x 2 2,i 2 - 1 2 x 2 1,i-1 x 2 3,i-1 x 2 2,i-1 + 1           . ( 3

.2.43)

We can see that the admissible discrete time flow vector, f i (i, x d ), is not in a linear form.

Simulations: The simulations for this example are implemented with the simulation duration T = 3s and the initial state x 0 = [1 1 -1] T . The state variable errors of these schemes are computed as

error = max i ||x i -x(t i )|| 2 ,
where x(t) is the continuous time state at the instant t, ||.|| 2 is the second norm. After implementing some simulations with different time steps h = 0.1s, h = 0.01s, h = 0.001s, we obtain Fig. 3.2.1 which indicates that the mentioned schemes are first-order (the slope of the straight lines). 3.3 Numerical results for the electro-mechanical elevator

Discrete-time model

In this section we use the discretization method presented in Section 3.2 for discretizing the electro-mechanical elevator dynamics given by (2.4.24). In the dynamics (2.4.24), the input matrix G l is modulated by the control variable d l . We simplify the input matrix by defining the voltages and currents on the direct and quadrature phase of the machine stator, denoted by v l (t), i l (t) ∈ R 2 , such that:

v l (t) d l (t)v l (t), i l (t) [I 2 0]∇H l (x l ).
Then, the dynamics (2.4.24) is rewritten as:

f l (t) = D l (x l )e l (t), v lR (t) = -R l i lR (t), (3.3.1)
where the flow/effort variables and the interconnection matrix are:

f l (t) =    -ẋl (t) i lR (t) i l (t)    , e l (t) =    ∇H(x) v lR (t) v l (t)    , D l (x l ) =    -J l (x l ) -G lR (x l ) -G ll G T lR (x l ) 0 0 G T ll 0 0    , (3.3.2)
with the input matrix:

G ll = I 2 0 ∈ R 4×1 . (3.3.3)
The Bond Graph description of this system can be found in Fig. 2

f l,i = D l (g D (i, x l,d ))e l,i , (3.3.4a) v lR,i = -R l i lR,i , (3.3

.4b)

∀i ∈ {1, . . . , N }, where x l,d is the discretized function of the state variable x l , g D (i, x l,d ) is described in the Definition 3.2.1. Since the Hamiltonian is quadratic, the two corresponding discretization schemes can be chosen as the forward finite difference formula and the midpoint rule forẋl and g H (i, x l,d ), respectively, as in (3.2.15), (3.2.18):

f l,i =    - x l,i -x l,i-1 h i lR,i i l,i    , e l,i =    Q l1 + Q l2 x l,i + x l,i-1 2 v lR,i v l,i    , (3.3.5)
where g H (i, x l,d ) is defined in the Definition 3.2.2 of the discrete storage, Q l1 , Q l2 are the weight matrices in the Hamiltonian (2.4.30)-(2.4.31). Combining (3.3.4) and (3.3.5), we obtain the discrete model of the electro-mechanical elevator system as: (3.3.6) ∀i ∈ {1, . . . , N }. Note that the maps g D (i, x l,d ) is freely chosen. In our work, three first schemes in (3.2.12) are considered. The benefits of the above presented methods are shown through simulations in the following section.

              - x l,i -x l,i-1 h i lR,i i l,i    = D l (g D (i, x l,d ))    Q l1 + Q l2 x l,i + x l,i-1 2 v lR,i v l,i    , v lR,i = -R l i lR,i ,

Simulation results

This section presents some simulation results for the discrete-time model of the electro-mechanical elevator system. The forthcoming simulations use the parameters presented in (2.4.21) and (2.4.28) with the numerical data given by the industrial partner Sodimas (an elevator company from France). They are listed in Table 3.3.1. The simulation setting is presented in Table 3.3.2: the simulation duration, the time steps, the control variables and the initial state variables. They satisfy the constraints on the rotor speed, on the position and on the duty cycle given in Section (2.6.2). The electro-mechanical elevator dynamics admit the multi-time scale property, i.e., the electromagnetic dynamics is much faster than the mechanical dynamics. In order to consider the transient period for all state variables (where the discretization effect is visible), we study the fastest dynamics for a duration T = 0.15 s (determined through simulations) and various time steps from h = 10 -5 s to h = 5.10 -2 s as in Table 3.3.2 Different energy-preserving discretization schemes: Firstly, we implement the energy-preserving discretization method with different schemes for g D (i, x l,d ) (i.e., different discrete interconnection matrices) defined in (3.3.6). Three simple schemes are considered:

1. Scheme 1: g D (i, x l,d ) = x l,i , (3.3.7) 2. Scheme 2: g D (i, x l,d ) = x l,i+1 , (3.3.8)
3. Scheme 3:

g D (i, x l,d ) = x l,i + x l,i+1 2 .
(3.3.9) Fig. 3.3.1 illustrates the logarithm maximal absolute discrepancies between the discrete and continuous states with different time steps:

error j = max i∈{1,...,N } |x j,i -x j (t 0 + ih)|,
where h is the time step, x j ∈ R is the j th coordinate of the state variable vector. Furthermore, from Fig. 3.3.1 we find that the orders of the mix Scheme 1, mix Scheme 2 and midpoint rule are 1, 1 and 2, respectively, which are equal to the slopes of the straight lines. We can see that the magnetic fluxes in the fast time scale converge to the steady values determined by the mechanical variables in the slower time scale. From the electro-mechanical dynamics, we can observe that only the rotor speed affects the two magnetic fluxes. Thus, even when the rotor position increases, the steady states of the two magnetic fluxes do not change. Since Scheme 3 is second-order, the obtained discrete state errors are smaller than the ones from the two others.

Energy-preserving discretization method and other methods:

The next simulations present some comparisons of the energy-preserving method under Scheme 1 (see (3.3.6) and (3.3.7)) and two classical discretization schemes (the explicit Euler, the implicit Euler). Based on (3.3.6), the discretization by the explicit and im-plicit Euler methods are respectively given by:

     - x l,i -x l,i-1 h i l,R,i i l,i      =D l (x l,i-1 )      Q l,1 + Q l,2 x l,i-1 v l,R,i v l,i      , (3.3.10a)      - x l,i -x l,i-1 h i l,R,i i l,i      =D l (x l,i )      Q l,1 + Q l,2 x l,i v l,R,i v l,i      , (3.3.10b)
where the discretization for the resistive element is given by (3.3.4b). Fig. 3.3.4 illustrates the logarithm of the maximal absolute errors of the discrete time states with different time steps:

error j = max i∈{1,...,N } |x j,i -x j (t 0 + ih)|.
where h is the time step, x j ∈ R is the j th coordinate of the state vector. From the results, we can realize that the order of the studied discretization methods is 1. Beside the state error, we study here the created energy sum error which is defined by the discrepancy between the increasing energy and the one supplied from the resistive and external elements:

E h = H(x l,i ) -H(x l,i-1 ) -(P R + P E )h. (3.3.11)
The power sum error is defined by:

P h = E h h . (3.3.12)
From the previous definitions, we can easily prove that the explicit Euler method creates the positive energy sum error.

E ex = Q l,0 + Q T l,1 x l,i + 1 2 x l,i Q T l,2 x l,i -Q l,0 + Q T l,1 x l,i-1 + 1 2 x l,i-1 Q T l,2 x l,i-1 -(i T l,R,i v l,R,i + i T l,i v l,i )h
, thanks to (2.4.30), = 1 2 (x l,ix l,i-1 ) T Q l,2 (x l,ix l,i-1 ) > 0 , thanks to (3.3.10a) and D = -D T .

Similarly, the implicit Euler method creates the negative energy sum error

E im = - 1 2 (x l,i -x l,i-1 ) T Q l,2 (x l,i -x l,i-1 ),
and the energy-preserving method does not create the energy sum error, i.e., E en = 0. The evolution of the Hamiltonian of the continuous and discrete systems are given in Fig. 3.3.6. We observe that, though Scheme 1 preserves the energy, the discrete energy error may be greater than the ones obtained by the classical first order methods. From the state errors in Fig. 3 Discussions: From the above simulations for the electro-mechanical elevator, some remarks are in order. An energy-preserving method does not create the energy sum error/power. Scheme 3 of the energy-preserving method for the electro-mechanical elevator is actually the midpoint method.

Numerical results for the global multi-source elevator dynamics 3.4.1 Discrete-time model

This section studies an energy-preserving discrete-time model for the DC microgrid presented in Section 2.5.2. Since the microgrid dynamics (2.5.7) have the multi-time scale property, the transient period of the fast dynamics takes place in a short time interval which requires short time steps. Other than investigating the efficiency of the discretization method, we will illustrate the consistency of the multi-time scale property and the stability of the fast dynamics. Therefore, we consider here a short time duration where the slow variables are assumed to be constant.

In the discretization method proposed in Section 3.2, we aim at finding the maps g D (i, x d ), f (i, x d ) and e(i, x d ). For the simplicity, the discretization of the flow vector is chosen by the left finite difference formula (3.2.15). Furthermore, since the Hamiltonian is quadratic as (2.5.11), the suitable choice for the effort discretization is given by the midpoint rule (3.2.18). Therefore, the discretization of the flow and effort variables in (2.5.8) is described as:

f i =        - x l,i -x l,i-1 h f R,i v e,i v r,i        , e i =        Q 1 + Q 2 x l,i + x l,i-1 2 e R,i i e,i i r,i        , ∀i ∈ {1, . . . , N }. (3.4.1)
Based on the results obtained for the three scheme comparisons for g D (i, x d ) in Section 3.3, we choose here the midpoint discretization:

g D (i, x d ) = x l,i + x l,i-1 2 , ∀i ∈ {1, . . . , N },
which leads to the discrete interconnection:

f i = D x l,i + x l,i-1 2 , d i e i , ∀i ∈ {1, . . . , N }. (3.4.2)
From Definition 3.2.7, the discrete model for the static resistive element is expressed as:

f R,i = -R R e R,i , ∀i ∈ {1, . . . , N }. (3.4.3)
From Definition 3.2.8, we get the discrete model for the renewable power source:

f r,i e r,i = P r,i , with P r,i = 1 h (i+1)h ih P r (t)dt, ∀i ∈ {1, . . . , N }. (3.4.4) Consequently, by combining (3.4.1)- (3.4.4) the discrete-time model for the microgrid is given as: (3.4.5) ∀i ∈ {1, . . . , N }.

                                  - x l,i -x l,i-1 h f R,i v e,i v r,i        = D x l,i + x l,i-1 2 , d i        Q 1 + Q 2 x l,i + x l,i-1 2 e R,i i e,i i r,i        , P r,i = -i r,i v r,i , f R,i = -R R e R,i ,

Simulations for the global multi-source elevator dynamics

This section presents simulation results for the discrete-time model of the DC microgrid elevator illustrated in Fig. 2.1.1. The parameters are presented in Section 2.3 and 2.4 with some numerical data given by the industrial partner Sodimas (an elevator company from France) which are given in Table 3.3.1 and 3.4.1. [Ω] 0.13 R t,2

[Ω] 0.17 R t,3

[Ω] 0.19 R t,4

[Ω] 0.23 R t,5

[Ω] 0.29 R t,6

[Ω] 0.31 Reference DC bus voltage

v * l [V ] 400 DC converter inductances L b,1 , L b,2 , L s,1 , L s,2 [mH] 0.25 DC converter capacitances C b,1 , C b,2 , C s,1 , C s,2 [F ] 0.008 Battery maximal charge q max [Ah] 183 Battery charge factor b 0.4 Battery internal coefficient k [s -1 ] 0.000105 Maximal voltage E max [V ] 13.8 Minimal voltage E min [V ] 13 Battery resistor R b [Ω] 0.015 Supercapacitor charge C s [C] 58 Supercapacitor resistor R s [Ω] 0.026 Renewable power P r [W ] 400 External current i e [A] - 1
Different scenarios with many time steps and discretization methods are considered. In fact, other than the energy-preserving method, the explicit/implicit Euler methods are also considered for comparisons. The duty cycles d(t) ∈ R 4 are chosen constant such that the constraints (2.6.5) and (2.6.12) are satisfied. The dynamics of the energy-supplying system admit the multi-time scale property, e.g., the dynamics of converter and DC bus are faster than the others (mechanical and chemical ones). We consider the transient period where the discretization effect is visible, we study the fastest dynamics over a time duration T = 0.01s (determined by the simulation), and various time step from h = 10 -6 s to h = 10 -4 s. Furthermore, during this short time interval, the external current i e and renewable power P r are assumed to be constant. The simulation configurations are presented in Table 3.4.2. x cs (0) [0 3.2 0 0.24] T Initial electro-mechanical elevator state x l (0) [1.2 1 0 0] T Fig. 3.4.1 describes the discrete state errors of the microgrid state variables (the battery, the supercapacitor, the converters and the DC bus) with different time steps. From the simulation results, we can observe that the orders of the explicit/implicit Euler and energy-preserving methods are 1. Especially, the order of the electro-mechanical elevator state errors under Scheme 3 is not 2 as the simulation results under this scheme in Section 3.3.2. This is caused by the short time simulation where these variables are nearly constant. Since the microgrid interconnection is modulated only by these variables, it makes the interconnection matrix constant, and the microgrid dynamics becomes linear (due to the quadratic Hamiltonian). Therefore, the midpoint rule becomes a first-order method. Fig. 3.4.2 illustrates the Hamiltonian evolution in the continuous and discrete cases. At the beginning, it decreases because of the energy dissipation in the resistors. Moreover, the transient period in the Hamiltonian dynamics (from 0 ms to 1 ms) corresponds to the fast dynamics of the converter and transmission lines. We note again that the transient period of these dynamics are much shorter than the transient period of the machine stator dynamics which approximates 0.15 s as in Fig. 3.3.2. Fig. 3.4.3 describes the element and the power sum error of the discrete methods. Similar to the conclusion in Section 3.3.2, we find that the explicit/implicit Euler method create the positive/negative power sum error for the considered microgrid system while the midpoint rule does not.

Conclusions

In this chapter, we formulated an energy-preserving time discretization method for nonlinear Port-Hamiltonian systems. We proposed separate discretizations for each of the essential elements in the PH formulation such as, the power-preserving interconnection, the energy storage, the static element and the time-varying power source. The energy conservation property is guaranteed by preserving the skew-symmetric form of the interconnection matrix and the chain rule for the time derivative of the Hamiltonian. Moreover, we showed that a discrete-time system obtained by a time invariant coordinate transformation for an energy-preserving discrete-time system is also an energy-preserving discrete-time system. An illustrative example is presented where this combination is used to improve the accuracy of the discretization method. The formulated energypreserving time discretization method is interesting since it is suitable for nonlinear PH system where the interconnection matrix is modulated by the control variables. Furthermore, for the passive PH system, the discrete-time model preserves the passivity which will be useful for control purposes.

We apply the presented method and two classical methods (explicit/implicit Euler methods) for the electro-mechanical system and the multi-sources elevator system within the fast time scale.

The energy-preserving time discretization method leads to the high accuracy discrete-time model with respect to some classical same order discretization methods. Moreover, the accuracy order of a time discretization scheme depends on the considered time scale. Some works which have proposed some discretizations methods can be found in [START_REF] Stramigioli | Sampled data systems passivity and discrete Port-Hamiltonian systems[END_REF], Talasila et al., 2006, Hairer et al., 2006, Aoues, 2014, Falaize and Hélie, 2017]. Optimization-based control for the electro-mechanical elevator

Introduction

As presented in Section 2.6, the dissipated energy minimization for the electro-mechanical elevator respecting the system dynamics, state and input constraints is formulated as a constrained continuous-time optimization problem. This chapter presents in detail the problem formulation and its solution through the combined use of Port-Hamiltonian system representation, differential flatness with B-splines parameterization and MPC (Model Predictive Control). Generally, it is difficult to solve a constrained continuous-time optimization problem. In the literature, some solutions are given for the unconstrained and linear case, for example, the Linear Quadratic Regulator (LQR) which is similar with a proportional controller determined from the solution of the Algebraic Riccati Equation [Liberzon, 2011]. In LQR it is assumed that the whole state is available for control at all times. One possible generalization is the Linear Quadratic Gaussian Regulator (LQG) where the design of a Kalman filter is employed. The LQG is also studied for the case of linear Port-Controlled Hamiltonian systems in [Wu, 2015]. Note that LQR and LQG are tracking controllers, i.e., they stabilize the system to the references by penalizing in the cost function the discrepancies between the actual signals and the references. In [START_REF] Lifshitz | Optimal control of a capacitor-type energy storage system[END_REF], the authors find the solution of a constrained continuous-time optimization problem for a capacitor-type energy storage system. The optimal control problem includes an economic cost function, a first-order dynamics and a linear constraint. Methods for finding the solution of a constrained non-linear optimal control problem with more general cost functions are still under study. A possible solution is to approximate the continuous optimal problem by a discrete-time optimization, [Liberzon, 2011, Boyd andVandenberghe, 2004], which is easier to study and to implement.

There are various methods for approximating a continuous-time optimization by a discrete-time optimization. A popular approach is by using the zero-order B-splines to parametrize the variables (see Section 3.2.1). This is easy to implement [START_REF] Rawlings | [END_REF]Mayne, 2009, Ellis et al., 2017]. A drawback of this approach is represented by the fact that the approximated variables do not respect the system dynamics. Thus, higher dimensions are necessary for good approximations, this requiring significant computations. To reduce the computational complexity, the optimization problem can be decomposed into an off-line reference trajectory generation and an on-line tracking control problem. This is the approach we follow in this work for the optimal control of the electro-mechanical elevator of the DC microgrid system illustrated in Fig. 2

.4.1

The electro-mechanical elevator includes the Permanent Magnet Synchronous Machine (PMSM), a mechanical elevator and an AC/DC converter. Usually, the reference profiles of the elevator speed and the motor currents are separately generated. The elevator speed (also the rotor speed) is chosen as a symmetrical trapezoidal curve [START_REF] Vittek | Energy near-optimal control strategies for industrial and traction drives with a.c. motors[END_REF]. In the feasible domain determined by the current and voltage bounds, the motor current references are optimized by minimizing the MTPA (Maximum Torque Per Ampere) criterion [START_REF] Lemmens | PMSM drive current and voltage limiting as a constraint optimal control problem[END_REF]. However, this result is useful only for machine speed control, i.e., the effect of the speed profile is not considered for the energy optimization. In [START_REF] Chen | Adaptive minimum-energy tracking control for the mechatronic elevator system[END_REF], the profiles of both stator current and rotor speed are generated in the transient period based on differential flatness [START_REF] Fliess | Flatness and defect of non-linear systems: introductory theory and examples[END_REF] with a polynomial parameterization. Note that, no constraints are taken into account.

Furthermore, for the PMSM tracking control, various methods are proposed in the literature. A conventional method is the Proportional Integral (PI) control combined with anti-windup techniques for dealing with the physical limits [START_REF] Mardaneh | Nonlinear PI controller for interior permanent magnet synchronous motor drive[END_REF]. Another approach is the backstepping method proposed in [START_REF] Bernat | Adaptive control of permanent magnet synchronous motor with constrained reference current exploiting backstepping methodology[END_REF] where the current constraints are tackled by switching the reference speed. In [START_REF] Petrović | Interconnection and damping assignment approach to control of pm synchronous motors[END_REF] the Interconnection and Damping Assignment Passivity-Based Control (IDA-PBC) [START_REF] Ortega | Interconnection and damping assignment passivity-based control of Port-Controlled Hamiltonian systems[END_REF], an energy-based control method used mainly for nonlinear PH systems, was applied for the control of PMSM. However, this approach does not explicitly take into account the constraints. In [START_REF] Bolognani | Design and implementation of Model Predictive Control for electrical motor drives[END_REF], the authors increase the state vector dimension to obtain a linear system which is used for formulating the tracking MPC. Note that the previously mentioned works do not consider the tracking control for the rotor angle. This is considered in [START_REF] Vittek | Energy near-optimal control strategies for industrial and traction drives with a.c. motors[END_REF] and [START_REF] Chen | Adaptive minimum-energy tracking control for the mechatronic elevator system[END_REF] through the forced dynamics control and adaptive control, respectively, but without taking into account the state and input constraints.

In here we use the differential flatness properties [Lévine, 2009] to express the state and input variables of the electro-mechanical elevator system in function of some flat outputs and their finite time derivatives. It allows us to take into account the system dynamics and to reduce the number of variables. Next, the flat outputs are parametrized using B-splines with appropriate order [Suryawan, 2011].

While the flat output offers some important theoretical guarantees (continuous time constraint validation, trajectory feasibility and the like) it still remains difficult to implement it in practice. The difficulties come from the nonlinear nature of the mappings between flat output and states and inputs. In particular, the input mappings are complex and thus lead to nonlinear constraints (for example those involving input magnitude or rate) and non-convex costs (for example when considering the system's energy).

The solution followed here is to consider the flat representations for the electro-mechanical elevator (the slow part of the plant dynamics) and provide these as references to the fast part of the dynamics. Note that giving these references implies that we need to check an equality constraint with nonlinear terms. This is not easy to implement and leads to a numerically cumbersome formulation. A relaxation of the equality (soft constraints where the slack term is penalized in the cost) is therefore proposed.

The original contributions of this chapter are summarized in the following:

• We formulate a quadratic cost function for the dissipated energy minimization through an appropriate choice of the system flat outputs (i.e., two stator current and rotor speed of the electro-mechanical elevator system). This choice leads to a continuous-time equality constraint related to the gravity torque which is further rewritten in the optimization problem as a soft constraint.

• We provide sufficient conditions for the control points describing the B-splines which guarantee the satisfaction of the stator currents and voltages constraints at all times. This condition is applied for the constraints of the stator currents and of the stator voltages.

• We formulate the tracking MPC problem for stabilizing the state variables to the reference profiles. We consider here both the nonlinear model and the linearized model of the discretized electro-mechanical elevator system. Through the simulations, we illustrate the usefulness of the linearized model for reducing the computation time of the MPC laws. Also, the open-loop simulations illustrate that the dynamics of the two currents and of the rotor speed are asymptotically stable while the dynamics of the rotor angle is not. This motivates us to concentrate on considering the tracking control for the rotor angle. The efficiency of the formulated tracking MPC are validated through simulation results of the closed-loop system.

This chapter is organized as follows. Section 4.2 presents the differential flatness notion, the B-splines curves and their properties and tracking MPC. In Section 4.3 we apply the previous tools for the constrained optimal control of the electro-mechanical elevator. Conclusions and discussions on the obtained results are given in Section 4.4.

Basic tools for the constrained optimal control

Constrained optimal control theory deals with the problem of finding a control law for a given system such that a certain optimality criterion is achieved under some given input and state constraints [Liberzon, 2011] (more details about different types of optimization problems are presented in Appendix C-D). This section recalls first the standard formulation of a constrained optimal control problem. Next, the notions of differential flatness, B-spline parameterization and tracking MPC are presented along the lines in [Lévine, 2009, Suryawan, 2011, Rawlings and Mayne, 2009].

The formulation of a constrained optimization problem includes the cost function, the control system and the constraints. Let x(t) ∈ R n , u(t) ∈ R m , y(t) ∈ R l denote the state, control and output variables, respectively. For a given initial time, t 0 , and a given initial state vector, x 0 , the control system is described by the following dynamics:

ẋ(t) = g(x(t), u(t)), x(t 0 ) = x 0 . (4.2.1)
The cost is denoted by V (x(t), u(t)) and given as:

V (x(t), u(t)) = V f (x f ) + t f t0 V r (t, x(t), u(t))dt. (4.2.2)
where V f and V r are given functions (terminal cost and running cost, respectively), t f is the final (or terminal) time, and x f = x(t f ) is the final (or terminal) state vector. This cost is determined according to the desired objective, e.g., dissipated energy, electricity cost. The state and control variables are limited by the equality and inequality constraints as:

g i (x(t), u(t)) = 0, i = 1, . . . , N g , ∀t ∈ [t 0 , t f ], h i (x(t), u(t)) ≤ 0, i = 1, . . . , N h , ∀t ∈ [t 0 , t f ], (4.2.3)
where N g , N h are the number of equality and inequality constraints, respectively. These constraints come from physical limitations and/or the operation requirements. Another constraint is defined by the target set S f ⊂ [t 0 , ∞) × R n of the final time t f and of the final state x f . For example, depending on the optimization formulation, we have the following target sets:

• S f = [t 0 , ∞) × R n corresponds to a free-time free-endpoint problem, • S f = [t 0 , ∞) × {x 1 } corresponds to a free-time fixed-endpoint problem, • S f = {t 1 } × R n corresponds to a fixed-time free-endpoint problem, • S f = {t 1 } × {x 1 } corresponds to a fixed-time fixed-endpoint problem.
The final time and the final state must satisfy the following constraint:

(t f , x(t f )) ∈ S f . (4.2.4)
Consequently, from the previous ingredients, the constrained optimal control problem finds a control law u(t)

which minimizes V (x(t), u(t)) (4.2.5a) subject to ẋ(t) = g(x(t), u(t)), x(t 0 ) = x 0 , ∀t ∈ [t 0 , t f ], (4.2.5b) g i (x(t), u(t)) = 0, i = 1, . . . , N g , ∀t ∈ [t 0 , t f ], (4.2.5c) h i (x(t), u(t)) ≤ 0, i = 1, . . . , N h , ∀t ∈ [t 0 , t f ], (4.2.5d) (t f , x(t f )) ∈ S f . (4.2.5e)
Generally, a constrained optimal control problem is difficult to solve. Note that the arguments of the cost V (x(t), u(t)) in (4.2.2) are functions, this denoting that (4.2.5) is a continuous-time optimization problem which is numerically intractable. As mentioned in the introduction of this chapter, only the unconstrained optimal control, the so-called LQR, with the linear dynamics and quadratic cost function is analytically solved [Liberzon, 2011]. When having constraints a nonlinear dynamics and a non-quadratic cost, the continuoustime optimization problem (4.2.5) is usually approximated by a discrete-time optimization problem. Usually, this is obtained by projecting the time-depending variables over some basis functions, and then replacing the cost and the constraints in (4.2.5) with the cost and the constraints of the coefficients of the projections. Also, it is important that the desired finite-dimensional optimization problem remains convex such that well-established theory in the literature can be applied [START_REF] Boyd | Convex Optimization[END_REF]].

In the following, the combination of differential flatness, B-splines and MPC notions will provide us the necessary properties for accomplishing the above objectives.

Differential flatness

This subsection recalls the differential flatness notion which is a structural property of the system dynamics exhibiting the state and control variables by a finite number of derivatives of a defined flat output [START_REF] Fliess | Flatness and defect of non-linear systems: introductory theory and examples[END_REF], Lévine, 2009] (see also Fig. 4.2.1). By using the differential flatness, we eliminate differential equations and reduce the number of variables in the optimization problem. Definition 4.2.1. (Flat system [Lévine, 2009]) The dynamical system (4.2.1) is called differentially flat if there exist variables z(t) ∈ R m such that the state and control variables can be algebraically expressed in terms of z(t) and a finite number of its higher-order derivatives:

x(t) = Φ x (z(t), ż(t), . . . , z (q) (t)), u(t) = Φ u (z(t), ż(t), . . . , z (q+1) (t)), (4.2.6) where z(t) = γ(x(t), u(t), u(t), . . . , u (q) (t)) is called the flat output and q + 1 is its maximal order derivative.

Remark 4.2.2. Generally, it is difficult to prove that the system is flat and find the flat output. We recall here some important remarks which are obtained by theoretical approaches.

1. For any linear and nonlinear flat system the number of flat outputs equals the number of inputs [Lévine, 2009].

2. For linear systems, the flat differentiability (existence and constructive forms) is implied by the controllability property [Lévine, 2009].

Figure 4.2.1: Differentially flat systems [Prodan, 2012].

By substituting the state variables, x(t), and the input variables, u(t), obtained from (4.2.6) in the optimization problem (4.2.5), we obtain the optimization problem rewritten in function of the flat output:

min z(t) V (z(t), ż(t), . . . , z (q+1) (t)) (4.2.7a) subject to Φ x (z(t 0 ), ż(t 0 ), . . . , z (q) (t 0 )) = x 0 , (4.2.7b) g i (z(t), ż(t), . . . , z (q) (t)) = 0, i = 1, . . . , N g , ∀t ∈ [t 0 , t f ], (4.2.7c) h i (z(t), ż(t), . . . , z (q) (t)) ≤ 0, i = 1, . . . , N h , ∀t ∈ [t 0 , t f ], (4.2.7d) (t f , Φ x (z(t f ), ż(t f ), . . . , z (q) (t f ))) ∈ S f . (4.2.7e)
As we can see the system dynamics are eliminated from the optimization problem (4.2.7). Note that the number of eliminated constraints equals the number of eliminated variables (state variables). However, (4.2.7) is still a continuous-time optimization problem. Its discretization will be considered in the next subsection when using B-splines-based parameterization. Note that the output vector dimension of the Port-Controlled Hamiltonian (PCH) system always equals to the dimension of the input vector since they are the conjugate variables (see Definition 2.2.5). From the previous property of the PCH system and the first point in Remark 4.2.2 we exemplify here through a specific PCH system where the system output represents also the flat output. Example 4.2.3. Consider an input-state-output PCH system given as: 4.2.8) where x(t) ∈ R n , y(t), u(t) ∈ R m are the state, output and input vectors, respectively, J(x), R(x) ∈ R n×n are the interconnection and resistive matrices, G ∈ R n×m is the input matrix, H(x) ∈ R is the Hamiltonian. Assume that:

ẋ(t) = [J(x) -R(x)] ∇H(x) + Gu(t), y(t) = G T ∇H(x), (
• the input matrix, G, is square, i.e., m = n,

• the input matrix, G, is invertible, i.e., det(G) = 0,

• the Hamiltonian is quadratic and positive, i.e., there exist the matrices

Q 0 ∈ R, Q 1 ∈ R n×1 , Q 2 ∈ R n×n such that Q 2 = Q T 2 > 0 and H(x) = Q 0 + Q T 1 x(t) + 1 2 x T (t)Q 2 x(t).
Then, the output, y(t), and the state, x(t), are the flat outputs of system (4.2.8). In fact, since H(x) is quadratic and positive definite, its gradient vector has the following affine form:

∇H(x) = Q 1 + Q 2 x(t), (4.2.9)
where Q 2 is invertible and positive. From (4.2.8) and ( 4.2.9), we derive the state variable x(t) from y(t) as:

x(y) = G T Q 2 -1 y(t) -G T Q 1 . (4.2.10)
Then, by replacing x(y) in ( 4.2.10) to (4.2.8), we obtain the input: This choice of the flat output has some following interests. If the structure matrices, J(x) and R(x), are affine, the state, x(y), and the input, u(y), are the affine and quadratic functions, respectively. Additionally, if the cost function is the dissipated energy, and if R is constant, the cost is a quadratic function of the flat output. This example will be used hereafter for the electro-mechanical elevator system.

u(y) = G -1 { ẋ1 (y) -[J(x) -R(x)] [Q 1 + Q 2 x(y)]} . ( 4

B-splines-based parameterization

In this subsection, the presented flat output will be projected over a finite set of time basis functions to discretize the optimization (4.2.7). We consider N basis functions

λ i (t) ∈ R with i = 0, . . . , N -1, t ∈ [t 0 , t f ].
Let z i ∈ R n with i = 1, . . . , N be the coefficients of the projections, or control points. Then, the flat output is approximated by:

z(t) = N -1 i=0 z i λ i (t) = ZΛ(t). (4.2.12) where Z = [z 1 . . . z N ] ∈ R m×N , Λ(t) = [λ 1 (t) . . . λ N (t)] T ∈ R N .
The basis function must have (q + 1) th derivative, i.e., λ i (t) ∈ C (q+1) , to ensure that the approximated variable z(t) has (q + 1) th derivative. By replacing (4.2.6) and ( 4.2.12) in the optimization problem (4.2.7) we obtain:

min Z V (Z) (4.2.13a) subject to Φ x (t 0 , Z) = x 0 , (4.2.13b) g i (t, Z) = 0, i = 1, . . . , N g , ∀t ∈ [t 0 , t f ], (4.2.13c) h i (t, Z) ≤ 0, i = 1, . . . , N h , ∀t ∈ [t 0 , t f ], (4.2.13d) (t f , Φ x (t f , Z)) ∈ S f . (4.2.13e)
Note that the optimization problem (4.2. 13) is a finite-dimensional optimization problem where the arguments are the N vectors z 1 , . . . , z N ∈ R m . However, the constraints explicitly depend on time, this requiring a continuous time validation. Furthermore, the explicit form of the discrete cost V (Z) is not easily found. Thus, the numerical solution of the optimization problem (4.2.13) is difficult to find. Therefore, we present hereinafter two methods to approximate the solution.

Discrete-time approximation of the cost and constraints: A simple method to approximate the solution is that we only verify these constraints at some chosen instants t j ∈ [t 0 , t f ] with t j < t j+1 . Let the time interval [t 0 , t f ] be divided into N dv sub-intervals such that t jt j-1 = h dv with j = 1, . . . , N dv . Thus, the cost V (Z) can be approximated by: 4.2.14) where h dv = t ft 0 N dv is the time step. Then, (4.2.13) is rewritten as:

V (Z) = V f (ZΛ(t f )) + h dw N dv -1 j=0 V r (t j , ZΛ(t f )) , (
min Z V (Z) (4.2.15a) subject to Φ x (t 0 , Z) = x 0 , (4.2.15b) g i (t j , Z) = 0, i = 1, . . . , N g , j = 1, . . . , N dg , (4.2.15c) h i (t j , Z) ≤ 0, i = 1, . . . , N h , j = 1, . . . , N dh , (4.2.15d) (t f , Φ x (t f , Z)) ∈ S f , (4.2.15e)
where N dg , N dh ∈ N are the numbers of the verification instants of the constraints (4.2.15c) and ( 4.2.15d), respectively. Remark 4.2.4. Note that this approach is simple to implement but is not complete since it provides no guarantees for the intra-sample behavior.

Continuous-time validation of the cost and constraints: By using suitable basis functions, Λ(t), the cost, V (Z), can be easily formulated as an explicit function of the control points, Z. Moreover, the time-varying constraints (4.2.13c)-( 4.2.13d) can be replaced by sufficient conditions which are time invariant constraints of the control points [Suryawan, 2011, Stoican et al., 2017]. In what follows, we present the B-splines-based parameterization and some of their properties. These basis functions are used because of their ease of enforcing continuity across way-points and ease of computing the derivatives. Also, the degree of the B-splines only depends on which derivative order is needed to ensure continuity.

The i th B-spline function of order d is denoted by λ i,d (t). It is defined using the following recursive formula [Suryawan, 2011]: (4.2.16) where

λ i,1 (t) = 1, τ i ≤ t < τ i+1 , 0, otherwise, λ i,d (t) = t -τ i τ i+d-1 -τ i λ i,d-1 (t) + τ i+d -t τ i+d -τ i+1 λ i+1,d-1 (t),
τ i ∈ [t 0 , t f ] is called knot such that τ i+1 ≥ τ i , i = 0 . . . ν, ν + 1 ∈
N is the number of knots. The knot vector which gathers all the knots is denoted by T ∈ R ν such that: 4.2.17) where τ 0 = t 0 , τ ν = t f . The relation between the knot number, ν, the B-spline order, d, and the B-spline number, N , is: State and input derivatives are combinations of B-splines derivatives. Due to their specific properties, B-splines derivatives can be expressed as combination of B-splines of lower order. In turn these can be expressed as combination of higher order B-splines with the weights changing for each sub-interval of the knot vector. This assumes, of course, that the B-splines of various order share the same knot vector (minus the start and end points). 1, 2, 3, 4, 5, 6, 7, 7, 7} 4 10 11 {0, 0, 0, 0, 1,2,3,4,5,6,7,7,7, 7} Definition 4.2.5 (Internally similar knot vectors [Suryawan, 2011]). Two knot vectors T 1 , T 2 as in (4.2.17) are said to be internally similar if they have the same elements except for the leftmost and the rightmost breakpoints, which differ in their multiplicities.

T = {τ 0 , τ 1 , . . . , τ ν-1 , τ ν } = {t 0 , . . . , t 0 d , τ d , . . . , τ ν-d-1 , t f , . . . , t f d }, (
ν = N + d. ( 4
Let us enumerate in the following several important properties of B-splines which will be used later [START_REF] Stoican | Constrained trajectory generation for uav systems using a b-spline parametrization[END_REF]: P1. A spline curve of order d is C d-1 -continuous at its breakpoints and C ∞ -continuous at any other point [START_REF] Stoican | Constrained trajectory generation for uav systems using a b-spline parametrization[END_REF].

P2. The B-splines basis function λ i,d (t) is zero outside the interval [τ i-1 , τ i+d-1 ) and the sum of all the B-splines equals 1 at all the time [Suryawan, 2011], i.e.

       λ i,d (t) > 0, ∀t ∈ [τ i-1 , τ i+d-1 ), λ i,d (t) = 0, otherwise, N i=1 λ i,d (t) = 1, ∀t ∈ [t 0 , t f ]. (4.2.19)
P3. The curve z(t) defined by (4.2.12) and (4.2.16) is contained in the convex hulls 1 of the sets including 1 We call a point of the form z(t) = α j z j |z j ∈ C, α j ≥ 0, N j=1 α j = 1, i = 1, ..., N [START_REF] Boyd | Convex Optimization[END_REF].

the control points [Suryawan, 2011]:

z(t) ∈ conv{z k-d+1 , . . . , z k+1 }, ∀t ∈ [τ k , τ k+1 ], d -1 ≤ k ≤ N -1, z(t) ∈ conv{z 1 , . . . , z N }, ∀t ∈ [t 0 , t f ]. (4.2.20)
This property is illustrated in Fig. 4.2.3 with a 2D spline curve generated using 7 B-splines of order 4 and 7 control points:

0 0 , 3 1 , 3 5 , 5 5 , 8 3 , 8 0 , 6 -2 ,
and the knot vector: T = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7}. P4. The previous properties are also validated for the products of the B-splines [START_REF] Stoican | Constrained trajectory generation for uav systems using a b-spline parametrization[END_REF].

Consider two natural numbers 0 ≤ r 1 , r 2 ≤ d -2. Based on the knot vector T in (4.2.17) we denote the internally similar knot vectors for the B-splines of order dr 1 , dr 2 by T 1 , T 2 , respectively. The corresponding B-splines vectors are Λ d-r1 (t) ∈ R N -r1 , Λ d-r2 (t) ∈ R N -r2 . Then, the products of these two B-splines have the following properties:

                   λ i,d-r1 (t)λ j,d-r2 (t) > 0, ∀t ∈ (τ k , τ k+1 ), k -d + r 1 + 1 ≤ i ≤ k, k -d + r 2 + 1 ≤ j ≤ k, λ i,d-r1 (t)λ j,d-r2 (t) = 0, otherwise, N -r1-1 j=0 N -r2-1 l=0 λ i,d-r1 (t)λ j,d-r2 (t) = 1, ∀t ∈ [t 0 , t f ]. (4.2.21)
As mentioned before, a general function of z may include many operators such as the addition, the derivative and the multiplication. To describe them on the same basis functions, we need the following theorems. theorem 4.2.6 ( [Suryawan, 2011]). The r th derivative of d th order B-spline vector Λ d (t) ∈ R N can be expressed as a linear combination of elements of (4.2.22) where Λ d (t) and Λ d-r (t) are defined over the internally similar knot vectors, and -r) .

Λ d-r (t) ∈ R N -r : Λ (r) d (t) = M d,d-r Λ d-r (t),
M d,d-r ∈ R N ×(N
theorem 4.2.7 ( [Suryawan, 2011]). A set of B-spline basis functions Λ d-r (t) of a certain degree defined on a knot vector can be represented as a linear combination of B-spline basis functions Λ d (t) of a higher degree defined over an internally similar knot vector, this applies segment-wise, i.e. 4.2.23) where S k,d-r,d ∈ R (N -r)×N .

Λ d-r (t) = S k,d-r,d Λ d (t), ∀t ∈ [τ k , τ k+1 ], (
The two important elements in an optimization problem are the cost function and the constraints. When replacing the B-splines parameterization in the optimization problem formulation (4.2.13), the cost and the constraints are rewritten in function of the control points Z, which become the new variables of the optimization. In the particular case of a quadratic cost function involving just the system states, if the dependency between the flat out z(t) and the states is linear then the cost remains quadratic2 . The following proposition describes this particular case. Proposition 4.2.8 ( [Suryawan, 2011]). Let z(t) be defined by (4.2.12)-( 4.2.16) over the time interval [t 0 , t f ]. Consider a real function V (z) ∈ R and matrices A 1 , A 2 , A 3 of suitable dimensions such that:

V (z) = t f t0 A 1 z (r) (t) + A 2 z(t) + z T (t)A 3 z(t) dt. (4.2.24)
The previous cost can be described by a quadratic function of the control points, Z, as: (4.2.25) where the weight matrices A 2,i , A 3,i,j with i, j = 1, . . . , N are given by:

V (Z) = N i=1 A 2,i z i + N i=1 N j=1 z T i A 3,i,j z j ,
A 2,i = t f t0 A 1 λ (r) i (t) + A 2 λ i (t) dt, A 3,i,j = t f t0 λ i (t)A 3 λ j (t)dt. (4.2.26)
The authors in [START_REF] Stoican | Constrained trajectory generation for uav systems using a b-spline parametrization[END_REF] propose some sufficient conditions on the control points Z which guarantee the satisfaction of constraint g(z) ∈ G at all the time, where g(z) is a quadratic function of z(t), and G is a convex set (see Lemma 1 and Proposition 1 in [START_REF] Stoican | Constrained trajectory generation for uav systems using a b-spline parametrization[END_REF]). In this work, the studied constraint function g(z) is obtained by the multiplication of the flat outputs and their derivatives. By extending this result for the case of the addition operator, we obtain the a result presented in two following proposition.

Proposition 4.2.9. Let z(t) be defined by (4.2.12)-(4.2.16), r be a natural number with 1 ≤ r ≤ d -2, g, g ∈ R be scalars, A 1 , A 2 , A 3 be matrices of suitable dimensions, and g(z) ∈ R be a function such that

g(z) = A 1 z (r) (t) + A 2 z(t) + z T (t)A 3 z(t). ( 4

.2.27)

A sufficient condition for the constraint g ≤ g(z) ≤ g, ∀t ∈ [τ k , τ k+1 ], is given by

g ≤ p k,i,j ≤ g, (4.2.28)
where kd + 2 ≤ i, j ≤ k + 1; p k,i,j is defined by

p k,i,j = A 1 ZM d,d-r S k,d-r,d,i + A 2 z i + z T i A 3 z j . (4.2.29) S k,d-r,d,i is the i th column of the matrix S k,d-r,d defined in Theorem 4.2.7. Proof. Consider the time interval [τ k , τ k+1 ]. Let β i,j,d (t) = λ i,d (t)λ j,d (t) with 1 ≤ i, j ≤ N .
From the parameterization (4.2.12) and the B-spline property (4.2.19), we obtain:

z(t) = N i=1 z i λ i,d (t) = N i=1 z i λ i,d (t) N j=1 λ j,d (t) = N i=1 N j=1 z i β i,j,d (t). (4.2.30)
Using the parameterization (4.2.12) and the B-spline properties (4.2.22)-(4.2.23), we describe the time derivative of the flat output as:

z (r) (t) = N i=1 ZM d,d-r S k,d-r,d,i λ i,d (t)
z (r) (t) = N i=1 N j=1 PM d,d-r S k,d-r,d,i β i,j,d (t). (4.2.32)
Substituting the parameterization (4.2.12) to the third term of g(z) in (4.2.27), we derive:

z(t) T A 3 z(t) = N i=1 N j=1 z T i A 3 z j β i,j,d (t). ( 4
g(z) = N i=1 N j=1 p k,i,j β i,j,d (t). (4.2.34) Since β i,j,d (t) with k -d + 1 ≤ i, j ≤ k satisfies the conditions (4.2.21), g(z) remains in the convex hull of {p k,i,j } with k -d + 1 ≤ i, j ≤ k. Thus, if {p k,i,j } with k -d + 1 ≤ i, j ≤ k satisfies (4.2.28), the continuous-time constraint g ≤ g(z) ≤ g, ∀t ∈ [τ k , τ k+1 ] is satisfied.
Proposition 4.2.9 is also valid for the equality constraint which is proved by the following corollary.

Corollary 4.2.10. Let z(t) be defined by (4.2.12)-( 4.2.16), r be a natural number with 1 ≤ r ≤ d-2, g, g ∈ R be scalars, A 1 , A 2 , A 3 be matrices of suitable dimensions, and g(z) ∈ R be the function defined by (4.2.27).

A sufficient condition for the constraint g(z

) = 0, ∀t ∈ [τ k , τ k+1 ], is that p k,i,j = 0, k -d + 2 ≤ i, j ≤ k + 1,
where p k,i,j is defined by (4.2.29).

Generally, we have many constraints which are gathered in g(z) ∈ G, where g(z) is a vector, and G is a convex set. Based on Proposition 4.2.9 and Corollary 4.2.10, we propose a sufficient condition for constraint g(z) ∈ G in what follows.

Proposition 4.2.11. Let z(t) be defined by (4.2.12)-( 4.2.16), r be a natural number with 1 ≤ r ≤ d, G ⊂ R Ng be a convex set, A 1 , A 2 , A 3,1 , . . . , A 3,N be matrices of suitable dimensions, and g(z) ∈ R Ng such that

g(z) = A 1 z (r) (t) + A 2 z(t) + m l=1 z l (t)A 3,l z(t) ∈ G, ∀t ∈ [τ k , τ k+1 ]. (4.2.35) z l (t) ∈ R is the l th coordinate of the flat output z(t). A sufficient condition for the constraint (4.2.35) is that p k,i,j ∈ G, (4.2.36)
where kd + 2 ≤ i, j ≤ k + 1 and p k,i,j is defined by:

p k,i,j = A 1 ZM d,d-r S k,d-r,d,i + A 2 z i + m l=1 z l,i A 3,l z j , (4.2

.37)

where Z ∈ R m×N denotes the control points matrix, z j ∈ R n denotes the j th control point, z l,i ∈ R denotes the l th coordinate of the i th control point.

Consequently, if the cost function V (z) in (4.2.7a) and the constraints (4.2.7c)-( 4.2.7d) admit the forms (4.2.24) and (4.2.35), then the optimization problem (4.2.13) can be rewritten:

min Z V (Z) (4.2.38a) subject to Φ x (t 0 , Z) = x 0 , (4.2.38b) p k,i,j (Z) ∈ G, k -d + 2 ≤ i, j ≤ k + 1, (4.2.38c) (t f , Φ x (t f , Z)) ∈ S f . (4.2.38d)
where k denotes the B-spline time interval index, V (Z) is defined by (4.2.25), and p k,i,j (Z) is defined by (4.2.37).

Convex optimization problems can be solved using a variety of algorithms [START_REF] Boyd | Convex Optimization[END_REF]. For example, elementary algorithms with simple computational steps are used for solving convex optimization problems arising in machine learning, data mining, and decision making [Negar, 2014]. Also, the interior point methods are a family of algorithms solving linear optimization programs which come along with an efficient performance guarantee [Wächter, 2002]. Other types of algorithms are Newton's method, gradient and subgradient methods, which combined with primal and dual decomposition techniques it becomes possible to develop a simple distributed algorithms for a problem [START_REF] Stegink | A unifying energy-based approach to stability of power grids with market dynamics[END_REF].

The theory of convex optimization has taken significant strides over the years. However, all approaches fail if the underlying cost function is not explicitly given, it is even worse if the cost function is non convex [START_REF] Ghadimi | Accelerated gradient methods for nonconvex nonlinear and stochastic programming[END_REF].

There are specialized solvers which can handle nonlinear optimization problems with relatively large prediction horizon, e.g., BARON [START_REF] Tawarmalani | A polyhedral branch-and-cut approach to global optimization[END_REF], FMINCON [START_REF] Coleman | On the convergence of interior-reflective newton methods for nonlinear minimization subject to bounds[END_REF], IPOPT [START_REF] Biegler | Large-scale nonlinear programming using ipopt: An integrating framework for enterprise-wide dynamic optimization[END_REF].

Model Predictive Control for tracking

After obtaining the control and state reference profiles, the tracking controller is designed to stabilize the system state around the generated reference. Since the generated reference profiles may stay close to the limit, the constraints should be taken into account in the tracking control.

Among the control methods dealing with the constraints, MPC is considered as a good candidate [START_REF] Rawlings | [END_REF]Mayne, 2009,Ellis et al., 2017]. Depending on the cost function, we usually distinguish two types of MPC: tracking MPC [Maciejowski, 2002,Rawlings and[START_REF] Rawlings | [END_REF] and economic MPC [START_REF] Angeli | On average performance and stability of economic model predictive control[END_REF],Grüne, 2013, Ellis et al., 2017]. Tracking MPC penalizes the discrepancies between the actual and reference profiles (state, output, control variables). Economic MPC penalizes the general "profit" cost, e.g., dissipation energy, electricity cost. An example for the cost functions in a tracking and an economic MPC are illustrated in Fig. 4.2.4. MPC is the on-line version of the constrained optimal control (see also Annex D). However, to make it practical for the real-time control, one • discretizes the system dynamics with the time (see Chapter 3 for details on the discretization of PH systems),

• replaces the cost and constraint functions by functions of the discrete-time variables,

• studies the finite horizon, i.e., fixed-time free-endpoint

S f = {t 1 } × R n in (4.2.4).
For simplicity, we shift the coordinate origin to the generated reference trajectory by the following state and control transformations:

x(t) x(t)x(t), ũ(t) u(t)u(t). (4.2.39)

Note that (4.2.39) is a time-varying transformation which leads to the time-varying constraints of the shifted state and control variables such that:

x(t) ∈ X(t), ũ(t) ∈ Ũ(t). ( 4.2.40)

The system dynamics in the new coordinate is called the discrepancy dynamics which will be used in the MPC formulation. Since the MPC is usually formulated in the discrete-time form, we must choose a suitable discrete-time discrepancy dynamics. We have at least two ways to obtain this dynamics corresponding to the two procedures: discretization after transformation, and transformation after discretization. Both of them will be investigated for the electro-mechanical elevator in the next section.

Remark 4.2.12. For the PCH system, the transformed system obtained by a time-varying coordinate transformation is not a PCH [START_REF] Stadlmayr | Tracking control for Port-Hamiltonian systems using feedforward and feedback control and a state observer[END_REF]. This remark is also valid for the discrete-time case.

After partitioning the prediction time interval [t, t 1 ] to N p similar time intervals, we denote predicted values of the discrete-time discrepancy variables by x(t + jh|t), ũ(t + jh|t), where j = 0, . . . , N p and h = (t 1t)/N p is the time step. We consider the recursive construction of an optimal open-loop state and control sequences:

X(t) {x(t|t), . . . , x(t + jh|t), . . . , x(t + (N p -1)h|t), x(t + N p h|t)}, Ũ(t)
{ũ(t|t), . . . , ũ(t + jh|t), . . . , ũ(t + (N p -1)h|t)} at instant t over a finite receding horizon, N p , which leads to a feedback control policy by the effective application of the first control action β(t, x) ũ(t|t) as system input:

Ũ * (t) = argmin Ũ(t)   Ṽf (x(N p |t)) + Np-1 j=0 Ṽr (x(j|t), ũ(j|t))   (4.2.41a) subject to
x(t + (j + 1)h|t) = ĝ(x(t + jh|t), ũ(t + jh|t)), x(t|t) = x(t), j = 0, . . . , N p -1, (4.2.41b)

x(t + jh|t) ∈ X(t + jh), j = 1, . . . , N p , (4.2.41c) ũ(t + jh|t) ∈ Ũ(t + jh), j = 0, . . . , N p -1. (4.2.41d)

x(t + N p h|t) ∈ Xf (t 1 ), (4.2.41e)
where (4.2.41b) describes the discrete-time model of (4.2.5b), and ĝ(.) depends on the time discretization method (see also Chapter 3). In the MPC formulation (4.2.41), the tuning control parameters are the final cost, Ṽf (x(N p |t)), the stage cost, Ṽr (x(j|t), ũ(j|t)) and the final constraint, Xf (t 1 ). Let x(t + jh|t, Ũ) denote the state variable at the instant t + jh corresponding to the application of the control sequence Ũ to the system dynamics (4.2.41b). Let the sets of the state and control sequences, XS(t), ŨS(t), and the state sequences, X(t, Ũ), be defined by:

XS(t) X(t) × . . . X(t + jh) × . . . X(t + N p h -h) × . . . Xf (t 1 ), ŨS(t) Ũ(t) × . . . Ũ(t + jh) × . . . Ũ(t + N p h -h), X(t, Ũ) {x(t|t, Ũ), . . . , x(t + jh|t, Ũ), . . . , x(t + N p h -h|t, Ũ), x(t + N p h|t, Ũ)}.
Let XNp (t) ⊂ X(t) denote the set including all the state variables such that the state sequence X(t, Ũ) belongs to XS(t), i.e.

XNp (t) = x ∈ X(t)| ∃ Ũ ∈ ŨS(t), X(t, Ũ) ∈ XS(t) .
Let V min (t, x) be the minimum of the cost function in the optimization problem (4.2.41). Based on the presented elements, the following theorem recalls the stability conditions for the closed-loop time-varying system using the tracking MPC formulated in (4.2.41).

theorem 4.2.13 ( [Rawlings and Mayne, 2009]). Suppose the following assumptions hold.

• The function ĝ(.), Ṽr (.), and Ṽf (.) are continuous; for all t ≥ t 0 , ĝ(0, 0) = 0, Ṽr (0, 0) = 0, Ṽf (0) = 0.

• For all t ≥ t 0 , X(t) and Xf are closed, Xf ⊂ X(t) and Ũ(t) are compact; each set contains the origin.

• For all t ≥ t 0 and ∀x(t) ∈ Xf , there exists ũ ∈ Ũ(t) such that ĝ(x(t), ũ) ∈ Xf .

• For all t ≥ t 0 ,

min ũ∈ Ũ(t) { Ṽf (ĝ(x(t), ũ)) + Ṽr (x(t), ũ)| ĝ(x(t), ũ) ∈ Xf } ≤ Ṽf (x(t)), ∀x(t) ∈ Xf .
• The terminal cost Ṽf (.) and terminal constraint set Xf are time invariant.

• The running cost Ṽr (.) and the terminal cost Ṽf (.) satisfy, for all t ≥ t 0 ,

Ṽr (x(t), ũ) ≥ α 1 (|x|), ∀x ∈ XNp (t), ∀ũ ∈ Ũ(t), Ṽf (x) ≤ α 2 (|x|), ∀x ∈ Xf ,
in which α 1 (.) and α 2 (.) are K ∞ functions3 .

• There exists a K ∞ function α(.) such that

V (t, x) ≤ α(|x|), ∀x ∈ XNp (t), t ≥ t 0 .
Then, for each initial time t ≥ t 0 , the origin is asymptotically stable with a region of attraction XNp (t) for the time-varying system x(j + 1|t) = ĝ(x(j|t), ũ(τ, x)), τ ≥ t.

PH formalism for tracking MPC: As presented above, the PH formalism is useful for the system stability analysis and for the control design based on the interconnection, dissipation and stored energy of the system dynamics [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]]. An interesting property of PH system is the passivity where the energy (Hamiltonian) is considered as a Lyapunov function. There are many control methods developed for the PH system as presented in [van der Schaft andJeltsema, 2014, Wei and[START_REF] Wei | [END_REF]], e.g., Control by Interconnection, Interconnection and Damping Assignment Passivity-Based Control (IDA PBC). However, all these methods can not explicitly deal with the state and input constraints while MPC is chosen for this purpose. While the theory on linear MPC gained ground over the last decades [START_REF] Rawlings | Model Predictive Control: Theory and Design[END_REF], the non linear and economic MPC causes novel behavior. For example, stability demonstration for the closedloop nonlinear system is difficult since a Lyapunov function is not easy to find. From the previous arguments, while both PH formalism and MPC are established tools in the literature, to the best of our knowledge they have never been considered together by the control community.

Specifically, we propose to use the PH formalism such that, via an MPC control action, the closed-loop dynamics are describing a Port-Hamiltonian system. This is done in three steps: i) choosing the desired PH closed-loop system; ii) finding the explicit control laws and iii) finding the corresponding MPC.

Since any MPC-based closed-loop system is in fact a switched system [START_REF] Bemporad | The explicit linear quadratic regulator for constrained systems[END_REF], the desired PH system must also be a switched PH system. [Kloiber, 2014] proposes design methods for stable switched PH systems. Next, from the explicit form of the closed-loop system, we find the explicit control laws by solving the matching equation. Then, the processes to find MPC laws corresponding to given explicit laws is seen as an inverse parametric programing problem [Nguyen, 2015].

Constrained optimization-based control for the electro-mechanical elevator

Considering the theoretical tools presented above, this section concentrate on the control of the electromechanical elevator system for minimizing the dissipated energy while respecting some physical constraints.

Let us begin by presenting the dynamical electro-mechanical elevator model used in the optimization problem.

Electro-mechanical elevator system: As presented in Section 2.4, the electro-mechanical elevator is represented by the combination of the AC/DC converter, the Permanent Magnet Synchronous Machine (PMSM) and the mechanical elevator. Using (2.4.24),(2.4.26),, we write in a compact form the system dynamics:

ẋl (t) = [J l (x l ) -R l ] ∇H l (x l ) + G ll v l (t), i l (t) = G T ll ∇H l (x l ), (4.3.1)
where x l (t) = [φ ld (t) φ lq (t) p l (t) θ m (t)] T ∈ R 4 is the state vector consisting of a direct stator flux, a quadrator stator flux, a mechanical momentum and a pulley angle. Furthermore, in (4.3.1) v l (t) = d l (t)v l (t) ∈ R 2 is the input vector, which also represents the control variables describing the direct and quadrature voltages of the motor stator, i l (t) ∈ R 2 is the output vector describing the direct and quadrature currents of the motor stator, d l (t) ∈ R 2 is the AC/DC converter duty cycle defined by (2.4.27) and v l (t) ∈ R is the DC bus voltage at the connection point with the corresponding converter. The structure matrices

J l (x l ) ∈ R 4×4 , R l ∈ R 4×4
and G ∈ R 4×2 are given by:

J l =      0 0 φ lq (t) 0 0 0 -φ ld (t) 0 -φ lq (t) φ ld (t) 0 -1 0 0 1 0      , R l =      R l 0 0 0 0 R l 0 0 0 0 0 0 0 0 0 0      , G ll =      1 0 0 1 0 0 0 0      , (4.3.2)
where R l is the phase resistance of the PMSM stator. The Hamiltonian, which has a quadratic form, describes the magnetic energy in PMSM stator, the kinematic energy and the potential energy in the mechanical elevator:

H l (x l ) = 1 2L d φ ld (t) - 3 2 φ f 2 + 1 2 φ 2 lq (t) L q + 1 2 p 2 l (t) I l -Γ res θ m (t), = Q l0 + Q T l1 x l (t) + 1 2 x T l (t)Q l2 x l (t), (4.3.3)
where φ f is the magnetic flux of the PMSM rotor, L d , L q are the direct and quadrature inductances of the PMSM stator, I l is the mechanical inertia, Γ res is the mechanical torque caused by the gravity,

Q l0 ∈ R, Q l1 ∈ R 4×1 , Q l2 ∈ R 4×4
are the weight matrices such as:

Q l0 = 3 4 φ 2 f L 2 d , Q l1 =        - 3 2 φ f L d 0 0 -Γ res        , Q l2 =          1 L d 0 0 0 0 1 L q 0 0 0 0 1 I l 0 0 0 0 0          . (4.3.4)
Dissipated energy: The dissipated energy in the PMSM, which will be also added in the cost function, is expressed by:

V l (x l ) = t f t0 ∇H l (x l ) T R l ∇H l (x l )dt, (4.3.5)
where t 0 and t f are the initial and final instants of an elevator travel, H(x l ) is the Hamiltonian defined in (4.3.3), R l is the resistive matrix defined in (4.3.2). Constraints: In Section 2.6.2 we enumerated some physical constraints which are rewritten here for the direct and quadrature voltages and currents of the motor stator, and for the rotor speed:

v l (t) 2 ≤ v ref √ 2 , (4.3.6a) i l (t) 2 ≤ I l,max √ 2 , (4.3.6b) ω l,min ≤ ω l (t) ≤ ω l,max , (4.3.6c)
where v ref is the reference voltage of the DC bus, I l,max is the maximal PMSM current amplitude, ω l (t) = p l (t) I l ∈ R is the PMSM rotor speed, ω l,min , ω l,max ∈ R are, respectively, the minimal and maximal rotor speed of the mechanical elevator. Moreover, one of the momentum limits ω l,min , ω l,max is zero. The initial elevator speed and position fulfill the following constraints:

p l (t 0 ) = 0, θ m (t 0 ) = θ 0 , (4.3.7)
Similarly, the target set at the final time of the elevator travel is given by:

S l,f = {t f } × x l ∈ R 4 |p l = 0, θ m = θ f , (4.3.8)
where θ f is the final pulley angle which usually equals the maximal angle if the cabin goes down and equals the minimal angle if the cabin goes up.

Constrained optimal control problem: Combining all the element presented above, the constrained optimal control problem is formulated as:

min V l (x l ) ( 4
(t f , x l (t f )) ∈ S l,f , (4.3.9d)
where V l (x l ) is the dissipated energy defined by (4.3.5), S l,f is the target set defined by (4.3.8). This set implies that (4.3.9) is a fixed-time and partial fixed-endpoint optimization problem.

In the optimization problem (4.3.9), the cost function is quadratic, the constraints are nonlinear due to the ellipsoidal constraints (4.3.6a)- (4.3.6b). A finite-dimensional optimization problem for approximating (4.3.9) will be formulated in the next subsection by using appropriate parameterization variables and their B-splines-based parameterization.

Speed profile generation

This subsection reformulates the optimization problem (4.3.9) using differential flatness and B-splines-based parameterization. In most cases, there exist different flat outputs for a system dynamics, but there is no general method to find them. For simplicity we concentrate on the flat outputs represented by the state, input and output variables. Therefore, a first choice of flat outputs for the dynamics (4.3.1) is given by the stator direct flux z 1 (t) = φ ld (t) and the pulley angle z 2 (t) = θ m (t):

z(t) = [z 1 (t) z 2 (t)] T = [φ ld (t) θ m (t)] T ∈ R 2 .
(4.3.10) Using Definition 4.2.1 the rest of the state and control variables are described in function of the flat output:

φ ld (t) = z 1 (t), (4.3.11a)
φ lq (t) = I l z2 (t) + Γ res L d -L q L d L q z 1 (t) + 3 2 φ f L d , (4.3.11b) p l (t) = I l ż2 (t), (4.3.11c) θ m (t) = z 2 (t), (4.3.11d) u l,1 (t) = ż1 (t) + R l z 1 (t) - 3 2 φ f L d - I l z2 (t) + Γ res L d -L q L d L q z 1 (t) + 3 2 φ f L d ż2 (t), (4.3.11e) u l,2 (t) =      I l z2 (t) + Γ res L d -L q L d L q z 1 (t) + 3 2 φ f L d      , t + R l I l z2 (t) + Γ res L d -L q L d z 1 (t) + 3 2 L q φ f L d + z 1 (t) ż2 (t), (4.3.11f)
We can easily see that the above choice of the flat output will make the cost and the constraint functions in (4.3.5)-(4.3.8) more complex, i.e., by using B-splines-based parameterization we can not rewrite the cost as a function of the control points. Furthermore, (4.3.11) requires a complex numerical computation. In what follows we choose the flat outputs of a subsystem of the electro-mechanical elevator which are used to parametrize all the variables. First of all, we observe that the dynamical system (4.3.1)-( 4.3.4) can be decomposed in two subsystems where one of them has the form presented in Example 4.2.3 and the other subsystems has the first-order dynamics:

             ẋ1 (t) ẋ2 (t) = J 11 (x 1 ) -R 11 J 12 -J T 12 0 ∇H 1 (x 1 ) ∇H 2 (x 2 ) + G 1 0 v l (t) i l (t) = G 1 0 T ∇H 1 (x 1
), (4.3.12) where the state vectors, x 1 (t) ∈ R 3 , x 2 (t) ∈ R, are given as:

x 1 (t) = φ ld (t) φ lq (t) p l (t) T , x 2 (t) = θ m (t), (4.3.13)
the structure matrices,

J 11 ∈ R 3×3 , J 12 ∈ R 3×1 , G 1 ∈ R 3×1 , R 11 ∈ R 3×3
, are given by:

                     J 11 (x 1 ) =    0 0 φ lq 0 0 -φ ld -φ lq φ ld 0    , J 12 =    0 0 -1    , R 11 =    R l 0 0 0 R l 0 0 0 0    , G 1 =    1 0 0 1 0 0    , (4.3.14)
the Hamiltonian described by H 1 (x 1 ) and H 2 (x 2 ) is:

               H 1 (x 1 ) = 1 2L d φ ld (t) - 3 2 φ f 2 + 1 2 φ 2 lq (t) L q + 1 2 p 2 l (t) I l = Q 10 + Q T 11 x 1 (t) + 1 2 x T 1 (t)Q 12 x 1 (t), H 2 (x 2 ) = -Γ res θ m (t), (4.3.15) with Q 10 ∈ R, Q 11 ∈ R 3×1 and Q 12 ∈ R 3×3
. In (4.3.12), the dynamics coupling is described by the interconnection matrix J 12 . Let u c (t) and y c (t) denote the conjugate variables at the interconnection ports4 between x 1 (t) and x 2 (t). Then, the dynamics corresponding to the state variable x 1 (t) are given by5 : 4.3.16) and the dynamics corresponding to x 2 (t) are described by: .3.17) where the input vector, u 1 (t) ∈ R 3 , the output vector, y 1 (t) ∈ R 3 , and the input matrix, G 1 ∈ R 3×3 , of the first subsystem (4.3.16) are defined by: (4.3.18) As also shown in Example 4.2.3 the flat output of (4.3.16) can be chosen as:

ẋ1 (t) = [J 11 (x 1 ) -R 11 ] [Q 11 + Q 12 x 1 (t)] + Gu 1 (t), y 1 (x 1 ) = G T [Q 11 + Q 12 x 1 (t)] , (
ẋ2 (t) = -y c (x 1 ), u c = -Γ res . ( 4
u 1 (t) = v l (t) u c (t) T , y 1 (t) = i l (t) y c (t) T , G = G 1 J 12 = I 3 .
z(t) = y 1 (t). (4.3.19)
Using (4.3.16) and the flat output z(t) in (4.3.19), we can express the state and control variables x 1 (t), u 1 (t) as: .3.20) Note that z(t) is the flat output of the system (4.3.16) which can not generally describe the state variable x 2 (t) of the system (4.3.17) by its derivatives. However, from (4.3.17), (4.3.18) and (4.3.19), the state vector x 2 (z) can be described by:

     x 1 (z) = G T Q 12 -1 z(t) -G T Q 11 , u 1 (z) = G -1 G T Q 12 -1 ż(t) -[J 11 (z) -R 11 ] G -T z(t) . ( 4
x 2 (z) = x 2 (t 0 ) - t t0 y c (t)dt = x 2 (t 0 ) -0 0 1 t t0 z(t)dt. (4.3.21)
The cost function in (4.3.5) is rewritten in function of the flat output as follows:

V l (z) = t f t0 z(t) T R z z(t)dt, (4.3.22)
where the weight matrix,

R z ∈ R 3×3 , is given by R z = G -1 R T 11 G -T
, with G defined in (4.3.18) and R 11 defined in (4.3.14). Thanks to formulation (4.3.20)-(4.3.22), we can reformulate the optimization problem (4.3.9) as follows:

min z(t) V l (z) (4.3.23a) subject to z(t) ∈ G y , (4.3.23b) u 1 (z) ∈ G u , (4.3.23c) [0 0 1]z(t 0 ) = 0, (4.3.23d) [0 0 1]z(t f ) = 0, (4.3.23e)
[0 0 1] t f t0 z(t)dt = θ f -θ 0 , (4.3.23f)
where the convex sets G y , G u ⊂ R 3 are defined by

G y = (x 1 , x 2 , x 3 ) ∈ R 3 | x 2 1 + x 2 2 ≤ I l,max / √ 2, ω l,min ≤ x 3 ≤ ω l,max , (4.3.24a)
G u = (u 1 , u 2 , u 3 ) ∈ R 3 | u 2 1 + u 2 2 ≤ v ref √ 2 , u 3 = -Γ res . (4.3.24b) Remark 4.3.1.
After comparing the optimization problem (4.3.23) with the original problem (4.3.9), we draw several remarks:

• by using the flat output we can eliminate the electro-mechanical elevator dynamics in the optimization problem (4.3.23);

• there is an additional equality constraint in (4.3.23c) and (4.3.24b), which needs to be fulfilled at all times.

Next, by parametrizing the flat output, z(t), as in (4.2.12) using the B-splines basis function we obtain a discrete number of constraints in the optimization problem (4.3.23). In addition, we define the time integrations of the basis functions by:

λ Ij (t) = t t0 λ j (t)dt, j = 1, . . . , 3, (4.3.25a) Λ I (t) = t t0 Λ(t)dt. (4.3.25b)
From (4.2.12) and (4.3.25), we can describe the time integration of z(t) by:

t t0 z(t)dt = ZΛ I (t). (4.3.26)
Thanks to the properties of the B-splines enumerated in Section (4.2.2), λ j (t), we rewrite the cost and the constraint functions in (4.3.23) as explicit functions of the control points, z j . Based on Proposition 4.2.9, the quadratic cost function V l (z) in (4.3.22) is rewritten as:

V l (Z) = N i=1 N j=1 z T i   t f t0 λ i (t)R z λ j (t)dt   z j , (4.3.27)
where N is the number of the B-splines. Based on Proposition 4.2.11, we formulate the sufficient condition for the satisfaction of the constraint (4.3.23b), y 1 (t) ∈ G y , at all times as:

z j ∈ G y , ∀j = 1, . . . , N. (4.3.28)
From the description of the interconnection matrix, J 11 , in (4.3.14) and of the state variables in (4.3.20), we can express J 11 (z) as:

J 11 (z) = 3 s1=1 3 s2=1 J 11,s2 a T s2 G T Q 12 -1 a s1 z s1 (t), (4.3.29)
where z s1 (t) ∈ R is the s th 1 coordinate of the flat output vector, z(t), the matrices J 11,1 , J 11,2 , J 11,3 ∈ R 3×3 are defined by:

J 11,1 =   0 0 0 0 0 -1 0 1 0   , J 11,2 =   0 0 1 0 0 0 -1 0 0   , J 11,3 = 0, (4.3.30)
and the vectors a 1 , a 2 , a 3 ∈ R 3×1 are defined by:

a 1 = 1 0 0 T , a 2 = 0 1 0 T , a 3 = 0 0 1 T . (4.3.31)
Based on Proposition 4.2.11 and (4.3.20), we obtain the sufficient condition for the satisfaction at all times of the constraint (4.3.23c), u 1 (t) ∈ G u , as:

u 1,i,j = A 1 ZM d,d-1 S k,d-1,d,i + A 2 z i + 3 s1=1 z s1,i A 3,s1 z j ∈ G u , (4.3.32)
for all k, i, j

∈ N satisfying d -1 ≤ k ≤ n -1, k -d + 2 ≤ i ≤ k + 1, k -d + 2 ≤ j ≤ k + 1.
The matrices A 1 , A 2 and A 3 are defined by: (4.3.33) Note that in (4.3.24) and (4.3.32), there is an equality constraint over the input u 1 (t) which is in general, difficult to respect. Therefore, we propose a soft-constrained reformulation [START_REF] Kerrigan | Soft constraints and exact penalty functions in model predictive control[END_REF] of the optimization (4.3.23). More precisely, the cost (4.3.27) and the constraint (4.3.23c) are rewritten as: (4.3.34c) where Q ∈ R is a positive coefficient, ∈ R is the relaxation factor. Using (4.2.19), (4.3.26), the constraints (4.3.23d)-(4.3.23f) are rewritten as: (4.3.35) where z 3,1 , z 3,N ∈ R are the third coordinates of the first and N th control points. By replacing the cost and the constraint functions in (4.3.27)-(4.3.35) [START_REF] Biegler | Large-scale nonlinear programming using ipopt: An integrating framework for enterprise-wide dynamic optimization[END_REF]) which can handle the nonlinear optimization problem with relative large prediction horizon.

           A 1 = G -1 G T Q 12 -1 , A 2 = G -1 R 11 G -T , A 3,s1 = G -1 3 s2=1 J 11,s2 a T s2 G T Q 12 -1 a s1 G -T , s 1 = 1, 2 , 3.
Vl (Z, ) = V l (Z) + Q , (4.3.34a) u 1,i,j ∈ Ǧu = (u 1 , u 2 , u 3 )| u 2 1 + u 2 2 ≤ v ref √ 2 , -Γ res -≤ u 3 ≤ -Γ res + , (4.3.34b) ≥0,
   z 3,1 = 0, z 3,N = 0, [0 0 1] ZΛ I (t f ) = θ f -θ 0 .
Once we obtain the optimal control point described by Z, we can generate the reference profiles for the system states, x 1 (t), representing the stator magnetic fluxes and the pulley speed, x 2 (t), representing the pulley angle, and for the control variable, v l (t), representing the motor voltages. This will be numerically considered in the next simulation results.

Simulation results

This section presents the simulation results for the electro-mechanical elevator reference profile generation. The forthcoming simulations use the parameters listed in Table 3.3.1 with the numerical data given by the industrial partner SODIMAS (an elevator company from France). Details on the simulation setting are presented in Table 4.3.1. The numerical optimization problem is solved by using Yalmip [Löfberg, 2004] and IPOPT [START_REF] Biegler | Large-scale nonlinear programming using ipopt: An integrating framework for enterprise-wide dynamic optimization[END_REF] solvers in Matlab 2013a. 1×10 -7 d=6 3×10 -5 1×10 -5 7×10 -5 28×10 -5 19×10 -5 (4.3.34), and the computation time with different B-splines parameterizations, i.e., various orders, various B-splines numbers. The numerical value of the relaxation weight, Q , in (4.3.34), is given as: Q = 10 5 [(N m) -1 ]. We see that with B-splines of order 5 the soft constraint technique gives the smallest torque error. Thus, 8 B-splines of order 5 will be used to generate the reference profiles in the following. .2 illustrate the obtained reference profiles of the output currents, i l (t), of the rotor speed, ω l (t), of the rotor angle, θ m (t), and of the input voltage, v l (t) and of the magnetic torque, u c , using two different methods:

• Method 1: trapezoidal rotor speed profiles with the MTPA method (see Appendix E) as in [START_REF] Vittek | Energy near-optimal control strategies for industrial and traction drives with a.c. motors[END_REF].

• Method 2: differential flatness with the B-splines-based parameterization as in Section 4.2.1-4.2.2.

Solving the constrained optimization problem (4.3.36) we show in Fig. 4.3.1 that the constraints on the currents, on the voltages and on the rotor speed are respected. Moreover, since the rotor speed varies slowly, the rotor acceleration is small. Thus, the motor nearly generates a constant torque which requires smallvarying currents. Therefore, the currents are not far from the limits. Also, note that the generated mechanical torque through our method (above denoted Method 2) is not equal to the elevator gravity torque, it respects the soft constraints defined in (4.3.34). Figure 4.3.2 describes the reference rotor angle profile which is the integration of the speed profile with the time. It satisfies the boundary constraints of the initial and final rotor angles in (4.3.23f).

Comparing the results using the above two methods we have several remarks. The results obtained using Method 1 do not satisfy the electro-mechanical elevator dynamics and give a higher dissipated energy with respect to Method 2, that is, 2709 J. The results obtained using Method 2 do not respect the equality constraint in (4.3.23c) but provides the lower dissipated energy with respect to Method 1, that is, 2646 J. Our results can be improved by modifying the order and number of the used B-splines. The reference profiles from Method 2 will be used for the coming tracking control problem.

Reference profile tracking

In this subsection, we consider a MPC law for tracking the reference profile of the electro-mechanical elevator system. This choice is due to the fact that the reference profiles stay close to the boundary, and the actual signal may not satisfy the constraints. Thus, some of the constraints in (4.3.28) and (4.3.34b) should be taken into account in the tracking control design.

To implement the MPC, we need to use the discretized formulations of the system dynamics, the cost function, the constraints and of the reference profiles. First, the simulation time interval [t 0 , t f ] is partitioned into N equal subintervals with the time step defined by h = t ft 0 N . The discrete-time state and control reference profiles are described by: v l,k = v l (t 0 + kh), ∀k = 0, . . . , N -1,

x l,k = x l (t 0 + kh), ∀k = 0, . . . , N. (4.3.37) For comparison we provide in the following two discrete-time models which will be used for the tracking MPC. Nonlinear discrete-time model: The first model is described by the nonlinear discrete-time dynamics (3.3.6) with Scheme 1 in (3.3.7): (4.3.38) where

       x l,k+1 -x l,k h = [J l (x l,k ) -R 11 ] Q l1 + Q l2 x l,k+1 + x l,k 2 + G ll v l,k , i l,k = G T ll Q l1 + Q l2 x l,k+1 + x l,k 2 ,
J l ∈ R 4×4 , R l ∈ R 4×4 , Q l1 ∈ R 4×1 , Q l2 ∈ R 4×4
are the matrices defined in (4.3.2)- (4.3.4).

MPC with the nonlinear discrete-time model in 4.3.38: In this work, we investigate the MPC which allow to track the generated reference profiles. The cost function penalizes the discrepancies between the actual signals and the references. We consider the recursive construction of an optimal open-loop state and control sequences:

X l (t) = {x l (t|t), . . . , x l (t + N p |t)}, U l (t) = {v l (t|t), . . . , v l (t + N p -1|t)},
at instant t over a finite receding horizon N p , which leads to a feedback control policy by the effective application of the first control action v l (t|t) as system input:

U * l (t) = argmin U l (t) V (X l , U l ) (4.3.39) subject to       
the discrete-time dynamics (4.3.38), ∀k = 0, . . . , N p -1, (4.3.40) where G y is defined in (4.3.24), the cost function penalize the discrepancies between the predicted state/input (4.3.41) In (4.3.41) Q f , Q x , Q u are symmetric weight matrices with appropriate dimensions. Generally, these matrices must be positive definite to guarantee the stability of the state vector and to modify the convergence speed.

v l (t + k|t) 2 ≤ v ref √ 2 , ∀k = 0, . . . , N p -1, [I 3 0] [Q l1 + Q l2 x l (t + k|t)] ∈ G y , ∀k = 0, . . . , N p ,
V (X l , U l ) = x l (t + N p |t) -x l,t+Np Q f + Np-1 k=0 x l (t + k|t) -x l,t+k Qx + v l (t + k|t) -v l,t+k Qu .
In the next simulation results for the tracking control, we concentrate on the stability objective. Moreover, through the simulation we observe that the dynamics of the current and rotor speed is asymptotically stable. Therefore, only the rotor angle needs to be stabilized. Consequently, only the elements of the weight matrices Q f , Q x corresponding to the rotor angle are positive. Since (4.3.38) is nonlinear, the resolution of the optimization problem (4.3.40) requires a complex computation. Therefore, as a second solution, we consider the linearization of this model and the corresponding MPC formulation.

Linearized discrete-time model: The second proposed model of the electro-mechanical elevator system is obtained using the energy-preserving discretization method proposed in Section 3.3 for the linearized model of the continuous-time model (4.3.1)-(4.3.4). Let the discrepancies between the actual state, input and output vectors, x l (t) ∈ R 4 , v l (t) ∈ R 2 , i l (t) ∈ R 2 , and their references, x l (t), v l (t), i l (t) be denoted by: (4.3.42) Note that x 1 (t), v l (t) respect the electro-mechanical elevator dynamics (4.3.1)- (4.3.3). Therefore, from (4.3.1)- (4.3.3), (4.3.42) and x l (t) ≈ x l (t), we obtain the linearized discrepancy dynamics:

       xl (t) = x l (t) -x l (t), ṽl (t) = v l (t) -v l (t), ĩl (t) = i l (t) -i l (t).
ẋl (t) = [J l (x l ) -R l -S(x l )] Q l2 xl (t) + G ll ṽl (t), ĩl = G T ll Q l2 xl (t) (4.3.43)
where J l (x l ), R l , Q l2 ∈ R 4×4 are defined in (4.3.1)-(4.3.4) and S(x l ) ∈ R 4×4 is defined as: 4.3.44) with J l,1 , . . . , J l,4 ∈ R 4×4 defined as: (4.3.45) By using the energy-preserving discretization method in Chapter 3 we obtain the discrete-time models of the linearized dynamics (4.3.43) as: V ( Xl , Ũl ) (4.3.47) subject to

S(x l ) = [J l,1 (Q l1 + Q l2 x l (t)) . . . J l,4 (Q l1 + Q l2 x l (t))] , (
J l,1 =     0 0 0 0 0 0 -1 0 0 1 0 0 0 0 0 0     , J l,2 =     0 0 1 0 0 0 0 0 -1 0 0 0 0 0 0 0     , J l,3 = 0, J l,4 = 0.
     xl,k+1 -xl,k h = [J l (x l,k ) -R l -S(x l,k )] Q 12 xl,
      
the elevator discrete-time dynamics (4.3.46), ∀k = 0, . . . , N -1,

v l,t+k + ṽl (t + k|t) 2 ≤ v ref √ 2 , ∀k = 0, . . . , N -1, [I 3 0] [Q l1 + Q l2 (x l,t+k + xl (t + k|t))] ∈ G y , ∀k = 0, . . . , N, (4.3.48)
where G y is defined in (4.3.24), the cost function penalize the discrepancies between the predicted state/input signals and the reference profiles:

V ( Xl , Ũl ) = xl (t + N p |t) Q f + Np-1 k=0 xl (t + k|t) Qx + ṽl (t + k|t) Qu , (4.3.49) Q f , Q x , Q u are
the symmetric matrices with the appropriate dimensions.

The presented MPC in (4.3.39)-(4.3.40) and in (4.3.47)-(4.3.48) includes 4 tuning parameters: prediction horizon N p , state weight matrix Q x , final state weight matrix Q f and the input weight matrix Q u . They are chosen such that the enumerated conditions in Theorem 4.2.13 are satisfied. The increasing of the prediction horizon leads to the decreasing of the value function which corresponds to the decreasing of the discrepancies of state and input with respect to the references. However, this makes the optimization problem more complex. By increasing the input weight matrix, the controller gives more importance to the input reference tracking than state reference tracking. The MPC formulations (4.3.47)-(4.3.49) will be used in the following simulations.

Simulation results

This section presents the simulation results for the reference profile tracking problem of the electro-mechanical elevator illustrated in Fig. 2 4.3.3 illustrates the time evolutions and discrepancies of the state and input variables for the case of nominal dynamics with the feedforward control. Since the actual control signals are equal to the reference one, v l (t) = v l (t), the input discrepancies are zero, ṽl (t) = 0. However, the discrepancies of the state variables differs from zero due to two following reasons. The first reason is that there are differences between the time discretizations of the electro-mechanical dynamics and of the reference profiles. The second reason is related to the employment of the soft constraint instead of the equality constraint (4.3.34). 4.3.4 describe the time evolution and tracking errors of the state and input variables for the case of perturbation-affected dynamics and feedforward control. The perturbation is defined by giving a random state variables near the state reference at a chosen time instant. In the following simulations, the random discrepancies are chosen as δx = [0.5 1 4 -1] T . Physically, this perturbation represents a very strong interaction between the system and the environment during a short time duration (much shorter than the time step, h). By modifying the state variables, this also modifies the system stored energy, H l (x l ). For the simplicity, we do not consider here the uncertainty on the control variables, on the feedback (output) signals and on the model parameters. From the figures, we note that the dynamics of two currents and rotor speed are asymptotically stable around the corresponding reference profiles. It is described by the convergences to zero of the corresponding discrepancies. However, the error of the rotor angle is constant. It causes the angle errors at the end of the elevator travel, i.e., the cabin does not stop at the required position.

Remark 4.3.2. By considering the dynamics of the two currents and of the rotor speed in the linearized model (4.3.43), we determine the corresponding eigenvalues. Though their real parts as illustrated in Fig. 4.3.5 are negative, we can not conclude that the nonlinear discrepancy dynamics are asymptotically stable [Khalil, 2002]. The previous constant angle error motivates us to concentrate on the rotor angle tracking in the MPC formulation. Note that when the rotor angle error converges to zero, the rotor speed will increase which may overpass the speed limitation. This problem is especially important when the perturbation affects the system at the instant t = 15 s when the rotor speed and the voltages are closest to the boundary (illustrated in Fig.4.3.4). Based on the simulations for the open-loop system, we consider some simplifications for the tracking control problem such as:

• only the discrepancies of the rotor angle and of the stator voltages are penalized in the MPC cost such that

Q x = Q f = diag{0, 0, 0, k 0 } ∈ R 4×4 , Q x = Q u = I 2 ∈ R 2×2 , with k 0 > 0;
• only the perturbation on the rotor speed is considered;

• the perturbation-affected state variables always respect the constraints (4.3.6);

• one-step MPC is considered, i.e., N p = 1.

The controller parameters are enumerated in the Table 4.3.4. The numerical optimization problem is solved by using Yalmip [Löfberg, 2004] and IPOPT [START_REF] Biegler | Large-scale nonlinear programming using ipopt: An integrating framework for enterprise-wide dynamic optimization[END_REF] in Matlab 2013a. 4.3.6-4.3.7 describe the time evolution and discrepancies of the state and input variables for the case of the perturbation-affected dynamics with the MPC formulated in (4.3.39)-(4.3.40) and in (4.3.47)-(4.3.48). We observe that the proposed tuning MPC parameters guarantee the asymptotic stability of the electro-mechanical elevator system at the generated reference profiles. Besides, increasing the weight parameter, k 0 , increases the vibration of the state discrepancies but can not reduce the convergence time.

x diag{0, 0, 0, k 0 } Final state weight matrix Q f diag{0, 0, 0, k 0 } Input weight matrix Q u I 2 Figures

Conclusions

In this chapter we firstly recalled the method using the differential flatness, the B-splines-based parameterization and the tracking MPC for approximating the constrained optimal control problem. A special case of the Port-Controlled Hamiltonian system is presented where the output variables are also the flat outputs. Using the properties of B-splines, a sufficient condition for the satisfaction at all the time of the continuous-time quadratic constraints is given. Moreover, the exploitation of the Port-Controlled Hamiltonian formalism for designing the tracking MPC is discussed with the concerned references. The presented control method is modified for adapting to the case of the electro-mechanical elevator system. The modifications reside on the "flat output-like" parameterization variables and the equality constraint relaxation by the soft constraint technique. Then, some simulation results for the reference profile generation illustrate the efficiency of the used method. They are compared to the method using the trapezoidal reference speed profile and the Maximum Torque Per Ampere technique. From the simulations with the feedforward control, we realize that the dynamics of the stator currents and of the rotor speed are asymptotically stable, but the rotor angle dynamics is not. Then, a tracking MPC is used to stabilize the rotor angle errors validated by the numerical simulations.

More details on differential flatness used for electro-mechanical systems can be found in [Delaleau andM.Stankovi, 2004, Chen et al., 2013]. B-splines formulations can be found in [Suryawan, 2011]. Some applications of Tracking Model Predictive Control for regulating the Permanent Magnet Synchronous Machine are introduced in [START_REF] Bolognani | Design and implementation of Model Predictive Control for electrical motor drives[END_REF], Rodriguez et al., 2013].

In the future works, we may take into account the quadratic equality constraint of the control points instead of the soft constraint technique in the reference profile generation. Also, the convergence time of the closed-loop discrepancy dynamics may be reduced by considering the cost of the discrepancies of the two currents and of the rotor speed.

Chapter 5

Power balancing through constrained optimization for the DC microgrid

Introduction

As presented in Sections 1.3 and 2.6.3, the objective of the high level control of the DC microgrid system is the electricity cost minimization. This is formulated as a constrained optimization problem which takes into account the slow time scale dynamics of the microgrid, constraints over the distributed energy storage systems, power predictions of the loads, the distributed energy generation system and the electricity price of the electrical utility grid [START_REF] Lifshitz | Optimal control of a capacitor-type energy storage system[END_REF],Prodan and Zio, 2014,Desdouits et al., 2015,Parisio et al., 2016, dos Santos et al., 2016, Touretzky and Baldea, 2016]. The slow dynamics correspond to the energy storage unit (e.g., battery, thermal system). In the case where the load demand cannot be modified, all the available renewable energy is used and the power balance is guaranteed, the microgrid energy management problem reduces to an electrical storage scheduling problem.

Usually, the excess power of a distributed system is evaluated by selling to the external grid, or it can be stored in an electrical storage system. Therefore, the storage scheduling is an important issue, knowing the fact that the storage capacity (i.e., power and energy) is limited. [Paire et al., 2010, Xu and[START_REF] Xu | [END_REF] proposed a reactive method (without the prediction) that uses logic rules to switch the system to different operation modes. To reduce the required computation and increase the robustness, this method is formulated in [START_REF] Lagorse | A multi-agent system for energy management of distributed power sources[END_REF] through the use of multi-agent systems paradigm. However, this approach requires a high storage capacity and is not efficient since, in some cases, the battery can charge from the external grid when the electricity price is expensive. An off-line optimization-based control approach which takes into account the system dynamics, constraints and power prediction is proposed in [START_REF] Lifshitz | Optimal control of a capacitor-type energy storage system[END_REF].

Furthermore, to improve the robustness, some works concentrate on its on-line version, i.e., MPC (Model Predictive Control) (see, e.g., [START_REF] Dos | [END_REF]). Note that there are two types of MPC: tracking MPC [Maciejowski, 2002,Rawlings and[START_REF] Rawlings | [END_REF] and economic MPC [Grüne, 2013,Ellis et al., 2017] (see also Section 4.2.3 of Chapter 4). The tracking MPC aims at stabilizing the systems to given references by penalizing in the cost function the discrepancies between controlled variables and their references. Moreover, for the effectiveness, chosen cost functions are usually convex which are minimal on the corresponding reference profiles. In economic MPC, the cost functions reflect profit criteria which are generally nonlinear and non-convex. Moreover, this controller is used to generate references for lower levels regulators. Thus, the MPC for minimizing the electricity cost of microgrid systems can be called economic MPC [START_REF] Touretzky | A hierarchical scheduling and control strategy for thermal energystorage systems[END_REF].

The authors in [START_REF] Prodan | Fault tolerant predictive control design for reliable microgrid energy management under uncertainties[END_REF],Desdouits et al., 2015,Lifshitz and Weiss, 2015,Parisio et al., 2016,dos Santos et al., 2016] use simple models for the battery and/or transmission lines which do not entirely capture the real dynamics. Some works use a first-order model for the electrical storage unit [START_REF] Prodan | Fault tolerant predictive control design for reliable microgrid energy management under uncertainties[END_REF], Desdouits et al., 2015, Parisio et al., 2016]. In fact, the electrical storage unit (e.g., a battery) may include many sub storage parts which are connected by resistive elements. Only some of these parts can directly supply the energy. For the slow time scale, the internal charge distribution between these parts can not be ignored. Thus, a first-order model for the electrical storage unit may give incorrect informations about the real available charge. Also, in these works, the transmission lines network dynamics are simply described by a power balance relation. This is not realistic for DC microgrids where each component is placed far from the others. Hence, the resistance of the transmission lines can not be neglected.

95

In general, the microgrid dynamics has at least two energetic properties which may be useful for studying the energy cost optimization: the energy balance and the underlying power-preserving structure. [Lefort et al., 2013,Touretzky andBaldea, 2016] do not take explicitly into account these properties when developing the model of the microgrid system. Thus, they may be lost while studying the energy cost optimization through the model discretization and reduction. Thus, we delineate the following remarks:

• The energy cost optimization is a continuous-time optimization problem for which the solution gives the time profile of the control variables (see Appendix C.2). Usually, it is difficult to find its exact solution. Therefore, we can discretize the optimization problem to obtained a finite-dimensional optimization problem which is easier to solve (details on finite-dimensional optimization problems are given in Appendix C.1). Moreover, its discretization requires the discrete-time model of the microgrid dynamics.

• The microgrid dynamics has different time scales. To reduce the computation complexity, the energy cost optimization usually uses the slow dynamics obtained by reducing the fast dynamics of the global model using singular perturbation approach [START_REF] Kokotović | Singular perturbations and order reduction in control theory-an overview[END_REF].

The present chapter proposes a discrete-time economic MPC for power balancing in a continuous DC microgrid. More precisely, the contributions of this work are the following:

• A PH formulation which completely describes the power interconnection of the DC microgrid components is developed. Moreover, PH representation on graphs (see also [van der Schaft and Maschke, 2013]) allows us to explicitly preserve the physical relations of current and voltage in an electrical circuit.

• A discrete-time model satisfying the energy conservation property is derived.

• A centralized economic MPC design for battery scheduling is developped taking into account the global discrete time model of the system, constraints and electricity cost minimization.

• Extensive simulation results are provided for different scenarios which validate the proposed constrained optimization approach.

This chapter is organized as follows. Section 5.2 details some basic notion on PH systems on graphs and continuous-time optimization-based control formulation. Section 5.3 introduces the DC microgrid model and the constraints. Next, Section 5.4 formulates the on-line constrained optimization problem for reliable battery scheduling. Section 5.5 details the simulation result under different scenarios. Finally, Section 5.6 draws the conclusions and presents the future work.

Port-Hamiltonian systems on graphs

This section briefly introduces some basic definitions and notions related to PH systems on graphs, which will be further used for modeling the DC network (for more details the reader is referred to [van der Schaft and Maschke, 2013]). Note that the PH formalism for system dynamics allows to explicitly describe the power-preserving interconnection within the physical system (see also Section 2.2). However, its general representations (e.g., hybrid input-output, constrained input-output, kernel, image [van der Schaft and Jeltsema, 2014]) do not preserve the topology of the power network which is achieved using the representation of PH system on graphs [START_REF] Fiaz | A port-Hamiltonian approach to power network modeling and analysis[END_REF]. This formalism is obtained by describing the system power-preserving interconnection (i.e., the Dirac structure of the PH system defined in Section 2.2) using a directed graph. Definition 5.2.1. [Directed (closed) graph, [van der Schaft and Maschke, 2013]] A directed graph G = (V, E) consists of a finite set V of N v vertices, a finite set E of N e directed edges, together with a mapping from E to the set of ordered pairs of V, where no self-loops are allowed. The incidence matrix B ∈ R Nv×Ne describes the map from E to V such that:

B ij =    1, if node i is a head vertex of edge j, - 1
, if node i is a end vertex of edge j, 0, else.

(5.2.1)

Note that the incidence matrix always satisfy the following property [van der Schaft and Maschke, 2013]:

1 T Nv B = 0 T Ne , (5.2.2)
where N v , N e ∈ N are the numbers of vertices and edges in the graph. This is illustrated in the following example.

Example 5.2.2. Fig.

B =     1 0 0 1 1 1 -1 -1 0 0 0 0 0 0 1 -1 0 0 0 1 -1 0 -1 -1     .
(5.2.3)

Next, the graph notion is used to define the Kirchhoff-Dirac structure (KDS) of a DC circuit of N v nodes and N e edges. The associated graph, G, is chosen such that each vertex corresponds to a node of the DC circuit, each edge corresponds to an electrical element1 , and edge directions are positive directions of the element currents. This graph, G, is characterized by an appropriate incidence matrix, B, defined in Definition 5.2.1. This matrix is used for describing the admissible node potentials, edge currents and voltages of the circuit which is the KDS defined in the following definition. Definition 5.2.3. [KDS on graphs, [van der Schaft and Maschke, 2013]] The KDS on graphs is defined as: 5.2.4) where B is the incidence matrix of the electrical circuit graph G as defined in (5.2.1), v p ∈ R Nv denotes the node potential, v ∈ R Ne denotes the edge voltage and i ∈ R Ne denotes the edge current.

D(G) {(i, v) ∈ R Ne × R Ne |Bi = 0, ∃v p ∈ R Nv such that v = -B T v p }, (
Example 5.2.4. Fig. 5.2.2 illustrates the Bond Graph representation defined in Section 2.2.1 and the directed graph defined in Definition 5.2.3 for a DC circuit. The circuit includes 4 nodes and 6 elements. Thus, the corresponding directed graph, G, includes 4 vertices and 6 edges which is given in Fig. 5.2.1. Therefore, this graph is characterized by the incidence matrix in (5.2.3). Moreover, the node potential vector, v p (t) ∈ R 4 , the edge current vector, i(t) ∈ R 6 , and the edge voltage vector, v(t) ∈ R 6 , are described as:

       v p (t) = [ v 1 (t) v 2 (t) v 3 (t) v 4 (t)] T , v(t) = [v C1 (t) v R1 (t) v I (t) v E (t) v C2 (t) v R2 (t)] T , i(t) = [i C1 (t) i R1 (t) i I (t) i E (t) i C2 (t) i R2 (t)] T .
(5.2.5) Similar to Definition 2.2.5, a PH system is constructed by connecting the KDS with the energy storage, the energy dissipative element and the environment through corresponding ports. Thus, N e edge ports (i, v) as in Definition (5.2.3) are partitioned into N S energy storage ports (i S , v S ), N R resistive ports (i R , v R ) and N E external ports (i E , v E ). Definition 5.2.5. [PH system on graphs, [van der Schaft and Maschke, 2013]] Consider a state space X with its tangent space T x X, co-tangent space T *

x X, and a Hamiltonian H : X → R, defining the energy-storage.

A PH system of KDS D(G) on X is defined by a Dirac structure D(G) ⊂ T x X × T * x X × R N R × R N R × R N E × R N E having energy-storing port (i S , v S ) ∈ T x X × T *
x X, a resistive structure:

R = (i R , v R ) ∈ R N R × R N R r(i R , v R ) = 0, i T R v R ≤ 0 ,
and the external ports

(i E , v E ) ∈ R N E × R N E .
Generally, the PH dynamics are described by:

(-ẋ(t), ∇H(x), i R (t), v R (t), i E (t), v E (t)) ∈ D(G).

Slow time scale model of the DC microgrid

This section derives the slow time scale model of the DC-microgrid elevator system illustrated in Fig. 2.1.1. It corresponds to the battery dynamics, the renewable power and the electricity price, within a range of minuteshours [START_REF] Parisio | Stochastic model predictive control for economic/environmental operation management of microgrids: an experimental case study[END_REF]. Moreover, the fast time scale dynamics corresponding to the transmission lines (x t (t) ∈ R 5 ), the converter (x cs (t), x cb (t) ∈ R 4 ) and the supercapacitor (x s (t) ∈ R) can be eliminated thanks to the singular perturbation argument presented in Appendix F. According to this argument, the slow dynamics are obtained by considering the global dynamics with the steady state of the fast dynamics. This steady state is described by the following constraints: ẋt (t) =0, (5.3.1a) ẋ cs (t) =0, (5.3.1b) ẋ cb (t) =0, (5.3.1c) ẋs (t) =0, (5.3.1d) where the details of the state vectors, x cs (t), x cb (t), x t (t), x s (t), are presented in (2.3.1), (2.3.6), (2.3.9) and (2.3.29).

The state vector of the electro-mechanical elevator, x l (t) ∈ R 4 , in the slow time scale is also steady. However, when the elevator stops, passengers come in/out which modify the stored energy of the electromechanical elevator. Therefore, in the slow time scale this subsystem is modeled as a combination of the dynamics and of a power source. Moreover, in the slow time scale the electro-mechanical elevator dynamics are assumed to be steady. Thus, this subsystem is reduced to a power source.

The constraint (5.3.1) for the microgrid dynamics (2.5.7) and the mentioned simplification for the electromechanical elevator will be used to derive the component models in the slow time scale.

Components models and constraints

This subsection presents the slow time scale model of the microgrid components including the external grid, the battery unit, the supercapacitor unit, the renewable source, the electro-mechanical elevator and the transmission lines.

External grid: The external grid is modelled as a controllable current source i e (t) ∈ R (see also Fig. 2.3.4) satisfying the constraint (2.6.13): i e,min ≤ i e (t) ≤ i e,max , (5.3.2)

with i e,min , i e,max ∈ R.

Renewable source: As in Section 2.3.2 the solar panel unit is modelled as a power source (see also Fig. 2.3.3) characterized by the current, i r (t) ∈ R, and the voltage, v r (t) ∈ R, which satisfy the constraint (2.3.8):

i r (t)v r (t) = -P r (t) < 0.

( Load unit: The load component of the DC microgrid represents a combination of the electro-mechanical elevator and an AC/DC converter. During an elevator travel (i.e., some seconds), it is modelled as the dynamics of the mechanical momentum, p l (t) ∈ R, of the rotor angle, θ l (t) ∈ R, and of the motor magnetic flux, Φ l (t) ∈ R 2 , which are described in (4.3.1). However, within a range of minutes-hour, the stored energy of the electro-mechanical elevator is modified when the passenger come in/out the cabin as presented in Section 2.6.1. Moreover, the electro-mechanical elevator dynamics is assumed to be at the steady state in the slow time scale. The required load power depends on the profiles of the passenger mass, m c , of the required arrival floor, θ, of the elevator travel start instant, t in , and of the stop instant, t f i (see also Eq. (2.6.1)). These vectors vary arbitrarily but respect statistical rules. They determine the load average power in the slow time scale, P l (t), which is nearly the same for every day. Thus, this power is determined from the recorded data in the past and is used for the required power in the future.

Opposing to the electro-mechanical elevator model in Chapter 4, we here use a simpler model which is a power source P l (t) ∈ R (see also Fig. 5.3.1) under current, i l (t) ∈ R, and voltage, v l (t) ∈ R, constraints: .3.4) Note that, in the nominal case with the slow time scale, the load power, P l (t) equals to the reference load power, P l (t). Battery: Since the battery dynamics correspond to the slow time scale [START_REF] Parisio | Stochastic model predictive control for economic/environmental operation management of microgrids: an experimental case study[END_REF], the battery model is described by the electrical circuit in Fig. 2 5.3.15) where the resistor current vector, i tR (t) ∈ R 4 , the voltage vector, v tR (t) ∈ R 4 , and the resistive matrix, R tR ∈ R 4×4 , are defined by:

i l (t)v l (t) = P l (t). ( 5
 -ẋb (t) v bR (t) i bb (t)   =   0 -G bSR 0 G T bSR 0 G bRE 0 -G T bRE 0     ∇H b (x b ) i bR (t) v bb (t)   , (5.3.5a) v bR (t) = -R bR i bR (t), ( 5
i tR (t) + R -1 tR v tR (t) = 0, (
       i tR (t) = [ i t,bl (t) i t,be (t) i t,er (t) i b,rl (t) ] T , v tR (t) = [ v t,bl (t) v t,be (t) v t,er (t) v b,rl (t) ] T , R tR = diag {R bl , R be , R er , R lr }.
( 5.3.16) Next, using the definition of the KDS in (5.2.4) we present the interconnections of the DC microgrid network through a closed graph.

DC microgrid network

The microgrid network includes all the elements enumerated above, the battery charges, the battery resistors, the load, the renewable source, the external grid, the DC/DC converter and the DC bus resistors. For a better graph on the modelling approach adopted in this work the multi-source elevator system is equivalently represented by the electrical DC circuit in Fig 5.3.3 where we denote at the circuit node 1 the common ground.

Using Definition 5.2.3, we represent the microgrid electrical circuit in Fig. 5.3.3 by a directed graph as in Fig. 5.3.4. The edge current, i(t) ∈ R 13 , and voltage, v(t) ∈ R 13 , vectors are denoted by: 5.3.17) where 5.3.18) gather the currents and voltages of the load, the external grid and the renewable source, respectively, 5.3.19) gather the DC/DC converter current and voltage variables at the two sides. Let v p (t) ∈ R 8 gather the potentials at the nodes in the circuit. As illustrated in Fig. 5.3.3, we consider node 1 as the circuit "ground" node of the DC microgrid hence, its potential is set to zero: 5.3.21) where B ∈ R 8×13 is the incidence matrix defined in (5.2.1): .3.22) Alternative description for the microgrid network: By considering characteristics of the microgrid network, we simplify some algebraic equations in (5.3.21)-(5.3.22) and eliminate the node potential vector, v p (t). Let the edge current and voltage vectors, i(t) and v(t), defined in (5.3.17) be partitioned into the vectors i

i(t) = [-ẋb T (t) -i T E (t) i T c (t) i T bR (t) i T tR (t)] T , v(t) = [∇H T b (t) v T E (t) v T c (t) v T bR (t) v T tR (t)] T , (
i E (t) = [i l (t) i e (t) i r (t)] T ∈ R 3 , v E (t) = [v l (t) v e (t) v r (t)] T ∈ R 3 (
i c (t) = [i bb (t) i b (t)] T ∈ R 2 , v c (t) = [v bb (t) v b (t)] T ∈ R 2 (
v(t) = -B T v p (t), 0 = Bi(t), (
B =             -1 -1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 -1 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 -1 0 0 -1 0 0 0 -1 0 0 0 0 0 0 -1 1 0 0 0 0 0 -1 0 0 0 0 0 0 -1 1 0 0 0 0 0 -1 0 0 1 0 0 0 0 0 0 0 0 0 0 -1 0 0 1 1 0 0             . ( 5
1 (t) ∈ R 7 , i 2 (t) ∈ R 6 , v 1 (t) ∈ R 7 and v 2 (t) ∈ R 6 such as:              i 1 (t) = [ -ẋb T (t) i T E (t) i T c (t) ] T , v 1 (t) = [ ∇H T b (t) v T E (t) v T c (t) ] T , i 2 (t) = [ i T bR (t) i T tR (t) ] T , v 2 (t) = [ v T bR (t) v T tR (t) ] T .
( 5.3.23) Note that i 1 (t), v 1 (t) describes the currents and voltages of the battery capacitors, the energy sources and the converter. i 2 (t), v 2 (t) describe the currents and voltages of the circuit resistors. From the details of the microgrid incidence matrix, B, in (5.3.22) we note that it can be rewritten as: 5.3.24) where B 11 ∈ R 1×7 , B 22 ∈ R 7×6 , and B 21 ∈ R 7×7 is invertible. From (5.3.20), (5.3.21), (5.3.23) and (5.3.24) the microgrid network described in (5.3.21)-(5.3.22) is rewritten as:

B = B 11 0 B 21 B 22 , (
i 1 (t) v 2 (t) = 0 -B -1 21 B 22 B -1 21 B 22 T 0 v 1 (t) i 2 (t) , (5.3.25a)
B 11 i 1 (t) =0, (5.3.25b) where i 1 (t), v 1 (t), i 2 (t), v 2 (t) are defined in (5.3.23). Note that the equations (5.3.25a) implies the powerpreserving property of the microgrid network.

Remark 5.3.1. Bond Graph (see also Section 2.2.1) of the microgrid circuit in Fig. 5.3.3 is illustrated in Fig. 5.3.5. Although this graph explicitly describes the power flows within the microgrid, the derived Dirac structure representation does not fully capture the topology of the electrical circuit which is given in the incidence matrix, B, [START_REF] Fiaz | A port-Hamiltonian approach to power network modeling and analysis[END_REF].

Next, we introduce the microgrid dynamics which characterizes the centralized system.

subject to the constraints: 5.3.29) where we define the matrices A 5.3.30d) x b (t) ∈ R 2 is the state vector describing the battery charges, H b (x b ) is the Hamiltonian describing the stored energy in the battery (see also (2.3.21)), i E (t), v E (t) ∈ R 3 describe the current and voltage variables of the load, the external grid and the renewable source (see also (5.3.18)). Furthermore, in (5.3.28) we denote by L(d) ∈ R 5×5 a symmetric full rank matrix (similar to the weighted Laplace matrix of a resistor network [van der Schaft, 2010]) depending on the duty cycle d as in (5.3.10): .3.31) Using (5.3.18)-(5.3.19), (5.3.23), (5.3.27) and (5.3.30), the battery charge/discharge current constraint in (5.3.30) is rewritten in the constraint of the state x(t) ∈ R 2 , the current variables i E (t) ∈ R 3 , the voltage variables v E ) ∈ R 3 and the duty cycle d(t) ∈ R: .3.32) Reference profiles: The load, the external grid and the renewable source are characterized by certain profiles of reference as presented in Section 2.6.1. Taking into account the available statistical measurements of electricity consumption we consider the reference power of the consumer denoted by P l (t). Next, we denote by P r (t) the power profile of the renewable source estimated from meteorological data. Lastly, using existing historical data of electricity market, we denote the predicted electricity price profile by price(t). Also, we assume that the selling and buying prices are the same. These parameter profiles with the centralized model and constraints of the microgrid system are used to formulate in the forthcoming section the global optimal power balancing problem.

     0 = -B 11 B -1 21 B 22 A 2 (d) ∇H b (x b ) T v T E (t) T , P l (t) = v l (t)i l (t), P r (t) = -v r (t)i r (t), (
0 (d) ∈ R 6×1 , A 1 (d) ∈ R 6×6 , A 2 (d) ∈ R 6×5 , R ∈ R 6×6 by: A 0 (d) = R -1 B T 3 d(t) 1 T , (5.3.30a) A 1 (d) = A 0 (d) A T 0 (d)R -1 A 0 (d) -1 A 0 (d) T , (5.3.30b) A 2 (d) = R -1 -A 1 (d) B T 1 B T 2 , (5.3.30c) R = R bR 0 0 R tR , (
L(d) = B 1 B 2 A 2 (d). ( 5
i min ≤ [0 1 0 0 0 0]A 2 (d) ∇H b (x b ) v E (t) ≤ i max . ( 5

Optimization-based control for the DC microgrid

The main goal of this work is to provide a control strategy for the DC microgrid system and, in particular, for the storage scheduling. The previously developed dynamics, constraints and profiles will be used in a discretetime constrained optimization problem. Hence, we will first introduce the global discrete-time model of the DC microgrid which preserves the energy conservation properties of the continuous time model formulated in (5.3.28)-(5.3.31).

Energy-preserving discrete-time model

In general, when discretizing a continuous time system, the energy conservation property should always be taken into account. For a nonlinear PH system as in (5.3.26) this property can be ensured by preserving the KDS (5.3.26a)- (5.3.26c) and the energy flowing through the storage ports (see also Chapter 3, Section 3.2). Let (.)(j) be the discrete value of variable (.)(t) at time instant t = t 0 + (j -1)h s with the time step h s and the initial time instant t 0 . Using Definition 3.2.1 of the discrete-time Dirac structure we obtain the discrete-time interconnection of the microgrid illustrated in (5.3.26a)-(5.3.26c): 5.4.1b) 5.4.1c) Using Definition 3.2.8 of the discretization of the time-varying power source we derive the discrete-time models of the load and of the renewable source:

i 1 (j) v 2 (j) = 0 -B -1 21 B 22 B -1 21 B 22 T 0 v 1 (j) i 2 (j) , (5.4.1a) v bb (j) i b (j) = 0 -d(j) d(j) 0 i bb (j) v b (j) , (
B 11 i 1 (j) = 0, (
i l (j)v l (j) = P l (j), (5.4.2a) i l (r)v r (j) = -P r (j), (5.4.2b) where the discrete-time power profiles, P l (j), P r (j), are the average values of the reference continuous-time power profiles, P l (t), P r (t), as in (3.2.27). Using Definition 3.2.7 of the discrete-time static element for the microgrid resistors described in (5.3.26f)-( 5.3.26g) we obtain the discrete-time Ohm's law:

v bR (j) = -R bR i bR (j), (5.4.3a) v tR (j) = -R tR i tR (j), (5.4.3b) where the resistive matrices, R bR ∈ R 2×2 R tR ∈ R 4×4 , are defined in (2.3.24)- (5.3.16).

Note that discretizations of the current and voltage vectors, i

1 (t), i 2 (t), v 1 (t), v 2 (t) defined in (5.3.23) imply that:              i 1 (j) = [ f T S (j) i T E (j) i T c (j) ] T , v 1 (j) = [ e T S (j) v T E (j) v T c (j) ] T , i 2 (j) = [ i T bR (j) i T tR (j) ] T , v 2 (j) = [ v T bR (j) v T tR (j) ] T , (5.4.4)
where f S (j), e S (j) ∈ R 2 are the discrete vectors of the charge time derivative,ẋb , and of the Hamiltonian gradient vector, ∇H b (x b ). The discrete-time current and voltage vectors, i E (j

) ∈ R 3 , v E (j) ∈ R 3 , i c (j) ∈ R 2 , v c (j) ∈ R 2 , are defined by:              i E (j) = [ i l (j) i e (j) i r (j) ] T , v E (j) = [ v l (j) v e (j) v r (j) ] T , i c (j) = [ i bb (j) i b (j) ] T , v c (j) = [ v b (j) v bb (j) ] T .
(5.4.5) Now, we discuss about the discretization of the energy storage characterized by the flow and effort variables, f S (j), e S (j). From (2.3.21) we note that the Hamiltonian, H b (x b ), is a quadratic function. Thus, according to Example 3.2.5, we obtain the discrete-time scheme for the energy storage flow and effort variables, f S (j), e S (j), as: (5.4.6) Using the discrete-time models of the microgrid interconnection (5.4.1), the load (5.4.2a), the renewable power (5.4.2b), the resistors (5.4.3) and the current and voltage variables (5.4.4)-(5.4.5), we obtain the discrete-time model of the microgrid system: 5.4.7) subject to the set of constraints: (5.4.8) where the matrices A

     f S (j) = - x b (j) -x b (j -1) h , e S (j) = Q b1 + Q b2 x b (j) + x b (j -1) 2 ,
f S (j) i E (j) = L(d(j)) e S (j) v E (j) , (
                     0 = B 11 B -1 21 B 22 A 2 (d(j)) e T S (j) v T E (j) T , P l (j) = v l (j)i l (j), P r (j) = -v r (j)i r (j), f S (j) = - x b (j) -x b (j -1) h , e S (j) = Q b1 + Q b2 x b (j) + x b (j -1) 2 ,
0 (d) ∈ R 6×1 , A 1 (d) ∈ R 6×6 , A 2 (d) ∈ R 6×5 , L(d) ∈ R 5×5
, are defined in (5.3.30)- (5.3.31), f S (j), e S (j) ∈ R 2 are defined in (5.4.6). Also, the discretization of the static constraints (5.3.10), (5.3.6a) and (5.3.32) are described as: Proof. Thanks to the quadratic form of the Hamiltonian, H b (x b ), in (2.3.21) and the discrete-time storage model (5.4.6) with the symmetry matrix Q b2 , it is easy to verify that:

                   0 ≤ d(j), 0.5x b,max ≤ x b (j) ≤ x b,max , i e,min ≤ i e (j) ≤ i e,max , i min ≤ [0 1 0 0 0 0]A 2 (d(j)) e S (j) v E (j) ≤ i max , (
H b (x b (j)) -H(x b (j -1)) = -f T S (j)e T S (j)h s .
(5.4.10) From (5.4.1a)- (5.4.1b) and (5.4.5), we obtain the power conservation property:

i T 1 (j)v 1 (j) + i T 2 (j)v 2 (j) = 0, i T c (j)v c (j) = 0, (5.4.11) Substituting i 1 (j), v 1 (j) in (5.4.4) to (5.4.11), we obtain:

f T S (j)e S (j) + i T E (j)v E (j) + i T 2 (j)v 2 (j) = 0, (5.4.12) From (5.4.3)-(5.4.5), (5.4.10)-(5.4.12), we obtain the system energy conservation relation:

H(x(j)) -H(x(j -1)) = i e (j)v e (j)h sv 2 (j) T R -1 v 2 (j)h s + jhs (j-1)hs (P l (τ ) + P r (τ ))dτ, where R ∈ R 6×6 is the resistive matrix defined in (5.3.30), h s ∈ R is the discretization time step. This result indicates that the evolution of the system energy equals the supplied energy minus the dissipated energy on the resistive elements, or simply the energy conservation.

Remark 5.4.2. Note that, besides the discretization method presented here, there is another method based on differential flatness and high-order B-splines-based parameterization (see Section 4.2). However, in this case, the flat output is difficult to find. Thus, this method is not considered in the presented work.

Next, we formulate the optimization problem for the online scheduling of the battery operation with the twin goals of minimizing the price of the acquired electricity while in the same time respecting the constraints introduced earlier.

optimization problem is nonlinear both in cost and in constraints (as seen in (5.4.14)-(5.4.16)). Still, there are specialized solvers (like IPOPT, [START_REF] Biegler | Large-scale nonlinear programming using ipopt: An integrating framework for enterprise-wide dynamic optimization[END_REF]) which can handle relatively large prediction horizons.

Note that the increase of the prediction horizon length N p in (5.4.16) entails that the optimization problem minimizes the cost along the entire horizon. It may, however, be the case that the cost function is affected by uncertainties such that the cost values subsequent to the present values along the prediction horizon are less reliable. A solution is to vary the weight γ ∈ (0, 1) from (5.4.16) associated to each cost value over the prediction horizon (i.e., varying γ we may assign less importance to the cost values which are further in the future [START_REF] Hovd | Handling state and output constraints in MPC using timedependent weights[END_REF]).

Simulation results

This section presents simulation results under different scenarios for the operation and control of the DC microgrid elevator system illustrated in Fig. 2.1.1 and equivalently represented by the electrical DC circuit in Fig. 5.3.3. The forthcoming simulations use the reference profiles described in Section 2.6.1 and the battery parameters presented in (5.4.6)-(5.4.9) with the numerical data given by the industrial partner Sodimas (an elevator company from France) and [START_REF] Desdouits | Multisource elevator energy optimization and control[END_REF]. They are illustrated in Fig. 5.5.1 and Table 5.5.1. Two simulation scenarios are considered here: nominal and perturbation-affected electrical power of load and renewable unit. The perturbation is assumed to be bounded in a symmetrical tube as in (5.5.2). We use different values for the SoC (States of Charge) of the battery state x b (t) ∈ R 2 given in (5.3.5):

SoC 1 (t) =
x b1 (t)

x 1,max , (5.5.1a)

SoC 2 (t) = x b2 (t)
x 2,max , (5.5.1b) 5.5.1c) where x b1 (t), x b2 (t) ∈ R are the first and the second coordinates of the state vector, x b (t) in (5.3.5a). 0.31, 0.29, 0.23, 0.19} The numerical optimization problem is solved by using Yalmip [Löfberg, 2004] and IPOPT [Wächter, 2002] in Matlab 2015a. The constrained closed-loop dynamics implementation are done by using fsolve function in Matlab 2015a with a fixed sampled time h = 36 seconds over a horizon of 24 hours. Note that this sampling time corresponds to the discretization of the continuous nonlinear dynamics. The update of the power profiles remains of 30 minutes. Nominal scenario: Fig. 5.5.2 illustrates the nominal scenario, where the battery charges x(t) along the simulation horizon (i.e., 24h). From 7 to 9 o'clock, the first charge, SoC 1 (t), attains the maximal limit but the second charge, SoC 2 (t), and the total charge, SoC, do not. It means that the battery can still be charged but with a smaller current. Moreover, because the battery charges respect their constraints, we conclude that the load power demand is always satisfied. Battery current 3 describes the actual electrical power charged/discharged by the DC components. Note that their positive signs indicate that the power is supplied to the microgrid. Also, it can be observed that when the electricity price is cheap, the battery is charged. Conversely, it is discharged during the high load and expensive electricity price. Furthermore, to minimize the cost, the battery is discharged completely to half its maximum capacity at the end of the day in preparation for the next day. Increasing the battery capacity has a diminishing effect on the overall cost reduction. We tested this assumption in simulation as illustrated in Fig. 5.5.4. Above a capacity of 13 times the initial capacity value q max described by (5.3.7) there is no discernible improvement. This is justified by the fact that there is enough capacity to reduce at minimum the external grid demand. In fact this may change with the length of the prediction horizon and a varying electricity price (where it makes sense for the battery to arbitrate the fluctuations). Perturbation-affected scenario: Similar simulations are implemented for a perturbation-affected scenario. More precisely, the electrical power of load and renewable source are within some uncertainty range: P l (t) ∈ P l (t) [1lmin , 1 + lmax ] ,

SoC(t) = x b1 (t) + x b2 (t) q max , (
(5.5.2a) P r (t) ∈ P r (t) [1rmin , 1 + rmax ] ,

( 5.5.2b) where (.) are positive numbers taken here as lmin = lmax , rmin = rmax with the values set to 0.2. The battery state of charge and components electrical power are presented in Figs. 5.5.5 and 5.5.6. Fig. 5.5.5 illustrates the battery state of charge (for the situations considered in (5.5.2)) with bounded uncertainty affecting the electrical power load and renewable. We can observe that the battery charge respects the imposed constraints and the load power demand is always satisfied. Note that this result is not significantly different from the nominal case in Fig. 5.5.2 since the integral of perturbation is zero as specified by (5.5.2). Furthermore, Fig. 5.5.6 describes the components actual provided electrical power under the perturbationaffected scenario. Since the current (and power) of the external grid is fixed, most of the fluctuation of the microgrid electrical power is absorbed by the battery.

Conclusions

This chapter introduced an efficient power scheduling for a DC microgrid under a constrained optimizationbased control approach. Firstly, a detailed model of the DC microgrid system was presented using Port-Hamiltonian formulations on graphs, with the advantage of preserving the underlying asset of an electrical Battery current system, the power conservation property. Next, a centralized optimization problem was formulated for efficient battery scheduling taking into account operating constraints, profiles and costs. Simulation results validated the proposed approach. Briefly, the original contributions of this work stem from:

• the DC microgrid is modeled through Port Hamilonian formulations. The procedure is a general one and can be easily extended and applied for any microgrid structure, with the advantage of explicitly taking into account the power conservation of the system interconnections;

• the constrained optimization problem proposed which finds the optimum balance between battery usage and the profit gained from electricity management;

• the simulation results for the energy management of a particular DC microgrid elevator system which validate the proposed approach.

As future work, we envision several directions of improvement for the constrained optimization-based control scheme: i) feasibility by considering the properties and specific form of Port Hamiltonian formulations; ii) computation improvements by reducing the prediction horizon; iii) robustness by taking explicitly in consideration the disturbances, etc. Furthermore, we envision the extension of this approach by taking explicitly into account different times scales in the control design scheme. Some recent works for additional informations regarding the hierarchical microgrid control are presented in [START_REF] Sechilariu | DC microgrid power flow optimization by multi-layer supervision control. Design and experimental validation[END_REF],Iovine et al., 2017]. Also, the comparison of stochastic model predictive control strategies applied to a hydrogen-based microgrid is studied in [START_REF] Velarde | Application of robust model predictive control to a renewable hydrogen-based microgrid[END_REF].

Chapter 6

Conclusions and future developments

Conclusions

The present manuscript studied different optimization-based control strategies for the optimal energy distribution within DC microgrids. For explicitly describing the power-preserving interconnection of microgrids, the system model described by [START_REF] Paire | A real-time sharing reference voltage for hybrid generation power system[END_REF] was extended using the PH (Port-Hamiltonian) formalism presented in [van der Schaft and Jeltsema, 2014]. Then, an optimization-based control design, which combines a differential flat output (parameterized with B-splines) with a tracking MPC, was considered for minimizing the dissipated energy within the electro-mechanical elevator. Furthermore, an economic MPC (Model Predictive Control) approach, coupled with a PH model on graphs of the microgrid, was investigated for optimal power balancing within the system.

We have to underline that the micro and smart grid field is vast and a thorough investigation goes beyond the bounds of possibility. Therefore, we have concentrated our contribution on a specific thematic related to modelling and control approaches for DC microgrid systems. However, we believe that the acclaimed concepts from Port-Hamiltonian formulations, differential flatness, Model Predictive Control and B-splines can be used, combined and redesigned for dealing with different challenging issues appearing in the control of complex energy systems.

We have begun the manuscript by presenting a dynamical model for DC microgrids using Bond Graph and PH formalisms with multiple time scales. This modelling method was used to describe all the microgrid components, their interconnections and the global system. The obtained microgrid dynamics were described in an implicit form composed of the differential and algebraic equations with the interconnection matrices being modified by the control variables (i.e., the duty cycles). Based on the derived model, we presented typical microgrid constraints and cost functions which were then used to formulate the optimal control problems.

To integrate the presented microgrid model within the optimization-based control formulation, we proposed a discretization scheme which preserves the power-preserving interconnection and the energy conservation properties of the continuous-time PH model. This scheme was obtained by combining the discrete-time models of PH system elements, i.e., Dirac structure, energy storage, resistive, environment. The proposed discretization method was validated for the cases of the electro-mechanical elevator and the DC microgrid in the fast time scale (corresponding to the dynamics of the converters, the DC bus, the supercapacitor and the electro-mechanical elevator). These simulation results illustrated the efficiencies of the proposed discretization method with respect to other classical methods (implicit and explicit Euler methods were used for the comparisons).

We have studied a constrained optimization-based control design method composed of the off-line reference profile generation and the on-line tracking control for minimizing the dissipated energy within the electromechanical elevator. Differential flatness with B-splines parameterization were used to represent the system dynamics and the state and input constraints. The obtained reference profiles were compared to classical profiles, obtained using the "trapezoidal speed" and the "Maximum Torque Per Ampere" methods. Online we realized the reference profile tracking through an MPC. The efficiency of the proposed method were highlighted through simulations of the singular perturbation-affected scenario.

Finally, we have developped an economic MPC approach to investigate the power balancing for the DC microgrid. The slow microgrid dynamical model corresponding to the battery dynamics time scale was first obtained from the simplifications of the fast dynamics, i.e., the converters, the DC bus, the supercapacitor and the electro-mechanical elevator system were considered at the steady state. The model was represented using the PH formalism on graphs which explicitly describes the microgrid circuit topology. For the MPC design, the presented dynamics were discretized using the energy-preserving discretization method proposed in Chapter 3. We formulated an economic MPC which takes into account the discrete-time model, the renewable and load power profiles and the electricity price. The control method was validated through simulations with different scenarios.

Since the combination of PH formalism and constrained optimization-based control is a new approach for the microgrid energy management topic, there are still many open questions that will be detailed in the last section.

Future developments

The short term future works are connected with the numerical feasibilities of the optimization-based control design presented throughout the manuscript and with the multi-layer control strategies for DC microgrids.

In Chapter 4, a remaining hard point is that there is a continuous-time equality constraint in the reference profile generation problem which is difficult to numerically satisfy. Since this constraint is parametrized using flat outputs and B-splines, there may be two possible solutions. In the first solution, we use the equality to simplify the dynamics such that there is no longer any equality constraint to deal with. In the second solution, we modify the B-spline parameterization (e.g., change the B-splines order and modify the number of B-splines) such that equality conditions involving the control points have solutions.

The control approach presented in Chapter 4 may be extended for minimizing the dissipated energy within the fast part of the microgrid dynamics. The fast part corresponds to the converters, the DC bus, the supercapcitor and the electro-mechanical elevator. The state variables are the converters capacitors, the converters fluxes, the DC bus capacitors, the supercapacitor charge, the magnetic fluxes of the motor, the mechanical momentum of the elevator and the motor angle. The control variables are the external current, the converter duty cycles of the battery unit, the supercapacitor unit and the electro-mechanical elevator. Furthermore, from the simulation results in Chapter 3, we notice that the dynamics of the converters, DC bus and the motor stator are faster than the others (i.e., the dynamics of the mechanical elevator and the supercapacitor). Thus, based on the singular perturbation method [Khalil, 2002], we could use only the dynamics of the mechanical elevator and the supercapacitor in the reference profile generation procedure to reduce the computational complexity.

In Chapter 5, the designed economic MPC for the microgrid power balancing with short prediction horizons (e.g., 7 hours) often becomes infeasible during the simulation. This is due to the fact that the regulator cannot predict the lack of stored energy at the load peak power moment (i.e., the demand profile varies too much to be compensated by the short-prediction MPC). The drawback may be solved using an additional term to the cost function which matches control laws to the laws obtained in the long prediction horizon case (i.e., 24h in the current design). Moreover, energy efficiencies of the proposed control design should be compared with other methods such as the priority rule approach [Paire, 2010] and the economic MPC with first order model of energy storage units [START_REF] Dos | [END_REF].

The extension of the MPC for the optimal microgrid power balancing to a multi-layer control design is our approach to deal with different control objectives and different time scales of the DC micrigrid. Fig. 6.2.1 presents an electrical circuit of the DC microgrid, and Fig. 6.2.2 shows the control architecture. The control decomposition is based on the separation of the control objectives, the microgrid dynamics and the constraints.

The high level regulator aims at minimizing the electricity cost while taking into account the slow part of the microgrid dynamics, the electricity price, the power balance and the constraints of the external grid current, the battery current and the battery charge (see also Fig. 6.2.2). The slow model corresponds to the battery dynamics, the renewable power profile and the slow load power profile. The state and control variables are the battery charges and the external grid current, respectively (see also Fig. 6.2.1 where the electrical circuit which takes into account these specifications of the microgrid is presented). The power balance is assumed to be always satisfied thanks to low level regulators. The control laws are formulated using an economic MPC which penalizes the electricity cost in a finite horizon (see also Chapter 5). Then, this high level regulator sends the computed references of the external grid current (control signal), the supercapacitor voltage and the load voltage to the low level regulator (see also Fig. 6.2.2). Tracking control The low level regulator aims at tracking the references given by the high level regulator while considering the fast part of the microgrid dynamics, the constraint of the supercapacitor charge and the battery current. The fast microgrid model corresponds to the supercapacitor dynamics and the fast load power profile (obtained using the reference profiles designed in Chapter 4). The state and control variables are the su-percapacitor charge and the duty cycles, respectively. The control laws are formulated using tracking MPC which penalizes the discrepancies between the actual supercapacitor charge, the actual load voltage and their references given by the high level regulator (see also Fig. 6.2.2).

The long term future works are concerned with the insightful integration of the PH formalisms in the constrained optimization-based control designs with multi-layer architecture. This should be reflected through considerations of PH system properties (e.g., power-preserving interconnection, energy conservation, Casimir function) in different aspects of the control such as model reduction and stability.

The model reduction is important when designing multi-layer controls for multi time scale systems, such as microgrids, since it drastically simplifies the computational complexity of the regulators. According to the singular perturbation method [Khalil, 2002], the reduced model implies the slow part of the system dynamics after reducing the fast part. This method mainly admits two following assumptions: i) in the fast time scale the slow state variables are constant; ii) in the slow time scale the fast dynamics are asymptotically stable.

Moreover, for preserving system properties described in the PH or graph formulations, reduced models have been derived using the PH [START_REF] Polyuga | Effort-and flow-constraint reduction methods for structure preserving model reduction of port-Hamiltonian systems[END_REF]van der Schaft, 2012,Wu, 2015] or PH on graphs [Monshizadeh and van der Schaft, 2014] formalisms. However, these works consider systems with constant interconnections which is not the case for the microgrid investigated in our work, since the microgrid interconnection is modulated by the control signals, i.e., the duty cycles. Thus, reduction processes for the microgrid model depend on low level control designs which give the relation between the control and state variables.

The model reduction using the B-splines approximation for the system's flat outputs is used to approximate the continuous-time optimization problems in control designs (see Chapter 4). However, we have not considered any insightful relation between the flat outputs and the PH formalism yet. Since the differential flatness implies the feasible system trajectory, there may be a connection between flat outputs and Casimir functions of the Port-Controlled Hamiltonian system (a class of PH systems).

The stability of the constrained closed-loop system using tracking MPC may be studied through the PH formalism. As presented above, the PH formalism is useful for the system stability analysis and for the control design based on the interconnection, the dissipation and the stored energy of the system dynamics [START_REF] Duindam | Modeling and Control of Complex Physical Systems: The port-Hamiltonian approach[END_REF]]. An interesting property of PH system is the passivity where the energy (Hamiltonian) is considered as a Lyapunov function. There are many control methods developed using the PH formalism as presented in [van der Schaft andJeltsema, 2014, Wei and[START_REF] Wei | [END_REF], e.g., Control by Interconnection, Interconnection and Damping Assignment Passivity-Based Control (IDA PBC). However, none of these methods can explicitly deal with the state and input constraints while MPC handles these easily. While the theory on linear MPC has gained ground over the last decades [START_REF] Rawlings | Model Predictive Control: Theory and Design[END_REF], the non-linear and economic MPC are still open research topics. For example, the stability demonstration for the closed-loop non-linear system is difficult since a Lyapunov function is not easy to find. From the previous arguments, while both PH formalism and MPC are established tools in the literature, to the best of our knowledge (state of the art in 2017), they have never been considered together by the control community.

We propose to use the PH formalism such that, via an MPC control action, the closed-loop dynamics are describing a PH system. This is done in three steps: i) choosing the desired PH closed-loop system, ii) finding the explicit control laws, iii) finding the corresponding MPC. Since any MPC-based closed-loop system is in fact a switched system [START_REF] Bemporad | The explicit linear quadratic regulator for constrained systems[END_REF], the desired PH system must also be a switched PH system. [Kloiber, 2014] proposes design methods for stable switched PH systems. Next, from the explicit form of the closed-loop system, we find the explicit control laws by solving the matching equation. Then, the process to find MPC laws corresponding to given explicit laws is seen as an inverse parametric programing problem [Nguyen, 2015].

             -˙l Φ(t) -θe (t)

  (4.3.16). . . . . . . . . . . . . . . . . . . . . . . . . . . 90 4.3.6 The time evolutions and the discrepancies of the state variables for the case of perturbationaffected dynamics with MPC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 4.3.7 The time evolutions and the discrepancies of the input variables for the case of perturbation-

Figure 1 .

 1 Figure 1.2.1: Typical hierarchical control architecture.

Figure 1 . 5 . 1 :

 151 Figure 1.5.1: The organization of the thesis.

Figure 2 . 1 . 1 :

 211 Figure 2.1.1: The microgrid elevator system.

Figure 2

 2 Figure 2.2.1: The Bond Graph for simple series and parallel DC electrical circuit.

Figure 2

 2 Figure 2.2.2: The PH system.

1 :

 1 Figure 2.3.1: Cuk circuit for the DC/DC converter.

Figure 2 . 3 . 2 :

 232 Figure 2.3.2: Electrical circuit for the DC/AC converter and PMSM stator.

Figure 2 . 3 . 3 :

 233 Figure 2.3.3: Renewable source model.

Figure 2 . 3 . 4 :

 234 Figure 2.3.4: External grid model.

5 :

 5 Figure 2.3.5: Electrical circuit for the transmission lines.

Figure 2 . 3 . 6 :

 236 Figure 2.3.6: Battery model: (a) the KiBaM model(b) the corresponding electrical circuit.

Figure 2 . 4 . 1 :

 241 Figure 2.4.1: Electro-mechanical elevator scheme.

Fig. 2

 2 Fig. 2.4.2 describes the Bond Graph of the original model. In the same figure, D DC/AC , D e and D m represent the Dirac structures of the DC/AC converter, the PMSM and the mechanical elevator, respectively.The storage elements reside in the PMSM stator and mechanical elevator. The resistive element only resides in the PMSM stator. There are two external ports: the zero-flow source Sf representing the flow constraint (2.4.8d) and the electrical port (i l , v l ) connecting to the transmission lines. Note that the Dirac structure of the DC/AC converter is modulated by the duty cycle ďl (t). We can see that the Bond Graph describes different physical domains in the same theoretic formalism: magnetic, electric and mechanic.

Figure 2

 2 Figure 2.4.2: Bond Graph for the electro-mechanical elevator model in the original coordinates.

Fig. ( 2

 2 Fig. (2.4.3) illustrate the Bond Graph of the reduced model for the electro-mechanical elevator. By comparing the Bond Graphs in Fig. 2.4.2 and Fig. 2.4.3, we can see that the state-space transformation and the order reduction modify the representations of the Dirac structures of PMSM stator and DC/AC converter.

Figure 2 . 4 . 3 :

 243 Figure 2.4.3: Bond Graph for the electro-mechanical elevator model in the d-q coordinates.

  Figure 2.4.4: numerical data of dq currents, i l (t), dq voltages, v l (t), rotor speed, ω l (t), and rotor angle, θ m (t).

Fig 2. 5

 5 Fig 2.5.1 illustrates the Bond Graph of the multi-source elevator system. The Dirac structures of the transmission lines, the mechanical elevator, the PMSM and the associated converter, the battery, the battery converter, the component interconnection and the supercapacitor converter are represented by the nodes D t , D m , D e , D b , D bc , D I and D sc , respectively. The energy storage of the transmission lines, the mechanical elevator, the PMSM, the battery, the battery converter and the supercapacitor are represented by the nodes C t , C m , C e , C b , C bc , C s and C sc , respectively. The resistive elements reside in the transmission lines, PMSM, battery and supercapacitor. They are represented by R t , R l , R b and R s , respectively. The renewable power source and the external grid are denoted by P r (t) and S f (Details on the flow source S f is presented in Section 2.2.1), respectively. Moreover, the control variables d l (t), d b (t), d s (t) modulate the Dirac structures of the PMSM and converter, D e , of the battery converter, D bc , and of the supercapacitor converter, D sc . The external current i e (t) modulates the flow source S f , i.e., i e (t) denotes the port control variable.

Figure 2 . 5 . 1 :

 251 Figure 2.5.1: Bond Graph representation of the DC microgrid electrical circuit.

Figure 2 . 6 . 1 :

 261 Figure 2.6.1: Profiles of load, renewable power and electricity price.

Figure

  Figure 3.2.1: State variable errors of the discretization schemes: explicit Euler, implicit Euler, mix scheme 1, mix scheme 2 and Casimir-preserving scheme.

Figure 3

 3 Figure 3.2.2: The evolutions of the Hamiltonian and Casimir of the discrete time systems obtained by the explicit Euler, implicit Euler, mix scheme 1, mix scheme 2 and Casimir-preserving schemes.

Figure 3 . 3 . 1 :

 331 scheme 1 scheme 2 scheme 3

Fig. 3 .

 3 Fig. 3.3.2 illustrates the state evolutions of the continuous dynamics and discrete dynamics with the time step h = 0.01 s. We can see that the magnetic fluxes in the fast time scale converge to the steady values determined by the mechanical variables in the slower time scale. From the electro-mechanical dynamics, we can observe that only the rotor speed affects the two magnetic fluxes. Thus, even when the rotor position increases, the steady states of the two magnetic fluxes do not change. Since Scheme 3 is second-order, the obtained discrete state errors are smaller than the ones from the two others.

Figure 3 Figure 3 . 3 . 3 :

 3333 Figure 3.3.2: The state evolution of the continuous dynamics (cont.) and of the energy-preserving discrete models by using Scheme 1, Scheme 2, Scheme 3.

Figure 3 . 3 . 4 :

 334 Figure 3.3.4: The state errors of the electro-mechanical elevator by using the explicit Euler (ex), implicit Euler (im), energy-preserving (st) methods.

Fig. 3 .Figure 3 . 3 . 5 :

 3335 Fig. 3.3.5 illustrates the previous demonstrations. The first three sub-figures describe the supplied power from storage, resistive and external elements. The last one indicates the power sum error defined by(3.3.12).

Figure 3 . 3 . 6 :

 336 Figure 3.3.6: The stored energy evolutions of the continuous dynamics and discrete ones by using the explicit Euler, implicit Euler and Scheme 1 methods.

Figure 3 . 4 . 1 :Figure 3

 3413 Figure 3.4.1: The microgrid state errors by using the explicit Euler (ex), implicit Euler (im) and energypreserving (midpoint) methods.

Figure 3 . 4 . 3 :

 343 Figure 3.4.3: The element and power sum errors of the discrete time system by using the explicit Euler, implicit Euler and energy-preserving methods.

Figure 4

 4 Figure 4.2.2: B-splines of order 1 to 4.

α

  j z j , where α j ≥ 0, N -1 j=0 α j = 1, i = 1, ..., N , a convex combination of the points {z 1 , . . . , z N }. The convex hull of a set C, denoted by conv (C), is the set of all convex combinations of points in C, i.e., convC = N j=1

Figure 4 .

 4 Figure 4.2.3: B-spline curve (red), its control polygon (blue) and convex hull (green).

Figure 4

 4 Figure 4.2.4: Tracking MPC cost (left) and economic MPC cost (right).

Figure 4 . 3 . 1 :

 431 Figure 4.3.1: Reference profiles for the currents, voltages, rotor speed and magnetic torque.

Figure 4

 4 Figure 4.3.2: Reference profile for the rotor's angle.

  .4.1. The references are generated using differential flatness and B-splines-based parameterization with continuous time validation of the constraints. They are given in Sections 4.3.1-4.3.2 and described in Fig. 4.3.1. The parameters are presented in Table3.3.1 with the numerical data given by the industrial partner SODIMAS. The time step of the discrete-time model is h = 0.001s.

Figure 4 . 3 . 3 :

 433 Figure 4.3.3: Time evolution and tracking errors of the state variable for the case of nominal dynamics and feedforward control.

Figures

  Figures 4.3.3 illustrates the time evolutions and discrepancies of the state and input variables for the case of nominal dynamics with the feedforward control. Since the actual control signals are equal to the reference one, v l (t) = v l (t), the input discrepancies are zero, ṽl (t) = 0. However, the discrepancies of the state variables differs from zero due to two following reasons. The first reason is that there are differences between the time discretizations of the electro-mechanical dynamics and of the reference profiles. The second reason is related to the employment of the soft constraint instead of the equality constraint(4.3.34).

Figure 4 . 3 . 4 :

 434 Figure 4.3.4: Time evolution and errors of the state variable for the case of perturbation-affected dynamics and feedforward control.

Figures

  Figures 4.3.4 describe the time evolution and tracking errors of the state and input variables for the case of perturbation-affected dynamics and feedforward control. The perturbation is defined by giving a random state variables near the state reference at a chosen time instant. In the following simulations, the random discrepancies are chosen as δx = [0.5 1 4 -1] T . Physically, this perturbation represents a very strong interaction between the system and the environment during a short time duration (much shorter than the time step, h). By modifying the state variables, this also modifies the system stored energy, H l (x l ). For the simplicity, we do not consider here the uncertainty on the control variables, on the feedback (output) signals and on the model parameters. From the figures, we note that the dynamics of two currents and rotor speed are asymptotically stable around the corresponding reference profiles. It is described by the convergences to zero of the corresponding discrepancies. However, the error of the rotor angle is constant. It causes the angle errors at the end of the elevator travel, i.e., the cabin does not stop at the required position.

Figure 4 . 3 . 5 :

 435 Figure 4.3.5: The eigenvalues of the subsystem 1 in (4.3.16).

Figure 4 . 3 . 6 :

 436 Figure 4.3.6: The time evolutions and the discrepancies of the state variables for the case of perturbationaffected dynamics with MPC.

Figure 4

 4 Figure 4.3.7: The time evolutions and the discrepancies of the input variables for the case of perturbationaffected dynamics with MPC.

Figure 5

 5 Figure 5.2.2: (a) Electrical circuit (b) Bond Graph (c) Directed graph.

Figure 5 . 3 . 1 :

 531 Figure 5.3.1: Electro-mechanical elevator model in the slow time scale.



Figure 5

 5 Figure 5.3.2: Electrical circuit of the transmission lines in the slow time scale: (a) the original resistor network (b) the simplified resistor network.

Figure 5 . 3 . 3 :

 533 Figure 5.3.3: Electrical circuit of the DC microgrid in the slow time scale.

Figure 5 . 3 . 4 :

 534 Figure 5.3.4: Directed graph corresponding to the DC microgrid circuit in the slow time scale.

1 .

 1 The discrete-time model defined by (5.4.7)-(5.4.8) preserves the energy conservation property.

Figure 5 . 5 . 1 :

 551 Figure 5.5.1: Profiles of load, renewable power and electricity price.

Figure 5 .

 5 Figure 5.5.2: Battery charges as in (5.5.1) (nominal scenario).

Fig. 5 .

 5 Fig. 5.5.3 describes the actual electrical power charged/discharged by the DC components. Note that their positive signs indicate that the power is supplied to the microgrid. Also, it can be observed that when

Figure 5 . 5 . 3 :

 553 Figure 5.5.3: Actual electrical power charged/discharged by the DC components.

Figure 5 . 5 . 4 :

 554 Figure 5.5.4: Cost and battery capacity relation.

Figure 5 . 5 . 5 :

 555 Figure 5.5.5: Battery charges as in (5.5.1) (perturbation scenario).

Figure 5 .

 5 Figure 5.5.7: Actual electrical power charged/discharged by the DC components under perturbation scenario.

Figure 6

 6 Figure 6.2.1: DC microgrid electrical circuit.

Figure 6 .

 6 Figure 6.2.2: Two-layers control design.

∂

  Φl H e ( Φl , θ e ) ∂ θe H e ( Φl , θ e )

  The state variable errors of the energy-preserving discretization schemes for the electro-mechanical elevator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3.3.2 The state evolution of the continuous dynamics (cont.) and of the energy-preserving discrete models by using Scheme 1, Scheme 2, Scheme 3. . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.3 The stored energy evolution of the continuous dynamics (cont.) and of the energy-preserving discrete models by using Scheme 1, Scheme 2, Scheme 3. . . . . . . . . . . . . . . . . . . . . . 3.3.4 The state errors of the electro-mechanical elevator by using the explicit Euler (ex), implicit Euler (im), energy-preserving (st) methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.5 The element power of the continuous dynamics (cont.) and discrete ones by using the explicit Euler, implicit Euler, Scheme 1 methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.6 The stored energy evolutions of the continuous dynamics and discrete ones by using the explicit Euler, implicit Euler and Scheme 1 methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.1 The microgrid state errors by using the explicit Euler (ex), implicit Euler (im) and energypreserving (midpoint) methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.2 The microgrid stored energy evolution of the continuous dynamics and discrete ones by using the explicit Euler, implicit Euler and energy-preserving methods. . . . . . . . . . . . . . . . . 3.4.3 The element and power sum errors of the discrete time system by using the explicit Euler, -spline curve (red), its control polygon (blue) and convex hull (green). . . . . . . . . . . . . 72 4.2.4 Tracking MPC cost (left) and economic MPC cost (right). . . . . . . . . . . . . . . . . . . . . 75 4.3.1 Reference profiles for the currents, voltages, rotor speed and magnetic torque. . . . . . . . . . 85 4.3.2 Reference profile for the rotor's angle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 4.3.3 Time evolution and tracking errors of the state variable for the case of nominal dynamics and feedforward control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 4.3.4 Time evolution and errors of the state variable for the case of perturbation-affected dynamics and feedforward control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 4.3.5 The eigenvalues of the subsystem 1 in

	vi xii	List of Figures
	Variable 4.2.3 B
	Notation	Description
	I n 1 n 0 n f, f	identity matrix of size n × n array of ones of size n × 1 array of zeros of size n × 1 flow variables
	e, e	effort variables
	x, x	state variables
	F, E	flow and effort spaces
	F *	dual space of F
	D Parameter and variable fonts Dirac structure X state space
	Element R	Font set of real number
	Scalar parameter capital letter N set of natural number
	Hamiltonian T x X	capital letter stangent space of X
	Scalar variable R resistive matrix normal letter
	Vector J, D	normal and bold letter interconnection matrix
	Matrix G	capital and bold letter input matrix
	Set H	capital and blackboard bold letter Hamiltonian function
	d	converter duty cycle
	i, i	currents
	v, v Operator P	voltages power
	Notation C	Description capacitance, capacitor
	∂ x1 g L, L	partial derivative of g with respect to x 1 inductance, inductor
	R ∇H ẋ q	the vector of gradient of H(x) resistance, resistor time derivative of vector x(t) capacitor charge
	Im G φ, Φ	imagine of matrix G magnetic flux
	det(G) Q	determinant of matrix G weight matrix (in Hamiltonian, in cost function)
	G T k	transpose matrix of G internal battery coefficient, or number index
	G ⊥ b	orthogonal matrix of G charge factor of the battery
	diag{a, b, c} diagonal matrix with the diagonal elements a, b, c E internal voltage of the battery
	x p ρ n! m c , m p	pulley radius p-norm of vector x with p = 1, 2 or ∞ factorial n masses of the cabin and the counterweight
	conv (G) m c	convex hull of the set G vector of masses of the cabin
	Subscript and superscript Notation Description (.) cb variable of the converter associated with the battery (.) cs variable of the converter associated with the supercapacitor (.) bb variable of the battery (.) ss variable of the supercapacitor (.) b variable of the battery unit (.) s variable of the supercapacitor unit (.) d discretized function (.) a , (.) approximation of (.) (.) variable (.) in the original elevator coordinates (.) variable (.) in the transformed elevator coordinates (.) * reference value of (.) v I l mechanical inertia p l explicit Euler, implicit Euler, mix scheme 1, mix scheme 2 and Casimir-preserving schemes. . mechanical momentum θ m pulley angle ω l rotor angular speed τ e magnetic torque of the motor P(θ m ) Park transformation W Jacobian matrix t, t time instant and vector of time instants n, N natural numbers V 1 , V 2 cost functions pr(t) electricity price N p prediction horizon x(t + jh|t) predicted state vectors at the instant t + jh Q x , Q u weight matrices of the state and input variables N number of control points λ j,d B-spline of order d Λ d B-spline vector of order d τ i knot T knot vector 3.3.1 xi

implicit Euler and energy-preserving methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.1 Differentially flat systems [Prodan, 2012]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.2 B-splines of order 1 to 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

  describes the transmission line capacitors. Note that ẋt (t) and ∇H t (x t ) are the charge current and voltage vectors of the DC bus capacitors.Employing the Kirchhoff's laws for the DC bus electrical circuit, we obtain the following dynamics of transmission lines:

Table 2 .

 2 4.1: Real and estimated values in the Case without Noise R

	Real value	0.53	0.00896 0.01123 0.05
	OE 0.5s	0.6000 0.0798	0.0167	0.0395
	0.005s 0.6010 0.0088	0.0111	0.0425
	LSI 0.5s	0.5290 0.0090	0.0112	0.0500
	0.005s 0.5281 0.0090	0.0113	0.0524

s (Ω) L d (H) L q (H) φ f (W b)

Table 2 .

 2 4.2: Real and estimated values in the case with noise R

	Real value 0.53	0.00896 0.01123 0.05
	OE	0.6000 0.0799	0.0158	0.0396
	LSI	0.347	0.0004	0.0012	0.0407

s (Ω) L d (H) L q (H) φ f (W b)

Table 2 .

 2 4.3: Real and estimated values in the case with noise and with a low-pass filter R

	Real value 0.53	0.00896 0.01123 0.05
	OE	0.6001 0.0797	0.0193	0.0392
	LSI	0.5294 0.0089	0.0112	0.0503

s (Ω) L d (H) L q (H) φ f (W b)

  ), the transmission lines description (2.3.9), (2.3.19), and the electro-mechanical elevator structure matrices (2.4.26), (2.4.28), we obtain the global dynamics of the microgrid system as follows:

	Gathering the dynamical equations (2.3.1), (2.3.8), (2.3.15), (2.3.25), (2.3.29), (2.4.24), the components
	connection (2.5.1
	.5.6)

  by f S,d , f R,d , f E,d , e S,d , e R,d , e E,d . Thanks to(3.2.10) and the skew-symmetry form of D i , the power conservation is also satisfied in the discrete case:f T S,i e S,i + f T R,i e R,i + f T E,i e E,i = 0, ∀i ∈ {1, . . . , N },(3.2.13) wheref S,i , f R,i , f E,i , e S,i , e R,i , e E,i are the i-th elements of the discrete functions f S,d , f R,d , f E,d , e S,d , e R,d, e E,d , respectively. Discrete energy storage: In the continuous case, the Hamiltonian satisfies the chain rule. This will be also guaranteed in the discrete time case by appropriate choices of the discrete functions for the storage port variables f S,d , e S,d which satisfy the discrete energy balance equation on each time interval [t i-1 , t i ].Definition 3.2.2 (Discrete energy storage). Let f S,d (x d ), e S,d (x d ) and x d ∈ X N be the discrete functions of f S (t), e S (t) and x(t), respectively. They are said admissible if:

  E,z,d be the discretizations of the state variable and the flow and effort vectors of the PH system (3.2.30)-(3.2.32) by using the energy-preserving discretization method as in Definitions 3.2.1-3.2.2, 3.2.7-3.2.8. Then, the discretizations of the state, flow and effort vectors of the PH system (3.2.4)-(3.2.6) obtained by

.2.33) Proposition 3.2.10. Let z d , f S,z,d , f R,z,d , f E,z,d , e S,z,d , e R,z,d , e

  The discrete-time state, flow and effort vectors in(3.2.34) satisfy conditions(3.2.11),(3.2.14), thus, concluding the proof.

.2.34) is an energy-preserving discretization of the PH system (3.2.4)-

(3.2.6)

.

Proof.

  3.2.1: State variable errors of the discretization schemes: explicit Euler, implicit Euler, mix scheme 1, mix scheme 2 and Casimir-preserving scheme. Fig. 3.2.2 illustrates the evolution of the Hamiltonian and Casimir of the presented discretization schemes. We can see that the schemes (3.2.37a) and (3.2.37b) do not preserve these invariants. The schemes (3.2.38a) and (3.2.38b) preserve the Hamiltonian (i.e., energy) but not the Casimir. The scheme (3.2.41)-(3.2.43) preserves both the Hamiltonian and the Casimir.

Table 3 .

 3 .

	3.1: Numerical data for the electro-mechanical elevator.
	Name		Notation	Unit	Value
	Number of pole pair		p	10
	Stator resistor		R l	[Ω]	0.53
	Direct stator inductance		L d	[mH]	8.96
	Quadrature stator inductance	L q	[H]	11.23
	Rotor linkage flux		φ f	[V s]	0.94
	Cabin mass			M c	[kg] 350.00
	Counterweight mass		M p	[kg] 300.00
	Pulley radius		ρ	[cm]	6.25
	Gravity acceleration		g [m/s 2 ]	9.81
	Table 3.3.2: Configuration for the electro-mechanical elevator simulation.
	Name	Notation Unit		Value
	Time interval	T	[s]		0.15
	Time steps {10 Input voltages h [s] v l [V ]		[230 230] T
	Initial states	x l0			[7 7 150 0] T

-5

, 10 -4 , 10 -3 , 10 -2 , 5.10 -2 }

Table 3 .

 3 4.1: Numerical data for the ESS.

	Name	Notation	Unit	Value
	DC bus capacitors	C b , C s , C l , C e , C r	[C]	0.008
	DC bus resistors	R t,1

Table 3 .

 3

	4.2: Configuration for microgrid simulation.
	Name	Notation Unit Value
	Time interval	T	[s]	0.01
	Duty cycles	d		[0.97 0.93 0.5 0.5] T
	External current	i e	[A]	-1
	Renewable power	P r	[W ]	400
	Initial DC bus charges	x t (0)	[C]	[3.432 2.808 3.432 3.120 3.120] T
	Initial battery charges	x b (0)	[C]	[210816 316224] T
	Initial battery converter states	x cb (0)		[0 3.2 0 0.104] T
	Initial supercapacitor charges	x s (0)	[C]	1740
	Initial supercapacitor converter states

Table 4 .

 4 2.1: Parameters for the B-spline example in Fig. 4.2.2. oder, d B-spline number, N knot number, ν

	knot vector, T

  in the optimization problem(4.3.23), we obtain: Notice that, in the optimization problem(4.3.36), the cost function is quadratic, the constraints in(4.3.28) are convex, the constraints in(4.3.35) are linear. However, since the constraints (4.3.34) are nonlinear, (4.3.36) is a nonlinear optimization problem. Still, there are specialized solvers (like IPOPT,

	min Z, Vl (Z, )	(4.3.36a)
	subject to the constraints (4.3.28), (4.3.34b)-(4.3.35).	(4.3.36b)

Table 4 .

 4 3.1: Setting for the simulations of the electro-mechanical elevator speed profile generation.

	Name	Notation Unit	Value
	Time interval	[t 0 , t f ]	[s]	[0, 30]
	B-spline number	N		10
	B-spline order	d		4
	Number of pole pairs	p		10
	Direct inductance	L d	[mH]	8.96
	Quadrature inductance	L q	[mH]	11.23
	Stator resistance	R s	[Ω]	0.53
	Rotor linkage flux	φ f	[V.s]	0.944
	Mechanical inertia	J	[kg.m 2 ]	3.53
	Gravity torque	Γ res	[N.m]	149
	Maximal current amplitude i max	[A]	41.2
	DC-link voltage	v ref	[V ]	400
	Maximal angular speed	ω l,max	[rad/s]	29.6
	Minimal angular speed	ω l,min	[rad/s]	0
	Initial rotor angle	θ 0	[rad]	0
	Final rotor angle	θ f	[rad]	592.6

Table 4 .

 4 3.3: Computation time in seconds of the off-line reference profile generation.

		N=8	N=9	N=10	N=11	N=12
	d=4	6.0800	7.0780	7.9130	8.8400	9.9960
	d=5	8.3550 10.0300 11.9450 13.6260 15.2460
	d=6 11.0610 13.8170 16.8470 20.5200 23.8510
	Tables 4.3.2-4.3.3 present values of the relaxation factor, in

Table 4 .

 4

		3.4: MPC parameters.
	Variable	Notation Unit	Value
	Sample time	h	[s]	0.001
	Prediction horizon	N p		1
	State weight matrix	Q

  5.2.1 illustrates a directed graph which is composed by 4 vertices and 6 directed edges. Using Definition 5.2.1 of directed graphs, we determine the incidence matrix, B ∈ R 4×6 , of the graph in Fig.5.2.1 as in (5.2.1):

		Vertex 4
	E d g e 1 E d g e 2 Edge 5	Edge 6	E d g e 3 E d g e 4
	Vertex 2		Vertex 3
		Vertex 1
	Figure 5.2.1: Directed graph example.

Table 5 .

 5 5.1: Numerical data for the microgrid components.

	Name	Notation	Value
	Scheduling time step	h s [h]	0.5
	Prediction horizon	N p	48
	Weighting parameter Battery parameters	γ ∈ (0, 1) Q b1 [V ]	0.5 [ 13 13 ] T
	Battery constraints	Q b2 [V /C] x max [Ah]	diag {0.3036, 0.2024} [ 73.2 109.8 ] T
		i b,min [A]	-20
		i b,max [A]	20
	Grid constraints	i e,min [A]	-8
		i e,max [A]	8
	Load voltage reference	v ref [V ]	380
	Resistors	R [Ω]	diag {0.012, 0.015,

  Electrical power of the DC microgrid components storage unit: vc2(t) • ic2(t) load: -Pl(t) external grid: ve(t) • ie(t) renewable: Pr(t)

	-500 0 500 1,000 Electrical power [W]	0	1	2	3	4	5	6	7	8	9	10	11	12	13	14	15	16	17	18	19	20	21	22	23	24
													Time [h]

  Figure 5.5.6: Actual electrical power charged/discharged by the DC components under perturbation scenario.Electrical power of the DC microgrid components under perturbation storage unit: vc2(t) • ic2(t) load: -Pl(t) external grid: ve(t) • ie(t) renewable: Pr(t)

	-500 0 500 1,000 1,500 Electrical power [W]	9	9.2	9.4	9.6		9.8	10	10.2 10.4 10.6 10.8	11	11.2 11.4 11.6 11.8	12	12.2 12.4 12.6 12.8	13
													Time [h]
						Electrical power of the DC microgrid components under perturbation
	-500 0 500 1,000 1,500 Electrical power [W]	0	1	2	3	4	5	6	7	8	9	10	11	12	13	14	15	16	17	18	19 storage unit: vc2(t) • ic2(t) 20 21 22 23 load: -Pl(t) external grid: ve(t) • ie(t) renewable: Pr(t)	24
													Time [h]

The elevator operation is separated into many travels during a day. At the travel end, the cabin must arrive to the desired building floor while the supercapacitor electrical storage must be at the reference voltage to prepare for the next travel.

Port-Controlled Hamiltonian system is a special case of PH system where the control variables are also the input variables.

A more general model for the transmission lines includes capacitors, inductors and resistors[START_REF] Zonetti | Modeling and control of HVDC transmission systems from theory to practice and back[END_REF]. For simplicity we choose here to use capacitors and resistors.

A similar conclusion for a system of AC/DC converters can be found in[START_REF] Zonetti | Modeling and control of HVDC transmission systems from theory to practice and back[END_REF]

Note that, usually there is not a linear dependency between the input variables and the flat output. Therefore, the cost and the constraints are more difficult to handle since they have a more complex form in function of the control points variables.

A continuous function α : [0, ∞) → [0, ∞) is said to belong to class K∞ if: * it is strictly increasing, * α(0) = 0, * lim r→∞ α(r) = ∞.

Usually, we use two pairs of conjugate variables to describe the inputs and outputs of the two subsystems. They satisfy a feedback interconnection defined by (2.2.2). However, for simplicity, we use one pair of the conjugate variables with the appropriate signs in each subsystems.

Note that, in Example 4.2.3 we intentionally chose the dynamical system as in (4.2.8) to show the corresponding flat output representation. It can be verified that(4.3.16) is the system presented inExample 4.2.3.

An electrical element can be a circuit of many basic elements (e.g., the resistor, the inductor, the capacitor, the voltage source, the current source).

by i bR (t), v bR (t) ∈ R 2 , the battery current and voltage are denoted by i bb (t), v bb (t) ∈ R, the structure matrices, G bSR ∈ R 2×2 and G bRE ∈ R 2×1 , are defined in (2. 3.26) and the resistive matrix, R bR ∈ R 2×2 , is defined in (2. 3.24). Furthermore, from (2.6.8)-(2.6.9) the constraints of the battery charges and of the battery current are given as: 0.5x b,max ≤ x b (t) ≤ x b,max , (5.3.6a) i b,min ≤ i bb (t) ≤ i b,max , (5.3.6b) where x b,max ∈ R 2 is the maximal charge vector, i b,min , i b,max ∈ R are the minimal and maximal charge currents. In the one-dimension model of the battery [START_REF] Prodan | Fault tolerant predictive control design for reliable microgrid energy management under uncertainties[END_REF], the maximal charge q max ∈ R is derived from x max by the relation: q max = 1 T 2 x max .

(5.3.7)

Supercapacitor: From the supercapacitor dynamics (2.3.28)-(2. 3.31) and the constraint (5.3.1d), we derive that:

i ss (t) = 0, (5.3.8) where i ss (t) ∈ R is the supercapacitor current. (5.3.8) implies that the supercapacitor is not charged or discharged. Thus, it can be eliminated from the microgrid model in the slow time scale.

The DC/DC converter: As illustrated in Section 2.3.1, the battery unit has an associated DC/DC converter which is described in (2. 3.1)-(2.3.4). In the slow time scale the converter is assumed to be at the steady state defined by the dynamics (2.3.1)-(2. 3.4) and the constraint (5.3.1c). These lead to the relations (5.3.11). For simplicity we define the representative duty cycle, d(t), such that: 5.3.9) where d b (t) ∈ R is the real duty cycle of the converter. From (5.3.9) and (2.6.12) we derive the constraint of d(t): 0 ≤ d(t). (5.3.10) Consequently, in the slow time scale the converter model is assumed to be an ideal transformer described by the following relations: 5.3.11) where i bb (t), i b (t) ∈ R denotes the DC/DC converter current variables, v b (t), v bb (t) ∈ R denote the voltage variables at the two sides as in Fig. 2.3.1.

Similarly, the converter associated to the supercapacitor is also modelled in the slow time scale as:

d sup (t) 0 i ss (t) v s (t) , (5.3.12) where d sup (t) is the representative converter duty cycle, v ss (t), v s (t) ∈ R are the converter voltage variables at the two sides, i ss (t), i s (t) ∈ R are the converter current variables at the two sides as in Fig. 5.3.3. From (5.3.8) and (5.3.12), we obtain: i s (t) = 0.

(5.3.13) (5.3.13) implies that there is not the charged/discharged current through the converter associated to the supercapacitor. Thus, we can eliminate this converter from the microgrid model in the slow time scale. Moreover, from the interconnection between the transmission line and the microgrid components described in (2.3.9), (2.5.1)-(2.5.2) and the elimination of the supercapacitor unit described in (5.3.13), we obtain:

i ts (t) = a T i t (t) = 0, (5.3.14) with a = [0 1 0 0 0] T ∈ R 5 .

Transmission lines: The transmission line model is illustrated in Fig. 2.3.5 and is described in the equations (2.3.9)-(2. 3.14). In the slow time scale the transmission line dynamics are considered at the steady state illustrated by the constraint (5.3.1a). The constraints (5.3.1a) and (5.3.14) imply the elimination of the transmission line capacitors and of the supercapacitor unit in the electrical circuit described in Fig. 2.3.5. Therefore, in the slow time scale the transmission lines (i.e., the DC bus) are modelled as a resistor network

Global DC microgrid model

Combining the above relations (5.3.3), (5.3.4), (5.3.5b), (5.3.11), (5.3.15), (5.3.23) and (5.3.25) we formulate the global microgrid model: (5.3.26c) i r (t)v r (t) = -P r (t), (5.3.26d) (5.3.26g) where i 1 (t), v 1 (t) ∈ R 7 gather the current and voltage variables of the microgrid components (see also (5.3.23)), i 2 (t), v 2 (t) ∈ R 6 gather the current and voltage variables of the resistors of the battery and of the transmission lines (see also (5.3.23)). Also, in (5.3.26)

are the current and voltage variables at the two sides of the DC/DC converter (see also Fig. 5.3.3), i r (t), v r (t) ∈ R are the current and voltage variables of the renewable source, i l (t), v l (t) ∈ R are the current and voltage variables of the load (i.e., the electro-mechanical elevator). Furthermore,

are the structure matrices defined in (5.3.24). Next, i bR (t), v bR (t) ∈ R 2 are the current and voltage variables of the battery resistors, i tR (t), v tR (t) ∈ R 4 are the current and voltage variables of the transmission line resistors, R bR ∈ R 2×2 , R tR ∈ R 2×2 are the resistive matrices of the battery and of the transmission lines.

Compact microgrid dynamics: For compactness we define the matrices

( 5.3.27) From (5.3.18)-(5.3.19), (5.3.23) and (5.3.27) we rewrite the microgrid dynamics (5.3.26) as: 5.3.28) Low level control

Scheduling formulation

In the microgrid model (5.3.28)-(5.3.30) there are two variables that can be used as control variables: the duty cycle d(t) and the external grid current i e (t). Fig. 5.4.1 illustrates the general control scheme of the DC microgrid system where two control levels can be considered. At a lower level (corresponding to fast dynamics) the aim is to keep the load voltage v l (t) constant and at a higher level (corresponding to slow dynamics), an optimal scheduling of the battery operation should be provided. In this work, we concentrate only on the latter problem, and the first objective is assumed to be achieved in the much faster time scale (e.g., [Zonetti et al., 2015, Zhao and[START_REF] Zhao | [END_REF]) by using the duty cycle d(t). Thus, we consider that the only control variable is the external grid current i e (t). Also, at the low level, we assume that the load voltage is forced to a desired value

( 5.4.13) Furthermore, in this work, we aim to minimize the electricity cost that is chosen as the cost in the optimization problem (5.4.14)-(5.4.16) of the scheduling control. Therefore, the considered controller is different from the conventional MPC which penalizes the discrepancy between the system state and the setpoint for the tracking objective. Due to its profit objective, the controller is called economic MPC ( [START_REF] Touretzky | A hierarchical scheduling and control strategy for thermal energystorage systems[END_REF]).

We consider the recursive construction of an optimal open-loop control sequence i e (t) = {i e (t|t), . . . , i e (t + jh s |t), . . . , i e (t + (N p -1)h s |t)} at instant t over a finite receding horizon N p , which leads to a feedback control policy by the effective application of the first control action as system input: 5.4.14) subject to: discrete-time dynamics (5.4.6)-(5.4.8), constraints (5.4.9), (5.4.13), (5.4.15) with j = 1, . . . , N p . In (5.4.14) we make use of the electricity price price(t) to penalize buying and encourage selling with the cost described by the following relation: .4.16) The profiles introduced in Section 2.6.1 appear as parameters here (e.g., the electricity price profile, price(t), the load electrical power, P l (t), and the renewable electrical power, P r (t)). Therefore, the cost (5.4.16) is variable due to the variation in the energy price, but otherwise is linear with respect to the input variable. We can see that the dynamics (5.4.6)-(5.4.8) and the constraints (5.4.9), (5.4.13) are overall nonlinear. Thus, the Appendix A

Permanent Magnet Synchronous Machine

This section explains the PMSM dynamics in detail its dynamical model including a permanent magnet rotor and a three phases stator [START_REF] Nicklasson | Passivity-Based Control of a class of Blondel-Park transformable electric machines[END_REF]. The PH formulation involves the determination of the energy storage, the resistive element, the external environment and the interconnection (Dirac structure) for the PMSM dynamical system. Energy storage: It can be seen that the machine energy is stored in the magnetic field of three stator coils. Their currents and voltages are denoted by i l,L (t) ∈ R 3 and v l,L (t) ∈ R 3 , respectively. It is well-known that the energy of the inductors are expressed by:

where the inductance matrix L abc (θ e ) ∈ R 3×3 depends on the rotor angle since the air gap between the rotor and stator varies with different rotor position such that:

where L 1 , L 2 , L 3 correspond to the self and mutual inductors of the stator coils, p is the number of the pole pairs, ϕ a (t) = 2pθ e (t), ϕ b (t) = 2pθ e (t) -2π 3 , ϕ c (t) = 2pθ e (t) + 2π 3 are three magnetic phases of the stator coils. The permanent magnet rotor is characterized by the magnetic flux φ f that causes three fluxes on three stator coils represented by Φ f abc (θ e ) ∈ R 3 :

Then, the magnet flux through the stator is the total of the fluxes of self inductance and of the rotor:

Next, i l,L (t) is derived from (A.0.4) and replaced in (A.0.1). We obtain the stored energy formulation H e ( Φl , θ e ) as a function of stator magnetic fluxes, Φl (t), and rotor angle, θ e (t),:

Consequently, from (A.0.4), (A.0.5) and the Lenz's law, the stator inductance current and voltage are rewritten as:

Resistive elements: Obviously, the resistive elements correspond to the stator resistors characterized by the resistance R l for each phase. Assuming that they are linear, the Ohm's law is written as:

External environment: The external environment supplies energy to the PMSM through three ports: electrical voltage source îl (t), vl (t) ∈ R 3 and mechanical source τ e (t), ω l (t) ∈ R. The stator central node is not connected to an external port that leads to a zero current constraint. This is modeled by adding a zero current source i ln (t), v ln (t) ∈ R such that:

i ln (t) = 0. (A.0.8)

Dirac structure: Finally, from the physical laws, we derive the Dirac tructure of PMSM which describes the relations of the previous element conjugate variables. Firstly, the Kirchhoff laws for the stator electrical circuit are given by:

(A.0.9)

Secondly, the magnetic torque of the machine is expressed as:

Next, the relation of the rotor angle and its speed is given by:

From (A.0.6)-(A.0.11) we derive the PMSM dynamics as:

Appendix B

Symplecticity of Hamiltonian system

This section presents firstly the symplectic vector space and related notions. Then, the symplecticity of the closed-Hamiltonian system in canonical form and on symmplectic submanifolds are defined.

B.1 Symplectic vector space and manifold

Definition B.1.1 (Symplectic bilinear form [START_REF] Marsden | Introduction to Mechanics and Symmetry: A basic exposition of classical mechanical systems[END_REF]). A symplectic bilinear form is a mapping ϕ : S × S → R that is

• bilinear: linear in each argument separately,

• alternating: ϕ(s, s) = 0 hold for all s ∈ S, and

• nondegenerate: ϕ(s, r) = 0 for all s ∈ S implies that r is zero.

A simple example of symplectic form is given as:

where I n ∈ R n×n is the identity matrix.

Definition B.1.2 (Symplectic vector space [START_REF] Marsden | Introduction to Mechanics and Symmetry: A basic exposition of classical mechanical systems[END_REF]). A symplectic vector space is a vector space S over a field F (for example the real numbers R) equipped with a symplectic bilinear form.

The symplectic bilinear form for the basis vectors (s 1 , ..., s n , r 1 , ..., r n ) is given by:

Similarly, the definition of the symplectic manifold M is formulated by replacing the linear vector space S in the previous definition with the manifold M.

Definition B.1.3 (Symplectic map [START_REF] Marsden | Introduction to Mechanics and Symmetry: A basic exposition of classical mechanical systems[END_REF]). Suppose that S, W are symplectic vector spaces with the corresponding symplectic forms φ, ρ. A differentiable map η : S → W is called symplectic if it preserves the symplectic forms, i.e.,

for all s, s 1 , s 2 ∈ S, where ∂ s η(s) is the Jacobian of η(s).

Definition B.1.4 (Symplectic group and symplectic transformation [START_REF] Marsden | Introduction to Mechanics and Symmetry: A basic exposition of classical mechanical systems[END_REF]). In the previous definition, if S = W, then a symplectic map is called a linear symplectic transformation of S. In particular, in this case one has that ϕ(γ(s), γ(r)) = ϕ(s, r) and thus, the linear transformation γ preserves the symplectic form. The set of all symplectic transformations forms a group called the symplectic group and denoted by Sp(S).

B.2 Hamiltonian system B.2.1 Hamiltonian system in canonical form

The Hamiltonian system in canonical form has the form:

where x(t) ∈ X ⊂ R 2n is state variable, H(x) is the Hamiltonian. Thus, the system (B.2.1) is a special case of Port-Hamiltonian system defined in Section B.2. The interconnection matrix J ϕ represents the Dirac structure. H(x) describes the energy in the storage element. Let ϕ t : X ⊂ R 2n of (B.2.1) be the mapping that advances the solution by time t, i.e., ϕ t (x 0 ) = x(t, x 0 ), where x(t, x 0 ) is the solution of the system (B.2.1) corresponding to initial value x(0) = x 0 . The dynamics (B.2.1) has two important properties [START_REF] Marsden | Introduction to Mechanics and Symmetry: A basic exposition of classical mechanical systems[END_REF].

1. Hamiltonian is the first integral, i.e., its time derivative is zero, Ḣ(t) = 0.

2. The state evolution satisfies the simplecticity which is described by the following theorem given by Poincaré in 1899.

theorem B.2.1. [START_REF] Marsden | Introduction to Mechanics and Symmetry: A basic exposition of classical mechanical systems[END_REF] Let H(x) be a twice continuously differentiable function on X ⊂ R 2n . Then, for each fixed t, the flow ϕ t is a symplectic transformation wherever it is defined, i.e.,

where ∂ x0 ϕ t (x 0 ) is the Jacobian of ϕ t (x 0 ).

B.2.2 Hamiltonian system with state-modulated Dirac structure

The interconnection matrix J ϕ depends on the state variables in some situations. For example, the Hamiltonian system (B.2.1) is represented on other coordinates, or some constraints are added. Therefore, the Hamiltonian is described as:

where x ∈ X is the state variable, J(x) is skews-symmetric. The interconnection matrix J(x) represents the Dirac structure. H(x) describes the energy in the storage element. In this case, the Dirac structure is called modulated by the state variable.

The Hamiltonian system (B.2.2) has some following properties [van der Schaft and Jeltsema, 2014].

It is easy to see that Hamiltonian and Casimir are constant on the state trajectory, i.e., Ḣ(t) = 0, Ċ(t) = 0.

• (Integrability) Loosely speaking, a Dirac structure is integrable if it is possible to find local coordinates for the state-space manifold such that the Dirac structure expressed in these coordinates is a constant Dirac structure (i.e., it is not modulated anymore by the state variables). Integrability in this case means that the structure matrix J satisfies the conditions:

for i, j, k = 1, . . . , n. Using Darboux's theorem (see [START_REF] Marsden | Introduction to Mechanics and Symmetry: A basic exposition of classical mechanical systems[END_REF]) around any point x 0 where the rank of matrix J(x) is constant, there exist the local canonical coordinates z = [z 1 z 2 c] T in which the dynamics (B.2.2) are rewritten as:

In (B.2.5) c indicates the independent Casimirs. From Theorem B.2.1 and transformed system (B.2.5), the time evolution of z is a symplectic transformation.

Appendix C

Optimization C.1 Discrete optimization

The discrete optimization is studied in [START_REF] Boyd | Convex Optimization[END_REF]. A discrete optimization problem has the form minimize g 0 (x) subject to

Here the vector x = [x 1 . . . x n ] T is the optimization variable of the problem, the function g : R n → R is the objective functions, the function g i : R n → R, i = 1, . . . , m, are the constraint functions, and the constants b 1 , . . . , b m are the limits, or bounds, for the constraints. A vector x * is called optimal if it has the smallest objective value among all vectors that satisfy the constraints: for any z with g

We generally consider families or classes of optimization problems, characterized by particular forms of the objective and constraint functions. As an important example, the optimization problem (C.1.1) is called a linear program if the objective and constraint functions are linear, i.e., satisfy

for all x, y ∈ R n and all α, β ∈ R. If the optimization problem is not linear, it is called a nonlinear program.

An important class of optimization problems is the convex optimization problems [START_REF] Boyd | Convex Optimization[END_REF]. For these types of problems the objective and the constraint functions are convex, hence they satisfy the following inequality g i (αx + βy) ≤ αg i (x) + βg i (y), i = 0, . . . , m, (C. 1.3) for all x, y ∈ R n and all α, β ∈ R with α + β = 1, α ≥ 0, β ≥ 0. Comparing (C.1.2) and (C.1.3), we see that convexity is more general than linearity: inequality replaces the more restrictive equality, and the inequality must hold only for certain values of α and β. Since any linear program is therefore, a convex optimization problem, we can consider convex optimization to be a generalization of linear programming.

C.2 Continuous-time optimization

The details of continuous-time optimization is referred to [Liberzon, 2011]. In Section C.1 we considered the problem of minimizing a function g : R n → R. Now, instead of R n we want to allow a general vector space V, and in fact we are interested in the case when this vector space V is infnite-dimensional. Specifically, V will itself be a space of functions. Typical function spaces that we will consider are spaces of functions from some interval [a; b] → R n (for some n ≥ 1).

Let us denote a generic function in V by . The letter x is reserved for the argument of y. (x will typically be a scalar, and has no relation with x ∈ R n from the previous section). The function to be minimized is a real-valued function on V, which we now denote by W . Since W is a function on a space of functions, it is called a functional. To summarize, an continuous-time optimization problem has the form minimize W (y) (C.2.1)

123

with the functional W : V → R.

We also need to equip our function space V with a norm . . This is a real-valued function on V which is positive definite, homogeneous, and satisfies the triangle inequality. The norm gives us the notion of a distance, or metric. This allows us to define local minima. We will see how the norm plays a crucial role in the subsequent developments.

We are now ready to formally define local minima of a functional. Let V be a vector space of functions equipped with a norm . , let A be a subset of V, and let W be a real-valued functional defined on V (or just on A). A function y * ∈ A is a local minimum of W over A if there exists an > 0 such that for all y ∈ A satisfying yy * < we have W (y * ) ≤ W (y).

Appendix D

Optimal control D.1 Optimal control formulation

In this section, we briefly present the optimal control problem with its ingredients: control system, cost functional and target set. All the details of optimal control can be found in [Liberzon, 2011].

The first basic ingredient of an optimal control problem is the control system. It generates possible behaviors and is described by ordinary differential equations (ODEs) of the form

where x is the state taking values in R n , u is the control input taking values in some control set U ⊂ R m , t is time, t 0 is the initial time, and x 0 is the initial state.

The second basic ingredient is the cost functional. For a given initial data (t 0 ; x 0 ), the cost functional assigns a cost value to each admissible control. It is denoted by W . In the finite-horizon case, it has the form:

In the previous forms, V f and L are given functions (running cost and terminal cost, respectively), t f is the final (or terminal) time, and x f = x(t f ) is the final (or terminal state). Note again that u itself is a function of time. This is why we say that W (u) is a functional (a real-valued function on a space of functions).

The last basic ingredient of an optimal control problem is the target set. It is defined as the desired set S f ⊂ [t 0 , ∞) × R n of the final time t f and the final state x f . Depending on its formulation, we have the following corresponding problems:

Then, the optimal control problem can be defined as follows:

D.2 Dynamic programming and Hamilton-Jacobi-Bellman equation

Finite-horizon optimal control problem This section studies the solution of the optimal control problem (D. 1.3). According to Bellman, in place of determining the optimal sequence of decisions from the fixed state of the system, we wish to determine the optimal decision to be made at any state of the system. Only if we know the latter, we understand the 125 intrinsic structure of the solution. The approach realizing this idea is called dynamic programming. It leads to the necessary and sufficient conditions for optimality expressed in the Hamilton-Jacobi-Bellman (HJB) equation.

For the convenience in the later explanation, we define the value function such as:

where the notation u [t0,t f ] indicates that the control u is restricted to the interval [t 0 , t f ]. In the infinite horizon case, t f is replaced by +∞. Loosely speaking, we can think of V (t, x) as the optimal cost at (t, x). It is important to note that the existence of an optimal control is not actually assumed, which is why we work with an infimum rather than a minimum in (D.2.1).

The necessary and sufficient condition, which describes the solution the optimal control problem (D.1.3), is derived from the principle of optimality. It is found by Bellman in and expressed as follows.

Lemma D.2.1. For every (t, x) ∈ [t 0 , t 1 ) × R n and every ∆t ∈ (0, t 1t]), the value function V defined in (D.2.1) satisfies the relation

where x(s) on the right hand side is the state trajectory corresponding to the control u [t0,t f ] and satisfying

This statement implies that to search for an optimal control, we can search over a small time interval for a control that minimizes the cost over this interval plus the subsequent optimal value cost. Thus, the minimization problem on the interval [t, t f ] is split into two, one on [t, t + ∆t] and the other on [t + ∆t, t f ].

Relying on first-order Taylor expansions, we can easily derive the following expressions:

Substituting the expressions given by (D.2.3) into the right-hand side of (D.2.2), we obtain

The two V (t, x) terms cancel out (because the one inside the infimum does not depend on u and can be pulled outside), which leaves us with

Let us now divide by ∆t and take it to be small. In the limit as ∆t → 0 the higher-order term o(∆t)/∆t disappears, and the infimum is taken over the instantaneous value of u at time t (in fact, already in (D.2.4) the control values u(s) for s > t affect the expression inside the infimum only through the o(∆t) term). Pulling ∂ t V (t, x) outside the infimum as it does not depend on u, we conclude that the equation

must hold for all t ∈ [t 0 , t f )] and all x ∈ R n . This equation for the value function is called the Hamilton-Jacobi-Bellman (HJB) equation. In the previous equation, the time derivative of value function does not depend on the terminal cost V f (t f , x f ). However, the value function must satisfy the boundary condition which is given by the terminal cost:

From the previous procedure, we can realize that the HJB equation (D.2.5) and the boundary condition (D.2.6) are the necessary conditions for the solution of the optimal control problem (D. 1.3). In fact, they are also the sufficient conditions. The proof is referred to Section 5.1.4 in [Liberzon, 2011]. Furthermore, in the case of infinite-horizon optimal control problem, the necessary and sufficient conditions does not include the boundary condition (D.2.6).

Infinite-horizon optimal control problem Generally, the infinite-horizon optimal control problem is more complicated than the finite-horizon one. Thus, we consider here one of its important simple case. In this case, the control system and running cost are time invariant. The terminal cost is zeros. The previous assumption are described as ẋ(t) = g(x, u), x(t 0 ) = x 0 , (D.2.7)

It is clear that in this scenario, the cost does not depend on the initial time, hence the value function depends on x only: V = V (x). Thus, the HJB equation (D.2.5) is rewritten as

In this case, there is not the boundary condition for the value cost V (x).

D.3 Linear Quadratic Regulator

Finite-horizon Linear Quadratic Regulator Based on the results for general optimal control in the previous section, we now consider Linear Quadratic Regulator (LQR). In this case, the control system in (D.1.1) is linear.

, where t f is a fixed time. Besides, the cost functional in (D.1.2) is given by:

From Section 6.1 in [Liberzon, 2011], we recall the following solution of optimal control problem (D.1.3) with the control system (D.3.1) and cost functional (D.3.2). The optimal control laws is given as

where the matrix P(t) is the solution of Riccati Differential Equation (RDE):

with the boundary condition: Infinite-horizon Linear Quadratic Regulator The infinite-horizon Linear Quadratic Regulator problem is a special case of infinite-horizon optimal control problem. The control system and running cost are time invariant. And there is not the terminal cost. Thus, the control system and cost functional are expressed as:

Consequently, the RDE (D.3.4) is rewritten as:

Note that there is not the boundary condition for matrix P.

Appendix E

Trapezoidal elevator speed profile and PMSM current profile using MTPA method

In this section, we present a reference profile generation method which is used popularly for the elevator system. In this method, the reference speed profile is trapezoidal determined by the maximal limits (ω l,min , ω l,max ), travel initial/final instant (t 0 , t f ) and travel angular distance (θ 0 , θ f ). The accelerations at the beginning and at the end of a travel should be also limited for the comfortable of the passenger. However, in our work, it is small enough to be neglected. Then, the reference current profiles are derived using the Maximum Torque Per Ampere (MTPA) method. It aims at determining the minimal current corresponding to a given torque at each time instant while respecting some constraints on the current and voltage. This objective is actually the minimization of the instantaneous dissipated power in the motor. The electro-mechanical elevator dynamics (4.3.1) can be rewritten as:

where i d (t), i q (t) are respectively the direct and quadrature currents of the motor stator; v d (t), v q (t) are respectively the direct and quadrature currents of the motor stator; L d (t), L q (t) are respectively the direct and quadrature inductances of the motor stator; p is the number of pole pair; Γ res is the elevator gravity torque; J is the mechanical elevator inertia.

Trapezoidal reference speed profile In this work, we consider the case where the elevator goes down. The trapezoidal speed profile is composed of three straight lines. It is characterized by the acceleration a and two instants t 1 , t 2 such that t 0 < t 1 < t 2 < t f . Their values will be determined by (ω l,min , ω l,max ), (t 0 , t f ) and (θ 0 , θ f ). The time interval [t 0 ; t 1 ] is the acceleration phase; [t 1 ; t 2 ] is the constant speed phase; [t 2 ; t f ] is the deceleration phase. Since the profile is symmetric, we have:

Besides, from the definition of acceleration, we obtain:

The travel angular distance is given by θ fθ 0 which leads to:

(E.0.5)

If t 0 = 0, θ 0 = 0, ω l,min = 0, we have

MTPA method Since the dynamics of the mechanical elevator are much slower than one of the electrical part, we only consider the dynamics of two stator currents i d (t), i q (t) in the following reference current generation. Furthermore, the current dynamics are considered at the steady state, i.e. i d = 0, i q = 0. Thus, the dynamics (E.0.1) is replaced by:

The currents and voltages are limited by:

where I l,max is the maximal current amplitude, v ref is the DC bus voltage. The instantaneous dissipated power is given by P dis (i d , i q ) = R s i 2 d (t) + i 2 q (t) , (E.0.8)

where R s denotes the stator resistance. Consequently, the instantaneous current and voltage reference profiles are determined by the solution of the following optimization problem at each time instant:

subject to the constraints (E.0.6), (E.0.7).

(E.0.9)

Appendix F

Singular Perturbation

This section presents a model class of dynamical system where the derivatives of some of the states are multiplied by a small positive parameter [Khalil, 2002]. It is described as: ẋ = g(t, x, z, ), x(t 0 ) = ξ( ), (F.0.1) ż = l(t, x, z, ), z(t 0 ) = η( ), (F.0.2) with t 0 ∈ [0, t 1 ). We assume that the function g, l are continuously differential in their arguments for (t, x, z, We say that the model (F.0.1)-(F.0.2) is in standard form if (F.0.3) has k > 0 isolated real roots

To obtain the ith reduced system, we substitute (F.0.4) into (F.0.1), at = 0 to obtain ẋ = g(t, x, h(t, x), 0), x(t 0 ) = ξ 0 , (F.0.5)

where we indicate h i by h. Singular perturbations cause a multitime-scale behavior of the system dynamic. Denote the solution of (F.0.5) by x(t). Then, the quasi-steady-state is

We shift the quasi-steady-state of z to the origin z = zh(t, x).

Besides, the new time variable τ = (tt 0 )/ indicate the fast time scale. Setting = 0 frees the parameters (t, x) in their slowly varying region. Thus, the model (F.0.1)-(F.0.2) becomes ẋ = g(t, x, z + h(t, x), ), x(t 0 ) = ξ( ), (F.0.6)

which has equilibrium at z = 0. (F.0.7) is called the boundary-layer system.

theorem F.0.1. [Khalil, 2002] Consider the singular perturbation problem of (F.0.1) and (F.0.2). Assume that the following conditions are satisfied

for some domains S x ⊂ R n , S z ⊂ R m , in which S x is convex and S z contains the origin.

Appendix F. Singular Perturbation

• The function g, l, their first partial derivatives with respect to (x, z, ), and the first partial derivative of l with respect to t are continuous; the function h(t, x) and the Jacobian [∂l(t, x, z, 0)/∂z] have continuous first partial derivatives with respect to their arguments; the initial data ξ( ) and η( ) are smooth functions of .

• The reduced system (F.0.5) has a unique solution x ∈ S, t ∈ [t 0 , t 1 ], where S is a compact subset of S x .

• The origin is an exponentially stable equilibrium point of the boundary-layer system (F.0.7), uniformly in (t, x); let R z ⊂ S z be the region of attraction of (F.0.7) and Ω z be a compact subset of R z .

Then, there exists a positive constant * such that ∀η(0)h(t 0 , ξ(0)) ∈ Ω z and 0 < < * , the singular perturbation system (F.0.1)-(F.0.2) has a unique solution x(t, ), z(t, ) on [t 0 , t 1 ], and

hold uniformly for t ∈ [t 0 , t 1 ], where z is the solution of the boundary-layer system (F.0.7). Moreover, given any t b > t 0 , there is * * ≤ * such that

Abstract

The goal of this thesis is to provide modelling and control solutions for the optimal energy management of a DC (direct current) microgrid under constraints and some uncertainties. The studied microgrid system includes electrical storage units (e.g., batteries, supercapacitors), renewable sources (e.g., solar panels) and loads (e.g., an electro-mechanical elevator system). These interconnected components are linked to a three phase electrical grid through a DC bus and its associated converters. The optimal energy management is usually formulated as an optimal control problem which takes into account the system dynamics, cost, constraints and reference profiles. An optimal energy management for the microgrid is challenging with respect to classical control theories. Needless to say, a DC microgrid is a complex system due to its heterogeneity, distributed nature (both spatial and in sampling time), nonlinearity of dynamics, multi-physic characteristics, presence of constraints and uncertainties. Not in the least, the power-preserving structure and the energy conservation of a microgrid are essential for ensuring a reliable operation.

These challenges are tackled through the combined use of PH (Port-Hamiltonian) formulation, differential flatness and economic MPC (Model Predictive Control). The PH formalism allows to explicitly describe the power-preserving structure and the energy conservation of the microgrid and to connect heterogeneous components under the same framework. The strongly non-linear system is then translated into a flat representation. Taking into account differential flatness properties, reference profiles are generated such that the dissipated energy is minimized and the various physical constraints are respected. Lastly, the modelling approach is extended to PH formalism on graphs which is further used in an economic MPC formulation for minimizing the purchasing/selling electricity cost within the DC microgrid. The proposed control strategies are validated through extensive simulation results over the elevator DC microgrid system using real profiles data.

Résumé

Cette thèse aborde les problèmes de la la modélisation et de la commande d'un micro-réseau courant continu (CC) en vue de la gestion énergétique optimale, sous contraintes et incertitudes. Le micro-réseau étudié contient des dispositifs de stockage électrique (batteries ou super-capacités), des sources renouvelables (panneaux photovoltaïques) et des charges (un système d'ascenseur motorisé par une machine synchrone à aimant permanent réversible). Ces composants, ainsi que le réseau triphasé, sont reliés à un bus commun en courant continu, par des convertisseurs dédiés. Le problème de gestion énergétique est formulé comme un problème de commande optimale qui prend en compte la dynamique du système, des contraintes sur les variables, des prédictions sur les prix, la consommation ou la production et des profils de référence.

Le micro-réseau considéré est un système complexe, de par l'hétérogénéité de ses composants, sa nature distribuée, la non-linéarité de certaines dynamiques, son caractère multi-physiques (électro-mécanique, électro-chimique, électro-magnétique), ainsi que la présence de contraintes et d'incertitudes. La représentation consistante des puissances échangées et des énergies stockées, dissipées ou fournies au sein de ce système est nécessaire pour assurer son opération optimale et fiable.

Le problème posé est abordé via l'usage combiné de la formulation hamiltonienne à port, de la platitude et de la commande prédictive économique basé sur le modèle. Le formalisme hamiltonien à port permet de décrire les conservations de la puissance et de l'énergie au sein du micro-réseau explicitement et de relier les composants hétérogènes dans un même cadre théorique. Les non linéarités sont gérées par l'introduction de la notion de platitude différentielle et la sélection de sorties plates associées au modèle hamiltonien à ports. Les profils de référence sont générés à l'aide d'une paramétrisation des sorties plates de telle sorte que l'énergie dissipée soit minimisée et les contraintes physiques satisfaites. Les systèmes hamiltoniens sur graphes sont ensuite introduits pour permettre la formulation et la résolution du problème de commande prédictive économique à l'échelle de l'ensemble du micro-réseau CC. Les stratégies de commande proposées sont validées par des résultats de simulation pour un système d'ascenseur multi-sources utilisant des données réelles, identifiées sur base de mesures effectuées sur une machine synchrone.