discretetime variational mechanicsof multidomainsystems...

179
Discrete time variational mechanics of multidomain systems: Applications to coupled electronic, hydraulic, and multibody systems by Tomas Sj¨ ostr¨ om Master Thesis for the degree of Master of Science in Engineering Physics Supervisor: Claude Lacoursiere Examiner: Matrin Servin November 23, 2012 Ume˚ a University Department of Physics SE-901 87 UME ˚ A Sweden

Upload: others

Post on 20-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Discrete time variational mechanics of

multidomain systems:

Applications to coupled electronic,

hydraulic, and multibody systems

by

Tomas Sjostrom

Master Thesis

for the degree of

Master of Science in Engineering Physics

Supervisor: Claude LacoursiereExaminer: Matrin Servin

November 23, 2012

Umea University

Department of Physics

SE-901 87 UMEA

Sweden

Page 2: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden
Page 3: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Abstract

English

Today there exist few non-smooth multi-domain simulation tools using time-discretized Lagrangian mechanics for circuits.The main goal is to show that itis possible to use a semi-implicit, parameter free non-smooth variational timestepper to simulate the circuits with time-steps proportional to the system timescales.

This is demonstrated by implementing and performing extensive numericaltests for various types of electrical, mechanical and hydraulic components anddemonstrate that the components are stable, with the correct behavior whenthe system is solved using a modified block pivot solver.

Simulation results shows that piecewise linear models are enough for thesimple switching circuits in this thesis.

Svenska

Idag finns det fa simulatorer for icke-slata multidoman kretsar som bygger patidsdiskretisering av Lagranges ekvationer.

Huvudmalet ar att visa att det ar mojligt att anvanda en semi-implicit,parameter fri icke-slat diskret losare for att simulera kretsar med tidssteg pro-portionella mot systemens tidsskalor.

Detta visas genom att implementera olika typer av elektriska, mekaniska ochhydrauliska komponenter samt att visa att komponenterna ar stabila och harratt beteende nar systemet simuleras av en modifierad block pivot losare.

Simulerings resultaten visar att icke-slata Newton metoder med styckvis-linjara komponenter och komplementara villkor ar tillrakligt for att simulerabrytande komponponenter i de simulerande kretsarna.

Page 4: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Acknowledgments

First and for-most I want to thank my supervisor Claude Lacoursiere for helpingme under a year will I worked on this Master Thesis. I also want to thankAlgoryx Simulation AB for providing me with an interesting master thesis.Last I want to thank all at UMIT Research Lab at Umea University for lettingme work there.

4

Page 5: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Contacts

Student

Name Tomas Sjostrom

Adress Bobacksvagen 12 92262 Tavelsjo Sweden

Visit address MIT building, Campustorget 5, UMIT-lab

Phone number 076 1470678

Email tomas [email protected]

Client

Name Algoryx Simulation AB

Adress Uminove Science Park, Box 7973SE – 907 19 Umea Sweden

Visit address Uminove Science Park, Box 7973SE – 907 19 Umea Sweden

Phone number 46-90-717090

Email [email protected]

Supervisor

Name Claude Lacoursiere

Adress Umea University SE-901 87 Umea Sweden

Visit address MIT building, Campustorget 5, MA456

Phone number 46 706754242

Email [email protected]

Examinator

Name Matrin Servin

Adress Umea University SE-901 87 Umea Sweden

Visit address MIT building, Campustorget 5,MA456

Phone number 46 907866508

Email [email protected]

5

Page 6: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Contents

1. Introduction 11

1.1. Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.2. Related work . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.3. Original contributions . . . . . . . . . . . . . . . . . . . . . . . 13

1.4. Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2. Definitions 14

I. Theory 15

3. Lagrangian mechanics 16

3.1. Euler Lagrange equation . . . . . . . . . . . . . . . . . . . . . . 163.2. Generalization . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

3.2.1. Kinetic storage . . . . . . . . . . . . . . . . . . . . . . . 17

3.2.2. Potential storage . . . . . . . . . . . . . . . . . . . . . . 18

3.2.3. Pure dissipators . . . . . . . . . . . . . . . . . . . . . . 183.3. Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3.3.1. Charge-conservation . . . . . . . . . . . . . . . . . . . . 20

4. Multi-domain system 21

4.1. Mechanical systems . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.2. Electrical systems . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.3. Hydraulic systems . . . . . . . . . . . . . . . . . . . . . . . . . 22

5. Discrete time variational mechanics 24

5.1. Potential and kinetic storage . . . . . . . . . . . . . . . . . . . 24

5.2. Pure dissipators . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

5.3. Component connection . . . . . . . . . . . . . . . . . . . . . . . 255.4. Time stepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

6. The linear complementarity problem 28

6.0.1. Inequality constraints . . . . . . . . . . . . . . . . . . . 29

6

Page 7: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

6.0.2. Impact stage . . . . . . . . . . . . . . . . . . . . . . . . 29

6.1. Mixed LCP solver . . . . . . . . . . . . . . . . . . . . . . . . . 30

7. Lumped components and their discretization 33

7.1. Creating component . . . . . . . . . . . . . . . . . . . . . . . . 33

7.2. The resistor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

7.3. The ideal voltage source . . . . . . . . . . . . . . . . . . . . . . 36

7.4. The ideal current source . . . . . . . . . . . . . . . . . . . . . . 37

7.5. The inductor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

7.6. The capacitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

7.7. The diode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

7.8. The transformer . . . . . . . . . . . . . . . . . . . . . . . . . . 42

7.9. The transistor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

7.10. The operational amplifier . . . . . . . . . . . . . . . . . . . . . 47

7.11. The electric motor . . . . . . . . . . . . . . . . . . . . . . . . . 52

7.11.1. Ideal motor . . . . . . . . . . . . . . . . . . . . . . . . . 52

7.11.2. Non-Ideal motor . . . . . . . . . . . . . . . . . . . . . . 54

7.12. The hydraulic pump . . . . . . . . . . . . . . . . . . . . . . . . 57

7.13. The hydraulic pipe . . . . . . . . . . . . . . . . . . . . . . . . . 58

7.14. The check valve . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

7.15. The relief valve . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

7.16. The hydraulic piston . . . . . . . . . . . . . . . . . . . . . . . . 62

8. Circuits 68

8.1. Serial circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

8.1.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

8.1.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 71

8.2. Parallel circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

8.2.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

8.2.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 72

8.3. RLC circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

8.3.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

8.3.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 75

8.4. Single diode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

8.4.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

8.4.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 76

8.5. The diode bridge . . . . . . . . . . . . . . . . . . . . . . . . . . 77

8.5.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

8.5.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 79

7

Page 8: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.6. The transformer . . . . . . . . . . . . . . . . . . . . . . . . . . 81

8.6.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

8.6.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 83

8.7. The common emitter amplifier with BTJ . . . . . . . . . . . . . 84

8.7.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

8.7.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 85

8.8. The flip-flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

8.8.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

8.8.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 87

8.9. The differential amplifier . . . . . . . . . . . . . . . . . . . . . . 88

8.9.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

8.9.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 89

8.10. The non-Inverting amplifier . . . . . . . . . . . . . . . . . . . . 90

8.10.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

8.10.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 92

8.11. The electric motor start up . . . . . . . . . . . . . . . . . . . . 93

8.11.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

8.11.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 94

8.12. The hydraulic piston with dry friction . . . . . . . . . . . . . . 96

8.12.1. Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

8.12.2. Time scale . . . . . . . . . . . . . . . . . . . . . . . . . 98

II. Method 99

9. Implementation 100

9.1. Breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

9.1.1. Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

9.2. Circuit split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

9.2.1. Artificial ground potential . . . . . . . . . . . . . . . . . 108

9.2.2. Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 111

III. Results 112

10.Test runs 113

10.1. Serial circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

10.2. Parallel circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

10.3. RLC circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

10.4. Single diode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

8

Page 9: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.5. The diode bridge . . . . . . . . . . . . . . . . . . . . . . . . . . 122

10.6. The transformer . . . . . . . . . . . . . . . . . . . . . . . . . . 123

10.6.1. High impedance . . . . . . . . . . . . . . . . . . . . . . 123

10.6.2. Low impedance . . . . . . . . . . . . . . . . . . . . . . . 125

10.7. The common emitter amplifier with BTJ . . . . . . . . . . . . . 127

10.8. The flip-flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

10.9. The differential amplifier . . . . . . . . . . . . . . . . . . . . . . 130

10.10.The non-Inverting amplifier . . . . . . . . . . . . . . . . . . . . 131

10.11.The electric motor start up . . . . . . . . . . . . . . . . . . . . 133

10.11.1.The ideal electric Motor . . . . . . . . . . . . . . . . . . 133

10.11.2.The non-ideal electric Motor . . . . . . . . . . . . . . . 135

10.12.The hydraulic piston with dry friction . . . . . . . . . . . . . . 137

11.Discussion 139

11.1. Solvability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

11.2. Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

11.3. Computational complexity . . . . . . . . . . . . . . . . . . . . . 141

11.4. Circuit split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

11.5. The diode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

11.5.1. The ideal diode model . . . . . . . . . . . . . . . . . . . 144

11.5.2. The Shockley diode . . . . . . . . . . . . . . . . . . . . 146

11.5.3. Piecewise linear model . . . . . . . . . . . . . . . . . . . 147

11.6. The transistor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

11.7. The transformer . . . . . . . . . . . . . . . . . . . . . . . . . . 148

11.8. The operational amplifier . . . . . . . . . . . . . . . . . . . . . 148

11.9. The electric motor . . . . . . . . . . . . . . . . . . . . . . . . . 148

11.10.The hydraulic pump . . . . . . . . . . . . . . . . . . . . . . . . 149

11.11.The hydraulic pipe . . . . . . . . . . . . . . . . . . . . . . . . . 149

11.12.The check valve . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

11.13.The relief valve . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

11.14.The hydraulic piston . . . . . . . . . . . . . . . . . . . . . . . . 150

11.15.Comparison to 5Spice . . . . . . . . . . . . . . . . . . . . . . . 151

11.16.Comparison to Hopsan . . . . . . . . . . . . . . . . . . . . . . . 154

11.17.Proof of concept . . . . . . . . . . . . . . . . . . . . . . . . . . 155

12.Conclusions 156

13.Future work 157

9

Page 10: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

IV. References 158

V. Appendix 161

14.Appendix A 162

14.1. Serial Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16314.2. Parallel Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . 16414.3. RLC Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16514.4. Single Diode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16614.5. The diode Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . 16714.6. The transformer . . . . . . . . . . . . . . . . . . . . . . . . . . 16814.7. Common Emitter Amplifier with BTJ . . . . . . . . . . . . . . 16914.8. The flip-flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17014.9. The differential Amplifier . . . . . . . . . . . . . . . . . . . . . 17114.10.the Non-Inverting amplifier . . . . . . . . . . . . . . . . . . . . 17214.11.The electric motor ramping up . . . . . . . . . . . . . . . . . . 17314.12.The hydraulic piston with dry friction . . . . . . . . . . . . . . 174

15.Appendix B 175

15.1. Connection 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17515.2. Connection 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17615.3. Connection 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17815.4. Connection 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17815.5. Connection 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17915.6. Connection 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

10

Page 11: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

1. Introduction

Large vehicles consist of components from many different domains, a loadermay have a mechanical scoop powered by hydraulic cylinders that is in turncontrolled by an electric system. If the time-step used by the time stepper islonger then the time it takes to calculate the time-step, it’s possible to simulatethe loader in real-time. It’s also important that the solution is stable with anerror not diverting to infinity.

The main objective for this thesis is to evaluate an semi-implicit, parameterfree non-smooth variational multi-domain time stepper that is build on workdone for mechanical systems in Lacoursiere (2007). This is demonstrated byimplementing and performing extensive numerical tests for various types ofelectrical, mechanical and hydraulic components and then demonstrate thatthe components are stable, with the correct behavior when the system is solvedusing a modified block pivot solver.

The thesis is divided into three parts. The first part describes the theory be-hind the project, the second part highlights special parts of the implementationand the last part contains results together withe proof of concept.

The theory part begins by explaining Lagrangian mechanics and constraintsin chapter 3 with the equation of motion in equation 3.16. It counties in chapter4 by showing that the different domains can be described using conservationof energy. Chapter 5 discretize the Lagrangian and shows the time stepper.The chapter about linear complementarity problem shows how inequalities canbe described by complementarity conditions. In chapter 7 the components arediscretized and chapter 8 shows the dynamics for the different circuits.

The general principles behind the breadboard and modifications to the blockpivot solver is in methods, chapter II.

The last part contains the results from the simulated circuits in chapter 10and are then discussed in chapter 11. Chapter 12 together with chapter 13contains the general conclusions from this master thesis.

The appendix’s contains the parameters from the simulations as well as andescription of the principal sub matrices for an non-symmetric diode.

11

Page 12: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

1.1. Problem Statement

The purpose of this thesis is to show, using extensive numerical testing that dis-crete time variational principle can be used to formulate and solve multi-domainsystems. The goal is to systematic use differential algebraic equations(DAEs)with free variables to describe the system and avoid using co-simulation, butinstead simulate the different domains in the same solver.

Solving DAE numerically often introduce numerical difficulties. The usualway is therefor to describe the circuits as systems of ordinary differential equa-tions, ODEs. In this thesis this is avoided by using discrete-time variationalmechanics.

The main reason for using discrete-time variational is to construct a solverthat can simulate systems using time steps in the same order as the naturalperiods of oscillations of interest. This is unlike models like Spice requiresunnecessary small time-step because of non-linearities represented by functionswith sharp derivatives.

1.2. Related work

This is not the first time DAEs and the variational principle is used to describedelectrical circuits For instance Layton has a similar approach but unlike thedescription in this thesis, the equation of motion used by Laytons in (Layton,1998, page 297) leads to singular matrices.

Ad hoc integration methods in Acary et al. (2011b) for non-smooth DAE’sincludes free parameters, i.e., the θ method where they need to choose θ anddon’t have a solid justification for it. Spice in Quarles et al. (2012) requiresnon-linear iterative solvers with small time-steps to resolve non-linear functionsusing smooth ODE’s. The Modelica solver in Modelica Association (2012) usesgeneral high order, solver DAE solvers, while according to (Lacoursiere, 2007,chap 4) the solver in this thesis is a one step stable method tailored to for cir-cuits. Marsden in Ober-Blobaum et al. (2011) has Variational method for elec-trical circuits but not electronics. According to solving Modelica Association(2012) multi-domain systems with co-simulation using ODE integrators is gen-erally less stable then system DAE’s.

Many if not all these methods require clever preprocessing to eliminate thenodal matrix. For instance modified nodal analysis where the size of the solu-tion matrix is reduced by making the smaller matrix more dense.

12

Page 13: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

1.3. Original contributions

The theoretical work done in this thesis has been a collaboration between theauthor of this thesis Tomas Sjostrom and the supervisor Claude Lacoursieresee table 1.1.

Tomas Sjostrom Claude LacoursiereWork Section Work Section

Transformer 10.6 Resistor 7.2None ideal motor 7.11.2 Inductor 7.5Piston 10.12 Capacitance 7.6The split circuit algorithm 9.2 Diode 7.7Breadboard 9.1.1 Transistor 7.9The expanded tikz library Whole report Op-amp 7.10

Motor 7.11.1Pipe 7.13

Figure 1.1.: Shows the theoretic work done by Claude Lacoursiere

1.4. Limitations

Ideal components pose a problem as they can introduce undamped high fre-quencies. This means that if they operates at time scales shorter than thetime-step won’t be damped. Two of the components, the op-amp and tran-sistor introduce asymmetries in the complementarity problems. It is easier tosolve symmetric positive define LCP problems. The proof to show that theasymmetries can be solved are not done. Only the time-step size has beencompared between the different methods used in this thesis. The solution timehas not been compared due to the solver used by this thesis is has not beenoptimized.

13

Page 14: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

2. Definitions

Matrices in this thesis are denoted with capital letters iEX the impedancematrix is denoted by Z. Vector and scalars are denoted with small lettersexcept for volume-rate that is denoted by Q, the distinction is apparent fromthe context.

Symbols

The following symbols are used in circuit diagrams

Voltage Source Current SourceResistor Inductor

Diode Motor

Transformer Opamp

NPN Transistor Mosfet Transistor

Ground Mass

Pump Check Valve

Spool Valve Piston

Relife Valve Reservoir

General circuitZ

14

Page 15: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Part I.

Theory

15

Page 16: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

3. Lagrangian mechanics

3.1. Euler Lagrange equation

The theory in this master thesis is based on classical Lagrangian mechanics.By using an energy based principle, the coupling between different domains,i.e. mechanical, electrical and hydraulic can be formulated in a unified way,and solved simultaneously. This is unlike methods i.e. Simulink that requiresthe use co-simulations using different time integrators and solvers for differentdomains.

Conservative physical systems can be described by the Lagrangian is givenby

Lps, 9s, tq T ps, 9s, tq V ps, tq (3.1)

where s are the generalized coordinates and 9s are the generalized velocities.The action is defined as

S »Lps, 9s, tqdt (3.2)

Equation 3.1 only accounts for conservative forces. In order to account for dissi-pative forces given by the Rayleigh dissipation function as defined in (Lacoursiere,2007, page 68) to be

fℜ Bℜps, 9sqB 9s (3.3)

The energy dissipation rate for a Lagrangian without explicit depends givenby (Lacoursiere, 2007, page 69) by

dE

dt BℜB 9s 9s (3.4)

where E T V is the energy.

The derivation of the Euler Lagrange’s equation can be derived in differentways, using the Hamiltonian principle of least action or the energy principle as

16

Page 17: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

in (Layton, 1998, page 290-297) and can be written as

d

dt

BLB 9s BLBs Bℜps, 9sqB 9s (3.5)

3.2. Generalization

In Lacoursiere (2007) components are build on energy transference, storage andtransformation which is common to mechanical, electrical and the hydraulicdomain. Energy in a components is defined as

E »P ptq dt » peptqf ptqqdt (3.6)

where E is the energy of the component, P is the power, e is the effort and f

is the flow. For instance electrical circuits has the P IU . The systems areseen as ideal, energy don’t leave the system.

Due to the fact that 9s and s is in general coordinates and can be interpretedas in table 3.1

Effort e Flow f Displacement s Momentum p

force F velocity v position x linear Momentum x

torque τ angular velocity ω angle Θ angular Momentum Θvoltage U current I charge q flux linkage Λpressure P volume rate Q volume V Pressure momentum V

temperature T entropy rate S entropy S pnoneqFigure 3.1.: Shows correspondence between mechanical, electrical and hy-

draulic systems, from (Layton, 1998, page 276)

the energy postulate can be used in all domains.

3.2.1. Kinetic storage

The derivative of the momentum is defined as9p e (3.7)

for example for a single particle with mass m the momentum is p mv andthe effort is F m 9v.

Replacing edt dp and using the same definition of kinetic storage as in(Layton, 1998, page 276) yields the kinetic energy part of the Lagrangian to

17

Page 18: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

be

Lps, 9s, tq »gpf qBf (3.8)

where gpf q is a function of the flowEach component can then be derivatived with respect to the flow to yield

the Euler Lagrange equation

d

dt

BLps, 9s, tqB 9s gpf q (3.9)

3.2.2. Potential storage

The derivative of displacement flow as9s f (3.10)

in mechanical systems v 9xReplacing fdt ds and using the same definition of kinetic storage as in

(Layton, 1998, page 276) yields the potential energy part of the Largrantian tobe

Lpq, 9q, tq » gpf qdf (3.11)

where gpqq is only depending on displacement.

Each component can then be derivatived respect to the displacement to yieldthe Euler Lagrange equation BLpq, 9q, tqBq gpqq (3.12)

3.2.3. Pure dissipators

Pure dissipator is by definition not conservative forces and can’t be describedby the Lagrangian. A flow through a component exerts a dissipative efforton the system described in the same way as in (Layton, 1998, page 279) by adissipative state function on the form

ℜ pf q »g pf qdf (3.13)

where ℜ is a Rayleigh dissipation function. For a resistor with resistance R

and current I the state function becomes ℜ pf q 12RI2.

18

Page 19: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

The derivative in the Euler Lagrange equation becomes

ℜ pf qBf g pf q (3.14)

3.3. Constraints

Constrains are restrictions on the degrees freedoms in the system, in this thesison the displacements, flows and on the effort. If a constraint is violated itapplies a constraint force on the system that direct the system to a nonvolatilestate, i.e. a ball penetrating a surface is force up to the surface by a non-penetration constraint.

In this thesis only holonomic(displacement dependent) gps, tq ¥ 0 and non-holonomic(displacement and flow dependent) aps, f, tq ¥ 0 constraints are con-sidered. The f part of the Euler equation can in principle be seen as effortconstraints with regularization in the form of mass. Pure effort constraints,without regularization are not allowed due to the fact that it is possible to putthe constraints parallel to each other see figure 11.2.

The constraints can augmented to equation 3.1 as seen in (Lacoursiere, 2007,page 72-79) to

L

s, 9s, λ, 9λ, t Lps, 9s, tq λgps, 9sq (3.15)

subjected to Rayleigh function in equation 3.3.

The corresponding Euler Lagrange equation is derived in (Lacoursiere, 2007,page 72-79) to

d

dt

BLps, 9s, tqB 9s BLps, 9s, tqBs GTλAT 9α Bℜps, 9sqB 9sd

dt

BLλ, 9λ, tB 9λ BLλ, 9λ, tBλ gps, 9s, tq 0Bℜpα, 9α, tqB 9α aps, 9s, tq 0

(3.16)

where the Jacobian matrix is defined as Gij BgiBqj and Aij BaiBIj . Note that

the constraint force is given by Aα and Gλ. The magnitude of the force isgiven by λ ,α and it’s direction is given by the steepest descent (the Jacobian).

Equation 3.16 can be written

19

Page 20: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

3.3.1. Charge-conservation

Coupling lumped components together is done using Kirchhoff’s current lawor corresponding conservation of mass for hydraulics, i.e. that the current intoa node must be the same as the current out from a node, if not the node willhave a buildup of charge

The Kirchhoff’s current law can be written as

i

aji 9qi Is,j 0 (3.17)

where aji P r1, 0, 1s is the Jacobian matrix A also called nodal matrix and Is,jis the sum of current source i at node j. The rows of the Jacobian correspondsto the nodes in the circuit and the coulombs corresponds to the currents. Acomponent with one current connected to node one and two would have aJacobian matrix on the form

A 11 (3.18)

where the sign indicates if the current goes into the node or out from the node.Equation 3.17 correspond to the holonomic conservation of charge constraint

and is enforced by the current.Equation 3.16 then becomes

d

dt

BLps, 9s, tqB 9s BLps, 9s, tqBs ATU Bℜps, 9sqB 9sA 9q Is

(3.19)

where f contains the current sources and the constraint force is the voltage U .

20

Page 21: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

4. Multi-domain system

4.1. Mechanical systems

The flow variable for mechanical systems is as can be seen in table 3.1 velocityand the constraint effort is force. In this thesis only 1D kinetic stores in theform of 1D multi-body has been implemented to describe the mechanical world.The kinetic energy becomes

T pf q T pvq 1

2mv2 (4.1)

where m is the mass. The body can subjected to some potential V psq , iEX

gravity as well as some dissipative force gpvq. This yields the equation ofmotion3.5 to be on the form

m 9v BVBs gpvq (4.2)

and can then be augmented with other constraints, i.e. distance constraints asin equation 3.16

4.2. Electrical systems

The electrical systems are fundamental laws, Kirchhoff’s current(KCL) andKirchhoff’s voltage law (KVL). KVL in electrical circuits is a result of conser-vation of energy and can be written as

i

Ui 0 (4.3)

where Ui is the voltage drop over the component i. Equation states that 4.3the sum of all the voltage sources in a loop must be equal to the sum of all thevoltage drops over all loads in the same loop. In other case, energy will havebeen created or destroyed.

Coupling lumped components together is done using Kirchhoff’s current law.The current into a node must be the same as the current out from a node, inother case the node will have a buildup of charge.

21

Page 22: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

As seen in table 3.1 the effort for an electrical circuit is the voltage and theflow is the current I. In this thesis the electrical system consist of dissipators i.e.resistors, kinetic storage’s i.e. inductors and potential storage’s i.e. capacitors.The kinetic energy becomes

T ps, f q T pIq (4.4)

for inductors, the potential energy for capacitors becomes

V psq V pqq (4.5)

and the dissipative state function becomes

ℜ ps, f q ℜ pq, Iq (4.6)

The equation of motion 3.5 becomes

d

dt

BT pIqBI BV pqqBs Bℜpq, IqBI (4.7)

which is correspondence to Kirchhoff’s voltage law due to that both laws ensureconservation of energy .

Equation 4.7 can then be augmented with constraints i.e. the conservationof charge as in equation 3.16.

4.3. Hydraulic systems

In correspondence to the electrical circuits in section 4.2 the hydraulically cir-cuits are govern by the conservation of mass and the Bernoulli’s equation.Bernoulli’s equation ensure conservation of energy is given in (Husain et al.,2009, page 31) as

P

ρA2Q

2

2 const (4.8)

where ρ is the density, A the area and the system has no high difference.

The connection between components are in the hydraulic case done withmass conservation. The mass of the flow into a node from one component mustmach the mass of the flow out a node. In correspondence to equation 3.17 theconservation of mass becomes

i

ajiQi Qs,j 0 (4.9)

22

Page 23: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

where aji P rAi, 0,Ais is the Jacobian matrix A, Qs,j is the sum of Q sourcesi at node j, Ai is the Cross section area of the components. A component withone flow connected to node 1 and 2 would have a Jacobian matrix on the form

A AA (4.10)

where the sign indicates if the fluid goes into the node or out from the node.As seen in table 3.1 the effort for a hydraulic circuit is the pressure and

the flow if the volume rate Q. In correspondence to the electrical circuits thehydraulic systems consist of dissipators by viscosity, kinetic storage’s throughinertia in the fluid and potential storage’s in form of containers. The kineticenergy becomes

T ps, f q T pQq (4.11)

for inductors, the potential energy for containers becomes

V psq V pVq (4.12)

and the dissipative state function becomes

ℜ ps, f q ℜ pV, Qq (4.13)

The equation of motion 3.5 becomes

d

dt

BT pQqBI BV pVqBQ BℜpV, QqBI (4.14)

which is correspondence to the Bernoulli’s equation due to that both lawsensure conservation of energy.

Equation 4.14 can then be augmented with constraints i.e. the conservationof mass from equation 4.9 as in equation 3.16.

23

Page 24: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

5. Discrete time variational mechanics

5.1. Potential and kinetic storage

In this thesis the Lagrangian is discretized in the same way as in (Lacoursiere,2007, page 48-49) to a sum of linear functions of short intervals ∆t

Lpsk, sk1,∆tq » h

0

Lps, 9s, tqdt (5.1)

where N is a constant, s sk1 and 9s 1∆tpsk1 skq.

The discrete action is defined as

Sps0, s1, .., sN ,∆tq N1

k0

Lpsk, sk1,∆tq∆t (5.2)

The Hamiltonian principle of least action yieldsBSps0, s1, .., sN ,∆tqBsk BLpsk, sk1,∆tqBsk BLpsk1, sk,∆tqBsk 0 (5.3)

and the discrete time Lagrange equationBLpsk, sk1,∆tq∆tBsTk BLpsk1, sk,∆tq∆tBsTk 0 (5.4)

5.2. Pure dissipators

The derivative of the Rayleigh dissipation from equation 3.5 is done in the sameway as in (Lacoursiere, 2007, page 66-68) to yield the discrete Euler Lagrangeequation with dissipative force asBLpsk, sk1,∆tq∆tBsTk BLpsk1, sk,∆tq∆tBsTk ∆tfℜpsk, fk1q (5.5)

24

Page 25: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

where fℜ is defined as in equation 3.3 ofBLpsk, sk1,∆tq∆tBsTk BLpsk1, sk,∆tq∆tBsTk ∆tfℜpsk, fkq (5.6)

depending on which time-step the velocity is taken.

5.3. Component connection

The charge conservation from equation 3.17 is discretized at time-step k 1and is enforce by the current. It is augmented to equation 5.5 asBLpqk, qk1,∆tq∆tBqTk BLpqk1, qk,∆tq∆tBqTk ∆tATU ∆tfℜpsk, fk1q ∆tUe

Afk1 Is

(5.7)

where U is the constraint force force, Ue are external efforts and Is are externalflows. Note that the constraint forces don’t depends on previous time-step.

5.4. Time stepping

For the case of inductors the kinetic energy has the form

T ptq 1

2fTLf (5.8)

where L is a block diagonal matrix with non-zeros one the diagonal for thekinetic components. For instance for a body with mass m T ptq 1

2mv2

Potential storage can be can be written as

V ptq 1

2sTC1s (5.9)

where C1 is a block diagonal matrix with non-zeros on the diagonal for thepotential components. For instances for a capacitor equation 5.9 would beV ptq 1

2C1 q2

In this thesis only linearly dissipators are used this yields a Rayleigh dissi-pation function on the from

ℜpf q 1

2fTRf (5.10)

25

Page 26: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

where R would contain the resistance on the diagonal in the same way as above.

Discrediting equation 5.8, 5.9 and 5.10 can be done in many different ways.In this thesis they are chosen in order to yield a non-singular impedance matrix.The kinetics storage are discretized with

f ptq sk1 sk

∆t(5.11)

The potential storage are discretized using the midpoint rule

sptq sk1 sk

2(5.12)

The discrete Lagrangian becomes

Lpsk, sk1,∆tq 1

4∆t2psk1 skqTZpsk1 skq1

8psk1 skqTZpsk1 skq (5.13)

The derivatived dissipation function becomes

fℜpsk, fk1q Rfk1 (5.14)

Equation 5.7 divided by ∆t would then become1

∆tLR ∆t

4C1

fk1 ATU Lfk C1

sk ∆t

4fk

ee

Afk1 Is

sk1 sk ∆tfk1

(5.15)

where ee is eternal efforts and the solver first solves a matrix to get the flowsand efforts then steps the displacements with an semi implicit Euler step.

Collecting the terms in front of fk1 to an impedance matrices as

Z 1∆t

L 0 00 R 0

0 0 ∆t4 C1

(5.16)

26

Page 27: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

and defining the right hand side

b Lfk C1

sk ∆t

4fk

ee (5.17)

as yields equation 5.15 to becomeZ AT

A 0

fk1

e

b

Is

sk1 sk ∆tfk1

(5.18)

where 0 is the zero matrix representation no relaxation of the constraint. Therelaxation is not needed as the KCL is a linear constraint, the constraint issolved exactly and there is no need for relaxation.

Other constraints like the distance constraints may have relaxation with adiagonal matrix instead of zero matrix. This represents soften the constraintand is used in the original Spook solver to ensure that the solution matrix isa P -matrix. As can be seen in chapter 6, having no relaxation gives a Semidefinite matrix requiring the algorithm from section 9.2 reduce the number ofsolutions to one when the circuit is split. The discretization is done in moredepth for each component in chapter 7.

If you only remember one thing from this chapter remember the solutionmatrix

Z AT

A 0

(5.19)

27

Page 28: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

6. The linear complementarity problem

The switching in this thesis is described using complementarity instead of fastchanging function, i.e. the diode in section 7.7 has a complementarity conditionon the form Is ¤ I K U ¥ Us (6.1)

which means that if Is ¤ I then U Us and if U ¤ Us then I Is.equation 6.1 is shown in figure 6.1

Us

I

Us UQ

IQ

Is

Figure 6.1.: Shows the ideal diodes IV curve

28

Page 29: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

6.0.1. Inequality constraints

An Other example on complementarity are inequality constraints. The con-straints have the form aps, f, tq ¥ 0, constraints that can be both active andinactive. A mechanical example would be a ball falling towards the floor witha non-penetrating constraint. When the ball falls towards the floor the non-penetration constraint is turn off. But when the ball penetrates the floor theconstraint is activated and takes the ball to the surface.

In this thesis the inequality constraints will be used for describing diodesthat blocks the current in one direction but not in the other. The constraintEuler Lagrangian is as described in (Lacoursiere, 2007, page 78-79) as

d

dt

BLps, 9s, tqB 9s BLps, 9s, tqBs CTβ Bℜps, 9sqB 9s0 ¤ cps, 9s, tq K β ¥ 0

(6.2)

The Kmeans that if the constraint force is negative the constraint is set inactiveand if the constraint force is positive the constraint is active.

6.0.2. Impact stage

If the inequality constraint from section 6.0.1 was the only thing that stops theball from falling through the floor in section 6.0.1 the ball would collide withthe floor with non-zero incident velocity, and be forced to move away from thefloor in a very short time interval. An impact model sets that time interval tozero.

This is imposed on the Lagrangian given in (Lacoursiere, 2007, page 167) asan LCP on the form M GT CT

Imp

G 0 0CImp 0 0

vλν

MvGvw

0 ¤ ν K w ¥ 0

(6.3)

where M is the mass matrix, G is the Jacobian for other constraints, CImp isthe Jacobian for the impact constraints, v is the velocity before the collision,v is the velocity after the collision, λ is the constraint force, w is a slackvariable for the LCP. Notice that the n 0 and the relaxations been removed.

When a collision is detected the the impact constraint activates and set the

29

Page 30: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

velocity of the particle to zero. With the velocity set to zero the time-stepbefore the impact the particle will never penetrate the wall.

6.1. Mixed LCP solver

The electrical and corresponding hydraulic circuits is described as an the linearcomplementarity problem(LCP) defined in the same way as in (Acary et al.,2011a, 51) as

w Sx a

w ¯ 0, x ¯ 0, wTx 0(6.4)

where LCP is totally defined by the matrix S and vector a. The goal is to finda vector x that fulfills that Sx a ¯ 0 while x ¯ 0.

To ensure that equation 6.4 is solvable for any right hand side the S mustaccording to (Lacoursiere, 2007, page 298) be a p-matrix, all principle submatrices have non-zero determinant. Symmetric positive definite matrices area subclass of p-matrices.

The solution matrix used in this thesis is positive semi definite p0-matrix withone or several solution, especially in the non-symmetric case with transistorand op amp the. To ensure that the LCP has one unique solution all principalsub matrix of S must have full rank. The LCP is solved with a block pivotalgorithm. As can be seen in section 9.2 some of the principle sub matricescan have zero determinant. It’s possible to split the circuits into sub circuitswith blocking diodes. This is taken care of in the same section by introductionartificial ground nodes.

A S on the form

S Z AT

A 0

(6.5)

is solvable as long as the square nn matrix Z has full rank and the rectangularmatrix m n A has full row rank. The complementary conditions used in thisthesis is either on the currents corresponding to the Z matrix or on the voltagescorresponding to the A. This means that either nodes or currents or both isset to inactive. In practices the equations are removed from the S and thecorresponding variable is set to a fix value. If a row is removed the dimensionA will decrease but the rows will still be linearly independent and the LCP stillsolvable. On the other hand if a current is removed the system can split into

30

Page 31: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

sub system. These is not the only restriction needed on the S to ensure thatthe LCP is solvable when the currents are remove.

All components in this thesis are build of Thevenin equivalent componentsconsisting of bi-port devices with one current, i.e. the transistor has tree portsbut is build by two diodes where each diode is connected to two ports. Themost general form is one bi port device connected to two other circuits on theform

S

m 0 0 i j 0 k l 0 n

0 Z2 0 B1 B2 B3 0 0 0 00 0 Z3 0 0 0 B4 B5 B6 0

b A1 0 0 0 0 0 0 0 0c A2 0 0 0 0 0 0 0 00 A3 0 0 0 0 0 0 0 0

d 0 A4 0 0 0 0 0 0 0e 0 A5 0 0 0 0 0 0 00 0 A6 0 0 0 0 0 0 0

f 0 0 0 0 0 0 0 0 0

(6.6)

where b, c, d, e, f , i, k, l, m, n are real constants, m ¡ 0 ,Z are mass matrices,A are a rectangular matrices with full row rank and Z B has full row rank. Ais the nodal matrix and B is the corresponding matrix in KVL, not necessarysymmetric.

When the bi-port device is connected to the circuit it can do it in six wayssee figure 6.2

Appendix B in section 15 shows which constants that needs to be non-zero.Note connection with entries not connected to any nodes are only allowed if

the node is parallel to an other component also connected to these nodes. Inother case it is possible to build a constraint loop which would require a newground node. A loop would lead to a short circuit between the two nodes andin principle collapse them to one node. For instance the op-amp is workingbecause the input side drives the out put side, but the output side don’t drivethe input side. Note that it is possible to connected the input and output sidebut

In order for the principle sub matrices to have full rank the constants mustfulfill table 6.3.

This shows that the components that are designed need to fulfill that theconstants fulfill the requirement in table 6.3 as well as full rank in the S.Note that this require the LCP to be solved by the modified block pivotnon-smooth LCP sovler in order to handle the splitting of circuits.

31

Page 32: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Z3Z2

1

2

3 4

5 6

Figure 6.2.: Shows the six different ways a component can be coupled betweentwo circuits with impedance matrix Z2 and Z3

Connection type Required non-zero constants Required zero constants1 f, n

2 b, d, i, k3 b, f , i, n d, j4 d, f , k, n e, l5 b, c, i, j6 d, e, k, l

Figure 6.3.: Shows the required values for the constant in equation 6.6 depend-ing on connection type in figure 6.2. The mass is always m ¡ 0

32

Page 33: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7. Lumped components and their

discretization

7.1. Creating component

The general method for creating electrical components are

* State the Kirchhoff’s volt law for the components. This is the equationthat is to be solved for each components.

* Assume the KVL is the current derivative of the Lagrangian.

* Integrate the KVL with respect to current in order to get Lagrangian andRayleigh function

* Augment corresponding constraints, i.e. charge conservation

* Discretization of the Lagrangian

* Derivative the Lagrangian with respect to charge at time k and voltage

The hydraulic components subjected to lamina flow are done in the sameway.

33

Page 34: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.2. The resistor

The resistor can be seen as an ideal dissipator yielding a dissipative force onthe system. This means that it can be described with a Rayleigh dissipationfunction.

Kirchhoff’s voltage law, KVL is given by

U RI (7.1)

The Energy dissipation is given by

ℜ » I

0

RIdI 1

2ITRI (7.2)

A resistor has input ports, one in and one out node. This means that theJacobian from section 3.3.1 becomes

A 11 (7.3)

The resistors is discretized with I Ik1 as

ℜ R

2I2k1 (7.4)

In order for it to have a term in the mass matrix.

The derivation of the Rayleigh dissipation function can be found in (Lacoursiere,2007, page 68) and yields BℜBqk ∆tRIk1 (7.5)BℜBU 0 (7.6)

Combining equation , , and 3.16 yields the discretized augmented Euler La-grange equation divide by ∆t to be

Zr 00 R

Ir

Ik1

Ar1 Ar2

1 1 Ui

Uj

Ur

0

Ar1 1Ar2 1 Ir

Ik1

00

(7.7)

where Zr, Ari, Is, Ur belongs to the rest of the circuit and Ui, Uj is the voltage

34

Page 35: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

at the nodes connecting the resistor to the circuit.

35

Page 36: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.3. The ideal voltage source

An ideal voltage source is an infinite external source of energy imposing avoltage difference UExt between in between two nodes. In reality this is not thecase, but there is also a small resistance R in a battery reducing the voltage toU0. This gives a KVL as

RI U0 UExt (7.8)

The battery is connected to the circuit in the same way as a resistor with aJacobian matrix as in equation . This yields the calculations for the batteryto be the same as in section 7.2 with the different that the resistor now hasan imposed external voltage on the rightsized. In correspondence to equation7.9 the discretized augmented Euler Lagrange equation divide by ∆t for thebattery becomes

Zr 00 R

Ir

Ik1

Ar1 Ar2

1 1 Ui

Uj

Ur

UExt

Ar1 1Ar2 1 Ir

Ik1

00

(7.9)

where Zr, Ari,Is ,Ur belongs to the rest of the circuit and Ui, Uj is the voltageat the nodes connecting the resistor to the circuit.

36

Page 37: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.4. The ideal current source

A current source is an infinite supply of external voltage to two existing nodesin the circuit. In order to ensure that the current source is added to existingnodes it is attached in parallel to a resistor with resistance R.

This yields the same KVL as for the resistor but a different in the KCL. Thecurrent from the current source IExt will flow into one of the resistors nodesand out from the other the KCL form equation 3.17 becomes¸

aji 9q Ij 0¸aki 9q Ik 0

(7.10)

As can be seen in equation 5.7 this corresponds to adding IExt on the righthand side of the current constraint. In correspondence to equation 7.9 thediscretized augmented Euler Lagrange equation divide by ∆t for the batterybecomes

Zr 00 R

Ir

Ik1

Ar1 Ar2

1 1 Ui

Uj

Ur

0

Ar1 1Ar2 1 Ir

Ik1

IExtIExt (7.11)

where Zr, Ari,Is ,Ur belongs to the rest of the circuit and Ui, Uj is the voltageat the nodes connecting the resistor to the circuit.

37

Page 38: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.5. The inductor

Inductors can be seen as kinetic storages. The voltage over the inductor isgiven by

U LdI

dt L

d2q

dt2(7.12)

The voltage U can be seen as the force created by the second derivative of thecharge. The associated flux linkage, momentum is given as

Λ » T

0

LdI

dtdt LI (7.13)

where t is an arbitrary time. The kinetic energy is defined as in (Layton, 1998,page 276-278) to be

T » I

0

LIdI 1

2ITLI (7.14)

The inductor has the same type of connections as a resistor, one in and oneout node. This means that the jacobian from section 3.3.1 becomes

A 11 (7.15)

The current is I dqdt

and is discretized to I qk1qk∆t

, as the equation is notstiff and will have a mass. The discrete Lagrangian at time k becomes

Lpqk, qk,∆tq∆t 1

2∆tpqk1 qkqT L pqk1 qkq (7.16)

The discrete augmented Euler Lagrangian, divided by ∆t becomesZr 00 1

∆tL

Ir

Ik1

Ar1 Ar2

1 1 Ui

Uj

Ur

1∆t

LIk

Ar1 1Ar2 1 Ir

Ik1

00

(7.17)

where Zr, Ari, Ur,Is belongs to the rest of the circuit and Ui, Uj is the voltageat the nodes connecting the inductor to the circuit.

38

Page 39: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.6. The capacitor

The Capacitors can be seen as ideal potential storage with a voltage-drop givenby

U q

C(7.18)

According to is the potential energy is given by (Layton, 1998, page 277-279)

V » q

0

Udq » q

0

q

Cdq q2

2C(7.19)

The capacitor is a two device with an in and an out port. This gives a Jacobianto be

A 11

(7.20)

In-order for the capacitor to have a term in the mass matrix the charge isdesecrated with the midpoint rule as q qk1qk

2

The discrete Lagrangian becomes

Lpqk, qk,∆tq∆t h

8pqk1 qkqT C1 pqk1 qkq (7.21)

Using that Ik pqk1 qkq the discrete augmented Euler Lagrangian, dividedby ∆t can be written as

Zr 0

0 ∆t4 C1

Ir

Ik1

Ar1 Ar2

1 1 Ui

Uj

Ur 1

C

qk ∆t

4 Ik

Ar1 1Ar2 1 Ir

Ik1

00

(7.22)

where Zr, Ari, Ur,Is belongs to the rest of the circuit and UiUj is the voltagedrop over the capacitor.

39

Page 40: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.7. The diode

The diode in this thesis is constructing using a piecewise linear model with alinear complementary condition on the formIs ¤ I K U ¥ Us (7.23)

where I is the current through the diode, Is is the bias current, U is the voltagedrop over the diode and Us is the forward bias voltage.

This yields an IV curve as in figure 7.1

Us

I

Us UQ

IQ

Is

Figure 7.1.: Shows the piecewise linear diode circuit

The resistance is given as in (Rizzoni, 2000, page 357) by equation 7.24

1

RD BIBU pIQ,UQq (7.24)

where pIQ, UQq is the intersection between the piecewise curve and the diode

40

Page 41: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

equation given by the diode equation 7.25

I Is

exp

U

NUT

1

(7.25)

where in the thesis IQ 50103 A. The equation 7.25 is linearized due tothe fact that the IV curve has a very steep knee when the diode switches fromconducting to blocking. This would require a very small time-step to accuratelyresolve. Notice that the exact value of IQ can be set depending on what regionof the IV curve in figure 11.3 that is important. Deriving equation 11.5 andreordering equation 7.24 yields equation 7.26

RD NUT

Isexp

UQ

NUT

(7.26)

where UQ NUT logIQIs

. The exact value of the resistance is determined

during the simulation. The forward bias voltage UQ is given the diode equation7.25 at I 1103 A. The exact value is determined when creating the diode.

The diode is discretized in the same way as the ideal voltage soucre with thediscretized augmented Euler Lagrange equation divide by ∆t as in equation7.27

Zr 00 RD

Ir

Ik1

Ar1 Ar2

1 1 Ui

Uj

UrUD

Ar1 1Ar2 1 Ir

Ik1

00

(7.27)

where Zr, Ari,Is ,Ur belongs to the rest of the circuit, RD is the diode resistance,UD

is the diode bias voltage , Ui and Uj is the voltage at the nodes connecting thediode to the circuit. The current Ik1 is bound by rIs, infs.

41

Page 42: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.8. The transformer

The transformer consist of two inductive coils. A current in one of the coilsgenerates a magnetic field that apply a force on the charges in the second coil.When the charges in the second coil moves they in turn creates a magneticfield that apply a force in the opposite direction and slowing down the chargesin the first coil.

Lp Ls

U0

R0

I0

R2

I2

Figure 7.2.: Show a transformer connected to two diffrent circuits with param-eters in section 14.6

This can be described with mutual induction as in (Rizzoni, 2000, page 771-775). The voltage drop over the coils are defied as

Up LpdIp

dtM

dIs

dt

Us M dIp

dt Ls

dIs

dt

(7.28)

where Up is the voltage drop over the primary coil, Us is the voltage dropover the secondary coil and the mutual induction is defined as M f

aLpLs.

f P r0, 1s is the amount of flux from one coil that penetrates the other one.The coupling to the rest of the circuit is done with four ports. The current

through the primary side is coupled to the first two ports while the currentson the secondary coil is connected to the last two ports. The Jacobian matrixfor the transformer becomes

A 1 01 00 10 1 (7.29)

where the primary currents part is in first column and secondary currents partin second column.

The discrete Lagrangian is calculated in the same way as for a normal in-

42

Page 43: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

ductor in chapter 7.5. The flux linkage is given by

Λp » t1

0

LpdIp

dtM

dIs

dtd∆t LpIpMIs

Λs » t1

0

M dIp

dt Ls

dIs

dtd∆t MIp LsIs

(7.30)

where t1 is an arbitrary time. The kinetic energy is defined as in (Layton, 1998,page 276-278) with the contribution from each coil becoming

Tp » I

0

Λ1dI 1

2

IpTLpIp IsT MIs

Ts » I

0

Λ2dI 1

2

IpT MIp IsTLsIs

(7.31)

,where Tp is the kinetic energy from the primary coil and Ts is the kineticenergy from the secondary coil. Unlike the inductor this yields two currents,one through the primary coil and one through the secondary coil.

The transformer is discretized in the same way as for the inductor with

Ip pqpk1qpkq∆t

and Is pqsk1qskq∆t

yielding the discrete Lagrangian to be

Lppqpk, qpk1,∆tq∆t 1

2∆tpqpk1 qpkqT Lp pqpk1 qpkq 1

2∆tpqsk1 qskqT M pqsk1 qskq

Lspqpk, qpk1,∆tq∆t 1

2∆tpqpk1 qpkqT M pqpk1 qpkq 1

2∆tpqsk1 qskqT Ls pqsk1 qskq (7.32)

This puts the coupling between the secondary and primary side in the massmatrix Z as of diagonal terms. The discrete Euler Lagrange equation divided

43

Page 44: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

by ∆t becomesZr 0 00 1

∆tLp 1

∆tM

0 1∆t

M 1∆t

Ls

IrIpk1

Iskp

Ar1 Ar2 Ar3 Ar4

1 1 0 00 0 1 1Ui

Uj

Uk

Ul

Ur1∆t

LpIpk1∆t

LsIsk

Ar1 1 0Ar2 1 0Ar3 0 1Ar4 0 1 Ir

Ipk1

Iskp

000

(7.33)

where Zr, Ari, Ur, Is belongs to the rest of the circuit. Ui Uj is the voltagedrop over the primary coil and Uk Ul is the voltage drop over the secondarycoil.

Note that with this derivation the constant f in the mutual induction M isnot allowed to be 1 nut instead f P r0, 1q. If f 1 the mass matrix wouldbe rank deficient and the stepping matrix is no longer guarantied to have fullrank.

44

Page 45: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.9. The transistor

The transistor can be described according to the Ebers-Moll as two diodesparallel to a current source see figure 7.3

UC ICUEIE

DC0IC DE0 IE0

UB

IB

ǫf IE0 ǫrIC0

Figure 7.3.: Shows the Ebber Molls model for a transistor

The current through the diodes can be described with the Ebers-Moll equa-tions

IC0

IE0

IE0

IC0

IE0ǫf

ǫrIC0 1

expUCB

UT

1

expUEB

UT

1

(7.34)

The above equation is on the form

I IE0Wexp

UUT

1

(7.35)

where I and U are vectors containing the currents and voltages. Multiplyingwith W1 on both sides yields

W1I IE0

W1

!exp

UUT

1)

(7.36)

where W1 is the inverse of W . taking the logarithm on both sides yields

V UT log

W1 I

IE0 1

(7.37)

Note that I is the currents through the emitter and collector. The currentsthrough the diodes is given by

J W1I (7.38)

45

Page 46: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

This yields the KVL on the same form as a diode

V UT log

J

IE0 1

(7.39)

The difference comes when connecting the transistor to the rest of the circuit.The currents calculated each time step is the diode currents J but the currentsconnected to the circuits is the currents through the collector and emitter I.If two diodes would have been connected the Jacobian would look like

A 1 01 10 1

(7.40)

The first current is the current through the collector diode(current 1) is con-nected to the first node. both diodes is connected to the base. The emitterdiode (current 2) is connected to the third node.

Using equation 7.39, the charge conservation can be rewritten to beAr1 1 0Ar2 1 1Ar3 0 1

W

IrIEk1

ICk1

000

(7.41)

where Ari belongs to the rest of the circuit.

The equation 7.39 is discretized in the same way as the diodes in section 7.7.This yields the flow part of the discrete Euler Lagrange equation to beZr 0 0

0 ncUT

IE00

0 0 neUT

IE0

IrIEk1

ICk1

Ar1 1 0Ar2 1 1Ar3 0 1

TUi

Uj

Uk

UrncUT

IE0ICk

ncUT log pICkq

neUT

IE0IEk

neUT log pIEkq (7.42)

where ne, nc is constants given for each diode, Ui,Uj ,Uk is the voltage at eachnode, Zr is the rest of the mass matrix and Ur is the other voltage sources inthe system. The bounds for when both diodes are active is given by rIE, infs

The ideal case is done in the same way as for the diode section 7.7 with aconstant small resistor to beZr 0 0

0 R 00 0 R

IrIEk1

ICk1

Ar1 1 0Ar2 1 1Ar3 0 1

TUi

Uj

Uk

000

(7.43)

where R is a very small resistance. Note that the transistor is non-symmetric.

46

Page 47: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.10. The operational amplifier

The op-amp is an active 5-port device as seen in figure 7.4. The signal on theoutput side is an amplification of the voltage difference on the input side, whilethe current on the output side is given by an external source through at theramp ports. This means that the op-amp can’t amplify the input signal morethat the voltage supplied by the ramp voltages. The model used in this reporthas only three ports where the ramp voltages are instead set to specific values.

ÁÀ O

cccc

IRin

IORoutUoutÁÀ O

ccccFigure 7.4.: Ideal op-amp with voltage supply limits

The output voltage between node O and the ground node is an amplificationof the input voltage between the inverting

Áand non-inverting

Àas seen in

equation 7.44

Uout 1

ǫpU Uq (7.44)

where 0 ǫ ! 1 yields the amplification and Rout ! ǫ.

The op-amp can be seen as a connection given by equation 7.44 between aleft circuit at

À,Á

and the right circuit connected to O. Assume that the leftcircuit has a impedance matrix is given by Zl and that the right circuits massmatrix is given by Zr. Then the flow variables in the left and right circuit isconnected with non-holonomic constraints, KCL to the op-amp. The equation

47

Page 48: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.1 can then be written as for a system not containing the op-amp Zl 0 ATl,À AT

l,Á AT

l,O CTl

0 Zr ATr,À AT

r,Á AT

r,O CTr

Ar,À Ar,

À 0 0 0 DT1

Ar,Á Ar,

À 0 0 0 DT2

Ar,O Ar,À 0 0 0 DT

3

Cl Cr D1 D2 D3 0

Ir,k1

Il,k1

UUUout

I1,k1

Ur

Ul

IÀIÁIOU1

(7.45)

where the left and right circuits are assumed to have full rank, the A are thenodal matrices for each port and circuit, D and C correspondence to otherop-amps.

The op-amps left circuit connected to the inverting and non-inverting portcan be described in correspondence to 7.2 as a Rayleigh dissipation functionon the form

ℜin RinI2,k1 (7.46)

A very high input impedance gives a stiff system and requires a Legendretransform with variable τ to

ℜin a

2τ2k1 τk1I,k1 (7.47)

where a 1Rin

. Deriving equation 7.47 with respect to qku and τk yields thenew KVL on the form BℜinBqku τk1BℜinBτk aτk1 I,k1

(7.48)

where qku is the charge corresponding to the input current I,k1.

48

Page 49: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Adding equation 7.48 to the rest of the circuit yieldsZl 0 0 AT

l,À AT

l,Á AT

l,O CTl 0

0 Zr 0 ATr,À AT

r,Á AT

r,O CTr 0

0 0 a 0 0 0 0 1

Ar,À Ar,

À 0 0 0 0 DT1 1

Ar,Á Ar,

À 0 0 0 0 DT2 1

Ar,O Ar,À 0 0 0 0 DT

3 0

Cl Cr 0 D1 D2 D3 0 00 0 1 1 1 0 0 0

Ir,k1

Il,k1

τk1

UUUout

I1,k1

I,k1

Ur

Ul

0

IÀIÁIOU1

0

(7.49)

where I1,k1 and U1 belongs to other op-amps. The voltage in port O canbe seen as a non-holonomic constraint given in equation 7.44 impost by IO.As mentioned in section 11.1 two components parallel to each other, imposingdifferent voltage differences between two nodes without having any resistancescreates a linear dependency between the two components. This can be avoidedby observing that an op-amp in reality have an output resistance Rout andequation 7.44 becomes

Uout 1

ǫpU Uq RoutIO (7.50)

Note that The output voltage is dependent by the input voltage despite thefact that they are not physically connected. This means that the output KVLequation 7.50 will be asymmetric to the KCL. This is a result of using anidealized model. A real op-amp is constructed using transistor connecting theinput to the output side.

Equation 7.50 is discretized as a resistor and adding it to equation 7.49 yieldsthe system to be solved for the op-amp to be

49

Page 50: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Zl 0 0 0 ATl,

À ATl,

Á ATl,O CT

l 0

0 Zr 0 0 ATr,

À ATr,

Á ATr,O CT

r 0

0 0 a 0 0 0 0 0 10 0 0 b 1 1 ǫ 0 0

Ar,

À Ar,

À 0 0 0 0 0 DT1 1

Ar,

Á Ar,

À 0 0 0 0 0 DT2 1

Ar,O Ar,

À 0 1 1 0 0 DT3 0

Cl Cr 0 0 D1 D2 D3 0 00 0 1 0 1 1 0 0 0

Ir,k1

Il,k1

τk1

Iout,k1

UUUout

I1,k1

I,k1

Ur

Ul

00

IÀIÁIOU1

0

(7.51)

50

Page 51: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

where b ǫRout. The ramp voltages limits the output voltage to Ucc ¤Uout ¤ Ucc. This constraint on the Uout value similar to a dry friction con-straint. In the non-smooth LCP sovler this would mean to remove the nodeand replace it with a fix voltage.

51

Page 52: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.11. The electric motor

7.11.1. Ideal motor

This is the first multi-domain component. The motor takes electric energy andconvert it to mechanical energy. In this thesis a motor is seen as a componentwith resistance that convert all energy that is not dissipate over the resistanceR to rotational energy. The total voltage drop over the motor is given by Ua.The energy disappearing over the resistance is given by

IR I pUa UEq (7.52)

where IUE is the energy converted to mechanical energy. The mechanicalenergy is given by

Iω τ τe (7.53)

where I is the inertia, ω is the motors rotational velocity, τ is the torque gainedfrom the motor and τe is the external torque.

For a motor the torque is proportional to the current as given by

τ KI (7.54)

where K is the torque constant, specific for each motor and given in datasheets.

The motor speed is proportional to the voltage drop as

UE Kω (7.55)

After discretization of equation 7.52, 7.53, 7.54 and 7.55 the discrete EulerLagrange equation becomesI 0 1 0

0 ∆tR 0 11 0 0 σ0 1 σ 0

ωk1

Ik1

∆tτ

∆tUa

Iωk ∆tτe∆tUa

00

(7.56)

where ωk1 is the discretized angular velocity, Ik1 is the discretized current

52

Page 53: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

and σ 1∆tτ

To see that this is similar to the other components define

M I 00 Z

, A

1 00 1 ,H

0 σσ 0

M AT

A H

~vk1

σ

I~vk ∆tf

0

(7.57)

where ~vk contains the angular velocity and current, σ contains the torque andvoltage.

This can be simplified by just looking at a motor connected to a voltagesource, in that case equation 7.56 becomes I ∆t 0

∆t ∆t RK2 ∆t

K

0 1K

0

ωk1

τ∆t

Ua

Iωk ∆tτe00

(7.58)

The equation 7.58 can be rewritten to I∆t

1 0

1 RK2 1

K

0 1K

0

ωk1

τ

Ua

1∆t

Iωk τe00

(7.59)

The first line in equation 7.59 give that the derivative of the mechanical energyis the same as the torque. The second equation tells us that the voltage dropover the motor is combined of voltage drop over the resistor and the voltageused to make mechanical energy. The last line is the KCL connecting to therest of the circuit.

The motor gets a pure dissipation from the resistor and a pure kinematicstorage from the mass.

53

Page 54: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.11.2. Non-Ideal motor

A common type of motor used is motors with brushes as can bee seen in figure7.5 from Open Strax College (2012).

Figure 7.5.: Shows how the rotor effected by a magnetic field where F is theforce, I is the current, w is the part of the wire not canceled

Depending on the rotors orientation it exhibit different amount of the mag-netic field see figure 7.6 from Open Strax College (2012)

54

Page 55: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Figure 7.6.: Shows how the force on the motors wires changes with the angleof the rotor

The force from the moving charges is depending on the angle between themagnetic field and the orientations of the wire. The torque on the wire is thewell known formula

τ BlI sin pΘq (7.60)

as described in (Rizzoni, 2000, page 811) where B is a constant magnetic field,l is the length of the wire and Θ is the angle between the wire and I is thecurrent.

The constant K from equation 7.54 is now dependent on the angle of therotor K KpΘq. The number of wires in a motor can be increase to makea smoother wave shape. According to (Wildi, 2006, page 49, figure 4.8) the

55

Page 56: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

induced voltage in a generator and torque from a motor can be described as asum of absolute values of sin waves see and equation 7.61

U U01

e

N1

i0

sinωΘ 2π

Ni

(7.61)

where

e limNÑ8N1

i0

sinωΘ 2π

Ni

2N

π(7.62)

is a normalization factor and U0 is the amplitude.This corresponds for the motor constant to be

KpΘq K1

e

N1

i0

sinωΘk 2π

Ni

(7.63)

where K is the original value in the ideal model and Θk is the present value ofthe rotor angle.

One other way to make the motor more non-ideal is to apply an externaltorque proportional to ω. This will then correspond to a kinetic friction forcebreaking the motor down as well as forcing the motor to draw current to holda fixed speed.

56

Page 57: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.12. The hydraulic pump

One of the advantages of using Lagrange formulation is that it gives a naturalway to couple different domains. As seen in table 3.1 the hydraulic flow andpressure correspondence directly to the electrical current and voltage.

A displacement pump is a pump that produces a flow. The pump in thisthesis is driven by a electrical motor with a rotational velocity ω as describedin section 7.11. The rotation of the motor is then converted as in (Akers et al.,2006, page 38) to flow according to

f DMω (7.64)

where f is the flow and DM is the pump displacement, the flow produce perrevelation.

To push flow from a pump results in a pressure difference that give rise to atorque that in turn slows down the motor. The toque produced by the pressuredifference is according to (Akers et al., 2006, page 38) given by

τ DMP (7.65)

where τ is the torque and P is the pressure difference.The flow out from the motor and the torque back to the motor is discretized

to come from the next time-step. This yields a motor that feels an externaltorque as

τ DMPk1 (7.66)

and a volume source on the hydralic part of the circuit as

fk DMωk1 (7.67)

The equation 7.59 can be rewritten to include the pump as I∆t

1 0 DM

1 RK2 1

K0

0 1K

0 0DM 0 0 0

ωk1

τ

Ua

P1

1∆t

Iωk τ

000

(7.68)

where the Ua constraint is the KCL and coupled to the rest of the circuit andP1 is the corresponding conservation of volume coupled to the hydraulic circuit.

57

Page 58: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.13. The hydraulic pipe

An Ideal pipe with laminar flow correspondence according to (Akers et al.,2006, page 340) to an electrical resistor, inductor and capacitance. The pressuredrop due to the inductance is given by

P ρl

A

df

dt(7.69)

where P is the pressure drop, ρ is the density l is the length of the pipe andA is the pipe’s area. This correspondence to the pressure resisting the changeflow in the fluid. Given by an inductance L ρl

A. The discretization of the

inductive part can then be done as in section 7.5. The discrete augmentedEuler Lagrangian, divided by ∆t becomes

Zr 0

0 1∆t

ρlA

fr

fr,k1

Ar1 Ar2

A A Pi

Pj

Pr

1∆t

ρlAPk

Ar1 A

Ar2 A Pr

fr,k1

00

(7.70)

where Zr, Ari, Ur,Is belongs to the rest of the circuit and Ui, Uj is the voltageat the nodes connecting the inductor to the circuit.

The correspondence to a capacitance comes from the fact that the fluid inthe pipe can be compressed. The pressure coming from the change volume isaccording to (Akers et al., 2006, page 340) given as

dP

dt βe

Vf (7.71)

In correspondence to section 7.6 the discrete augmented Euler Lagrangian di-vided by ∆t can be written as

Zr 0

0 ∆tA4

V

βe

fr

fr,k1

Ar1 Ar2

A A Pi

Pj

PrVA

βe

Vk ∆t

4fr,k

Ar1 A

Ar2 A frfr,k1

00

(7.72)

where Zr, Ari, Pr,fr belongs to the rest of the circuit and PiPj is the pressuredrop over the capacitor.

The viscosity, the fluids viscosity corresponds according to (Akers et al.,

58

Page 59: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

2006, page 340) to the the the resistance as

P 8µlπ

A2f (7.73)

In correspondence to the resistor the yields the discretized augmented EulerLagrange equation divide by ∆t to be

Zr 0

0 8µlπA

fr

fr,k1

Ar1 Ar2

A A Pi

Pj

Pr

0

Ar1 A

Ar2 A frfr,k1

00

(7.74)

where Zr, Ari,fr ,Pr belongs to the rest of the circuit and Pi, Pj is the pressureat the nodes connecting the resistor to the circuit.

59

Page 60: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.14. The check valve

A check valve ensures that the flow one can flow in one direction by blockingthe flow coming from the wrong direction. This corresponds to an electric idealdiode with Us 0V. The resistance is set to a small value ensuring that themass matrix has full rank.

In correspondence to section 7.7 the discretized Euler Lagrange equationdivide by ∆t becomes

Zr 00 R

fr

fr,k1

Ar1 Ar2

A A Pi

Pj

Pr

0

Ar1 A

Ar2 A frfr,k1

00

(7.75)

where Zr, Ari,fr ,Pr belongs to the rest of the circuit, R 1106 is the checkvalve resistance, Pi, Pj is the pressure at the nodes connecting the check valveto the circuit. The flow fr,k1 is bound by r0,8s.

60

Page 61: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.15. The relief valve

A relief valve is a valve that opens when the pressure is over a given openingpressure Popen. This correspondence to an ideal diode with Us PopenV.

Alternatively if the relief valve is coupled to the reservoir with pressure equalto zero Pa, the pressure drop over the relief valve would be the same as the pres-sure at the node not connected to the ground. The complementary conditionthen becomes

0 ¤ f K Pi ¥ Popen (7.76)

where Pi is the pressure at the node the relief valve is connected to. Instead ofas in the diode case limiting the current to be larger than the bias current, therelief valve limits the pressure to be larger than Popen. This is the same thingdue to the complementarity condition.

As can be seen in section 4.3 the conservation of volume introduces theconstraint force pressure. In order to block the flow when the pressure is lessthan Popen the complementary condition in equation 7.76 is applied to theconstraint force. This means that the solver don’t need to keep track of theflow through the relief valve as it follows from keeping track of the pressure.

The discretized Euler Lagrange equation divide by ∆t becomesZr

fr Ar1 Ar2

Pi

Pj

Pr

Ar1

Ar2

fr

0 (7.77)

where Zr, Ari, fr ,Pr belongs to the rest of the circuit, Pi is bound by the boxcomplementary condition between rPopen min, Popen maxs where Popen min andPopen is the lowest respective highest pressure the relief valve is closed for.

61

Page 62: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

7.16. The hydraulic piston

The piston consist of a pipe with flow in it that moves the piston that in turnmoves a mass and is connected in parallel to two relief valves see figure 7.7

f3 m

P1 P1

f1

Popen above

f2

Popen below

Figure 7.7.: Shows the piston with relief valve and mass

The flow f through the piston is described as a pipe, with inductance formoving the fluid and in correspondence to section 7.13 resistance from theviscosity. The pipe’s capacitance is exclude due to the fact that the bulkconstant, βe is infinite and the oil can’t be compressed to any great extent.The pressure drop from the viscosity and inductance becomes

P ρl

A

df

dt 8µlπ

A2f (7.78)

where ρ is the density of the fluid, l is the length of the piston, A is the crosssection area for the inflow into the piston, f is the flow in the cylinder and t isthe time.

Newtons second law gives the equation of motion for the mass to be

md2x

dt2x F (7.79)

where x is the position of the mass, m is the mass and F is the force on the

62

Page 63: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

mass.

The connection between the mass and the piston is done by a holonomic 1Ddistance constraint in equation 3.15 on the form

g |xAf | (7.80)

where A1 is the cross section area of the cylinder. The pressure from thefluid and force on the mass is related as 1

A1. The flow in the cylinder and

velocity of the mass is changed by constraint forces in order to minimize thedistance between the mass and the piston. The Jacobian matrix from constraintequation is

G xAf|xAf | A xAf|xAf | (7.81)

Notice that the constraint acts only on the flow variables in the system. Thismeans that if an other components is coupled parallel to the mass and theflow in the piston the equation would be linearly dependent. For example twopistons pushing on the same mass and having a constraint loop. In this caseone of the constraints would be redundant and needed to be removed.

The piston has two walls, one at x 0 and the other one at x l, this givesthe piston the stroke l. The walls are modeled with inequality constraints.When the piston is in between the walls the constraint is inactive and the pistoncan move freely. But if the piston passes the walls the constraint exertinga constraint force forcing the piston to move to the bound. The inequalityconstraint to stop the piston from moving through the left wall in equation 6.2can be written as

0 ¤ c1 x 0 K β ¥ 0 (7.82)

where β is the constraint force. The Jacobian of equation 7.82 is

C 0 1

(7.83)

The right wall is similarly constraint with

0 ¤ c2 x l K β ¥ 0 (7.84)

The Jacobian of equation 7.84 is

C2 0 1

(7.85)

As can be seen in equation 7.83 and 7.85 both walls have the same Jacobian.

63

Page 64: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

This is not a problem for the solver as only maximum one of the constraintscan be activated at the same time.

Only using the walls as above risks of creating an over-constrained systemwhere there are two constraint on one degree of freedom. For instance if a flowsource forces a flow in the piston while the wall stops the flow from flowing.To solve this a pressure relief valve as in section 7.15 designed as a diode is putparallel to the piston. This means that if the piston blocks the flow it will beredirected through the relief valve.

If there where just an inequality constraint stopping the piston from movingbeyond the wall, the piston would first move into the wall the feel the constraintforce and move back. A real piston would stop directly at the wall. To correctthis an impact stage as described in section 6.0.2 white n 0. The Jacobianof the impact constraint is

CImp 0 10 1

(7.86)

where the first row is for the left wall and the second row is for the right wall.

The mass is influenced by a dry friction constraint. The mass is not set inmotion if the force exerted by the flow on the mass is lower than the dry frictionforce. This is simulated by a complementary condition on a non-holonomicconstraint giving that the velocity is zero

0 ¤ v K A pP1 P2q mgu ¥ 0 (7.87)

where A is the piston cross section, m is the mass, g is the gravity acceleration,u is the friction coefficient and v is the velocity of the mass.

The Jacobian form equation 7.87 is

Gdry 0 1

(7.88)

The connection to the system on the hydraulic side is done in the same waysas for a pipe with volume conservation yielding a Jacobian on the form

A A1 A A 0 1A2 A A 0 1 (7.89)

where the first and second column corresponds to the flow through the reliefvalves, the third column to the flow in the cylinder, the forth column corre-sponds to the mass movement speed and A1, A2 belongs to the rest of thecircuit. Note that the mass is not connected directly to the hydraulic side butinstead connected by the Jacobian in equation 7.81.

64

Page 65: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

The cylinder is discretized in the same way as the pipe in section 7.13, therelief valve is discretized in the same way as a diode in section 7.7, the acceler-ation of the mass corresponds to a kinetic storage and is therefor discretized inthe same way as an inductor in section 7.5. The discretized augmented EulerLagrange equation divided by ∆t an matrix from becomes

65

Page 66: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Zr 0 0 0 0 AT1 AT

2 0 0 0 0 0 00 D 0 0 0 A A 0 0 0 0 0 00 0 D 0 0 A A 0 0 0 0 0 00 0 0 m 0 0 0 b A A 1 1 10 0 0 0 l a 0 0 c 0 0 0 0 0

A1 A A 0 A 0 0 0 0 0 0 0 0A2 A A 0 A 0 0 0 0 0 0 0 0

0 0 b c 0 0 0 e1 0 0 0 0 00 0 1 0 0 0 0 0 e2 0 0 0 00 0 1 0 0 0 0 0 0 e3 0 0 0

0 0 1 0 0 0 0 0 0 0 0 0 00 0 1 0 0 0 0 0 0 0 0 0 0

0 0 1 0 0 0 0 0 0 0 0 0 0

fk1

f1,k1

f2,k1

vk1

f3,k1

P1

P2

λ

β1β2ν1ν2µ1

UrPopen abovePopen below

mf3,k τExtaf3,k

00 4

∆tegk eGk 4

∆tec1,k1 eC1,k 4

∆tec2,k1 eC2,k

00

0

(7.90)

66

Page 67: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

where D is the flow resistance for the relief valve, Popen above is the highestpressure relief valve 1 can have before f1 activates and divert flow, Popen below

is the highest negative pressure relief valve 2 can have before f2 activates anddivert flow, m is the mass with velocity v, a is the inductance in the pipe givenequation 7.78 to the flow f3 in the pipe , l is the flow resistance in the pipegiven equation 7.78, P1 is the pressure at the first port,P2 is the pressure atthe second port, b is the pipe component from equation 7.81, c is the masscomponent from equation 7.81, ei 1

14τi∆t

, τ i is the constraints time scale, λ

is the corresponding constraint force ensuring the mass to follow the pipe flow,β1 is the left walls Constraint force subjected to box constraint r0,8s, β2 is theright walls constraint force subjected to box constraint r0,8s, ν1 is the impactconstraint force at the left wall, ν2 is the impact Constraint force, µ1 is the dryfriction force subjected to the box constraint rmgu,mgus

Note that all constraints are not active at e same time. In fact only one ofthe wall, impact and dry friction constraint can be active at the same time.

67

Page 68: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8. Circuits

A general circuit is a graph consisting of components with flow variables con-nected by effort constrint’s in the form of nodes. For instance an electric circuithas KVL describing the voltage between nodes and KCL describing currentsmoving into and out from nodes. This can be represented in correspondenceto mechanical circuit given in (Lacoursiere, 2007, page 100) on the form

Z AT

A 0

Ik1

U

USource

ISource

(8.1)

where ZIk1ATU USource is the KVL, AIk1 ISource is the KCL, Ik1 isa vector containing all the component currents, U is a vector containing all thevoltages,USource is the voltage sources, ISource is the current sources, A is thenodal matrix and Z is the impedance matrix. Note that Z is a positive definitesquare matrix n n and A is rectangular matrix matrix with n m wheren ¥ n. In order for the system to be solvable by the non-smooth LCP sovlerall possible principal matrix’s must also be solvable. A condition for solvabillityof a square matrix is that it has full rank, i.e. all vectors and columns in thematrix are linearly independent. This is fulfilled if Z has full rank and A hasfull row rank.

Notice that one of the nodes in a general circuit is redundant as a groundnode. The system in equation can be rewritten as Z AT AT

g

A 0 0Ag 0 0

Ik1

U

Ug

USource

ISourceIg

(8.2)

where Ug is a vector containing all the ground nodes and Ig is a vector con-taining all the ground currents. The ground current is a linearly combinationof the other currents in the circuit.

From a physical perspective the system in equation 8.2 only determines therelative potential difference between the nodes, not the value of the groundpotential. Any reference value can be chosen for the ground potential.

Form a mathematical perspective the system in equation has one node equa-tion, the ground node that is a linearly combination of the other nodes in the

68

Page 69: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

circuit. This means that the system has an infinite number of solutions.In order for the system to only have one solution the potential is set to a spe-

cific value, i.e. Ug 0V for an electric circuit. In the non-smooth LCP sovlerthis is in practice done by removing the variable Ug and it’s equation from thesystem and setting it’s value to zero in in the rest of the equations.

There exist two types of circuits serial circuits and parallel circuits see figure11.3

U1

Z1

I1U2

Z2 I2

U1

Z1

I1 U2

Z2

I2

Figure 8.1.: The image shows two circuits represented with thereThevenin equivalent, the left circuit is a serial circuit whilethe right is a parallel circuit.

The system to solve for the left serial circuit is Z1 0 AT11 AT

12

0 Z2 AT21 AT

22

A11 A21 0 0A12 A22 0 0

(8.3)

and for the right parallel circuit is Z1 0 AT11

0 Z2 AT21

A11 A21 0

(8.4)

where the ground node has been removed and ij indicate to which component,respectively node a sub matrix belongs to.

The difference between a serial and a parallel circuit is in principle that whena current is coupled in serial to another circuit it adds a node, while adding thecurrent in parallel don’t introduce a new node. A circuit with N currents cantherefore maximum have N nodes after the ground nodes has been removedsee figure 11.3

69

Page 70: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

U1Z1 I1 U2

Z2 I2 U3Z3 I3

Figure 8.2.: The image shows a serial circuit represented with thereThevenin equivalent

70

Page 71: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.1. Serial circuit

8.1.1. Circuit

This simulation consisting of 3 serial coupled resistors driven by a constantvoltage source see circuit diagram in figure 8.3.

I1

R1

I2R2

I3

R3

I0 R0U0

Figure 8.3.: Seriel curcuit with parameters in section 14.1

This circuit is simulated to show that the solver can solve standard electricalsystem. The current through the DC voltage source is given by

I0 U0

Rtot 10

5 2 A (8.5)

where Rtot is the total resistance. Due to conservation of charge the Kirchhoff’scurrent law yields

I0 I1 I2 I3; (8.6)

Knowing the currents through the resistors yields the voltage drop to be

U1 R1I1 1 2 2 V (8.7)

U2 R2I2 3 2 6 V (8.8)

U2 R3I3 1 2 2 V (8.9)

8.1.2. Time scale

The circuit is powered by a DC voltage source and consist only of ideal dis-sipators. This yields a constant output which means that the timescale in isinfinite, i.e. any timescale works for this circuit.

71

Page 72: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.2. Parallel circuit

8.2.1. Circuit

Bellow in figure 8.4 is a diagram describing a circuit consisting of two parallelcoupled resistors powered by a voltage source.

I1R1

I2R2

I0 R0U0

Figure 8.4.: Seriel curcuit with parameters as in section 14.2

The circuit shows that the solver can handle pure dissipators.Due to parallel coupling the components has the same voltage as given by

U0 U1 U2 10 V (8.10)

Kirchhoff’s current law yields

I0 U0

Rtot 10

5 2 A (8.11)

where Rtot is the total resistance in the circuit

I1 U1

R1 10

10 1 A (8.12)

I2 U2

R2 10

10 1 A (8.13)

8.2.2. Time scale

The circuit is build by ideal dissipators and a DC current source. This gives aconstant current and therefor infinite timescale(any timescale works).

72

Page 73: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.3. RLC circuit

8.3.1. Circuit

The RLC circuit can be coupled as in figure 8.5

I0

R0

U0

R1 I1

L2

I2C3I3

Figure 8.5.: Seriel RCL curcuit with parameters in 14.3

and shows that it is possible to simulate dissipator, potential and kineticstorage with the solver.

Summing all the voltages with Kirchhoff’s voltage law yields

U0 U1 U2 U3 0; (8.14)

The voltage over an inductor is

U2 LdI2dt

(8.15)

For the capacitor holds

I3 1

C

dU3

dt(8.16)

substituting 8.15 and8.16 into 8.14 yields

RI LdI

dt 1

Cq U0 (8.17)

where qptq is the charge and I Iptq. A Laplace transform of equation 8.17(the current is the time integral of the charge) yields

Upsq RIpsq LIp0q 1

sCIpsq LIp0q (8.18)

73

Page 74: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

reordering 8.18 yields

Upsq ZpIpsqq LIp0q (8.19)

where

Z R Ls s

Cs(8.20)

The Laplace transform of the voltage source is

U0psq ω

s2 ω2(8.21)

using equation 8.21 the response for the resistor becomes

U1psq IpsqR a

s e b

s f c

s g d

s i(8.22)

where a,b,c are d complex constants and

e f jω (8.23)

and

g i R

2L j

d1

LC R

2L

2

(8.24)

Inverting equation 8.24 yields

U1 a exp petq b exp pftq c exp pgtq d exp pitq (8.25)

This means that the voltage consist of two waves with frequency

ω1 ω (8.26)

ω2 d1

LC R

2L

2

(8.27)

The first oscillation don’t decay. but the real part from equation 8.24 makesthe second oscillation ω2 decay over time.

74

Page 75: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.3.2. Time scale

The natural timescale for this circuit is the frequencies ω1 and ω2. Thetime-step used in the simulation is required to resolve the shortest of theseoscillations. In section 10.3, the simulation uses 10 samples per period and thetime-step becomes

∆t 1

10min pω1, ω2q (8.28)

75

Page 76: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.4. Single diode

8.4.1. Circuit

The circuit below show a single diode couple serial with a resistor and currentsource

I0 I0

I1

R1

D2I2

Figure 8.6.: A diode parallelle lwith a resistor and currentsource with parame-ters in section 14.4

This circuit shows that a diode can be simulated by seeing the diode as acomplementarity condition problem.

The diode will block of lead current depending on the direction of the currentsource. If the diode blocks it get a very high resistance and only leads a smallleak current pIsq while the rest of the current goes by the resistor. If the currentflows in the opposite direction the diode will lead with a very low resistanceand a very small current through the resistor.

8.4.2. Time scale

The circuit is driven by an oscillating current source of frequency f 1000 Hz.This is the only factor needed to be considered for ideal diodes as the resistanceis not dependent on previous time-steps. 10 samples per periods is sufficientto resolve the oscillation which yields a time step of ∆t 1104 s.

76

Page 77: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.5. The diode bridge

8.5.1. Circuit

The full-wave rectifier with Graetz bridge is coupled as in figure 8.7

I1D1

I2D2

I3D3

I4D4

C5

I5 I6

R6

I1 R0U0

Figure 8.7.: Fullwave diode bridge curcuit with condensator and parameters insection 14.5

The circuit shows that the solver can handle several diodes seen as comple-mentary conditions at the same time.

The point of this circuit is to convert the AC voltage source U0 to a DCvoltage for load U6

The circuit has three modes depending on the direction of the current andthe charge of the capacitor. Assume that the capacitor begins with no chargeand that the current has the same direction as in 8.7. In this case diode D1

and D3 will lead current,t while D2 and D4 will block the currents as in figure8.8.

77

Page 78: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

I1D1

I3D3

C5

I5 I6

R6

I1 R0U0

Figure 8.8.: Fullwave diode bridge mode 1

When the current from the voltage source has changed direction diode D1

and D3 blocks while diode D2 and D4 lets current through as in figure 8.9.

I2D2

I4D4

C5

I5 I6

R6

I1 R0U0

Figure 8.9.: Fullwave diode bridge mode 2

During the above modes the AC source charges the capacitor at the sametime as it supply current to the load R6.

The capacitor exist in order to minimize oscillation in the load current. Ifthere where no capacitor the current through the load would alternate between0 and 10 V two times per period between 0 and 10 V. With a capacitor thecircuit goes into a third mod if the supply voltage goes lower the the capacitorvoltage. In this case the diodes disconnects the current source as in figure 8.10and supplies the current to the load.

78

Page 79: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

C5

I5 I6

R6

I1 R0U0

Figure 8.10.: Fullwave diode bridge mode 3

Supplying current to the load results in the capacitor voltage to decrease andit will decrease until the supply voltage is higher than the capacitor voltage.When that happens the circuit goes back to a previous mode and the voltagesource supplies the current.

This results in a rippling current with a frequency twice that of the ACsource.

8.5.2. Time scale

In case of ideal diode the only component depending on previous time-stepare the capacitor. The capacitor operates during with two different timescales.During the third mode it’s slowly discharging and during the first two modesit’s charge quicker than it is discharge, if not the capacitor is to small anddo not produce ripple. In order to simulate the circuit it’s necessary to forthe time-steps to be small enough to resolve the discharge and charging ofthe capacitor. During the charging the circuit simplifies to figure 8.8, i.e. acapacitor loaded by a voltage source with a parallel resistor. Applying KCL atthe node connecting R0, C5 and R6 yields

U0 U5

R0 C5

dU5

dt I5 0 (8.29)

KVL on the right part of figure 8.8 yields

U0 U5

R0 C5

dU5

dt I5 0 (8.30)

79

Page 80: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

combining and reordering equation 8.29 and 8.29 yields

R0R6C5dI5dt

pR0 R6q I5 U0 (8.31)

Noting from figure 8.8 that U0 10 sinp2πftq yields the solution to 8.31 as

I5ptq a exp

R0 R6

R0R6C5

b sin p2πftq c cos p2πftq (8.32)

where a ,b and c are constants. This means that the loading of the capacitorhas two different timescales, one oscillating with frequency τ1 1

fone decaying

function. The decaying function in the same way as in section 8.11.1 decays63 % after τ2 R0R6C5

R0R6. If R6 " R0 than τ2 R0C5 that is the time constant

in a normal serial RC circuit. Note that values in the simulations are chosenso that τ1 ¡ τ2 in order for the capacitor to load during each period. Thetime-step in the simulations are 10 times smaller the τ2.

80

Page 81: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.6. The transformer

8.6.1. Circuit

Lp Ls

U0

R0

I0

R2

I2

Figure 8.11.: Transformer with load U0 10 sin p2πftq V, f 2 Hz andR2 100 Ω

The circuit in figure 8.11 can be described as two separate circuit with onecoil from the transformer in each. The coils are then connected by mutualinduction M f

aLpLs where f P r0, 1q. Mutual induction describes how

much of the magnetic flux from one coil, that penetrates the other coil.The voltage source is assumed to be an oscillating sin wave on the form

U0 Ua sin pωtq (8.33)

where Ua and ω is constants.This means that the impedance in a coil is given by

Z ωLj (8.34)

where j is the complex unit.The KVL for the left and right circuits becomes

0 U0 IpLpjω IsMjω

0 R2I2 IpMjω IsLsjω(8.35)

From the left circuit, the input impedance is given by

Zin U0

Ip Lpjω Is

IpMjω (8.36)

The right circuit loop gives

Is

Ip Mjω

R2 Lsjω(8.37)

81

Page 82: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

The impedance in primary coil becomes

Zin U0

Ip Lpjω fLpLsω

2

R2 Lsjω LpjωR2 p1 f qLpLsω

2

R2 Lsjω(8.38)

where M has been substituted. The output impedance can be calculated inthe same way to be

Zout U2

Is R2 (8.39)

Current gain

The current amplification can be found by substituting M into equation 8.37

Is

Ip fjω

aLpLs

R2 Lsjω(8.40)

This is a complex number and can be written on a jb form where

a dLs

Lp

b R2aLpLsω

(8.41)

The phase shift φ is then given by

φ arctan

b

a

arctan

R2

ωLs

(8.42)

This means that if the load resistance R2 is large compared to the inductanceLs the output current will be phase shifted compare to the input current. Incase of a low resistance the equation 8.40 becomes the well known transformerequation

Ip

Is Ns

Np(8.43)

where the inductance is proportional to the square of the number of turns inthe coil L9N2

82

Page 83: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Voltage gain

The voltage gain is given by

Up

Us

Zin

Zout

Lp

Ls

Np

Ns(8.44)

substituting equation 8.37, 8.36 and 8.43 yields the well known voltage relation

Up

Us Np

Ns(8.45)

Note that the voltage, unlike the current is not phase shifted.

8.6.2. Time scale

As can be seen from equation 8.40 and 8.45 the loading and discharging of thecoils is done with the same frequency as the input voltage. This means that itis sufficient to have a time-step that can resolve the oscillating voltage source,i.e. more the 2 samples per period. In the result section 10.6, 10 samples perperiod are used.

83

Page 84: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.7. The common emitter amplifier with BTJ

8.7.1. Circuit

A common emitter amplifier can be coupled with the Eben Mollr’s model asseen in figure 8.12

U0

R0

I0

RC IC

DCsIC0DEs IE0

RE

IEUB sin p2πfqRB

IB

ǫf IC0 ǫrIC0

Figure 8.12.: Voltage amplifier with Ebers-Moll transistor model and with pa-rameters in section 14.7

This is a standard transistor circuit designed to show that the solver cansimulate transistor using the Eben Mollr’s model and linearly complementaryconditions.

The oscillating in-signal at the base UB is amplified by the gain

g RC

RE(8.46)

unless the voltage is negative. This is due to that the transistor is a DC deviceand will block currents that goes from the emitter to collector. The transistoronly amplifies the signal when U0 is positive and UC UB , then the diode DCs

is blocking, neglecting revers bias and DEs is none-blocking. This means thatthe in-signal UB is divided between DEs and RE in the following way

UB UE0 UE (8.47)

note that

UE0 ! UE , (8.48)

the voltage-drop over the diode is much smaller than the voltage-drop over theresistor.

84

Page 85: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

The current through the diode is supplied from the base IB and from thecurrent-source on the collectors side ǫfIE0. Because ǫf is approximately 1,nearly all the current through RE is supplied from the collector. The currentrunning through the collector is the same current that runs through RC . Thismeans that the current through RC is approximately the same as the currentthrough RB

IC IB (8.49)

using 8.48 the voltage drop over RE is

UB UE0 (8.50)

and the current through RE is then

IE0 UE0

RE UB

RE(8.51)

The out-voltage, the voltage-drop over RC is then

VC RCIC UBRC

RE(8.52)

The minus sign is due to that the potential is higher at the base than at UC .

8.7.2. Time scale

If an ideal transistor is used in the circuit there is no components that aredependent on the previous time-step due to the complementarity conditionswhich replace the quick transistion to an instantaneous one. This means thatthe only timescale in the circuit is the oscillation frequency of U2. The timescaleis the τ 1

f. In the simulation the time-step is set to 10 times smaller than

the timescale.

85

Page 86: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.8. The flip-flop

8.8.1. Circuit

A Bistable Multivibrator is a circuit that has two stable states and can becoupled as in figure 8.13

N1 N2

U0

R0

I0

U7

R7

I7

U8

R8

I8

R1

I1

R4

I4R2

I2

R3

I3

Figure 8.13.: A flip flop circuit with parameters as given in section 14.8

and can be used for storing binary 1 or 0. The first state is when voltagesource U7 5 V and U8 0 V. In this case the left transistors will open andlet current through. This means that current in turn will go through resistorR1. Due to the fact that the resistance at R1 is higher than the resistancethrough the transistor the voltage at node N1 will be low. This means thatthe base voltage at the right transistor will block. If the right resistor blocksnearly no current will pass through resistor R4 and the voltage at node N2 willbe the same as the voltage from the voltage source. Note that after the statehas been set by a pulse at U7 it’s stable. This is due to the fact that the lefttransistor is opened and this keeps node N1 low and N2 high.

By setting U7 0V and U8 5V the right circuit will open and drop thevoltage at node N2. This in turn closes the left transistor and increases thevoltage at node N1

In addition to the two stable state the flip-flop has an unstable state. Whenthe flip-flop first is initiated with U7 0 V, U8 0 V and U0 0 V, dueto symmetry the voltage at N1 and N2 will be the same. As long as no pulseis given at either U7 or U8 the flip-flop will stay in this state. But a small

86

Page 87: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

perturbation on either U7 or U8 will yield one transistor to open more than theother and thereby closing the other transistor and the circuit takes one of thetwo stable states.

8.8.2. Time scale

The flip-flop circuit is due to negating the transistor’s saturation time, inde-pendent of information from the previous time-step. This means that the timescale is undefined, i.e. any time-step ¥ 0 works.

87

Page 88: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.9. The differential amplifier

8.9.1. Circuit

A differential amplifier amplifies the difference between two in signals and canbe coupled as in figure 8.14

NoutN2

N1

I1R1U1

I2R2U2

Rf If

Rout

IO

Rg

Ig

IccUccIccUcc

Figure 8.14.: Operational amplifier coupled as a diffrential amplifire with pa-rameters given in section 14.9

This circuit shows the operational amplifier working within the ramp voltagerange. In normal operation range the current through the op-amp is 0. Thatyields the voltage drop at the non-inverting node to be

U Rg

R2 R7U2 (8.53)

Due to the fact that there is no current going through the input side thevoltage at node N1 is the same as the voltage at node N2. This yields thecurrent through Rf to be the same as the current through R1

I6 U1 URf

(8.54)

This yields the voltage at the out port Nout to be

Uout Rf R1

Rg R2

Rg

R1U2 Rf

R1U1 (8.55)

88

Page 89: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

In the case whereRf

R1 Rg

R2equation 8.55 simplifies to

Uout Rf

R1pU2 U1q (8.56)

8.9.2. Time scale

The op-amp dose not due to instantaneous transitions, depend on previoustime-steps. This means that the time-step is determined by the rest of thecircuit. To resolve the oscillating voltage the time-step needs according to theNyquist-Shannon-theorem to be more than 2 samples per period. In the resultsection 10 samples per period is used.

89

Page 90: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.10. The non-Inverting amplifier

8.10.1. Circuit

The op-amp can be used to create an non-inverting amplifier by coupling thecircuit in figure 8.15

NNout

Rf If

Rout

IO

Rg

Ig

I0R0U0

IccUccIccUcc

Figure 8.15.: Operational amplifier coupled as none invertin amplifire with pa-rameters given in section 14.10

This circuit shows that, similar to the diodes the op-amp can be simulatedusing by using complementarity conditions

For an inverting amplifier the out voltage

Uout gU0 (8.57)

where g 1 Rf

Rg, holds when Uout P rUcc, Uccs

Equation 8.57 can be derived by using that the KCL for the node N is

Iin Ig If (8.58)

where Iin is the current between the op-amps plus and minus ports. Note thatRout " R where R is the rest of the resistances in the circuit. This means thatthere will not go any current through it.

For an op-amp holds that the out voltage is

Uout ApU Uq (8.59)

90

Page 91: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

where A is the amplification in the op-amp.

Assuming the source resistance R0 ! Rin where Rin is the input impedanceof the op-amp, the voltage at node N is given by

U U0 Uout

A(8.60)

The current through Rg and Rf is given by

Rg URg

(8.61)

Rf U Uout

Rf

(8.62)

Inserting equation 8.60 ,8.61 and 8.62 into 8.58 and reordering yields

Uout

1

ARin 1

ARg

1

ARf

1

Rg

U0

1

Rg

1

Rf

(8.63)

If A " Rf then 8.67 simplifies to

Uout 1 Rf

Rg

U0 (8.64)

which is the same as in equation 8.57

An op-amp can’t supply more voltage to the out port the given by the rampvoltages. The effect can be seen by the following. Assume the out voltage isset to a fix value Uout. From equation 8.60 the current between U and Ubecomes

Iin Uout

RinAR7(8.65)

inserted into equation 8.67 yields

Iin

1 Rin

Rg Rin

Rf

ARin

Rg

U0

1

Rg 1

Rf

(8.66)

Noting that 1 ! Rin and reordering yields

Iin U0

1 Rf

Rg

Uout

Rin

1 Rf

Rg

(8.67)

If Rin is not infinite and Uout is fixed the current Iin 0 A. This in turn yields

91

Page 92: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

a voltage drop over the op-amps in ports U U 0.

8.10.2. Time scale

The op-amp is due to instantaneous transitions not depending on previoustime-steps. This means that the op-amp can use the same time-step as the restof the circuit. To resolve the oscillating voltage the time-step needs accordingto the Nyquist-Shannon-theorem to be more than 2 samples per period. In theresult section 10 samples per period is used.

92

Page 93: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.11. The electric motor start up

8.11.1. Circuit

The Circuit in figure 8.16 shows a motor connected to a voltage source.

U0

R0

I0

M1

I1

Figure 8.16.: Motor circuit with parameters as given in section 14.11

This circuit is simulated in order to show the initial ramp up of the motormodel

The current through the motor is according to (Wildi, 2006, page 97) givenby

I1 U0 U1

R(8.68)

where I1 is the current through the motor, R is the resistance in the motor andU1 is the induced voltage from the rotor moving in a magnetic field. When themotor starts the rotor velocity is ω 0 rad

s . This yields U1 0 V and a startcurrent of

I1 U0

R(8.69)

The current creates a toque according to equation 7.54. which in turn makesthe rotor turn as given by

τ I 9ω (8.70)

. When the rotor rotates with velocity ω it generates a back-emf given byequation 7.55. When the motor rotates fast enough the back-emf will cancelthe input voltage U0 and the motor-speed will stop to increase.

Combining equation 8.69, 7.54,8.70 and 7.55 yields a differential equation on

93

Page 94: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

the form

dt a bω (8.71)

where a KU0

IRand b K2

IR. Solving equation 8.71 yields

ω U0

K

1 exp

K2

IRt

(8.72)

where t is the time.

In the case of a non-idea motor the torque constant is dependent on theangle of the rotor, K KpΘq where ω dΘ

dt. This still yields an exponential

decreasing current and increasing speed but with small oscillations given byequation .

8.11.2. Time scale

In the ideal case with a constant DC supply It is sufficient for the time-stepto be small enough to resolve the ramp up. The motors maximum speed isachieved when

ωmax limtÑ8 U0

K

1 exp

K2

IRt

U0

K(8.73)

the motor has achieved c % of ωmax after time

tc IR log p1 cqK2

(8.74)

In correspondence to a capacitor in a RC-circuit that has loaded 63 % of itsmaximum voltage after RC s the motor has reach 63 % after

t63 % IR

K2(8.75)

The time-step needs to be small enough to resolve t63 % i.e. 10 times smaller.

A non-ideal motor has toque constant that depends on the angle of the rotor,due to the fact that the amount of flux cutting the coils is depending on theangle of the rotation. This thesis uses the same model as in (Wildi, 2006, age74) where KpΘq is a sum absolute values of phase shifted sin waves

1

e

N1

i0

sinωΘk 2π

Ni

(8.76)

94

Page 95: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

where N is the number of coils in the motor and e is a constant. The frequencyof the oscillation is N higher than the rotation speed ω. The time-step mustbe able to resolve this i.e. 10 times smaller. This yields the time-step in thenon-ideal case to be

∆t 1

10min

1

Nωmax, t63 %

(8.77)

where ωmax is the maximum rotation speed.

95

Page 96: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

8.12. The hydraulic piston with dry friction

8.12.1. Circuit

The circuit in figure 8.17

s4

p5

m6

f5

f6f2

P2

d2 f3

d3

r3

f4

d4U0

R0

I0

M1

I1

Figure 8.17.: Shows a electric circuit driving a hydraulic circuit that in turnmoves a mass where parameters are given as in section 14.12

is simulated in order to show that it is possible to couple the electrical,mechanical and hydraulic components in the same solver.

The voltage source yields a current that makes the motor rotate. The motoris coupled to the pump that in turn creates a flow as it ramps up. The flow isthen directed to the piston that displaces the mass. The mass is subjected toa dry friction force. If the force supplied by the piston is to low, the frictionforce will hold the mass in place. The mass will only move if the force appliedby the piston is larger than the maximum friction force. The displacement ofthe piston is bounded by the size of the cylinder, i.e. the piston will stop if ithits the cylinder wall. When that happen the pressure from the pump buildsup until the relief valve opens and limit the pressure. If the relief valve wouldnot exist the increased pressure would stall the pump and no more liquid wouldflow.

The circuit in figure 8.17 can be seen as a motor that is slowed down by thehydraulic part of the circuit. Assume that the force produces by the pump islarger than the force necessary to overcome the dry friction. If this is not thecase the relief valve will open and the motor will work as in section 8.11.1.

96

Page 97: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

The ramp up for a motor without the pump is given by equation 8.71, butis now also slowed down by the torque from the hydraulic part given by

τ DMP (8.78)

where P is the pressure drop over the pump. The equation of motion is thengiven by

dt a bω DMP (8.79)

where a KU0

IR, b K2

IRand ω is the angular velocity of the motor.

The flow from a pump is given in (Akers et al., 2006, 38)

f DMω (8.80)

and the displacement of the mass is related to the flow through the piston as

AV x (8.81)

where A is the cross section area of the piston and x is the position of the mass.Moving the flow in the cylinder creates a pressure drop giving by

P1 ρl

A9f (8.82)

Substituting x from equation 8.81 in newtons second law yields pressure dropdue to the mass motion to be

P2 m

A29f (8.83)

The total pressure drop over the piston is the pressure that acts on the motorand is given by

P P1 P2 (8.84)

Noting that if the relief valve is blocking the flow through the pump is the sameas the flow through the piston. Then substituting equation 8.84 and 8.80 inequation 8.79 yields 9f DMa f

b

c(8.85)

where c 1 D2

M

ImA2 D2

M

IρlA

97

Page 98: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Solving equation 8.85 yields

f e expb

ct

DMa

c(8.86)

8.12.2. Time scale

By the same arguments as in section 8.11.2 the time for the flow to have reach63 % of its maximum value is given by

t63 % c

b(8.87)

Note that if there where no piston or pump, the time-step is the same as insection 8.11.2. When the piston exist c ¡ b the mass slows down the ramp upof the motor.

98

Page 99: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Part II.

Method

99

Page 100: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

9. Implementation

9.1. Breadboard

The most common way to to describe a system is to use a netlist. A netlistdescribes the connection between components in the circuit. The type, param-eters and the nodes the component is connected to may be given for each thecomponents. A netlist for the circuit in figure 9.1

R1

I1

R2 I2

R3

I3

Figure 9.1.: Shows the piecewise linear diode circuit

can be written as in table 9.2

Component type node node resistance

R 1 2 R1

R 2 3 R2

R 3 1 R3

Ground 3

Figure 9.2.: Shows an example of a netlist with two resistors couple to twonodes

One drawback of using a netlist is that the netlist is constructed to describethe circuit with with the minimum number of nodes possible. In the case wherethe user wish to add a component in between the already existing componentsrequires the nodes after the added components to be reordered. 5Spice createa netlist after the user graphically provided a schematic of the circuit.

100

Page 101: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

This thesis uses instead a breadboard model to define circuits see figure 9.3.This is more intuitive as it corresponds to the physical realization of circuits.

Figure 9.3.: Showing a breadboard where the each node is has several connectedports represented by lines

the vertical ports are usually used for connecting components while the hor-izontal is usually used for connection power supply. The breadboard is thenparsed by the algorithm to find the netlist describing the circuit.

The breadboard structure is implemented using a matrix of size 2N 5M

where N is the number of horizontal ports in a node and M is the number ofhorizontal nodes. Connecting a component to the breadboard is done in thesame way as on a real breadboard. Each port on a component is coupled to aport on the breadboard. Ports on the same line are seen as connected to thesame node. Due to the fact that the netlist is build automatically, the userdon’t need to reorder the port when adding a new component.

9.1.1. Example

The three resistors from figure 7.1 can be coupled on the breadboard structureas in figure 9.4.

After the breadboard has been coupled as in figure 9.4 a parsing algorithmbegins by going through the whole breadboard, storing the components in alist. It then makes a second run where it set all ports on the same columnto belong to the same node see figure 9.5 and store the connections for eachcomponent

Note that the last node on the breadboard has no component and will beremoved. This results in a netlist with the connection data given by 9.2. Usingthe netlist it is then possible to create the solution matrix in equation 5.18

101

Page 102: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

R1 I1

R2 I2

R3I3

Figure 9.4.: Show an example of components coupled on a simplified version offigure 9.3 with only vertical nodes

102

Page 103: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

R1 I1

R2 I2

R3I3

Figure 9.5.: Shows an example of how the nodes are decided

103

Page 104: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

9.2. Circuit split

One problem with with viewing diode as a complementarity condition is illus-trated in figure 8.10. In this mode the diode bridge has been split into twocircuits, one consisting of the battery and tho other consisting of load andcapacitor. The left circuit has a ground set from the start but not the rightcircuit. In reality the circuits are never split as the diode instead has a veryhigh resistance. In 5spice this is simulated by adding a large resistor parallel tothe diodes in the circuit. When the diode blocks the circuits are still connectedby a large resistance. This means that the circuit is never cut and an artificialground is not necessary. The drawback with a parallel resistor is that the allowleakage current from the diodes becomes larger than the reverse bias current.In addition, an artificial large resistor can produce ill-conditioning in the linearsystems of equations.

As seen in section 8 a circuit can be seen as a 2D graph Gpn, Iq with ver-tices’s given by the nodes connecting components and the edges by the currentsI through the components. The splitting of the circuit into sub circuits Sb oc-curs for graphs consisting of several sub-graphs see figure 9.6, connected bycomponents subjected to complementarity conditions.

Z1 Z2 Z3

Z4

Z5 Z6 Z7

Figure 9.6.: Shows several general sub circuits with impedance matrix Zi, con-nected with components, shown as diode subjected to complemen-tarity conditions

Note that all sub-graphs in figure 9.6 has connection to the ground node, i.e.all sub circuits is subjected to a reference potential ensuring that the systemhas a unique solution. Without a reference potential the circuit would haveinfinitely many solutions.

104

Page 105: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Assumes that the complementarity conditions inactivates the componentsconnecting the sub circuit see figure 9.7.

Z1 Z2 Z3

Z4

Z5 Z6 Z7

Figure 9.7.: Shows several general sub circuits with impedance matrix Zi, con-nected with inactive components subjected to complementarityconditions

In this case only the two circuits to the left has connection to a referencepotential and has unique solutions but the other sub circuits misses this con-nection and has an infinite number of solutions, one for each possible referencepotential. The problem comes from that complementarity conditions cuts thecircuit’s, while in reality the circuits would still be connected with a very largeresistance(larger then in Spice).

The algorithm presented in this thesis address the lack of reference poten-tials by noting that although the absolute values of the potential in the splitsub circuits is undetermined, the relative potential difference between the nodesin the sub circuits are not. The relative potential difference in a sub circuit isonly dependent on the components in that sub circuit. By setting the referencepotential to a specific value in each sub circuit through the introduction of ar-tificial ground nodes see figure 9.8, the full circuit will have a unique solution.Note that this solution is not the same as if the sub circuits would be connectedby large resistances as the reference potentials has been set to 0.

In order to solve the fully connected circuit, the algorithm applies a postprocessing stage where the diodes are assumed to be infinitely large resistorssee figure 9.9. The sub circuits potentials are the risen according to what theyshould have had if the diodes were infinitely large resistors. Since this is a postprocessing stage, it does not introduce ill-conditioning.

The reference potentials can only be determined after the relative potential

105

Page 106: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Z1 Z2 Z3

Z4

Z5 Z6 Z7

Figure 9.8.: Shows several general sub circuits with impedance matrix Zi con-nected to artificial ground nodes

difference in each sub circuits has been determined. Bellow is a derivationof the reference potential in between two sub circuits given that one of thesub circuits has a known reference potential. After the unknown potential hasbeen corrected this sub circuit can be used to calculate the reference potentialof other sub circuits connected to it.

106

Page 107: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Z1 Z2 Z3

Z4

Z5 Z6 Z7

R ÝÑ8 R ÝÑ8

R ÝÑ8 R ÝÑ8R ÝÑ8

Figure 9.9.: Shows several general sub circuits with impedance matrix Zi con-nected with infinitely large resistors

107

Page 108: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

9.2.1. Artificial ground potential

With the assumption that the diodes are infinitely large resistors, a connectionbetween two split circuits can be seen as one or several parallel coupled infinitylarge resistors. A generalized picture of the connection between two sub circuitscan be seen in figure 9.10

U12

ι12

U02

ι23

U45

ι45

R14 ι14

R25 ι25

R35

ι35

Figure 9.10.: Shows the connection between two subcircuits with thee repectivetwo nodes. Only the effect of the potential from the sucircuit iscomnsiterd as the current is assumd to be 0 A and the resistancein the subcircuits neglateble.

The figure shows the connection between two sub circuits, one on the leftand one on the right. The left circuit has three nodes(node 1,2,3) connectingit to the right sides two nodes(node 4,5). The two circuits are connected withthree blocking diodes,replaced with resistor.

Using the fact that any circuit can be seen as a black box, the Thevenin equivalentcircuit connected to the rest of the circuit with an impedance and voltage dif-ferences. This is shown as a voltage source in figure 9.10 as the sub circuitresistance is mush less than the diode resistances.

The goal is to calculate what voltage at specific node on the right-hand side,given that relative voltages between the nodes in each sub circuits are knownand that the left sub circuit already has the correct voltage levels.

One way of systematically do this is to use superposition of voltage sources,i.e. solving the system for a limited number of voltage sources at a time. Thealgorithm sees each voltage source between to nodes as a sum ofN1b voltagesources where N is the number of connecting diodes between the circuits andb is the number of pairs between this pair and the ground-node. Figure 9.10would then become as in figure 9.11

The algorithm then decides for which node in the left circuit that that isground node l and which node in the right circuit that is the additional ground

108

Page 109: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

U12,1

U12,2

ι12

U23,1

ι23

U45,1

U45,2

ι45

R14 ι14

R25 ι25

R35

ι35

Figure 9.11.: Shows how the algoritm splitts the voltagesources into smallerparts

node m connected to the real ground node. Because all diodes have the samehigh resistance, all pair of nodes are equally viable as long as they are connectedand in different sub circuits.

The next step is to go through all diodes and look at the nodes between thisdiodes nodes(k,n) and node 1 and m. For each pair connected, one the left oron the right side, i.e. 1,4 in figure 9.11, the algorithm takes a sub voltage sourceU12,1 and computes the voltage at m by seeing the circuit as parallel coupledresistors. The voltage contribution from voltage source Uij,x to the voltage atnode m becomes

Umij,x 1

N bUij,x (9.1)

where Uij,x is one of the sub voltage sources in a pair and Umij,xis the part of

the voltage at node m contributed from pair x The algorithms traverses throughall connected pairs between node l, k and pair k,m and sums the contributionfrom each one of the voltage sources as given in equation 9.1 to the total voltageat node m

Umd ¸

pairs

Umij,x(9.2)

where Umdis the voltage-contribution from the voltage-sources associated with

each diode. The summation in equation 9.2 can be simplified to be

Umd 1

NUkl 1

NUnm (9.3)

where 1NUkl takes into account the voltage-contribution from the left circuit

and 1NUnm the right circuit. When all diodes has been gone through, all sub

109

Page 110: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

parts of the voltage sources has been accounted for and the voltage level ofnode Um been estimated.

With the correct voltage at node m. The right sub circuit can either havethe voltage increased to match the voltage Um plus the left circuits referencevoltage U1. The reference voltage is can be different from zero if a groundpotential was not chosen as reference potential.

110

Page 111: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

9.2.2. Algorithm

In order to ensure that Sx b where S is on the form

S Z AT CT

A 0 DT

C D 0

(9.4)

x is a vector containing flow variables and effort constraints and b is a vectorhas a solution the following algorithm is used to estimate x

Algorithm 1

Require: S on the form in equation9.4Ensure: Sx b

Find all sub circuits SbFind all connections Cn between Sb

for Sb without ground do

Add a artificial ground to Sb with 0 potentialend for

Solve system Sx b with temporary ground nodesfor all Sb do

Correct temporary potential values according to equation 9.3end for

Note that this algorithm was developed to handle a specific type of positivesemi definite matrix and the main idea can be applied in other solvers then theblock pivot algorithm.

111

Page 112: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Part III.

Results

112

Page 113: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10. Test runs

In this chapter the the results from simulations of different coupled electrical,hydraulic and mechanical systems. For validation, the same circuits were sim-ulated with 5Spice, which is a widely used software, and Hopsan which is anacademic code, but considered as a reference.

For details about the operation of the circuits see chapter 8.As seen in the theory chapter 8. The timescale of the circuits is only de-

pending on natural constants in the models, f , RC, Is and similar.All test runs done by the non-smooth LCP sovler begins at an initial guessed

value. This is especially prominent for the serial circuit where the non-smooth LCP sovlerfirst start at a initial guess and then quickly reaches the correct current andvoltage.

113

Page 114: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.1. Serial circuit

The simulated current and power result form the circuit in figure 8.3 withparameters from table 14.1 can be found in figure 10.1

0

2

0 5 10

Current[A

]

Timet

τ

Circuit current, ∆t τ

1, τ 1 s

I05Spice: I0

-6e-16

0

0 5 10

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

1, τ 1 s

Power

Figure 10.1.: Shows the current through the battery in from the simulation andfrom 5spice

and the voltage drop in the circuit can be seen in figure 10.2The smallest time-step uses by 5Spice was ∆t 2103 s.

114

Page 115: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

10

0 5 10

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

1, τ 1 s

U0

U1

U2

5Spice: U0

5Spice: U1

5Spice: U2

Figure 10.2.: Shows the voltage drop over the battery and resistors from thesimulation and 5spice

115

Page 116: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.2. Parallel circuit

The current through the circuit in figure 8.4 and the power in the circuit canbe seen in figure with parameters from table 14.2 is in figure 10.3

0

2

0 5 10

Current[A

]

Timet

τ

Circuit current, ∆t τ

1, τ 1 s

I0I1I2

5Spice: I05Spice: I2

Figure 10.3.: Shows the current through the battery in from the simulation andfrom 5spice

The voltage over the components are shown in figure 10.5The smallest time-step uses by 5Spice was ∆t 2103 s

116

Page 117: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

1

0 5 10

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

1, τ 1 s

Power

Figure 10.4.: Shows the current through the battery in from the simulation andfrom 5spice

0

10

0 5 10

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

1, τ 1 s

U1

U2

5Spice: U0

Figure 10.5.: Shows the voltage drop over the battery from the simulation and5spice

117

Page 118: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.3. RLC circuit

The currents through the components in figure 8.5 with parameters from table14.3 is given by figure 10.8

0

3

0 35 70

Current[A

]

Timet

τ

Circuit current, ∆t τ

10, τ 0.0003 s

I0I2

5Spice: I0

0

4e-15

0 35 70

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

10, τ 0.0003 s

Power

Figure 10.6.: Shows the current through the resistor in from the simulation andfrom 5spice

The voltage drop in the circuit can be seen in figure 10.7The smallest time-step uses by 5Spice was ∆t 3108 s.An example on L-stability can be seen in figure where the simulation in

figure 10.8 has been run with to large time-step over a longer time. Note thatthe time-step is longer then the time scale in the circuit and the solution isexpected to fail, but that the fast oscillation damps and don’t blow to inifinitywhile the slover oscillation is still bounded.

118

Page 119: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

10

0 35 70

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

10, τ 0.0003 s

U0

U2

5Spice: U0

5Spice: U2

Figure 10.7.: Shows the voltage drop over the battery and resistors from thesimulation and 5spice

0

0 250 500

Current[A

]

Timet

τ

Circuit current, ∆t τ

0.25, τ 0.0003 s

I0I2

0

0 250 500

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

0.25, τ 0.0003 s

Power

Figure 10.8.: Shows the current through the resistor when the solver is run withto large time-step

119

Page 120: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.4. Single diode

The current though the ideal diode and resistor in figure 8.6 with parametersfrom table 14.4 can be seen in figure 10.9

0

0.01

0 2.5 5

Current[A

]

Timet

τ

Circuit current, ∆t τ

10, τ 0.4 s

I1I2

5Spice: I25Spice: I1

0

3e-17

0 2.5 5

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

10, τ 0.4 s

Power

Figure 10.9.: Shows the current throught the diode and resistor in from thesimulation and from 5spice

The voltage drop in the circuit can be seen in figure 10.11The IV curve for the diode is in figure 10.7The smallest time-step uses by 5Spice was ∆t 4.4104 s.

120

Page 121: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

-10

0

0 2.5 5

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

10, τ 0.4 s

U1

U2

5Spice: U0

Figure 10.10.: Shows the voltage drop over the battery and resistors from thesimulation and 5spice

0

0.01

-10 0

Current[A

]

Voltage [V]

Component IV curve, ∆t τ

10, τ 0.4 s

I2

Figure 10.11.: Shows the voltage drop over the battery and resistors from thesimulation and 5spice

121

Page 122: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.5. The diode bridge

The voltage drop over the diode bridge using ideal diode is in figure 10.12 withparameters from table 14.5 is in figure 10.12

0

0 120 250

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

10, τ 0.0001 s

U0

U1

U6

5S: U0

5S: U1

5S: U6

Figure 10.12.: Shows the voltage drop over the battery and output resistor fromthe simulation and 5spice

The smallest time-step uses by 5Spice was ∆t 5106 s.

122

Page 123: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.6. The transformer

This section contains the result from two different simulations of the circuit insection 8.6.1.

10.6.1. High impedance

The transformer from figure 8.11 with parameters from table 14.6. The currentand power though the circuit is given in figure 10.13

0

0.06

0 2.5 5

Current[A

]

Timet

τ

Circuit current, ∆t τ

10, τ 0.5 s

I0I2

5Spice: I05Spice: I2

-4e-17

0

0 2.5 5

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

10, τ 0.5 s

Power

Figure 10.13.: Shows the current through the battery and resistor from thesimulation and 5Spice

The voltage over the components are shown in figure 10.14The smallest time-step uses by 5Spice was ∆t 4106 s.

123

Page 124: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

10

0 2.5 5

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

10, τ 0.5 s

U0

U2

5Spice: U0

5Spice: U2

Figure 10.14.: Shows the voltage drop over the battery and resistor from thesimulation and 5spice

124

Page 125: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.6.2. Low impedance

Constrains the same simulation as in section 10.6.1 but with smaller primaryand secondary impedance’s given in table 14.7.The current and power thoughthe battery and resistor is in figure 10.15

0

0.2

0 2.5 5

Current[A

]

Timet

τ

Circuit current, ∆t τ

10, τ 0.5 s

I0I2

5Spice: I05Spice: I2

0

1

0 2.5 5

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

10, τ 0.5 s

Power

Figure 10.15.: Shows the current through the battery and resistor from thesimulation and 5Spice

the voltage drop in the circuit can be seen in figure 10.16The smallest time-step uses by 5Spice was ∆t 6106 s.

125

Page 126: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

15

0 2.5 5

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

10, τ 0.5 s

U0

U2

5Spice: U0

5Spice: U2

Figure 10.16.: Shows the voltage drop over the battery and resistor from thesimulation and 5spice

126

Page 127: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.7. The common emitter amplifier with BTJ

The current trough the base and collector from the circuit in figure 8.7 withparameters from table 14.8 using ideal diodes is in figure 10.17

0

0.001

0 2.5 5

Current[A

]

Timet

τ

Circuit current, ∆t τ

10, τ 0.0002 s

I0IB

5Spice: IB5Spice: IC

0

1e-17

0 2.5 5

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

10, τ 0.0002 s

Power

Figure 10.17.: Shows the current through the battery and resistor from thesimulation and 5Spice

The input UB and output voltage UC is in figure 10.18The smallest time-step uses by 5Spice was ∆t 5109 s.

127

Page 128: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

10

0 2.5 5

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

10, τ 0.0002 s

UB

UC

5Spice: UB

5Spice: UC

Figure 10.18.: Shows the voltage drop over UB and UC from the simulation and5spice

128

Page 129: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.8. The flip-flop

To show the three modes in the flip-flop from figure 8.13 with parameters fromtable 14.9 the circuit is simulated using ideal BTJ transistors. The mode ischanged by giving voltage pulses at U7 and U8. The voltage drop over the inand out signals is in figure 10.19

0

6

0 60 120

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

1, τ 1e 05 s

U1

U4

U8

U7

5Spice: U1

5Spice: U4

Figure 10.19.: Shows the voltage at the input voltage sources and output resis-tors from the simulation and 5spice

The smallest time-step uses by 5Spice was ∆t 61011 s.

129

Page 130: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.9. The differential amplifier

The amplification of the voltage difference between U1 and U2 in figure 8.14with parameters from table 14.10 can be seen in figure 10.20

0

15

0 2.5 5

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

15, τ 1 s

U1

U2

Uout

5Spice: Uout

5Spice: U2

5Spice: U1

Figure 10.20.: Shows the voltage drop over the outsources and the outimpedance from the simulation and 5spice

The smallest time-step uses by 5Spice was ∆t 2105 s

130

Page 131: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.10. The non-Inverting amplifier

This section contains the result from the simulation of the non-inverting oper-ational amplifier in figure 8.15 with parameters from table 14.11. The currentthought the voltage source and the large out impedance can be seen in figure10.21

0

1e-05

0 2.5 5

Current[A

]

Timet

τ

Circuit current, ∆t τ

10, τ 1 s

I0IO

-2e-06

0

0 2.5 5

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

10, τ 1 s

Power

Figure 10.21.: Shows the current through the voltage source and outputimpedance from the simulation and 5Spice

The input and output voltage for the simulation is shown in figure 10.22The smallest time-step uses by 5Spice was ∆t 5105 s.

131

Page 132: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

10

0 2.5 5

Voltage[V

]

Timet

τ

Circuit voltage, ∆t τ

10, τ 1 s

U0

Uout

5Spice: U0

5Spice: Uout

Figure 10.22.: Shows the voltage drop over the voltage source and the outimpedance from the simulation and 5spice

132

Page 133: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.11. The electric motor start up

This section contains two different simulations of the circuit in section 8.11.The first is the ideal motors speed ramping up given a constant voltage. Thesecond simulation is with the same parameters but with a non-ideal motor.

10.11.1. The ideal electric Motor

The ramp up of the rotation speed from the circuit in figure 8.16 with param-eters from table 14.11 and an ideal motor is seen in figure 10.25

0

50

0 12 25

AngularVelocity

srad t

Time

s tτ

Motor Speed, ∆t τ

10, τ 0.02 s

I1H: ω1

Figure 10.23.: Shows the rotors angular velocity from the simulation and Hop-san

The motor current is given in figure 10.26Time-step used in Hopsan is ∆t 1104 s.

133

Page 134: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

0.006

0 12 25

Current[A

]

Timet

τ

Circuit current, ∆t τ

10, τ 0.02 s

I0H: I0

0

1e-17

0 12 25

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

10, τ 0.02 s

Power

Figure 10.24.: Shows the rotors angular velocity from the simulation and Hop-san

134

Page 135: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.11.2. The non-ideal electric Motor

The ramp up of the motor speed in the non-ideal case of the circuit in figure8.16 with parameters from table 14.13 is in figure 10.25

0

50

0 120 250

AngularVelocity

[rad/s]

Time [s]

Motor Speed, ∆t τ

10, τ 0.002 s

I1H: ω1

Figure 10.25.: Shows the rotors angular velocity from the simulation and Hop-san

The motor current is given in figure 10.26Time-step used in Hopsan is ∆t 1104 s.

135

Page 136: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

0.01

0 120 250

Current[A

]

Timet

τ

Circuit current, ∆t τ

10, τ 0.002 s

I0H: I1

0

0.002

0 120 250

Pow

er[W

]

Timet

τ

Total power in circuit, ∆t τ

10, τ 0.002 s

Power

Figure 10.26.: Shows the rotors angular velocity from the simulation and Hop-san

136

Page 137: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

10.12. The hydraulic piston with dry friction

This section shows a simulation of the circuit in figure 8.17 with parametersfrom table 14.14. The velocity of the motor as a function of time can be seenin figure 10.27

00 170 350

AngularVelocity

[rad/s]

Time [s]

Motor Speed, ∆t τ

10, τ 0.008 s

f2Hopsan: f2

0

0 170 350

Pow

er[W

]

Time [s]

Total power in circuit, ∆t τ

10, τ 0.008 s

Power

Figure 10.27.: Shows the pumps angular velocity from the simulation and Hop-san

The flow from the pump displaces the mass M5 position as in figure 10.28The pressure drop over the pump is seen in figure 10.29Time-step used in Hopsan is ∆t 1104 s.

137

Page 138: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

0

0 170 350

Position[m

]

Timet

τ

Position of component, ∆t τ

10, τ 0.008 s

x6

Hopsan: x6

Figure 10.28.: Shows the displacement of the mass from the simulation andHopsan

0

0 170 350

Pressure

[Pa]

Time [s]

Circuit voltage, ∆t τ

10, τ 0.008 s

P2

Hopsan: P2

Figure 10.29.: Shows the pressure drop over Pump from the simulation andHopsan

138

Page 139: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11. Discussion

This section contains discussions of the different component models and com-parison to other models as well as a comparison to 5Spice and Hopsan.

11.1. Solvability

In order to ensure that a system is solvable a component with N currents addedto the circuit can’t add more than N nodes, efforts constraints to the circuit.I.e. when a two port device with one current is added in serial with a circuitcontaining a ground node, one of the two ports are the same as a node in theoriginal circuit this leaves maximum one port to be added to the system.

In the case of a multi port device, i.e. the transformer adds two currents whilehaving four ports. If only one port where connected to ground this would addthree ports to the circuit and A would not have full row rank. The transformerconsist of two separated circuit’s joint by the mass matrix and each circuitrequires it’s own ground node. This means that while the transformer onlyadds two currents it also only adds two ports.

Flow constraints are not the only constraints in that can be applied to thecircuit. Effort constraint’s can be applied to the flow constraint’s. As long asa added constraint don’t reduce the rank it is allowed. A constraint on an flowconstraint can be added to equation 8.2 on the formZ AT CT

A 0 DT

C D 0

Ik1

U

I1,k1

USource

ISourceU1

(11.1)

where I1,k1 is the constraint force on the effort variable . If D is the zeromatrix, then the constraint could be linearly dependent on the nodal constraintand the solution matrix not guarantied to have full row rank. In the case whereC is the zero matrix it would be possible to couple two components with thesame nodal constraint’s parallel to each other and creating a short circuit. Bothcomponents would impose different voltage difference between two nodes thathave collapsed to one.

Note that the KCL is a linear constraint and can be solved exactly for each

139

Page 140: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

time-step. Due to construction has the impedance matrix Z and the jacobianA full rank. This means that the constraint’s don’t need regularization in orderto give the system full rank as well as stabilize the constraints.

11.2. Stability

The RLC circuit from figure 10.8 shows the expected correct behavior when thetime-step is in the same order as the time scale. But if the time-step is largethen the time scale as in figure 10.8 but smaller then the oscillations it canno longer resolve the fast oscillation. The reistor in series with the capacitordamps the signal and give L-stabillity. The present oscillation comes from thevoltage source. The capacitor is dicretizided with the midpoint-rule and isL-stabel if the is no damping in the form of a resistance.

This is because the non-smooth LCP sovler used in this thesis is build on theSpook solver described in (Lacoursiere, 2007, page 87-108). The Spook solver isA-stable without damping and L-stable with damping due to high frequenciesbeing filtered out.

The systems appear to be co-positive with BJT transistor, but we do nothave solvability proofs yet. However, there’s no evidence that nonlinear systemssolved by spice are well-behaved. The Newton Raphson method can fail see(Acary et al., 2011a, 218) when the linearisation leads to oscillations betweentwo incorrect stages.

140

Page 141: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.3. Computational complexity

The computational complexity depends on the solver used and how sparsethe solution matrix is, essentially the nodal matrix’s. If the filling is in theorder of OpN log pNqq where N is the number of equations the system canaccording to Gilbert and Tarjan (1987) be solved using nested dissection witha computational complexity of O

N1.5

. This is the case for large systems

consisting of components connected to a limited amount of nodes, i.e. twonodes for diodes. In case where a component would be allowed to connectto all nodes the matrix could become a dense matrix. If the system becomeslarger but the components still only connects to a subset of the nodes in thesystem the solution matrix becomes sparse.

The computational complexity of the solution is outside the scope of thisthesis but the reasoning below is done to give a hint that the complexity ofthe split circuit algorithm in section 9.2. The present implementation has acomputational complexity of O

N2, where N is the number of equations in

the solution matrix.

This is due to the fact that the maximum number of complementary currentsconnecting the sub circuits are Opnq where n is the number of currents in thesystem and the maximum number of sub circuits in the system is Opmq wherem is the number of nodes. If the number of subsystems are mb where b is aconstant, then the number of nodes in each sub circuit are b.

The first stage in the algorithm in section can be done with Opmq com-putational complexity using etree from the UMFPACK library. Finding theconnections can be done by going through all connections Opnq. Finding towhich subsystem each connection is coupled to can be done by going through allconnections all nodes in Opnmq computational complexity. Introducing Opmqartificial grounds to Opmq nodes can be done in O

m2. Solving the system

depends on the density but can for sparse matrix with fill OpN log pNqq can ac-cording to Gilbert and Tarjan (1987) be done with computational complexityON1.5

. Changing the potentials for Opmbq sub circuits requires the need to

go through all connection Opnq and all nodes in the sub circuit Opbq totallyOpnmq.

The maximum of the computational complexity is Om2+Opnmq. The

number of currents and the number of nodes are bounded by the number ofequations in the systems and therefor O

m2+Opnmq ¤ O

N2. If the com-

plementarity conditions adds OpNq to the computational complexity, the timefor solving the sparse system with complementarity condition is in the sameorder as solving a dense system without complementarity conditions.

It has not been investigated if it is possible to use an iterative solver instead

141

Page 142: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

of a direct solver.

142

Page 143: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.4. Circuit split

The split circuit algorithm explained in section 9.2 is a general method to han-dle all asymmetric components build by two port devices subjected to comple-mentarity conditions, i.e. diodes, BTJ transistors and op-amps. A componentconnected to more then two nodes has more then one current flowing throughit. In practices there is a current in between each pair of nodes and each currentis connected to two nodes.

143

Page 144: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.5. The diode

11.5.1. The ideal diode model

The simplest way to see a diodes is as a switch, i.e. the diode is a short circuitif the voltage drop over it is larger than the forward bias voltage and an opencircuit if the voltage drop is less than the revers bias. This yields an IV diagramas in figure 11.3.

Us

I

Us UQ

IQ

Is

Figure 11.1.: Shows the ideal diodes IV curve

This is equal to a linearly complementary conditionIs ¤ I K U ¥ Us (11.2)

where I is the current through the diode, Is is the bias current, U is the voltagedrop over the diode and Us is the forward bias voltage.

This means that if the current through the diode is less than Is the diodeequation is inactive and act as an open circuit. If on the other hand, the

144

Page 145: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

current through the diode is larger than the bias current the equation is activeand works as a negative voltage source with zero resistance.

If two diodes with different voltage drops is coupled parallel to each otherare active at the same time they will both impose different voltage differencesbetween two nodes. To see this consider the system of two parallel coupledvoltage sources with finite resistance see figure 11.2

I1 R1U1

I1R1U1

Figure 11.2.: Shows a diode coupled to a general circuit

The system of equation to solve in the non-smooth LCP sovler becomesR1 0 10 R2 11 1 0

I1,k1

I2,k1

U

U1U2

0

(11.3)

where U is the voltage at non-ground node. Solving 11.3 yields

I1 U1 U2

R1 R2(11.4)

if the resistances goes to zero and the current to infinity in order to impose thevoltage differences until it is undefined when the resistance is zero. Note thatthis problem is arising from using idealized components.

145

Page 146: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.5.2. The Shockley diode

The problem with the ideal diode model is that the diode don’t have anyresistance. This can yield a rank deficient system and is unrealistic as realdiode has a finite small resistance. A good model for the IV relation in a diodeis given by the diode equation

I Is

exp

U

NUT

1

(11.5)

where UT is the thermal voltage and N is the emission coefficient. The IVcurve is shown in figure 11.3

Us

I

Us

Is

Figure 11.3.: Shows the diode equation’s IV curve

Note that equation 11.5 is non-linear and would, require an unnaturally smalltime-step to be resolve accurately.

146

Page 147: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.5.3. Piecewise linear model

In order to ensure that the system always is solvable as well as having naturallylarge time-steps the diodes in the thesis is simulated with a piecewise linearmodel as in (Rizzoni, 2000, page 357).

The diode is still treated as an open circuit when it is blocking. But whenit is not blocking it is seen as a resistor with finite constant resistance. Thisyields an IV curve as in figure 11.4

Us

I

Us UQ

IQ

Is

Figure 11.4.: Shows the piecewise linear diode circuit

This model is more accurate than the ideal model and has always full rank.It also has larger timescale than to resolve the non-ideal model. The exact IVrelation in figure 11.3 is not important in circuits where the diode is used asa switch, i.e. the diode bridge in section 10.5 and 8.5. In thesis the piecewisemodel in figure 11.4 is sufficient to resolve the dynamics of the circuit.

The algorithm described in section 9.2 is used in order to ensure that thesystem is solvable when the diode blocks.

147

Page 148: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.6. The transistor

In models where the transistor is used as a switch and the exact value of the re-sistance in unimportant the piecewise linear model in the non-smooth LCP sovleryields as can be seen in figure 10.18 the same amplification as in 5Spice. Thesmallest time-step needed in 5Spice is 1104 smaller than in the non-smooth LCP sovler.5Spcie also needs 1104 smaller time step to resolve the alternation in the flip-Flop, see figure 10.19.

11.7. The transformer

As can be seen in figure 10.14 and figure 10.16 the transformer amplies the sig-nal in the same way as expected from equation 8.44 and 5Spice. But the modelused in the non-smooth LCP sovler can handle the circuit with a time-stepthat is 1104 times larger than the smallest time-step 5Spice needs.

11.8. The operational amplifier

As can be seen from the test run in figure 10.20 the op-amp gives the expectedamplification from equation 8.53. The op-amp in 5Spice gives a little smalleramplification as there model contains several non-ideal behaviors that is notincluded in the op-amp in the thesis.

The op-amp in the test run in figure 10.22 shows correct behavior by havingthe amplification cutoff of if the amplification given by equation 8.57 is largerthan the ramp voltages.

The time-step used by the non-smooth LCP sovler is 1000 times larger thanthe time-step used by 5Spies.

11.9. The electric motor

The motor ramps up in figure 10.25 as expected by equation 8.73 to thespeed given by equation 8.73. The amplitude in the non-ideal part see fig-ure 10.25 is lower then the ideal due to that fact that the normalization factorin equation 7.62 is calculated with infinitely many brushes and not with fourbrushes as used in the simulation. The time-step in Hospan and the solvernon-smooth LCP sovler has the same order of magnitude.

148

Page 149: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.10. The hydraulic pump

With a constant applied voltage the pump in figure 10.27 ramps up like a motoras the motor part of constant c in equation 8.86. When the voltage later isincreased the pump ramps up again. After the piston hits the wall the reliefvalve opens at a little to high pressure that in turn slows down the motor.

11.11. The hydraulic pipe

There is no simulation of the pies behavior. Instead the pipe correspondentsto a RL circuit as the capacitance part is remove due to the fact that the bulkconstant is in the order of 1109 Pa. The bulk constant is large as the fluidcan’t compress very much, this yields a very small capacitance in the circuitand therefore a very fast load time. The time-step required to resolve the smallcompression would be much smaller than the time-step necessary to resolve themotion of the fluid and is therefore omitted. Also, the model doesn’t take intoaccount the effect of perturbation, or that of non-ideal flow.

11.12. The check valve

The check valve is directly corresponding to the diode and therefor stops theflow in one direction but let it trough in the other.

11.13. The relief valve

As can bee seen in figure 10.29 and 10.27 the relief valve opens when the pumpsis too weak to overcome the overcome the force from the dry friction model. Ifthe relief valve did not open the pump would stall. The same happens whenthe piston hits the wall.

Note that Hopsan can’t handle dry friction, instead the simulation in Hopsanhas a force equal to the force excerpted by the pump on the mass during thefirst 0.4 s. The relief valve in Hopsan open only partly and still slows the pumpdown.

As can be seen in figure 10.28 both Hopsan and the non-smooth LCP sovlermoves the mass in the same way. The relief valve is built in different waysin section 7.15 compared to Hopsan. In this thesis the relief valve is seen asa connection that opens when the pressure becomes too high, it don’t reducethe pressure over it. As can be seen after 1.6 s in figure 10.27 the pressurevalve opens but pump still feels the maximum pressure and slows down. The

149

Page 150: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

piston in Hopsan has an internal valve that redirects the flow with no pressuredrop when the piston hits the wall and the pressure on the motor is therefordifferent than in the this simulation.

11.14. The hydraulic piston

The simulation in section 10.12 consisting of a pump that ramps up to a lowspeed due to low supply voltage. Although the pump is supplying flow tothe piston, the mass has too high dry friction to be moved. This means thatthere is no flow going trough the piston, but it instead is diverted through therelief valve. After 0.4 s the speed of the pump is increased by increasing thesupply voltage, which in turn increase the flow in the circuit. An increasedsupply voltage, increase the current though the pumps motor and accordingto equation 7.54 also the stall toque. As the pump can handle more returnpressure from the circuit before it stops, the maximum allowed pressure in therelief valve is increased. The increased pressure exerts a stronger force thanbefore on the mass and it starts to move. When the piston then hits the wall ofthe cylinder the flow through it stops and goes again through the relief valve.

Both Hopsan and the solver non-smooth LCP sovler used the same time-stepand captures the over all dynamics of the circuit.

150

Page 151: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.15. Comparison to 5Spice

The Spice formulations dates back to the 70-ties and exist in both commercialand free open implementations. It’s widely used in electrical simulations.

The Spice simulator is a circuit simulate for DC and transient analysis. Thereare different implementation of the Spice mathematical model and algorithm,the one used for comparison in this thesis is 5Spice 1.67.0. 5Spice (5Spice,2012) is an user interface using the Spice simulator Winspice 5.00.2 (WinSpice,2012).

The main method used by 5Spice is the implicit trapezoidal method secondorder method. A general description of the time stepping method used isdescribed in (Tuma and Arpad Buermen, 2009, chapter 6). The circuits aredescribed by ODE’s consisting of KVL, KCL and the branch currents, i.e. theShockley equation for diodes. The system is then reduces using nodal analysisto a smaller denser matrix, this is unlike the non-smooth LCP sovler that solvea large sparse matrix. Spice then solves the non-linear equation iteratively foreach time-step. For most circuits the iterative solution converge to a solutionif the solver start close enough. In case where there exist multiple solutions orthe time-step is to long the solver is not guarantied to converge and the longerthe time-step is the longer it generally takes to reach the iterative solution. Itis not given in 5Spice how it determines the length of the time-step but it ispossible to do by observing if the number of iterations is larger then a curtainthreshold. The uses of non-linear components and iterative solvers requires5Spice to use small time-steps in case of fast changing derivatives as is thecase of the Shockley diode equation. The non-smooth LCP sovler has no suchproblems as the components are piece-wise linear and inequalities are simulatedwith complementarity conditions as well as solving the DAE system directly.

In order for the simulations in 5Spice to run as fast as possible 5Spice em-ploys adaptive step size control. During smooth regions the simulator useslarge time-steps while in non-smooth regions it uses small time-steps. Thenon-smooth time stepper in this thesis doesn’t have step size control but in-stead uses a fixed time-step as it is then possible to do real time simulations.Therefore The smallest time-step used by 5Spice is the time-step used for com-parison.

5Spice and the non-smooth LCP sovler in the thesis are both numericalsolvers. This means that the matrix that is in the end solved becomes rankdeficient if the difference between the components sizes are to large. In orderto ensure this the ratio between resistances in the circuit should never exceed1 1015 . A large difference will yield a very large condition number.

5Spice can handle non-linear components, it dose it by using different linear

151

Page 152: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

integration methods and nonlinear solvers. During comparison the trapezoidalintegration method is used. In excess to a linearized solver 5Spice uses differentperturbations to regularize the matrices.

5Spice handles the circuit split caused by diodes opening up branches be-tween sub circuits when they block differently than in the thesis. 5Spice avoidsthe problem by putting a finite sized resistor parallel to each diode and/ortransistor. This is unlike section 9.2 where the diode is seen as and infiniteresistors. The drawback of using 5Spice approach is that the current is largerthan it should be as some of the current passes through the resistor. This isespecially a problem when the diode blocks and the circuit has large differencesbetween the sizes of resistors. The parallel resistance can then not be put to amuch higher value the the resistances in the rest of the circuit due to numeri-cal limitations. This is unlike the modified non-smooth LCP sovler used in thisthesis that set the the current to the bias current when the diode is blockingas well as saying that the resistance is infinite and splitting the entire circuitsinto sub circuits, each of which is well-conditioned.

Pure voltage sources with no resistance causes problems for 5Spice and inour method. Without resistance the solver risk of not having full rank. 5Spicefixes this is by putting a resistor of 1103 Ω in series with the voltage source.The non-smooth LCP sovler handles this in the same way but allows for valuesadapted to the condition number of the solution matrix, instead of an arbitrar-ily chosen number. Physically this is needed to ensure that the current fromthe voltage don’t become infinite .

Unlike 5Spice that need to add large but finite resistors to ground at nodesthat are not connected, the thesis correspond the connection as an infiniteresistor. This means that 5Spice will have a small leakage current to ground,while the leakage current in the non-smooth LCP sovler will be zero.

The mathematical expression done in 5Spice is written on I f pUq form,while the expression used in this thesis are written on the inverse form U f1pIq.

Spice uses nodal analysis for that creates denser matrix then used in thenon-smooth LCP sovler. No comparison in complexity has been done betweenSpice and the non-smooth LCP sovler. According to (Acary et al., 2011a, chap7) the the Newton Raphson method can fail for system with a few stiff com-ponents, i.e. diodes while a non-smooth approach while the a non-smooth ap-proach succeed if the system has a unique solutions. The non-smooth don’tneed to converge each time-step which yields according to (Acary et al., 2011a,page 231) a faster and more robust simulation while maintaining the accuracy.

The use of noon-ideal models requiring Spice to use small time-steps in stiffregions as well as needing Spice to use iterative not stable solvers to solver the

152

Page 153: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

ODE’s iteratively.

153

Page 154: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.16. Comparison to Hopsan

Unlike 5Spice, Hopsan beta 0.5.4 is distributed by IEI at Lindkopings Uni-versity (university, 2012) and can simulate multi-domain, coupling betweenmechanic,electric and hydrological systems in real time using non-smooth for-mulations.

It dose it by employing transmission lines modeling(TLM). This means thatall components in the circuit is calculated separately using data from the pre-vious time-step and then coupled together with TML which are essentially stiffspring and dampers used to replace pure constraints. According to (Krus,2011) the use of distributed solvers makes it possible to parallelise the solverand solve the smaller systems in real time. (Krus, 2011) claims that the useof TML’s yields a stable solution although the use of iterative solvers can failand has low accuracy. In the test runs in section 10.11 and section 10.12 thetime-step in the LCP solver and Hopsan is of the same order of magnitude.

Using TLM requires having two types of components. AC type is a volumethat takes flow and pressure from the previous time-step and calculate wavevariables and characteristic impedance’s used by the Q-types. The Q-typesare components that limits the flow and takes in wave variables and charac-teristic impedance’s from the C-type previously time-step and calculate flowand pressure. Using non-smooth LCP sovler in this thesis there is no need tosplit the system using transmission lines and don’t need to work with previoustime-steps but can instead work with data from the present time-step usingan semi-implicit solver. This in turn means that only one type of componentsworking with effort and flow variables are needed.

The nodes are handled by introducing small capacitance that quickly loadsto the node voltage. This makes the nodes no longer ideal, with no chargebuildup as in the thesis.

154

Page 155: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

11.17. Proof of concept

To prove that it is possible to simulate multi-domain system using discretizedaugmented Lagrangian mechanics with complementary conditions, differentcomponents electrical, mechanical and hydraulic components has been imple-mented and controlled towards theoretical and numerical values from 5Spiceand Hopsan.

As can be seen in conclusion sections for each components the non-smoothLCP solver can be run with time-step proportional to the natural time scalefor the circuit. For the domains where the piecewise linear models holds,i.e. where the exact resistance of diodes or transistors are not important ,thenon-smooth LCP sovler yields the same dynamics as 5Spice but with a 1000times larger time-step. If more detailed model of the circuit is required, i.e.the knee in the diodes IV curve see figure 11.3, the naturaltime scale for thecircuit is decreased and the non-smooth LCP sovler would still use a time-stepproportional to the naturaltime scale.

Hopsan uses a time step that is in the same order of magnitude as thenon-smooth LCP sovler but needs special models designed to be stable whenoperating with transmission lines. The connection in the solver is done byusing the KCL constraint.

The block-pivot algorithm can be used to solve the system if modificationsas described in section 9.2 is used to handle the opening up of circuits whenthe diodes block.

It is possible to simulate the models using non-smooth LCP sovler where thedynamics that is needed to simulated dictates the size of the time-step, not thesolver.

155

Page 156: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

12. Conclusions

In this master thesis it has been shown that it is possible to use the discreteLagrange energy principle to simulated A-stable multi-domain systems con-sisting of piecewise linear components with time-steps only depending on thesystem time scale. This has been done by comparing result produced by animplementation of the modified block Pivot solver given in section to equiva-lent circuits simulated in 5Spice and Hopsan. The time-steps used has beenlarge while still achieving a stable solution. In general the time-step that canbe used by non-smooth LCP sovler is up to 1105 times larger then 5Spice andin the same order of magnitude as in Hopsan.

Fast transitions as seen in inequality circuits where diode are used as switches,can be handle as complementary conditions for the simple circuits simulatedin this thesis.

The solution matrix is a p0-matrix and always have at least one solution. Tohave one solution the components must fulfill table 6.3

156

Page 157: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

13. Future work

The scope of the present thesis is to prove that the concept for multi-domainsimulation works. It’s then possible to continue the work, creating new mod-els and implement in commercial tools, i.e. Algoryx multiphysics toolkit fromAlgoxy Simulations AB (2012). It would then be possible to simulate entireground vehicles and other machines using the same solver. The Spook solverin Algoryx multiphysics toolkit is not created to handle non-symmetric compo-nents like the op-amp and would need to be expanded to handle non-symmetricsystems.

Further investigation is needed to determine when piecewise models are suit-able, and when they are not.

157

Page 158: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Part IV.

References

158

Page 159: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Bibliography

5Spice. 5Spice, October 2012. URL http://www.5spice.com/.

Vincent Acary, Olivier Bonnefon, and Bernard Brogliato. Nonsmooth Modeling

and Simulation for Switched Circuits, volume 69 of Lecure notes in electrical

engineering. Springer-Verlag, 2011a.

Vincent Acary, Olivier Bonnefon, and Bernard Brogliato. Nonsmooth Mod-

eling and Simulation for Switched Circuits, volume 69 of Lecture Notes in

Electrical Engineering. Springer-Verlag, 2011b. ISBN 978-90-481-9680-7.

Arthur Akers, Max Gassman, and richard Smith. Hydraulic Power System

Analysis. CRC Press, Taylor & Francis group, 2006.

Algoxy Simulations AB. AgX Multiphysics Toolkit, October 2012. URLhttps://www.algoryx.se/agx.

John R. Gilbert and Robert Endre Tarjan. The analysis of a nested dissectionalgorithm. Numerische MathematikNumerische Mathematik, 50(4):377–404,1987.

Zoeb Husain, Zulkifly Abdullah, and Zainal Alimuddih. Basic Fluid Mechanics

And Hydraulic Machines. BS Publications, 2009.

Petter Krus. Robust modelling using bi-lateral delay lines for highspeed simulation of complex systems. In DINAME 2011: 14th Inter-

national Symposium on Dynamic Problems in Mechanics, 2011. URLhttp://urn.kb.se/resolve?urn=urn:nbn:se:liu:diva-67897.

Claude Lacoursiere. Ghosts and Machines: Regularized Variational Methods

for Interactive Simulations of Multibodies with Dry Frictional Contacts. PhDthesis, Dept. of Computing Science, Umea University, June 2007.

Richard A. Layton. Principles of Analytical System Dynamics. MechanicalEngineering Series. Springer-Verlag, 1998.

Modelica Association. Modelica Specification, version 3.3, November 2012.URL https://www.modelica.org/documents/ModelicaSpec33.pdf/view.

159

Page 160: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Sina Ober-Blobaum, Molei Tao, Mulin Cheng, Houman Owhadib, and Jer-rold E. Marsdenb. Variational integrators for electric circuits. Arxiv.org,(1130.1859v1), 2011.

Open Strax College. Torque on a currentloop: Motors and meters, October 2012. URLhttp://cnx.org/content/m42380/latest/?collection=col11406/latest.

T. Quarles, D. Pederson, R. Newton, A. S-Vincentelli, andChristopher Wayne. The Spice Page, November 2012. URLhttp://bwrc.eecs.berkeley.edu/classes/icbook/spice/.

Giorgio Rizzoni. Principles And Applications Of Electrical Engineering.Thomas Casso, 2000.

Tadej Tuma and Arpad Buermen. Circuit Simulation with SPICE OPUS.Birkhauser, 2009.

Linkoping university. Hopsan, oct 2012. URLhttp://www.iei.liu.se/flumes/system-simulation/hopsanng?l=en.

Theodore Wildi. Electrical Machines, Drives, and Power Systems. Charles E.Stewart, Jr., 2006.

WinSpice. WinSpice, October 2012. URL http://www.winspice.com/.

160

Page 161: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

Part V.

Appendix

161

Page 162: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14. Appendix A

Contains parameters for circuits in chapter 10

162

Page 163: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.1. Serial Circuit

Parameter Symbol ValueSolverTimescale τ 1 102 sTimestep ∆t τ

Electrical componentsVoltage Source U0 10 VVoltage Source Resistance R0 1103 ΩResistor 1 R1 1 ΩResistor 2 R2 3 ΩResistor 3 R3 1 Ω

Figure 14.1.: Parameters for simulation in section 10.1

163

Page 164: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.2. Parallel Circuit

Parameter Symbol ValueSolverTimescale τ 1 102 sTimestep ∆t τ

Electrical componentsVoltage Source U0 10 VVoltage Source Resistance R0 1103 ΩResistor 1 R1 10 ΩResistor 2 R2 10 Ω

Figure 14.2.: Parameters for simulation in section 10.2

164

Page 165: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.3. RLC Circuit

Parameter Symbol ValueSolverTimescale τ 3.2104 sTimestep ∆t τ

10

Electrical componentsVoltage Source U0 10 sin p2πftq VVoltage Source Frequency f 250 HzVoltage Source Resistance R0 1103 ΩResistor 1 R1 1 ΩInductor 2 L2 1103 HCapacitor 2 C3 1104 F

Figure 14.3.: Parameters for simulation in section 10.3

165

Page 166: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.4. Single Diode

Parameter Symbol ValueSolverTimescale τ 1 sTimestep ∆t τ

10

Electrical componentsCurrent Source U0 sin p2πftq 102 VCurrent Source Frequency f 1 HzResistor 1 R1 1 ΩDiode Tias Current I2s 11010 ADiode Thermal Voltage UT 2.59 102 VDiode Emission coefficient N 1.2

Figure 14.4.: Parameters for simulation in section 10.4

166

Page 167: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.5. The diode Bridge

Parameter Symbol ValueSolverTimescale τ 1104 sTimestep ∆t τ

10

Electrical componentsVoltage Source U0 10 sin p2πftq VVoltage Source Frequency f 200 HzVoltage Source Resistance R0 1103 ΩDiodes Bias Current I2s 11010 ADiodes Thermal Voltage UT 2.59 102 VDiodes Emission coefficient N 2.26Capacitance C5 1 101 FResistor R6 1 Ω

Figure 14.5.: Parameters for simulation in section 10.5

167

Page 168: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.6. The transformer

Parameter Symbol ValueSolverTimescale τ 0.5 102 sTimestep ∆t τ

10

Electrical componentsVoltage Source U0 10 sin p2πftq VVoltage Source Frequency f 2 HzVoltage Source Resistance R0 1103 ΩInductance Primery Side Lp 1000 HInductance Primery Side Ls 250 H

Figure 14.6.: Parameters for simulation in section 10.6.1

Parameter Symbol ValueSolverTimescale τ 0.5 102 sTimestep ∆t τ

10

Electrical componentsVoltage Source U0 10 sin p2πftq VVoltage Source Frequency f 2 HzVoltage Source Resistance R0 1103 ΩInductance Primery Side Lp 10 HInductance Primery Side Ls 2.5 H

Figure 14.7.: Parameters for simulation in section 10.6.2

168

Page 169: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.7. Common Emitter Amplifier with BTJ

Parameter Symbol ValueSolverTimescale τ 2104 sTimestep ∆t τ

10

Electrical componentsVoltage Source U0 1.50 VVoltage Source Resistance R0 1103 ΩCommitter Resistance RC 1104 ΩEmmitter Resistance RE 5000 ΩVoltage Source UB 5 sin p2πftq VVoltage Source Frequency f 5000 HzVoltage Source Resistance Rbase 1103 ΩTransistor ǫf 8 101

Transistor ǫr 8 101

Transistor IC0 11010 ATransistor IE0 11010 A

Figure 14.8.: Parameters for simulation in section 10.7

169

Page 170: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.8. The flip-flop

Parameter Symbol ValueSolverTimescale τ 1104 sTimestep ∆t τ

Electrical componentsVoltage Source U0 5VVoltage Source Resistance R0 1103 Ω

Voltage Source U7

$&% 5 V 20 t 40 ∆t

5 V 90 t 110 ∆t

0 V ElsewereVoltage Source Resistance R7 1000 Ω

Voltage Source U8

"5 V 60 t 80 ∆t

0 V ElsewereVoltage Source Resistance R8 1000 ΩResistance R1 100 ΩResistance R2 1000 ΩResistance R3 1000 ΩResistance R4 100 ΩLeft Transistor ǫf 0.998 101

Left Transistor IC0 11011 ALeft Transistor IE0 11014 ARight Transistor ǫf 0.998 101

Right Transistor IC0 11011 ARight Transistor IE0 11014 A

Figure 14.9.: Parameters for simulation in section 10.8

170

Page 171: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.9. The differential Amplifier

Parameter Symbol ValueSolverTimescale τ 1 sTimestep ∆t τ

10

Electrical componentsVoltage Source U1 5VVoltage Source Resistance R1 100 ΩVoltage Source U2 5 sin p2πftq VVoltage Source Frequency f 1 HzVoltage Source Resistance R2 100 ΩVoltage Source Ucc 30 VVoltage Source Ucc 30 VResistance Rf 200 ΩResistance Rg 200 ΩResistance Rout 1106 ΩOp Amp Gain g 1105 AOp Amp Input Impedance Zin 5107 AOp Amp Output Impedance Zin 1.4 A

Figure 14.10.: Parameters for simulation in section 10.9

171

Page 172: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.10. the Non-Inverting amplifier

Parameter Symbol ValueSolverTimescale τ 1 sTimestep ∆t τ

10

Electrical componentsVoltage Source U0 5 sin p2πftq VVoltage Source Frequency f 1 HzVoltage Source Resistance R0 1103 ΩVoltage Source Ucc 10 VVoltage Source Ucc 10 VResistance Rf 200 ΩResistance Rg 100 ΩResistance Rout 1106 ΩOp Amp Gain g 1105 AOp Amp Input Impedance Zin 5107 AOp Amp Output Impedance Zin 1.4 A

Figure 14.11.: Parameters for simulation in section 10.10

172

Page 173: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.11. The electric motor ramping up

Parameter Symbol ValueSolverTimescale τ 2.4 102 sTimestep ∆t τ

10

Electrical componentsVoltage source U0 1VVoltage Source Resistance R0 1103 ΩMotor Resistance R1 183 Ω

Motor Torque Constant K 2.47 102 nMA

Mechanical componentsMotor Inertia I 7.93108 kgm2

Figure 14.12.: Parameters for simulation in section 10.11.1

Parameter Symbol ValueSolverTimescale τ 2.5103 sTimestep ∆t τ

10

Electrical componentsVoltage source U0 1VVoltage Source Resistance R0 1103 ΩMotor Resistance R1 183 Ω

Motor Torque Constant K 2.47 102 nMA

Motor Inertia I 7.93108 kgm2

Figure 14.13.: Parameters for simulation in section 10.11.2

173

Page 174: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

14.12. The hydraulic piston with dry friction

Parameter Symbol ValueSolverTimescale τ 8103 sTimestep ∆t τ

10

Electrical components

Voltage source U0

"5000 V t ¤ 0.4 s8000 V t ¡ 0.4 s

Voltage Source Resistance R0 1103 ΩMotor Resistance R1 4.19 Ω

Motor Torque Constant K 3.68 102 nMA

Hydrological components

Liquid Density ρ 850 kgm3

Pump Displacment DM 1.6106 m3

rad

Pump Area A2 1.0 m2

Opening Pressure P3

"1.75105 Pa t ¤ 0.4 s3.64106 Pa t ¡ 0.4 s

Relief Valve Area A3 1.0 m2

Spool Valve Area A4 1.0 m2

Piton Hose Area A5 1.0 m2

Piton Cylinder Area pA5 1.0 m2

Mechanical componentsMass m6 10.0 kgMotor Inertia I1 2.51108 kgm2

Figure 14.14.: Parameters for simulation in section 10.12

174

Page 175: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

15. Appendix B

This appendix shows which constants from equation 6.6 that needs to be non-zero depending on how the non-symmetric current with complementary condi-tion is connected to the rest of the circuit.

15.1. Connection 1

The component is not connected to the rest of the circuit. One of the ports onwill be ground and the other one will be only connected to the new component.This means that there is no need to consider the rest of the circuit and equation6.6 simplifies to

S m n

f 0

(15.1)

where f 0 and n 0 in order to have full rank.Both the component m and the singe node in equation can be subjected to

complementary conditions and be put inactive. If the node is inactive equation15.1 simplifies to

S m

(15.2)

because m ¡ 0 the matrix have full rank.If on the other hand the current is set inactive, i.e. a blocking diode equation

15.1 becomes

S 0

(15.3)

Without the modification from section 9.2 the matrix in equation 15.3 wouldbe rank defiant. The circuit split algorithm will instead identify the single nodeas being a artificial ground node and remove it from the matrix. The emptymatrix will then have an empty null space.

175

Page 176: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

15.2. Connection 2

The component can instead be connected in between the two sub circuits.Due to symmetry it doesn’t matter to which of node in the sub circuits thecomponent is connected to. Therefor the component is connected to the nodeon the row with b and d. The node with c and e is omitted due to the symmetryand node f is omitted as it is not connected to anything and therefor a groundnode. Note that the internal connections A3 can contain the a ground node andcan be removed as long as one consider that the split circuit algorithm adds anartificial node if the new component are disconnected from the original groundnode. Equation 6.6 then becomes

S m 0 0 i k

0 Z2 0 B1 00 0 Z3 0 B4

b A1 0 0 0

d 0 A4 0 0

(15.4)

All components and nodes is subjected to complementary conditions. If theadded components are inactive the equation 15.7 simplifies to

S Z2 0 B1 00 Z3 0 B4

A1 0 0 0

0 A4 0 0

(15.5)

Note that due to them earlier being connected there don’t necessary exist aground in both sub circuits. This problem is taken care of by the algorithm insection 9.2.

If On the other hand if sub circuit Z2 is inactive equation simplifies to

S m 0 0 i k

0 Z3 0 0 B4

b 0 0 0 0d A4 0 0 0

(15.6)

If the connection to the ground node has been disconnected, i.e. if the groundnode was internally insideAJaccompc the split circuit algorithm adds a new node. The equation 15.6has full rank if b 0 and i 0. By Symmetry if Z3 is inactive the constantsc 0 and k 0 in order to have full rank.

It is also possible that both sub circuits blocks, in that case equation 15.7

176

Page 177: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

simplifies to

S m i k

b 0 0

d 0 0

(15.7)

The split circuit algorithm will detected that the circuit misses a ground andadd a artificial found to either node b or d. Which node that will be ground isnot possible to predict so b 0, i 0, d 0, k 0 to ensure that the matrixhas full rank.

If a node is inactive the A and B still full row rank and therefor the full soS will still have full rank.

177

Page 178: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

15.3. Connection 3

If the component is connected to Z2, then Z3 can be excludes as it is notconnected to the component. The internal connection may still contain a nodebut for simplification it is also removed. Due to symmetry node c is omittedas the component is connected to Consta. Equation 6.6 then simplifies to

S m 0 i n

0 Z2 B1 0

b A1 0 0f 0 0 0

(15.8)

If the component is inactive equation 15.8 simplifies to

S Z2 B1 0

A1 0 00 0 0

(15.9)

The split circuit algorithm in section will detect that the last node is a groundand remove it. As A and B has full row, resp. column rank the S has full rank.

If on the other hand the circuit Z2 would be inactive the equation 15.8simplifies to

S m i n

b 0 0f 0 0

(15.10)

If the ground node has been removed the split circuit algorithm will add anew. It is not guarantied which node that will be ground so in order to ensurefull rank b 0, f 0, i 0 and n 0.

If all components block the split circuit algorithm will set all nodes to groundnodes and S will be empty. If a node is inactive the A and B still full columnrank and therefor the full so S will still have full rank.

15.4. Connection 4

Due to symmetry connection 4 in figure 6.2 requires in correspondence to con-nection 3 that d 0, f 0, k 0 and n 0.

178

Page 179: Discretetime variational mechanicsof multidomainsystems ...umu.diva-portal.org/smash/get/diva2:571583/FULLTEXT01.pdf · Adress Uminove Science Park, Box 7973SE – 907 19 Ume˚a Sweden

15.5. Connection 5

The components is connected parallel to Z2. Because Z3 is not connected to thecomponent they are omitted. The empty node f is not connected to anythingand is a ground node and therefor omitted. The internal connections in Z2 cancontain a ground but can be omitted if this is noted. Equation 6.6 simplifiesto

S m 0 i j

0 Z2 B1 B2

b A1 0 0c A2 0 0

(15.11)

If the component is inactive equation 15.13 simplifies to

S Z2 B1 B2

A1 0 0A2 0 0

(15.12)

The S already has full rank as Z has full rank, A and B has full row resp.column rank.

If The circuit on the other hand is inactive equation 15.13 simplifies to

S m i j

b 0 0c 0 0

(15.13)

The split circuit algorithm in section 9.2 will add a new artificial node to thesystem. But it is undetermined if it is node b or c. This means that to ensurethat S the constants need to be b 0, c 0, i 0 and j 0.

If a node is inactive the A and rBs still full row resp. column rank andtherefor the full so S will still have full rank.

15.6. Connection 6

Due to symmetry connection 6 in figure 6.2 requires in correspondence to con-nection 5 that d 0, e 0, k 0 and l 0.

179