Sei sulla pagina 1di 66

An Introduction to Solvers

Plexim GmbH

Outline

Variable-step simulation
Ideal switches
Piecewise linear simulation
Non-stiff, stiff solvers
Stability domain
Event detection

2
Different Degrees of Simulation Detail
1. Power circuit modeled as linear transfer function
Small signal behavior
No switching, no harmonics
! Controller design
2. Power circuit modeled with ideal components
Large signal behavior, voltage and current waveforms
Overall system performance
! Circuit design and controller verification
3. Power circuit with manufacturer specific components
Parasitic effects (magnetic hysteresis)
Switching transitions (diode reverse recovery)
Component stress (electrical or thermal) Power input Power output
Power Load
!! Choice of components vi ii converter io vo

Control
signals Measurement

Controller Reference

Comparison - SPICE and PLECS

Passive component models are similar


R, L, C
The main difference is the semiconductor model
MOSFET model - SPICE
Detailed physical device model
Has 47 parameters
MOSFET model - PLECS
Simplified behavioral model
Two parameters: Ron and T

4
High Speed Simulations with Ideal Switches

Conventional continuous diode mode


Arbitrary static and
dynamic characteristic
Snubber often required

Ideal diode model in PLECS


Instantaneous on/off
characteristic
Optional on-resistance
and forward voltage

Comparison: Diode Rectifier

Simulation with conventional and ideal switches

Simulation steps:
1160 " 153
Computation time:
0.6s " 0.08s

6
State Space Model: Buck Converter

State space description

Switch conducting Diode conducting

Variable Time-Step Simulation: Buck Converter

Transistor conducts
Diode blocks

8
Variable Time-Step Simulation: Buck Converter

Transistor opens
Impulsive voltage across
inductor

Variable Time-Step Simulation: Buck Converter

Impulsive voltage closes


diode

10
Variable Time-Step Simulation: Buck Converter

Transistor open
Diode conducts

11

Variable Time-Step Simulation: Buck Converter

Switch timing Problem:


Diode opens too late
Impulsive voltage across
inductor

12
Variable Time-Step Simulation: Buck Converter

Zero-Crossing Detection:
Time-step is reduced
Diode opens exactly at
the zero-crossing

13

Operating Principle of PLECS

Circuit transformed into state-variable system


One set of matrices per switch combination
1 Solver
s

y
u
B A C
Switch manager

D
g

PLECS S-function

14
Solver Overview

Continuous solvers
Taylor series polynomial
Step size control
Acceptable error
Relative, absolute tolerance
Output refining

Discrete solvers
Trapezoidal rule
Step size selection
15

Taylor Series Expansion

Approximate a continuous
function with a higher order 1st order

polynomial
The higher the order, the 5th order

more accurate the solution y=sin(x)

Taylor series: Source: Wikipedia

16
Continuous Solver Operation

y(t) can be constructed using in a piecewise fashion using


p1(t) and p2(t), which are Taylor series polynomials
A continuous solver calculates the point yn+1 by calculating
the equivalent Taylor series for p1(t)
An nth order solver has the same accuracy as an nth order
Taylor series. '#$%

'()" !&#$%
!"#$% '(

*( *()"
$
$( $()"
17

Solver Settings

18
Acceptable Error

Local error
Difference between 4th and 5th order solutions
Acceptable error
Defines the local error limit
Determined by tolrel except for small state values

Result valid if:

Local error Acceptable error

19

Step Size Control

Step size automatically controlled by the solver


(variable step)
Goal: Keep error within acceptable error limits
Key advantage: Accuracy directly specified by the user
Step size calculated using
Relative error, ε
Relative tolerance, tolrel
hold
Previous time step, hold

20
Tolerances

Relative tolerance
Determines acceptable error limit when x > 0
Start with 10-3 (0.1%)
Numerical limit is 10-16
Absolute tolerance
Best to set to auto

21

Example LC circuit

Analytical solution:
  



Result: tolrel = 1e-3









     

22
Example LC circuit

Analytical solution:
  



Result: tolrel = 1e-6









     

23

Refining the Output

Option 1: Reduce tolrel or time step


Solver must recalculate polynomial coefficients at each time
step
Less efficient
Option 2: Increase refine factor
Solver uses existing polynomial coefficients to calculate
additional points.
More efficient

24
Solver Families

Non-stiff
Inherently more efficient (no iteration required)
Smaller stability domain
Forward Euler - 1st order
ode45/Dopri - 5th order
Stiff
Less efficient (iteration required)
Larger stability domain
Backward Euler - 1st order
Radau/ode23tb - 5th order

25

Forward Euler

Truncate the Taylor Series


after the first term:

1st order accurate

Explicit integration
algorithm

26
Numerical Experiment

Scalar system

Analytical solution

Forward Euler

Unstable for ah<-2

27

Stability Analysis

Autonomous LTI system

Analytical solution

Analytically stable if

28
Stability Domain of Forward Euler

Integration algorithm

Stable if the eigenvalues of


F are inside the unit circle
I.e. if the eigenvalues of Ah
are inside a unit circle
around (-1, 0)

29

Analysis of RLC Example

30
Floating Point Arithmetic

What is 0.3 - 0.2 - 0.1 ?

What MATLAB calculates:

0.299999999999999989
- 0.200000000000000011
- 0.100000000000000006
= -0.000000000000000028

31

Floating Point Arithmetic (2)

Summation of floating point numbers

+ b

+ c

= a+b+c

32
Backward Euler

Develop Taylor Series


around a time in the future:

Must be solved iteratively


for the unknown x(t*+h)

Implicit integration
algorithm

33

Numerical Experiment (Revisited)

Scalar system

Analytical solution

Backward Euler

34
Stability Domain of Backward Euler

Integration algorithm

Stable if the eigenvalues of


Ah are outside a unit circle
around (1, 0)

35

Stability Domain
Dopri

Tustin
Radau

36
Higher Order Integration Methods

E.g. Explicit Midpoint Rule

Two stages (one intermediate, one final)


2nd order accurate
More accurate than two FE steps of half size!

37

Event Detection

Define auxiliary functions that help locate discontinuities.


Function zeros must coincide with the discontinuities.

38
Missed Events - Problem

B
0

Time step1 Time step2

Output

39

Missed Events - Solution

B
0

1
Output

40
PWM Generation

41

Trapezoidal Rule

"&'(

"&
"#$%
!
$
$& $&'(

42
Time Step Selection

Accuracy is indirectly determined by the time step


To ensure accuracy, reduce the time step and observe any
changes in the output
Or: Compare with a continuous simulation
Continuous waveform
Highest transient frequency constrains sample time
Set tsample < ttransient/10
Integration underestimate approx 3%
Switched system
Switches turned on at sample instants
Set tsample < tsw/100

43

Comparison - Continuous and Discrete solver


Time steps:
Underdamped RLC circuit
Continuous: tolrel = 10-6







  






      
 


Simulated current
Discrete: ts = 50μs
 

 






 







       
 
       
 


44
Conclusion

Variable step solver operation


Causes of model stiffness
Solutions to stiffness
Explicit (non-stiff) vs. Implicit (stiff) solvers
Limits of stability
Limits of numerical accuracy
Event detection

45

Tips to Achieve a Fast Simulation

Plexim GmbH

46
Introduction

The problem
Large simulation models can become slow
Many states, detailed component models
Speeding up the simulation
Model simplification
Model tuning
Real-time accelerator
Averaged modeling
Efficient PWM generation
Example - Three phase inverter

47

Simplification of PV Cell Model

Exact model: accounts for non-linear VI characteristic


Needed for implementing MPPT simulation
Temperature and insolation dependency also important

•Insolation = 1000 W/m2


•T = 25 °C
•MPP occurs at 17.6 V

48
Diode PV Cell Model

Current = fn(voltage, insolation,


temp)
Cell model
Shockley diode eq.

Reference:

49

PV Lookup Table Implementation

Simplified implementation
Voltage-controlled current source
Capacitor included to add a state and avoid an algebraic
loop

Precalculated PV data

50
Model Tuning

Simulation settings.
Choose the correct solver.
Blockset Standalone
Non-stiff ode45 Dopri
Stiff ode23tb/ode15s Radau

Variable time step solver.


Reducing the switching frequency reduces the computational
overhead.

51

Real Time Accelerator

Converts model into c-code.


Compiles executable.
Runs as native rather than interpreted program.
PLECS circuit converted into C-code.
Automatically integrated with Simulink c-code.
Speed gain = 2 - 5 times.
Generate and compile takes 20 seconds.

52
Averaged Converter Modeling

Averaged converter models


Retain the low frequency dynamics.
Averages switching action over one cycle.
Requires specialized knowledge of topology.
Speed gains are an order of magnitude.
Procedure
Average inverter model.
Average space vector modulation.
Break algebraic loops.

53

Averaging a Three Phase Converter

Full switching model


Simulates exact electrical dynamics.
Switching action slows down the simulation where slower dynamics are
studied.

54
Inverter Leg

d.T

Vdc

d.Vdc

ia

d.ia

d=0.3

55

Averaged Inverter Leg

Va modeled using as a controlled voltage source


idc modeled as a controlled current source

56
Averaged Inverter Model

Assumes AC voltages are ideally imposed


Used for rotor-side and grid-side converter

Averaging of inverter legs A and B

57

Averaging Space Vector Modulation

Converter Vdq* to ma, mb, mc


Use 3 phase PWM.
Extend operating range using overmodulation.

Approximation of space vector modulation with a continuous modulation index

58
Overmodulation

Add zero-sequence signal to modulation index

Reference: Vector Control of a Double-Sided PWM Converter and Induction Machine Drive, R. Ottersten

59

Algebraic Loops

What?
Multiple direct feedthrough blocks connected in a loop.
PLECS continuous inputs appear as a direct feedthrough system to
Simulink.
In feedback control systems, this will cause an algebraic loop.
Problem: Algebraic loops must be solved iteratively
The simulation time of each step is increased

60
Breaking Algebraic Loops

Option 1. Use memory block or similar


Time delay causes instability.
Step size may need to be limited.
Option 2. Use a low pass filter
The extra state breaks the algebraic loop.
Time constant must be chosen with care.
Provides more deterministic behavior with variable step
simulation.

Breaking an algebraic loop with a low-pass filter.

61

Average DC-DC Converter Modeling

Average switch cell modeling


Replace switch/diode combination with a voltage current source.
Ref: Fundamentals of Power Electronics, Erickson & Maksimovic
Equations
I2 = (1 - d)/I1
V1 = (1 - d)/V2 !

62
Simplification of Current Controlled Converters

Boost converter is current controlled


Can replace the inductor with a current source.

63

Efficient PWM Generation in PLECS


Sampled PWM Continuous PWM

Doubly fed induction generator example, 0.1 s simulation, PLECS Blockset


Sampled PWM: 29.6 s => 52 % faster
Continuous PWM: 45.1 s

64
Example - Three Phase Boost Rectifier

Control aims
Sinusoidal input currents
Regulated dc bus voltage

65

Block Diagram

PWM

•Stiff system
•Simulated for 0.2 s in PLECS Blockset & Standalone

66
Results - PLECS Blockset

Controls in Simulink

•ode23tb solver used (stiff)

67

Results - PLECS Standalone

•Radau solver used (stiff)

68
Conclusion

Choose the right solver for the job (stiff or non-stiff)


Use sampled PWM
Make appropriate simplifications
For extremely large models:
PLECS Standalone
Real-time workshop
Averaged converter modeling

69

An Introduction to Thermal Modeling


and Simulation

Plexim GmbH

70
Why Thermal Simulation?

Reduce development time


Predict performance and investigate key
tradeoffs early in the design process
Thermal measurements can be difficult and
time consuming

71

Sources of Thermal Losses

Passive components
Resistive power loss: ploss(t) = vR(t) iR(t)
Loads e.g. break resistors
Filters
Winding resistance
Power semiconductors
Conduction loss
Switching loss

72
Semiconductor Losses

Gate signal

Switching loss
Conduction loss

73

Switching Losses

Switching energy loss dependent on:


Blocking voltage, device current, junction temperature, gate drive
Eon = f(Vce, Ic, Tj, Rg)

Turn on Turn off

74
Example IGCT Turn-off: Varying Stray Inductance

kV kA
4.5 300 nH (10.5 Ws) 3.0
VPK = 3800V 800 nH (12 Ws)
1500 nH (13.5 Ws)

3.0 2.0

VDC = 2 kV
1.5 1.0
TJ = 125°C

0.0 0.0
5 10 15 µs
Courtesy ABB tf ! 2.5µs, ttail ! 7µs

75

Switching Loss Calculation from Transients

Accurate physical device models required


Often unavailable
Physical parameters often unknown during design phase.
Stray inductance of PCB
Small simulation steps required
Large computation times

76
Lookup Table Approach for Switching Losses

Instantaneous switching maintained for speed.


Switching losses are read from a database after switching
event.
Esw = f(Tj, vblock, ion) (Rg = const)

77

Example Lookup Table

Turn-off loss a function of:


Current before switching
Voltage after switching
Temperature at switching
Rg is assumed constant
Exact loss found using
interpolation
Note the voltage and
current polarities!

78
Semiconductor Conduction Losses

On-state loss
Conduction profile is nonlinear:
von = f(ion, Tj).
Conduction profile stored in
lookup table
Exact voltage found using
interpolation
Conduction power loss:
ploss(t) = von(t) ion(t)

Off-state loss
Negligible - low leakage current

79

Simulation of an Electrical-Thermal Model

80
Combined Electrical-Thermal Simulation

Thermal and electrical


domains not coupled
Semiconductor losses don’t
appear in electrical circuit
Energy conservation can be
maintained by subtracting
thermal losses from electrical
circuit
Switching losses added over
zero time
Filtered by large capacitance
of thermal circuit

81

Semiconductor Thermal Behavior








   




  


 

!! 


!!

!!

 !"  !!  !! # 






 

82
Verification of Lookup Table Approach

IGBT loss modeling using an ideal switch and lookup table


Simulation speed increased by a factor of 20
Good agreement with measurements

Pt - simulated IGBT loss


Ptm - measured IGBT loss

83

Thermal Modeling of a Pulsed Resonant Converter

Simulation results

"t = 1.4℃

"t = 1.4℃

Experimental results

Acknowledments: Dr. Fabio Carastro, University of Nottingham

84
A combined electrical-thermal model

Losses, heatsink, ambient temperature.


How are these represented using PLECS?

85

Thermal Domain

Thermal circuit analogous to electrical circuit.


Thermal and electrical circuits solved simultaneously.

86
A complete electrical-thermal model

The heatsink is the interface between the two domains


Automatically absorbs component losses
Propagates temperature back to semiconductors
Thermal impedance modeled with RC elements

87

Hierarchical Modeling of Thermal Structures


Junctions IGBT Plate

Heatsink

Dual IGBT
module

88
Different Thermal Equivalent Networks

Cauer equivalent Foster equivalent


Physics based thermal equivalent Curve fitting approach based on
circuit heating and cooling characteristics.
Each Rth and Cth pair represents a No correspondence between Rth,n
physical layer in the thermal circuit. resp. Cth,n and the physical structure!
Any modification of the system
requires recalculation of all values

89

Junction-Case Thermal Impedance

Define in thermal editor to observe junction temp fluctuations


Foster coefficients often given in datasheet

Foster network coefficients

Example junction-case thermal impedance

90
Foster Network Pitfalls

Only accurate if reference point x is a constant temperature


Cannot be arbitrarily extended beyond point x
Tjunc immediately affected by temperature changes at x

Reference: M. März and P. Nance, “Thermal modeling of power electronic systems,” www.iisb.fraunhofer.de

91

Solution 1 - Use First Order Cauer Network

Calculate τ from 63% R value


C = τ/R

Vc reaches 63.2% Vfinal after τ

92
Solution 2 - Use a Constant-Temperature Heatsink

Set Cheatsink to 0
Set heatsink temperature with a const temperature source
Foster network can be used for junction thermal impedance

93

Measuring Average Device Losses

Concept
Calculate total switching
and conduction energy lost
during a sw cycle
Output as an average
power pulse during the
next cycle

Implementation
Based on a C-Script block
Conduction and switching losses measure with a Probe


 
 
 
 

  

 
 


94
Challenge: Large Thermal Time Constants

Thermal time constants: 0.1 … 100 s


Switching frequency: 1 … 100 kHz
Long simulation time until thermal steady-state is reached

Example

95

Newton Raphson Analysis

Approach: Finding the roots of Newton iteration

! ! : initial state vector


! ! : final state vector after a time T

Iterative solution

Jacobian J calculated numerically


requires n+1 simulation runs (for n state
variables)

96
Newton Raphson: Convergence

Typically converges after <10 iterations

97

Newton Raphson: Requirements for Convergence

The system must be convergent


Example problem
PLL model
Angle is a ramp signal towards infinity
! Solution: create a periodic signal with a self-resetting integrator

98
Thermal Loss Feedback 1

P1,Pi=100W Po=100W
P2=95W

Efficiency:

99

Thermal Loss Feedback 2

P1=105W Pi=100W Po,P2=100W

Efficiency:

100
Thermal Loss Feedback 3

P1=105.3W Pi=100W Po,P2=100W

Thermal feedback:

Efficiency:

101

Physical Rds Implementation

Rds constant during switching cycle


Resistance resolution:

102
Obtaining Switching Loss Data

Experimental measurements
Switching losses highly dependent on gate drive circuit and
stray parameters
Use a switching loss setup to characterize loss dependency on
voltage and current for two temperatures
Datasheets
Given for a specific gate resistance and stray inductance
Good approximations can be made by extrapolating
manufacturers data (or asking for complete loss
measurements)

103

Conclusion

Fast & accurate thermal simulation using lookup tables


Operation of a combined electrical-thermal simulation
Calculating average device losses
Steady state analysis using Newton Raphson analysis

104
Advanced PLECS Tools

Plexim GmbH

105

Advanced Tools

C-Script block
Control design tools
Steady-state analysis
AC sweep
Impulse response analysis
Loop gain analysis
Other
Subsystem - custom components

106
Small Signal Analysis Tools

Possible workflow for controller design using PLECS tools:


Converter Open Loop AC Sweep Analysis
Transfer Function Impulse Response Analysis

Voltage controller design


Freq domain

Loop Gain Analysis


Calculate loop gain
plbode function

Gain/phase
margins met?

Verify with simulation

107

Frequency Sweep

Algorithm:
For each frequency:
1. Run steady-state analysis
2. Apply sinusoidal perturbation
3. Extract system response using Fourier analysis

Caveats:
Period length: least common multiple of system period and
perturbation period
Computationally expensive

108
Impulse Response Analysis

Impulse response
of a buck converter

Transfer function:

109

Impulse Response Analysis

The original Laplace transform:

Apply some math …

Reference: D.Maksimovic, „Computer-Aided Small-Signal Analysis Based on Impulse Response of DC/DC


Switching Power Converters“, IEEE Trans. On Power Electronics, Vol. 15, No. 6, Nov. 2000, pp. 1183-1191

110
Buck Converter: Transfer Function

111

Stability Verification

Loop Gain
Use Loop Gain Analysis Tool (Blockset)
AC Sweep (Standalone), or
Calculate using plbode function
Measure gain and phase margins to check stability

112
Custom Components

Why?
Support the top-down design approach
Easy to reuse, configure and measure
Custom component features
Formed using the subsystem
User defined parameter, icon, initialisation commands and
probe signals
! All machines in PLECS are custom components

113

Example - PV String Model

3.5

2.5
Current (A)

1.5 Current surface data


1
in lookup table
0.5

0
1

0.5

5 0
0 15 10
25 20
Insolation (kW/m2)
Voltage (V)

114
Masked Subsystem Implementation

115

C-script Block

Plexim GmbH

116
What can it do?

C-control code emulation


Model custom components
Efficient sequence generation
State machine modeling

117

Function call interface

Solver operation (PLECS or Simulink)


Some function calls dependent on continuous or discrete states

118
Function calls in C-script block

Main loop
Always executed
Output() called at least once
Update() called after Output if discrete state variables exist
Integration loop
Executed if continuous states defined in settings
Used for solving continuous differential equations
Continuous states used for declaring DEs
Event detection loop
Executed if a zero crossing signal defined in settings
For detecting the exact instant of a discontinuity

119

C-Script parameter window

120
Code editor window

121

Sample time setting

Discrete
Value: +ve
Fixed sample time
Continuous
Value: 0
Inherited from solver
Variable
Value: -2
At each time step the NextSampleHit must be specified.

122
Hybrid fixed and variable step setting

Fixed and variable time


Format: [1/fs,0; -2, 0]
First row element is the time setting
Second element is the offset time
Continuous, only major time steps
Format: [0, -1]
C-Script not called during integration or event detection loop
Eliminates unnecessary calls for certain blocks.
Use for blocks with discrete output. Example: Lookup table

123

Pitfalls - cascading C-Script blocks

Controller cycle hit time - fixed step:


Cycle time obtained by multiplication: tn = 1/fs*n
PWM cycle hit time - variable step:
Cycle time is obtained by addition: tn = 1/fs + 1/fs + ... n
Synchronization may be lost due to accumulated rounding error
Solution
Use a hybrid fixed/variable step setting for PWM block

124
Macros

For interacting with model or solver


Examples
Input(0)
Output(0)
NextSampleHit
CurrentTime

125

Example - Space Vector Control

Three phase boost rectifier


Sinusoidal input currents
Regulated dc bus voltage

126
Control Strategy

•Outer voltage control loop


•Inner decoupled current control loop
•Space vector modulation

127

Space vector modulation


Timing calculation
Switch signal generation

C-script block2
C-script block1

128
Efficient sequence generation

Typical switching sequence


Space vector modulation
Option blanking delay
Method 1: Fixed time step
Test if t > thit, apply new switch signal
Requires small steps for accuracy => increased computational
overhead
Method 2: Variable time step
Calculate hit times at beginning of switching sequence
Fewer simulation steps – more efficient

129

Example: PWM with blanking

Calculate transition times, t1,t2,t3,t4 at beginning of cycle


State machine program executes at each transition:
Switching signal is updated
NextSampleHit is updated

Bipolar switching signal 1: S1, S4 on


-1: S2, S3 on

130
Efficient state machine implementation

Event driven
Useful for controller mode sequencing.
Example: Startup, overload, shutdown.
Relational operator
- generates major step

External event >


Time setting:
v1 C-Script Simulation model: variable
State machine C-Script: continuous
External event >
i1

if (IsMajorStep)
test_input(v1,i1);
update_state_machine();

131

Conclusion

Implement complex nonlinear and/or piecewise


functions without complex block diagrams
Model custom components and controls
Generate efficient sequencing with exact but flexible
time step control
State machine modeling
Incorporate external C code for hardware controllers

132

Potrebbero piacerti anche