16
Automating the Lee Model

Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Embed Size (px)

Citation preview

Page 1: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Automating the Lee Model

Page 2: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the 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

Page 3: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

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

Page 4: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Object Oriented Design

MeasuredCurrent

Axial Model Radial ModelExpandedColumn

ModelReflectedShock

ModelRadiative

Model

Metrics Simulator

ConfigPanel ResultsPanelGAConfigPanel TuningPanel GaphsPanel

AutoFit

GAFit

GA

ParametersIniFileConfigIniFile

IniFile

Views (GUI)

Lee Model

CoronaModel

Setup

PlasmaFocusMachine

ModelResults

Constants

1

1

MainForm

1

1

1

Fitting

ZedGraphLibrary

Base

Chromosome

Page 5: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Graphical output

NEW EXISTING

Page 6: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Machine Configuration

Page 7: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Simulation Results

Page 8: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Detailed Graphs

Page 9: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

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

Page 10: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Goodness of fit

• R2 definition

R2 = 1- SSreg / SStot

whereSSreg = Sum (Imeas- Icomp )2

i.e. sum of errors

squared

SStot = Sum ( I - Imean)2 normalization factor

• Curve features– Peak– Slope– End of radial phase

Peak

End of Radial Phase

Slope of radial phase

Page 11: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Locating features on current trace

• Peak – easy

• End of radial phase– Take 2nd difference– Take maximum difference as the point

• Slope– Calculate slope from end of pinch to mid-

radial phase

-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

-0.5 0 0.5 1 1.5 2

Series1

Most linear portionfrom mid slope to end

Page 12: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Fitness Function• Fitness, R2’

R2’ = w1 * R2 + w2 * ME + w3 * PE + w4 * SEw1, w2, w3, w4 are weights,w1 = 1w3 = peak current / (peak current – pinch current) w4 = 2 * w3w2 = 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

Page 13: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Genetic AlgorithmCreate Population

of sets of parameters

(genes)

Rank the Population using Fitness function

Save the best gene (set with

best fit)

Generate new population using

mutation and crossover

Add best gene from previous pop

Add a narrorw cluster of genes to

new population

• Create population

• Rank using fitness function

• Select parents for new population

• Create new population using – Mutation– Crossover

• Add fittest genes from last pop

Page 14: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

GA Concepts

– Population– Chromosome– Genes– Mutation – Cross-over– Elitism

Page 15: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Optimization strategy

massf, currf, massfr, currfr

massf, currf

Fit Axial Phase by maximizing r2

using massf, currf

Fit Radial Phase by maximizing r2

using massfr, currfr

Fit overall curve by maximizing r2

using all 4 parameters

massf, currf

massfr, currfr

Initial Guess

Find the graph features to fit

using the second order difference

Pre-process measured data

• Preprocess measured current

• Local optimization stages– Axial for fitness F( massf, currf)– Radial for fitness F( massfr, currfr)

• Global optimization stage– Whole model for fitness F( massf, currf,

massfr, currfr)

• Repeat above as “stages”

Page 16: Automating the Lee Model. Major Components Simulator code –Verifying outputs –Verifying model equations –Graphical User interface Auto-tuning the model

Results

00.10.20.30.40.50.60.70.80.9

1

Tunin

g R0

stage

Tunin

g R0

stage

Final s

tage

Final s

tage

Final s

tage

Tunin

g R0

stage

Tunin

g R0

stage

Final s

tage

Final s

tage

Final s

tage

massf

currf

massfr

currfr

fitness

0

0.2

0.4

0.6

0.8

1

1.2

Tunin

g R0

stage

Tunin

g R0

stage

Tunin

g R0

stage

Tunin

g R0

stage

Tunin

g R0

stage

Tunin

g R0

stage

Final s

tage

Final s

tage

Final s

tage

Final s

tage

Final s

tage

Final s

tage

Final s

tage

Final s

tage

Final s

tage

massf

currf

massfr

currfr

f itness