Automating the Lee Model

Download Report

Transcript Automating the Lee Model

Automating the Lee Model
Major Components
• Simulator code
– Verifying outputs
– Verifying model equations
– Graphical User interface
• Auto-tuning the model parameters
– Simple pre-processing of trace data
– Optimization of fit of current curves
– Tuning of genetic algorithm code
Simulator Code
• Rebuilding the simulation code
– Port Excel VBA to C#
– Object Oriented Design
• 5 models – Corona, Axial, Radial, Radial RS, Radiative,
Expanded Axial
• Provide for future modifications
– Runs in < 1sec
– Export results to Excel
– Graphical interface
• Ease of use to run with new parameters and view results
• Advanced graphing
• Predefined tuned models
Object Oriented Design
Lee Model
CoronaModel
PlasmaFocus
Machine
Axial Model
Constants
Radiative
Model
ReflectedShock
Model
Radial Model
ExpandedColumn
Model
1
Base
1
1
MeasuredCurrent
Metrics
Simulator
ModelResults
1
Views
(GUI)
ZedGraph
Library
MainForm
1
GAConfigPanel
ConfigPanel
ConfigIniFile
ParametersIniFile
Setup
ResultsPanel
TuningPanel
GaphsPanel
Fitting
AutoFit
GA
IniFile
GAFit
Chromosome
Graphical output
NEW
EXISTING
Machine Configuration
Simulation Results
Detailed Graphs
Auto-tuning problem
• Defining what is a good-fit
– Formulating a numerical problem
– Coefficient of determination, R2 (inadequate)
– Other visual cues of good fit
• Finding the model parameters that “fits”
– Optimization search algorithm
• Local maxima problem
• Genetic algorithm
Goodness of fit
• R2 definition
R2 = 1- SSreg / SStot
where
SSreg = Sum (Imeas- Icomp )2
SStot = Sum ( I - Imean)2
i.e. sum of errors squared
normalization factor
• Curve features
– Peak
– Slope
– End of radial phase
Peak
Slope of
radial phase
End of
Radial
Phase
Locating features on current trace
• Peak – easy
• End of radial phase
2
1.5
1
0.5
Series1
0
-0.5
0
0.5
1
1.5
2
-0.5
-1
– Take 2nd difference
– Take maximum difference as the point
-1.5
-2
• Slope
– Calculate slope from end of pinch to midradial phase
Most linear portion
from mid slope to end
Fitness Function
• Fitness, R2’
R2’ = w1 * R2 + w2 * ME + w3 * PE + w4 * SE
w1, w2, w3, w4 are weights,
w1 = 1
w3 = peak current / (peak current – pinch current)
w4 = 2 * w3
w2 = 1.2 * w4
•
ME is the maximum current errors (peaks), ME = (1 - ME1) + (1 - ME2)
ME1 = computed peak current – measured peak current
measured peak current – measured pinch current
ME2 = computed peak time – measured peak time
measured peak time – measured pinch time
•
•
PE is similarly calculated.
The radial slope error is calculated as follows:SE = 1 - computed peak current – mid-radial current
pinch time – mid-radial time
Genetic Algorithm
Create Population
of sets of
parameters
(genes)
Rank the
Population using
Fitness function
•
•
•
•
Create population
Rank using fitness function
Select parents for new population
Create new population using
Save the best
gene (set with
best fit)
Generate new
population using
mutation and
crossover
– Mutation
– Crossover
• Add fittest genes from last pop
Add best gene
from previous pop
Add a narrorw
cluster of genes to
new population
GA Concepts
– Population
– Chromosome
– Genes
– Mutation
– Cross-over
– Elitism
Optimization strategy
Pre-process
measured data
Find the graph
features to fit
using the second
order difference
• Preprocess measured current
• Local optimization stages
– Axial for fitness F( massf, currf)
– Radial for fitness F( massfr, currfr)
Initial Guess
massf, currf,
massfr, currfr
Fit Axial Phase by
maximizing r2
using massf, currf
• Global optimization stage
massf,
currf
– Whole model for fitness F( massf, currf,
massfr, currfr)
massf, currf
Fit Radial Phase
by maximizing r2
using massfr,
currfr
massfr
, currfr
• Repeat above as “stages”
Fit overall curve
by maximizing r2
using all 4
parameters
Tu
ni
ng
R
Tu
0
st
ni
ag
ng
e
R
Tu
0
st
ni
ag
ng
e
R
Tu
0
st
ni
ag
ng
e
R
Tu
0
st
ni
ag
ng
e
R
Tu
0
st
ni
ag
ng
e
R
0
st
ag
Fi
e
na
ls
ta
ge
Fi
na
ls
ta
ge
Fi
na
ls
ta
ge
Fi
na
ls
ta
ge
Fi
na
ls
ta
ge
Fi
na
ls
ta
ge
Fi
na
ls
ta
ge
Fi
na
ls
ta
ge
Fi
na
ls
ta
ge
Tu
ni
n
Tu g R
0
ni
n g st
R age
0
Fi sta
na ge
l
Fi sta
na ge
ls
F
Tu in tage
ni al s
n
Tu g R tage
0
ni
n g st
R age
0
Fi sta
na ge
l
Fi sta
na ge
l
Fi sta
na ge
ls
ta
ge
Results
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
massf
currf
massfr
currfr
fitness
1.2
1
0.8
0.6
0.4
0.2
0
massf
currf
massfr
currfr
fitness