#=============================================== # SemiconductorFromDFTDOS #=============================================== package SemiconductorFromDFTDOS; use TkFittingCommon2; @ISA = qw(TkFittingCommon2); #公開したいサブルーチン #@EXPORT = qw(DelSpace Reduce01 MakePath RegExpQuote); use strict; use Utils; use IniFile; use CSV; use MyTk::GraphFrameArray; use MyTk::MyDragDrop; use GraphData; use Sci::Science; use Sci::Optimize; use Crystal::VASP; use Sci::SemiconductorFromDFT; use Sci::PES; use Sci::Ellipsometry; #============================================================ # 変数等取得関数 #============================================================ my $ProgramName = "Semiconductor From DFT DOS"; #============================================================ # コンストラクタ、デストラクタ #============================================================ #呼び出されることはない sub new { my ($class, $app, @a) = @_; # my ($module, $app, $canvas) = @_; my $self = TkFittingCommon2->new($app, @a); my $this = bless $self, $class; # my $this = {}; # bless $this; $this->SetApplication($app) if($app); # $this->SetCanvas($canvas) if($canvas); return $this; } sub DESTROY { my $this = shift; $this->SUPER::DESTROY(@_); } #============================================================ # 継承クラスで定義しなおす関数 #============================================================ sub CreateLeftFrame { my ($this, $ConfigSide, @args) = @_; # return $this->SUPER::CreateLeftFrame(); return undef; } sub CreateSelectFilePane { my ($this) = @_; # return $this->SUPER::CreateSelectFilePane(); return undef; } sub CreateFileContentPane { return undef; } sub CreateWidgets { my ($this, $DoSuperOnly) = @_; $DoSuperOnly = 0 if(!defined $DoSuperOnly); my $mw = $this->mw(); $this->{ini} = new IniFile(undef, 0, 0); $this->{dini} = new IniFile(undef, 0, 0); $this->{ini}->{nStepBG} = 0; $this->{ini}->{nGL} = 0; # $this->{DataFile} = new Ellipsometry; $this->InitializeParameters($this->{ini}, $this->{dini}); $this->SUPER::CreateWidgets(); return if($DoSuperOnly); $mw->SetTitle("$ProgramName / TkPlot"); $this->App()->SetProgram("$ProgramName / TkPlot"); #=================================================== # ペインを作製 #=================================================== my $EntryWidth = $this->{EntryWidth} = 12; $mw->{NoteBook} = $this->MakeNotebookPanes($mw, $EntryWidth, $this->{ini}->pVariable("nFilmLayers", 1), $this->{ini}->pVariable("nLorentz", 0), $this->{ini}->pVariable("nDrude", 0), $this->{ini}->pVariable("nStepBG", 0), $this->{ini}->pVariable("nGL", 0), # [qw(Main Vars1 Vars2 ViewRange LSQ GaussLorentz Setup GraphFrame)], [qw(Main Defects Setup GraphFrame)], [qw(nPESStepBG nGaussLorentz)], ); $mw->{NoteBook}->pack(-fill => 'both', -expand => 'yes'); $this->UpdateParameters(); #ツールバーのOpenボタンをファイル読み込みにバインドする my $Samplefmask = '*.csv;*.spe;*.jel;*.asp;*.smo;*isa;*.ref;*.pal;*.bef;*.aft;*.txt'; $mw->{OpenButton}->configure( -command => sub { $this->{SampleCSV} = $this->ChooseFile("open", $Samplefmask, "ChooseSampleFile", "SampleCSV", $this->{SampleFileFrame}); }, ) if($mw->{OpenButton}); my $DragDrop = new MyDragDrop(); $DragDrop->ConfigureDrop( $this->mw(), [ "\\.prm\$", $this->{ParamFileEntry}, sub { $this->ReadParameterFile($_[0]); }, ], [ ".*", $this->{Sample1CSVFileEntry}, sub { $this->{Sample1CSVFileEntry}->SetText($_[0]); # $this->ReadSampleDataFile($_[0], 1, 1); }, ], ); my $IniFile = $this->App()->IniFile(); # $this->SetGeometry($IniFile->GetString("Window", "geometry", '')); $this->InitWindowPosition($IniFile->GetString("Window", "geometry", '')); $this->OnDestroy( sub { $this->App()->IniFile()->WriteString("Window", "geometry", $this->geometry()); # $this->Close(); } ); # $this->{FileNameEntry}->bind('' => sub { $this->Close(); } ); $this->bind('' => sub { my ($widget) = @_; if($widget =~ /PESFit=/) { $this->App()->IniFile()->WriteString("Window", "geometry", $this->geometry()); } } ); } sub BuildMainPane { my ($this, $MainPaneFrame, $EntryWidth) = @_; my $Frame = $MainPaneFrame->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); my $savefmask = '*.csv;*.ini;*.txt'; $this->{ParameterFileFrame} = $this->MakeChooseFileEntry( $Frame, 'Param', 'Param:', $this->{ini}->pVariable("ParameterFile", ""), '&Choose', sub { $this->ChooseFile("open", $savefmask, "ChooseParameterFile", @_); }, 1, sub { $this->SaveParameterFile("SaveParam", '', @_); }, 1, sub { $this->EditFile('EditParam', @_); }, [] ); $this->{ParameterFileFrame}->pack(-anchor => 'nw', -fill => 'x'); $Frame = $MainPaneFrame->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); my $CARDirfmask = '*.*'; $this->{CARDirFrame} = $this->MakeChooseFileEntry( $Frame, 'CARDir', 'CAR Dir:', $this->{ini}->pVariable("CARDir", ""), '&Choose', sub { $this->{CARDir} = $this->ChooseFile("open", $CARDirfmask, "ChooseSampleFile", @_); $this->AssignGraphData(); $this->Draw(); }, 0, sub {}, 0, sub {}, ['X1', 'Y1'] ); $this->{CARDirFrame}->pack(-anchor => 'nw', -fill => 'x'); $Frame = $MainPaneFrame->MyLabFrame( -label => 'General', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $this->{ChooseActionListBox} = $Frame->MyBrowseEntry( -variable => $this->{dini}->pVariable('Action', ''), -label => "Action:", -state => "readonly", -takefocus => 1, -width => 8, -Selections => ['Ne-T', 'Hf-EF', 'PlotHf-EF'], # -SelIndex => 0, )->pack(-side => 'left', -expand => 'yes', -fill => 'x'); $this->{ChooseActionListBox}->configure( -browsecmd => sub { $this->SelChangeListBox("Action", $this->{ChooseActionListBox}); } ); # $this->{ChooseActionListBox}->SetText($this->{dini}->{Action}); $Frame = $MainPaneFrame->MyLabFrame( -label => 'Convergence', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $this->MakeLabelEntry($Frame, "nMaxIter", "nMaxIter:", $this->{dini}->pVariable("nMaxIter", '300'), "%d", $EntryWidth, "", 0, 0, "normal"); $this->MakeLabelEntry($Frame, "xEPS", "xEPS:", $this->{dini}->pVariable("xEPS", 1e-15), "%e", $EntryWidth, "", 0, 1, "normal"); $this->MakeLabelEntry($Frame, "SEPS", "SEPS:", $this->{dini}->pVariable("SEPS", 1e3), "%e", $EntryWidth, "", 0, 2, "normal"); $Frame = $MainPaneFrame->MyLabFrame( -label => 'Plot', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $this->MakeLabelEntry($Frame, "Emin", "E:", $this->{dini}->pVariable("Emin", ''), "%g", $EntryWidth, "", 0, 0, "normal"); $this->MakeLabelEntry($Frame, "Emax", " - ", $this->{dini}->pVariable("Emax", ''), "%g", $EntryWidth, "eV", 0, 1, "normal"); $this->MakeLabelEntry($Frame, "nE", " nE:", $this->{dini}->pVariable("nE", ''), "%d", $EntryWidth, "", 0, 2, "normal"); $this->MakeLabelEntry($Frame, "Tmin", "T:", $this->{dini}->pVariable("Tmin", ''), "%g", $EntryWidth, "", 0, 0, "normal"); $this->MakeLabelEntry($Frame, "Tmax", " - ", $this->{dini}->pVariable("Tmax", ''), "%g", $EntryWidth, "", 0, 1, "normal"); $this->MakeLabelEntry($Frame, "Tstepx", " step:", $this->{dini}->pVariable("Tstep", ''), "%g", $EntryWidth, "K", 0, 2, "normal"); $Frame = $MainPaneFrame->MyLabFrame( -label => 'Temperature', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $this->MakeLabelEntry($Frame, "Electron", "Telectron:", $this->{dini}->pVariable("Telectron", ''), "%g", $EntryWidth, "K", 0, 0, "normal"); $this->MakeLabelEntry($Frame, "Defect", "Tdefect:", $this->{dini}->pVariable("Tdefect", ''), "%g", $EntryWidth, "K", 0, 1, "normal"); $Frame = $MainPaneFrame->MyLabFrame( -label => 'Band structure', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $this->MakeLabelEntry($Frame, "EV", "EV:", $this->{dini}->pVariable("EV", 0.0), "%g", $EntryWidth, "eV", 0, 0, "normal"); $this->MakeLabelEntry($Frame, "EC", "EC:", $this->{dini}->pVariable("EC", ''), "%g", $EntryWidth, "eV", 0, 1, "normal"); $Frame = $MainPaneFrame->MyLabFrame( -label => 'Doping', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $this->MakeLabelEntry($Frame, "ND", "ND:", $this->{dini}->pVariable("ND", 0.0), "%e", $EntryWidth, "cm-3", 0, 0, "normal"); $this->MakeLabelEntry($Frame, "ED", "ND:", $this->{dini}->pVariable("ED", 0.0), "%g", $EntryWidth, "eV", 0, 1, "normal"); $this->MakeLabelEntry($Frame, "NA", "NA:", $this->{dini}->pVariable("NA", 0.0), "%e", $EntryWidth, "cm-3", 1, 0, "normal"); $this->MakeLabelEntry($Frame, "EA", "EA:", $this->{dini}->pVariable("EA", 0.0), "%g", $EntryWidth, "eV", 1, 1, "normal"); $Frame = $MainPaneFrame->MyLabFrame( -label => 'Formation energy', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); # $this->MakeCheckEntry($Frame, "IgnoreS", "Ignore S for Gf", $this->{dini}->pVariable('IgnoreS', 0), # $this->{ini}->pVariable('IgnoreS', 1), "%g", $EntryWidth, "", 0, 0); # $this->MakeCheckEntry($Frame, "IgnoreSForMinHf", "Ignore S for Plot Hf-EF", $this->{dini}->pVariable('IgnoreSForMinHf', 0), # $this->{ini}->pVariable('IgnoreSForMinHf', 1), "%g", $EntryWidth, "", 0, 1); $Frame->MyCheckbutton( -text => "Ignore S for Gf ", -variable => $this->{ini}->pVariable('IgnoreS', 0), -onvalue => 1, -offvalue => 0, -indicatoron => 'no', -takefocus => 1, )->grid(-row => 0, -column => 0, -columnspan => 1, -sticky => 'e' ); # $this->{$ButtonLabel}->{status} = $$pCheckVariable; # $button->configure(-command => sub { print "$label1 is pressed [", $button->GetText(), "]\n"; }); $Frame->MyCheckbutton( -text => "Ignore S for Plot Hf-EF ", -variable => $this->{ini}->pVariable('IgnoreSForMinHf', 1), -onvalue => 1, -offvalue => 0, -indicatoron => 'no', -takefocus => 1, )->grid(-row => 0, -column => 1, -columnspan => 1, -sticky => 'e' ); # $Frame->MyEntry( # -name => "Emin", # -width => $EntryWidth, # -textvariable => $this->{dini}->pVariable("Emin", ''), # -format => "%g", # -takefocus => 1, # -state => 'normal' # )->grid(-row => 0, -column => 0, -columnspan => 1, -sticky => 'e' ); # $this->MakeCheckEntry($Frame, "EF", "EF:", $this->{dini}->pVariable('EFcheck', 0), # $this->{ini}->pVariable('EF', 0.0), "%g", $EntryWidth, "eV", 0, 0); $this->BuildFooter($MainPaneFrame, $EntryWidth); $this->UpdateParameters(); return; # $Frame = $MainPaneFrame->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); # my $Samplefmask = '*.csv;*.spe;*.jel;*.asp;*.smo;*isa;*.ref;*.pal;*.bef;*.aft;*.txt'; # $this->{SampleFileFrame} = $this->MakeChooseFileEntry( # $Frame, 'SampleCSV', 'Sample:', $this->{ini}->pVariable("SampleCSVFile", ""), # '&Choose', sub { # $this->{SampleCSV} = $this->ChooseFile("open", $Samplefmask, "ChooseSampleFile", @_); # $this->AssignGraphData(); # $this->Draw(); # }, # 0, sub {}, # 1, sub { $this->EditFile('EditSampleCSV', @_); }, # ['X1', 'Y1'] # ); # $this->{SampleFileFrame}->pack(-anchor => 'nw', -fill => 'x'); # $this->{SampleFileFrame}->{pXDataLabel} = ['.*E.*', '.*eV.*']; # $this->{SampleFileFrame}->{pYDataLabel} = ['.*signal.*', 'i.*', '.*']; $Frame = $MainPaneFrame->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); $this->mw()->{LSQFrame2} = $this->MakeLSQPanes( $Frame, $EntryWidth, 'Fitting', [qw(FittingRange)], [], [], ['FitXMin', 'Emin:', 'FitXMax', 'Emax:', 'nSkipData', 'nSkip:'], ['EPS', 'EPS:', 'nMaxIter', 'MaxIter:', 'nSaveSpectraInterval', 'SaveIntvl:'], ); $this->mw()->{LSQFrame2}->pack(-anchor => 'nw', -expand => 'yes', -fill => 'x'); my $lsb6 = $this->{ChooseConductionTypeListBox} = $Frame->MyBrowseEntry( -variable => $this->{ini}->pVariable('ConductionType', 'Metal'), -label => "Conduction Type:", -state => "readonly", -takefocus => 1, -width => 10, -Selections => ['Metal', 'Semiconductor'], -SelIndex => 0, )->pack(-side => 'left', -expand => 'yes', -fill => 'x'); $lsb6->configure(-browsecmd => sub { $this->SelChangeListBox("ConductionType", $this->{ChooseConductionTypeListBox}); }); $Frame = $MainPaneFrame->MyLabFrame( -label => 'Fermi-Dirac distribution', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $this->MakeCheckEntry($Frame, "EF", "EF:", $this->{dini}->pVariable('EFcheck', 0), $this->{ini}->pVariable('EF', 0.0), "%g", $EntryWidth, "eV", 0, 0); $this->MakeCheckEntry($Frame, "T", "T:", $this->{dini}->pVariable('Tcheck', 0), $this->{ini}->pVariable('T', 300.0), "%g", $EntryWidth, "K", 0, 1); $this->MakeCheckEntry($Frame, "Wa", "Wa:", $this->{dini}->pVariable('Wacheck', 1), $this->{ini}->pVariable('Wa', 0.1), "%g", $EntryWidth, "eV", 0, 2); $Frame = $MainPaneFrame->MyLabFrame( -label => 'Constant / Step BGs', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $this->MakeCheckEntry($Frame, "BG", "BG:", $this->{dini}->pVariable('BGcheck', 0), $this->{ini}->pVariable('BG', 0.0), "%g", $EntryWidth, "", 0, 0); for(my $i = 0 ; $i < $this->{ini}->{nStepBG} ; $i++) { $this->MakeCheckEntry($Frame, "EBG0$i", "E0:", $this->{dini}->pVariable("EBG0${i}check", 0), $this->{ini}->pVariable("EBG0$i", 0.0), "%g", $EntryWidth, "eV", $i+1, 0); $this->MakeCheckEntry($Frame, "BGLeft$i", "Left:", $this->{dini}->pVariable("BGLeft${i}check", 0), $this->{ini}->pVariable("BGLeft$i", 0.0), "%g", $EntryWidth, "", $i+1, 1); $this->MakeCheckEntry($Frame, "WBG$i", "W:", $this->{dini}->pVariable("WBG${i}check", 0), $this->{ini}->pVariable("WBG$i", 0.3), "%g", $EntryWidth, "eV", $i+1, 2); } $Frame = $MainPaneFrame->MyLabFrame( -label => 'Conduction / Valnce bands, Cut off, Secondary electron exponent', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $this->MakeCheckEntry($Frame, "ECBM", "ECBM:", $this->{dini}->pVariable('ECBMcheck', 0), $this->{ini}->pVariable('ECBM', 0.0), "%g", $EntryWidth, "eV", 0, 0); $this->MakeCheckEntry($Frame, "D0CB", "D0:", $this->{dini}->pVariable('D0CBcheck', 0), $this->{ini}->pVariable('D0CB', 0.0), "%g", $EntryWidth, "", 0, 1); $this->MakeCheckEntry($Frame, "k0Metal", "k0(metal):", $this->{dini}->pVariable('k0Metalcheck', 0), $this->{ini}->pVariable('k0Metal', 0.0), "%g", $EntryWidth, "", 0, 2); $this->MakeCheckEntry($Frame, "EVBM", "EVBM:", $this->{dini}->pVariable('EVBMcheck', 0), $this->{ini}->pVariable('EVBM', 0.0), "%g", $EntryWidth, "eV", 1, 0); $this->MakeCheckEntry($Frame, "D0VB", "D0:", $this->{dini}->pVariable('D0VBcheck', 0), $this->{ini}->pVariable('D0VB', 0.0), "%g", $EntryWidth, "", 1, 1); $this->MakeCheckEntry($Frame, "Ecut", "Ecut:", $this->{dini}->pVariable('Ecutcheck', 0), $this->{ini}->pVariable('Ecut', 0.0), "%g", $EntryWidth, "eV", 2, 0); $this->MakeCheckEntry($Frame, "K0Ecut", "K0:", $this->{dini}->pVariable('K0Ecutcheck', 0), $this->{ini}->pVariable('K0Ecut', 0.0), "%g", $EntryWidth, "", 2, 1); $this->MakeCheckEntry($Frame, "BGcut", "BG:", $this->{dini}->pVariable('BGcutcheck', 0), $this->{ini}->pVariable('BGcut', 0.0), "%g", $EntryWidth, "", 2, 2); $this->MakeCheckEntry($Frame, "C0Exp", "C0:", $this->{dini}->pVariable('C0Expcheck', 0), $this->{ini}->pVariable('C0Exp', 0.0), "%g", $EntryWidth, "", 3, 0); $this->MakeCheckEntry($Frame, "WExp", "W:", $this->{dini}->pVariable('WExpcheck', 0), $this->{ini}->pVariable('WExp', 1.0), "%g", $EntryWidth, "eV", 3, 1); $this->MakeCheckEntry($Frame, "BetaExp", "beta:", $this->{dini}->pVariable('BetaExpcheck', 0), $this->{ini}->pVariable('BetaExp', 1.0), "%g", $EntryWidth, "", 3, 2); # $Frame = $MainPaneFrame->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); $Frame = $MainPaneFrame->MyLabFrame( -label => 'Gauss-Lorentz functions', -labelside => 'acrosstop', )->pack(-side => 'top', -fill => 'x'); for(my $i = 0 ; $i < $this->{ini}->{nGL} ; $i++) { $this->MakeCheckEntry($Frame, "GLE0$i", "E0:", $this->{dini}->pVariable("GLE0${i}check", 0), $this->{ini}->pVariable("GLE0$i", 0.0), "%g", $EntryWidth, "eV", 2*$i, 0); $this->MakeCheckEntry($Frame, "GLC0$i", "C0:", $this->{dini}->pVariable("GLC0${i}check", 0), $this->{ini}->pVariable("GLC0$i", 0.0), "%g", $EntryWidth, "", 2*$i, 1); $this->MakeCheckEntry($Frame, "GLWL$i", "WL:", $this->{dini}->pVariable("GLWL${i}check", 0), $this->{ini}->pVariable("GLWL$i", 0.3), "%g", $EntryWidth, "", 2*$i, 2); $this->MakeCheckEntry($Frame, "GLGFraction$i", "GaussF:", $this->{dini}->pVariable("GLGFraction${i}check", 0), $this->{ini}->pVariable("GLGFraction$i", 1.0), "%g", $EntryWidth, "", 2*$i+1, 1); $this->MakeCheckEntry($Frame, "GLGWRatio$i", "WRatio:", $this->{dini}->pVariable("GLGWRatio${i}check", 0), $this->{ini}->pVariable("GLGWRatio$i", 1.0), "%g", $EntryWidth, "", 2*$i+1, 2); } $this->BuildFooter($MainPaneFrame, $EntryWidth); $this->UpdateParameters(); } sub BuildDefectsPane { my ($this, $MainPaneFrame, $EntryWidth) = @_; my $ini = $this->{ini}; my $pDefectHash = $ini->{pDefectHash}; my $pDefectHashLabels = $ini->{pDefectDataLabels}; my $pNames = $pDefectHash->{pOrderedNames}; if(!$pNames) { print("\nError in SemiconductorFromDFTDOS::BuildDefectsPane: Can not get pOrderedNames\n"); return; } my $Frame = $MainPaneFrame->MyLabFrame( -label => 'Defects', -labelside => 'acrosstop', )->pack(-side => 'top', -fill => 'x'); my $idx = 0; for(my $i = 0 ; $i < @$pNames ; $i++) { my $name = $pNames->[$i]; #print(" $name:\n"); my $pDefect = $pDefectHash->{$name}; #print "pDefect=$pDefect\n"; my $pQName = $pDefect->{pOrderedQ}; #print "pQName=$pQName\n"; for(my $j = 0 ; $j < @$pQName ; $j++) { my $q = $pQName->[$j]; my $pDefectQ = $pDefect->{$q}; #print "pDefectQ=$pDefectQ\n"; next if(!$pDefectQ); #print(" q=$q:\n"); $this->MakeLabelEntry($Frame, "DefectName$idx", "", \$pDefectQ->{Name}, "%s", $EntryWidth, "", $idx, 0, "normal"); $this->MakeLabelEntry($Frame, "Defectq$idx", "q:", \$pDefectQ->{q}, "%g", 3, "", $idx, 1, "normal"); $this->MakeLabelEntry($Frame, "Hf00$idx", "Hf00:", \$pDefectQ->{Hf00}, "%g", $EntryWidth, "", $idx, 2, "normal"); $this->MakeLabelEntry($Frame, "dS$idx", "dS:", \$pDefectQ->{dS}, "%g", 5, "", $idx, 3, "normal"); $this->MakeLabelEntry($Frame, "DefectSite$idx", "Site:", \$pDefectQ->{Site}, "%s", 5, "", $idx, 4, "normal"); # $this->MakeCheckEntry($Frame, "GLE0$i", "E0:", $this->{dini}->pVariable("GLE0${i}check", 0), # $this->{ini}->pVariable("GLE0$i", 0.0), "%g", $EntryWidth, "eV", 2*$i, 0); $idx++; } } } sub BuildVars1Pane { my ($this, $MainPaneFrame, $EntryWidth) = @_; return; my $Frame = $MainPaneFrame->MyLabFrame( -label => 'Fermi-Dirac distribution', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); my $row = 1; $this->MakeParameterConditionHeading($Frame, 0, 0); my @list = qw(EF T Wa); foreach my $key (@list) { $this->MakeParameterConditionColumn($Frame, "$key", "$key:", "%12.6g", $this->{dini}->pVariable("$key", 0.0), $this->{dini}->pVariable("${key}check", 0), $this->{dini}->pVariable("${key}scale", 0.1), $this->{dini}->pVariable("${key}min", ''), $this->{dini}->pVariable("${key}max", ''), $EntryWidth, $row++); } $Frame = $MainPaneFrame->MyLabFrame( -label => 'Constant / Step BGs', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $row = 1; $this->MakeParameterConditionHeading($Frame, 0, 0); my @list = qw(BG); foreach my $key (@list) { $this->MakeParameterConditionColumn($Frame, "$key", "$key:", "%12.6g", $this->{dini}->pVariable("$key", 0.0), $this->{dini}->pVariable("${key}check", 0), $this->{dini}->pVariable("${key}scale", 0.1), $this->{dini}->pVariable("${key}min", ''), $this->{dini}->pVariable("${key}max", ''), $EntryWidth, $row++); } for(my $i = 0 ; $i < $this->{ini}->{nStepBG} ; $i++) { my @list = qw(EBG0 BGLeft WBG); foreach my $key0 (@list) { my $key = "$key0$i"; $this->MakeParameterConditionColumn($Frame, "$key", "$key:", "%12.6g", $this->{dini}->pVariable("$key", 0.0), $this->{dini}->pVariable("${key}check", 0), $this->{dini}->pVariable("${key}scale", 0.1), $this->{dini}->pVariable("${key}min", ''), $this->{dini}->pVariable("${key}max", ''), $EntryWidth, $row++); } } $Frame = $MainPaneFrame->MyLabFrame( -label => 'Conduction / Valnce bands, Cut off, Secondary electron exponent', -labelside => 'acrosstop', )->pack(-anchor => 'nw'); $row = 1; $this->MakeParameterConditionHeading($Frame, 0, 0); my @list = qw(ECBM D0CB k0Metal EVBM D0VB Ecut K0Ecut BGcut C0Exp WExp BetaExp); foreach my $key (@list) { $this->MakeParameterConditionColumn($Frame, "$key", "$key:", "%12.6g", $this->{dini}->pVariable("$key", 0.0), $this->{dini}->pVariable("${key}check", 0), $this->{dini}->pVariable("${key}scale", 0.1), $this->{dini}->pVariable("${key}min", ''), $this->{dini}->pVariable("${key}max", ''), $EntryWidth, $row++); } $this->BuildFooter($MainPaneFrame, $EntryWidth); $this->UpdateParameters(); } sub BuildLSQPane { my ($this, $MainPaneFrame, $EntryWidth) = @_; return; my $Frame = $MainPaneFrame->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); $this->mw()->{LSQFrame} = $this->MakeLSQPanes( $Frame, $EntryWidth, 'Fitting', [qw(LSQMethod FittingRange FittingConditions)], # [qw(LSQMethod FitTo FittingRange FittingConditions)], ['Amoeba::Simplex', 'PDL::Simplex', 'ModifiedNewton'], ['PES'], ['FitXMin', 'Emin:', 'FitXMax', 'Emax:', 'nSkipData', 'nSkip:'], ['EPS', 'EPS:', 'nMaxIter', 'MaxIter:', 'nSaveSpectraInterval', 'SaveIntvl:'], ); $this->mw()->{LSQFrame}->pack(-anchor => 'nw', -expand => 'yes', -fill => 'x'); # $this->mw()->{LSQFrame}->{FitToListBox}->SetText('alpha'); $this->BuildFooter($MainPaneFrame, $EntryWidth); } sub BuildViewRangePane { my ($this, $MainFrame, $EntryWidth) = @_; $this->SUPER::BuildViewRangePane($MainFrame, $EntryWidth, [ ['x'], ['x'] ], [ ['x'], ['x'] ] ); if($this->mw()->{NoteBook}->{ViewRangePaneFrame}->{GraphFrame1ViewY0Button}) { $this->mw()->{NoteBook}->{ViewRangePaneFrame}->{GraphFrame1ViewY0Button}->Select(); $this->mw()->{NoteBook}->{ViewRangePaneFrame}->{GraphFrame1ViewY0Entry}->SetText(0.0); } $this->BuildFooter($MainFrame, $EntryWidth); } sub BuildFooter { my ($this, $MainFrame, $EntryWidth) = @_; my $Frame1 = $MainFrame->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); # my $ButtonFrame = $this->MakeFittingButtons($Frame1, ("Re&calc", "&Fit", "&Save")); my $ButtonFrame = $this->MakeFittingButtons($Frame1, ("&Plot")); $ButtonFrame->pack(-anchor => 'nw', -expand => 'yes', -fill => 'x'); # $this->{RestoreScaleButton}->configure( # -command => sub { $this->RestoreScale(); }, # ); # my $Frame = $MainFrame->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); # $this->{ChooseExcitatioListBox} = $ButtonFrame->MyBrowseEntry( # -label => "Excitation:", # -state => "readonly", # -takefocus => 1, # -width => 15, # -Selections => ["He I(21.2eV)", "He IIalpha(40.80eV)", "He IIbeta(48.36eV)", # "Ne I(16.7eV)", "Ne II(26.9eV)", "Al Ka(1486.6eV)", "Mg Ka(1253.6eV)", # "HX-PES(BL47XU, 7935.2eV)", "HX-PES(BL15XU, 5950.2eV)"], # -SelIndex => 0, # )->pack(-side => 'left'); } sub Plot { my ($this, $ResetViewRange, $CreateGraphFrame, $AssignGraphData, $Draw) = @_; $this->CalPlotHfEF(); $this->Recalc(); } sub CalPlotHfEF { my ($this) = @_; print("Make Hf-EF data for plotting most stable charge states\n"); my $ini = $this->{ini}; my $dini = $this->{dini}; my $s = $this->{pSemiconductorFromDFT}; my $pDefectHash = $ini->{pDefectHash}; my $pDefectHashLabels = $ini->{pDefectDataLabels}; my $pNames = $pDefectHash->{pOrderedNames}; my $Estep = ($dini->{Emax} - $dini->{Emin}) / ($dini->{nE} - 1); my $pNames = $pDefectHash->{pOrderedNames}; for(my $i = 0 ; $i < @$pNames ; $i++) { my $name = $pNames->[$i]; print(" $name:\n"); my $pInf = $s->FindTransitionEnergies(undef, $name, $dini->{Tdefect}, $dini->{Emin}, $dini->{Emax}, $dini->{IgnoreSForMinHf}); for(my $j = 0 ; $j < @$pInf ; $j++) { my $p = $pInf->[$j]; if(defined $p->{q}) { print " EF=$p->{E}: Min q=$p->{q} Hf=$p->{Hf}\n"; } else { print " Et=$p->{E} => q=$p->{qhigher} Hf=$p->{Hf}\n"; } } } } #=================================================== # データ処理 #=================================================== sub BuildOptimize { my ($this, $IsPrint) = @_; $IsPrint = 1 if(!defined $IsPrint); my $ini = $this->{ini}; my $dini = $this->{dini}; my $optimize = $this->{Optimize} = new Optimize;; $optimize->AddParameters( "EF", \$ini->{EF}, $dini->{EFcheck}, $dini->{EFscale}, $dini->{EFmin}, $dini->{EFmax}, sub { $ini->{EF} = $_[0]; }, "Wa", \$ini->{Wa}, $dini->{Wacheck}, $dini->{Wascale}, $dini->{Wamin}, $dini->{Wamax}, sub { $ini->{Wa} = $_[0]; }, "BG", \$ini->{BG}, $dini->{BGcheck}, $dini->{BGscale}, $dini->{BGmin}, $dini->{BGmax}, sub { $ini->{BG} = $_[0]; }, ); for(my $i = 0 ; $i < $this->{ini}->{nStepBG} ; $i++) { my $ii = $i; $optimize->AddParameters( "EBG0$ii", \$ini->{"EBG0$ii"}, $dini->{"EBG0${ii}check"}, $dini->{"EBG0${ii}scale"}, $dini->{"EBG0${ii}min"}, $dini->{"EBG0${ii}max"}, sub { $ini->{"EBG0$ii"} = $_[0]; }, "BGLeft$ii", \$ini->{"BGLeft$ii"}, $dini->{"BGLeft${ii}check"}, $dini->{"BGLeft${ii}scale"}, $dini->{"BGLeft${ii}min"}, $dini->{"BGLeft${ii}max"}, sub { $ini->{"BGLeft$ii"} = $_[0]; }, "WBG$ii", \$ini->{"WBG$ii"}, $dini->{"WBG${ii}check"}, $dini->{"WBG${ii}scale"}, $dini->{"WBG${ii}min"}, $dini->{"WBG${ii}max"}, sub { $ini->{"WBG$ii"} = $_[0]; }, ); } $optimize->AddParameters( "ECBM", \$ini->{ECBM}, $dini->{ECBMcheck}, $dini->{ECBMscale}, $dini->{ECBMmin}, $dini->{ECBMmax}, sub { $ini->{ECBM} = $_[0]; }, "D0CB", \$ini->{D0CB}, $dini->{D0CBcheck}, $dini->{D0CBscale}, $dini->{D0CBmin}, $dini->{D0CBmax}, sub { $ini->{D0CB} = $_[0]; }, "k0Metal", \$ini->{k0Metal}, $dini->{k0Metalcheck}, $dini->{k0Metalscale}, $dini->{k0Metalmin}, $dini->{k0Metalmax}, sub { $ini->{k0Metal} = $_[0]; }, "EVBM", \$ini->{EVBM}, $dini->{EVBMcheck}, $dini->{EVBMscale}, $dini->{EVBMmin}, $dini->{EVBMmax}, sub { $ini->{EVBM} = $_[0]; }, "D0VB", \$ini->{D0VB}, $dini->{D0VBcheck}, $dini->{D0VBscale}, $dini->{D0VBmin}, $dini->{D0VBmax}, sub { $ini->{D0VB} = $_[0]; }, "Ecut", \$ini->{Ecut}, $dini->{Ecutcheck}, $dini->{Ecutscale}, $dini->{Ecutmin}, $dini->{Ecutmax}, sub { $ini->{Ecut} = $_[0]; }, "K0Ecut", \$ini->{K0Ecut}, $dini->{K0Ecutcheck}, $dini->{K0Ecutscale}, $dini->{K0Ecutmin}, $dini->{K0Ecutmax}, sub { $ini->{K0Ecut} = $_[0]; }, "BGcut", \$ini->{BGcut}, $dini->{BGcutcheck}, $dini->{BGcutscale}, $dini->{BGcutmin}, $dini->{BGcutmax}, sub { $ini->{BGcut} = $_[0]; }, "C0Exp", \$ini->{C0Exp}, $dini->{C0Expcheck}, $dini->{C0Expscale}, $dini->{C0Expmin}, $dini->{C0Expmax}, sub { $ini->{C0Exp} = $_[0]; }, "WExp", \$ini->{WExp}, $dini->{WExpcheck}, $dini->{WExpscale}, $dini->{WExpmin}, $dini->{WExpmax}, sub { $ini->{WExp} = $_[0]; }, "BetaExp", \$ini->{BetaExp}, $dini->{BetaExpcheck}, $dini->{BetaExpscale}, $dini->{BetaExpmin}, $dini->{BetaExpmax}, sub { $ini->{BetaExp} = $_[0]; }, ); for(my $i = 0 ; $i < $this->{ini}->{nGL} ; $i++) { my $ii = $i; $optimize->AddParameters( "GLE0$ii", \$ini->{"GLE0$ii"}, $dini->{"GLE0${ii}check"}, $dini->{"GLE0${ii}scale"}, $dini->{"GLE0${ii}min"}, $dini->{"GLE0${ii}max"}, sub { $ini->{"GLE0$ii"} = $_[0]; }, "GLC0$ii", \$ini->{"GLC0$ii"}, $dini->{"GLC0${ii}check"}, $dini->{"GLC0${ii}scale"}, $dini->{"GLC0${ii}min"}, $dini->{"GLC0${ii}max"}, sub { $ini->{"GLC0$ii"} = $_[0]; }, "GLWL$ii", \$ini->{"GLWL$ii"}, $dini->{"GLWL${ii}check"}, $dini->{"GLWL${ii}scale"}, $dini->{"GLWL${ii}min"}, $dini->{"GLWL${ii}max"}, sub { $ini->{"GLWL$ii"} = $_[0]; }, "GLGFraction$ii", \$ini->{"GLGFraction$ii"}, $dini->{"GLGFraction${ii}check"}, $dini->{"GLGFraction${ii}scale"}, $dini->{"GLGFraction${ii}min"}, $dini->{"GLGFraction${ii}max"}, sub { $ini->{"GLGFraction$ii"} = $_[0]; }, "GLGWRatio$ii", \$ini->{"GLGWRatio$ii"}, $dini->{"GLGWRatio${ii}check"}, $dini->{"GLGWRatio${ii}scale"}, $dini->{"GLGWRatio${ii}min"}, $dini->{"GLGWRatio${ii}max"}, sub { $ini->{"GLGWRatio$ii"} = $_[0]; }, ); } } sub Recalc { my ($this) = @_; return if(!defined $this->{DataFile}); my $ini = $this->{ini}; return; # $ini->{AppFunction} = $this->{ChooseAppFunctionListBox}->GetText(); my $ConductionType = $this->{ini}->{ConductionType}; #$this->{ChooseConductionTypeListBox}->GetText(); my $IsMetal = 0; $IsMetal = 1 if($ConductionType eq 'Metal'); my $X1Label = $this->{SampleFileFrame}->{X1ListBox}->GetText(); my $Y1Label = $this->{SampleFileFrame}->{Y1ListBox}->GetText(); my $XMin = $ini->{FitXMin}; my $XMax = $ini->{FitXMax}; my $nSkipData = $ini->{nSkipData}; my $pX = $this->{DataFile}->GetData($X1Label) if($X1Label); my $pY1 = $this->{DataFile}->GetData($Y1Label) if($Y1Label); my (@X, @Y); my $c = 0; for(my $i = 0 ; $i < @$pX ; $i++) { my $x = $pX->[$i]; next if($x < $XMin or $XMax < $x); next if($nSkipData > 0 and $i % $nSkipData != 0); $X[$c] = $x; $Y[$c] = $pY1->[$i]; $c++; } $this->{pCalX} = \@X; my ($pY, $pCB, $pVB, $pCBFD, $pVBFD, $pGLArray, $pFD, $pBG) = PES::CalTotalDOSSpectrum(\@X, $this->{ini}, $IsMetal); $this->{pObsY} = \@Y; $this->{pCalY} = $pY; $this->{pCalCB} = $pCB; $this->{pCalVB} = $pVB; $this->{pCalCBFD} = $pCBFD; $this->{pCalVBFD} = $pVBFD; $this->{pCalGLArray} = $pGLArray; $this->{pCalFD} = $pFD; $this->{pCalBG} = $pBG; $this->SUPER::RePlot(); } sub Fit { my ($this) = @_; return if(!defined $this->{DataFile}); my $App = $this->App(); my $optics = new Optics; my $ini = $this->{ini}; $this->UpdateParameters(); $this->BuildOptimize(); my $Method = $this->mw()->{LSQFrame}->{LSQMethodListBox}->GetText(); #$this->{LSQMethodListBox}->GetText(); my $optimize = $this->{Optimize}; print "Method: $Method\n"; print "nMaxIter: $ini->{nMaxIter}\n"; # $this->{ini}->{AppFunction} = $this->{ChooseAppFunctionListBox}->GetText(); my $ConductionType = $this->{ini}->{ConductionType}; #$this->{ChooseConductionTypeListBox}->GetText(); my $IsMetal = 0; $IsMetal = 1 if($ConductionType eq 'Metal'); my $X1Label = $this->{SampleFileFrame}->{X1ListBox}->GetText(); my $Y1Label = $this->{SampleFileFrame}->{Y1ListBox}->GetText(); my $XMin = $ini->{FitXMin}; my $XMax = $ini->{FitXMax}; my $nSkipData = $ini->{nSkipData}; my $pX = $this->{DataFile}->GetData($X1Label) if($X1Label); my $pY1 = $this->{DataFile}->GetData($Y1Label) if($Y1Label); my (@X, @Y); my $c = 0; for(my $i = 0 ; $i < @$pX ; $i++) { my $x = $pX->[$i]; next if($x < $XMin or $XMax < $x); next if($nSkipData > 0 and $i % $nSkipData != 0); $X[$c] = $x; $Y[$c] = $pY1->[$i]; $c++; } #========================================================= # 最適化の実行 #========================================================= $optimize->SetnS2Calculation(0); my ($OptVars, $MinVal) = $optimize->Optimize( $Method, undef, undef, undef, $ini->{EPS}, $ini->{nMaxIter}, $ini->{iPrintLevel}, sub { $this->CalS2(\@X, \@Y, $IsMetal, @_); }, undef, sub { Optimize::BuildDifferentialMatrixes(@_); }, ); print "\nOptimized at:\n"; $optimize->RecoverParameters($OptVars); $optimize->PrintParameters(1, $OptVars, $MinVal, 1); $this->SetS2($MinVal); $this->UpdateParameters(); $this->Recalc(); } sub CalS2 { my ($this, $pX, $pY, $IsMetal, $pVars, $iPrintLevel) = @_; #print "pVars=", join(',', @$pVars); my $optimize = $this->{Optimize}; my $ini = $this->{ini}; $optimize->RecoverParameters($pVars); my ($pCalY) = PES::CalTotalDOSSpectrum($pX, $ini, $IsMetal); my $S2 = 0.0; my $c = 0; for(my $i = 0 ; $i < @$pX ; $i++) { my $x = $pX->[$i]; my $d = $pCalY->[$i] - $pY->[$i]; $S2 += $d * $d; $c++; } $S2 = sqrt($S2 / $c) if($c > 0); $optimize->IncrementnS2(); my $nS2 = $optimize->nS2Calculation(); my $nS2Interval = $ini->{nSaveSpectraInterval}; print "S2[$nS2] = $S2 / "; $S2 += $optimize->CalPenalty(1.0e10, $pVars, 1); print "$S2\n"; $optimize->PrintParameters(1, $pVars, $S2, 0); if($nS2Interval > 0 and $nS2 % $nS2Interval == 0) { $this->SetS2($S2); $this->Recalc(); $this->RePlot(); } $this->UpdateParameters(); $this->mw()->update(); return $S2; } sub CreateGraphFrame { my ($this, $canvas, $TargetData, $DoUpdate) = @_; return if(!$DoUpdate and $this->GetGraphFrameArray()); $canvas = $this->Canvas(); my $App = $this->App(); my $font = $App->{GraphFrameFont}; my @font = split(/,/, $font) if($font); my $w = $canvas->width(); my $h = $canvas->height(); my $RefreshGraphScaleFrame = (defined $this->{GraphFrameArray})? 0 : 1; my $GraphFrameArray = $this->{GraphFrameArray} = new GraphFrameArray($this->mw()); $GraphFrameArray->SetCanvasSize($w, $h); $GraphFrameArray->AddGraphFrame(); my $GraphFrame0 = $GraphFrameArray->GetGraphFrame(0); my $FramePosStr0 = $App->{GraphFrame0Position}; $GraphFrame0->SetPositionByStr($FramePosStr0); my $XScale0 = $GraphFrame0->GetXScale(0); my $YScale0 = $GraphFrame0->GetYScale(0); $XScale0->SetScaleStringVisible(1); $XScale0->SetCaptionVisible(1); $GraphFrame0->SetViewRange(0, 0, 1, 1); if($RefreshGraphScaleFrame) { my $EntryWidth = $this->{EntryWidth}; $this->RefreshViewRangePane($EntryWidth); } } sub AssignGraphData { my ($this, $ResetViewRange) = @_; $ResetViewRange = 1 if(!defined $ResetViewRange); return if(!defined $this->{ini}->{SampleCSVFile}); return if(!defined $this->mw()->{NoteBook}->{ViewRangePaneFrame}->{GraphFrame1YAxisListBox}); my $GraphFrameArray = $this->GetGraphFrameArray(); my $GraphFrame0 = $GraphFrameArray->GetGraphFrame(0); $GraphFrame0->ClearAllData(); my $X1Label = $this->{SampleFileFrame}->{X1ListBox}->GetText(); $X1Label = 'X' if(!$X1Label); my $Y1Label = $this->{SampleFileFrame}->{Y1ListBox}->GetText(); $Y1Label = 'Y1' if(!$Y1Label); $GraphFrame0->SetXCaption($X1Label); $GraphFrame0->SetYCaption($Y1Label); my $pX = $this->{DataFile}->GetData($X1Label) if($X1Label); my $pY1 = $this->{DataFile}->GetData($Y1Label) if($Y1Label); my $nData = $this->{DataFile}->nData(); if($pX) { $GraphFrame0->AddGraphData($pX, $pY1, 2, "black", "", 6, "red", 0, "red", "XAutoSkip", "Energy", "${Y1Label}") if($pY1); } my $pCalX = $this->{pCalX}; my $pCalY = $this->{pCalY}; my $pCB = $this->{pCalCB}; my $pVB = $this->{pCalVB}; my $pCBFD = $this->{pCalCBFD}; my $pVBFD = $this->{pCalVBFD}; my $pGLArray = $this->{pCalGLArray}; my $pFD = $this->{pCalFD}; my $pBG = $this->{pCalBG}; if($pCalX) { $GraphFrame0->AddGraphData($pCalX, $pCalY, 0, "", "circle", 3, "", 1, "red", "XAutoSkip", "Energy", "FT ${Y1Label}(real)") if($pCalY); $GraphFrame0->AddGraphData($pCalX, $pCB, 1, "blue", "", 3, "", 1, "red", "XAutoSkip", "Energy", "CB(cal)") if($pCB); $GraphFrame0->AddGraphData($pCalX, $pVB, 1, "blue", "", 3, "", 1, "red", "XAutoSkip", "Energy", "VB(cal)") if($pVB); $GraphFrame0->AddGraphData($pCalX, $pCBFD, 1, "green", "", 3, "", 1, "red", "XAutoSkip", "Energy", "CB*FD(cal)") if($pCBFD); $GraphFrame0->AddGraphData($pCalX, $pVBFD, 1, "green", "", 3, "", 1, "red", "XAutoSkip", "Energy", "VB*FD(cal)") if($pVBFD); for(my $i = 0 ; $i < $this->{ini}->{nGL} ; $i++) { $GraphFrame0->AddGraphData($pCalX, $pGLArray->[$i], 1, "blue", "", 3, "", 1, "red", "XAutoSkip", "Energy", "GL${i}(cal)") if($pGLArray->[$i]); } $GraphFrame0->AddGraphData($pCalX, $pBG, 1, "cyan", "", 3, "", 1, "red", "XAutoSkip", "Energy", "BG(cal)") if($pBG); } $GraphFrame0->SetXScalePlotType('x'); $GraphFrame0->SetYScalePlotType('x'); $this->SetViewRange($ResetViewRange); } sub SaveParameterFile { my ($this, $Option, $filepath, $name, $Frame) = @_; $filepath = $Frame->{PathEntry}->GetText() if($filepath eq ''); $this->{ini}->{SampleX1} = $this->{SampleFileFrame}->{X1ListBox}->GetText(); $this->{ini}->{SampleY1} = $this->{SampleFileFrame}->{Y1ListBox}->GetText(); # $this->{ini}->{AppFunction} = $this->{ChooseAppFunctionListBox}->GetText(); # $this->{ini}->{ConductionType} = $this->{ChooseConductionTypeListBox}->GetText(); $this->{ini}->{YAxisPlotType} = $this->mw()->{NoteBook}->{ViewRangePaneFrame}->{GraphFrame1YAxisListBox}->GetText(); if(!defined $filepath or $filepath eq '') { $filepath = $this->{ini}->{Sample1CSVFile}; $filepath = $this->{ini}->{SampleCSVFile} if(!defined $filepath or $filepath eq ''); $filepath = $this->{ini}->{SubstrateCSVFile} if(!defined $filepath or $filepath eq ''); $filepath = 'save.prm' if(!defined $filepath or $filepath eq ''); $filepath =~ s/\.[^\.]+$/\.prm/i; # $filepath =~ s/\.csv$/\.prm/i; $filepath = Deps::ExtractFileName($filepath); $filepath = $this->ChooseSaveFile($filepath, '*.prm'); if($filepath) { my $ext = Deps::ExtractExtention($filepath); if(!defined $ext or $ext eq '') { $filepath = Deps::ReplaceExtension($filepath, ".prm"); } $this->{ini}->{ParameterFile} = $filepath; } else { return; } } $this->{ini}->SetIniFile($filepath, undef, 1); $this->App()->print("\nSaveParameterFile:\n"); $this->ComposeParameters($this->{dini}, $this->{ini}); $this->{ini}->WriteAll(); $this->DecomposeParameters($this->{ini}, $this->{dini}); } sub ReadParameterFile { my ($this, $filepath) = @_; my $ini = $this->{ini}; my $dini = $this->{dini}; $this->Initialize(1, 1); $this->App()->print("\nRead paramter from [$filepath].\n"); my $s = $this->{pSemiconductorFromDFT} = new SemiconductorFromDFT; my ($pIn, $pParameters, $pDefect) = $s->ReadInputCSV($filepath, 0); #print "p[$pIn, $pParameters, $pDefect]\n"; #my $App = new MyApplication; # $s->PrintParameters($App, $pParameters, $pDefect) = @_; if($pParameters->{CARDir} !~ /^[\\\/]/ and $pParameters->{CARDir} !~ /:/) { my ($drive, $directory, $filename, $ext1, $lastdir, $filebody) = Deps::SplitFilePath($filepath); $pParameters->{CARDir} = Utils::MakePath("$drive$directory", $pParameters->{CARDir}, '/', 0); Utils::ReduceDirectory($pParameters->{CARDir}, '/'); } Utils::MergeHash($ini, $pParameters); Utils::MergeHash($dini, $pParameters); $ini->{pParameterHash} = $pIn->{pParameterHash}; $ini->{pDefectHash} = $pIn->{pDefectHash}; $ini->{pDefectDataLabels} = $pIn->{pDefectDataLabels}; foreach my $key (sort keys %$ini) { print " $key: $ini->{$key}\n"; } $this->{ChooseActionListBox}->SetText($dini->{Action}); print("\nRead DFT Data from [$dini->{CARDir}]\n"); my ($EF, $VBM, $CBM, $Eg, $pDOSupArray, $pDOSdnArray, $pEDOS, $pTDOS, $INCARHash, $KPOINTSHash, $VCRelaxKPOINTSHash, $POTCARHash, $POSCARHash, $SCFOUTCARHash, $VCROUTCARHash) = $s->ReadDFTData(undef, $pParameters->{CARDir}); if(!$EF) { print("Error: Can not read [$dini->{CARDir}]\n"); return; } $ini->{EV} = $dini->{EV} = $VBM; $ini->{EC} = $dini->{EC} = $CBM; $this->RefreshMainPane($this->{EntryWidth}); $this->RefreshPane("Defects", $this->{EntryWidth}); $this->RefreshViewRangePane($this->{EntryWidth}); $this->RePlot(0, 1, 0, 0); return 1; } sub Initialize { my ($this, $InitializeParameterFile, $InitializeData) = @_; $this->{DataFile} = new Ellipsometry; if($InitializeParameterFile) { # $this->{ini}->{SampleCSVFile} = ''; # $this->{ini}->{FitXMin} = ''; # $this->{ini}->{FitXMax} = ''; } if($InitializeData) { # $this->{pCalX} = undef; # $this->{pCalY} = undef; } } sub InitializeParameters { my ($this, $ini, $dini) = @_; return; $this->AddParameters($ini, $dini, "EF", 0.0, 1, 1.0, '', ''); $this->AddParameters($ini, $dini, "T", 300.0, 0, 10.0, 0.0, ''); $this->AddParameters($ini, $dini, "Wa", 0.1, 1, 0.2, 0.0, ''); $this->AddParameters($ini, $dini, "BG", 0.0, 1, 1000.0, 0.0, ''); for(my $i = 0 ; $i < $this->{ini}->{nStepBG} ; $i++) { $this->AddParameters($ini, $dini, "EBG0$i", 0.0, 0, 1.0, '', ''); $this->AddParameters($ini, $dini, "BGLeft$i", 0.0, 0, 1000.0, 0.0, ''); $this->AddParameters($ini, $dini, "WBG$i", 0.1, 0, 1.0, 0.0, ''); } } 1;