- 论坛徽章:
- 0
|
走过路过的大神们,请帮忙看下下面这段代码中为何写出Script.txt文件
- #!perl
- use strict;
- use Getopt::Long;
- use MaterialsScript qw(:all);
- my $a = 1;
- my $myDoc = $Documents{"$a.xsd"};
- my $stressz;
- sub castepcalculation ($stressz) {
- my ($stressz) = @_;
- my $castep = Modules->CASTEP;
- $castep->ChangeSettings(
- Settings(
- Task => "Geometry Optimization",
- NonLocalFunctional => "PBE",
- UseCustomEnergyCutoff => "Yes",
- EnergyCutoff => 350,
- SCFConvergence => 5e-002,
- MaximumSCFCycles => 200,
- CalculateStress => "Yes",
- OptimizeCell => "Yes",
- EnergyConvergence => 5e-001,
- Sxx => 0,
- Syy => 0,
- Szz => "$stressz",
- Quality => "Ultra-fine",
- # PropertiesKPointQuality => "Fine"
- KPointDerivation => "CustomGrid",
- ParameterA => 1,
- ParameterB => 1,
- ParameterC => 1
- )
- );
- $castep->GeometryOptimization->Run($myDoc);
- }
- for ( my $stressz = 0 ; $stressz <= 3 ; ++$stressz ) {
- &castepcalculation($stressz); #calculate the results files by castep module
- #Processing result file
- open( result, "$a.castep" || die("open 1.castep fasiled") );
- open( OUTFILE, ">>Script.txt" );
- my @line = ();
- my $count = 1;
- my $perlscript = "/Documents/script/try2";
- my $outputName;
- @line = <result>;
- while ( $count <= @line ) #$line[count]
- {
- if ($line[$count] =~ /" BFGS : Geometry optimization completed successfully."/ )
- {
- open (OUTFILE, ">>Script.txt") || die ("write Script.out fasiled");
- printf OUTFILE ("stressz=%d Lattice=%2.8f \n",$stressz,$line[$count+17]);
- opendir(filedir,"$perlscript" || die "open dir-try2 fasiled" );
- last;
- }
- else{
- if ( $count < @line ){
- $count++;
- }
- redo &castepcalculation if($count = @line);
- }
- }
- }
复制代码 |
|