计算化学公社

标题: MS计算过程中出现restart文件怎么解决 [打印本页]

作者
Author:
刘喜洋    时间: 2026-4-3 21:52
标题: MS计算过程中出现restart文件怎么解决
首先附上计算的perl脚本代码,其功能是使用AC盒子建模,并转为xyz文件,便于后续的计算孔径,随后采用sorption模块计算吸附等温线
x


作者
Author:
刘喜洋    时间: 2026-4-3 21:55
由于一直无法发帖(说有敏感词啥的,现在我在帖子中补充其它的内容)

问题的出现,在我一开始运行该脚本代码的时候,超算16核1小时左右即可计算完毕,随后我在不同文件夹下提交计算两到三次之后,突然发现计算速度特别慢,于是我就测试了一下,发现同样的脚本代码,第一次运行只需要1小时左右,而后续的提交计算需要一天都没计算完,核心数相同,观察发现(如图1),计算时间很长的作业中,出现了Restart等文件,此前同样的代码运行没有出现这些文件,不知道为什么会这样,图2中计算只需要一小时

下述的代码有一点小问题,循环计算第二次时会报错,但是不影响第一次的运行

想咨询一下各位大佬,有遇到过这种问题吗



作者
Author:
刘喜洋    时间: 2026-4-3 21:55
本帖最后由 刘喜洋 于 2026-4-3 21:59 编辑
刘喜洋 发表于 2026-4-3 21:55
由于一直无法发帖(说有敏感词啥的,现在我在帖子中补充其它的内容)

问题的出现,在我一开始运行该脚本 ...
图1图2如图所示,可以看到同样的代码运行,计算时间天差地别,很奇怪,无法解决
脚本如下


#!perl
use strict;
use Getopt::Long;
use MaterialsScript qw(:all);
our %Documents;
# ================= 配置参数 =================
my $start_probe = 0.0;    # 初始探针半径 (Å)
my $end_probe = 5.0;     # 终止探针半径 (Å,可根据活性炭孔径调整)
my $step_probe = 0.5;     # 探针半径递增步长 (Å)
my $grid_interval = 0.4;  # 网格间隔 (Å,保持原脚本推荐值)

# ================= 活性炭建模 =================
my $acConstruction = Modules->AmorphousCell->Construction;

# 添加环状结构组分
my $component1 = $Documents{"7ring.xsd"};
$acConstruction->AddComponent($component1);
$acConstruction->Loading($component1) = 3;

my $component2 = $Documents{"19ring.xsd"};
$acConstruction->AddComponent($component2);
$acConstruction->Loading($component2) = 3;

my $component3 = $Documents{"37ring.xsd"};
$acConstruction->AddComponent($component3);
$acConstruction->Loading($component3) = 3;




foreach my $i (1..2) {
my $min = 1;   # 或者你想要的固定值
my $max = 10; # 或者你想要的固定值
my $val1 = int($min + rand() * ($max - $min + 1));
my $val2 = int($min + rand() * ($max - $min + 1));
my $val3 = int($min + rand() * ($max - $min + 1));
# ================= 活性炭建模 =================
my $acConstruction = Modules->AmorphousCell->Construction;


$acConstruction->Loading($component1) = $val1;

$acConstruction->Loading($component2) = $val2;

$acConstruction->Loading($component3) = $val3;

# 运行无定形胞建模
my $results = $acConstruction->Run(Settings(
    Quality => 'Fine',
    TargetDensity => 0.55,
    CurrentForcefield => 'COMPASSIII'));
my $doc = $results->Trajectory;

# 几何优化
my $go_results = Modules->Forcite->GeometryOptimization->Run($doc, Settings(
        ChargeAssignment => 'Use current'));
$doc = $go_results->Trajectory;  # 更新为优化后的结构

$doc->SaveAs("ActivatedCarbon_Optimized-$i-$val1-$val2-$val3.xtd");

# ================= 1.84A计算  计算出比表面积等参数 =================
my $fieldConnolly = Tools->AtomVolumesSurfaces->Connolly->Calculate($doc, Settings(
        GridInterval => $grid_interval,
        ConnollyRadius => 1.84  # 动态设置探针半径
    ));
$fieldConnolly->Style = "None";
   
  # 提取总体积与占据体积,计算自由体积
my $field_volume = $fieldConnolly->FieldVolume;
my $isosurface = $fieldConnolly->CreateIsosurface([
    IsoValue => 0.0,
    HasFlippedNormals => "No"
]);
my $enclosed_volume = $isosurface->EnclosedVolume;
my $Surface_Area=$isosurface->SurfaceArea;

my $free_volume = $field_volume - $enclosed_volume;

printf "自由体积 %.2f ų | 整体体积 %.2f Ų | 表面积 %.2f ų |loading1%.2f|loading2%.2f|loading3%.2f\n",
        $free_volume, $field_volume,$Surface_Area,$val1,$val2,$val3;

#转换为xyz文件

my $trajectory = $doc->Trajectory;

if ($trajectory->NumFrames >= 1) {

    print "Found ".$trajectory->NumFrames." frames in the trajectory\n";
    # Open new xmol trajectory file
    my $xmolFile = Documents->New("trj_$i.txt");
   
    #get atoms in the structure
    my $atoms = $doc->DisplayRange->Atoms;
    my $Natoms = scalar(@$atoms);  # 修复:定义原子总数

    # loops over the frames
    my $framebegin = 1;
    my $frameend = $trajectory->NumFrames;
    # 如需只转前10帧,去掉下面一行的 #
    # my $frameend = 10;

    for (my $frame = $framebegin; $frame <= $frameend; ++$frame) {
        $trajectory->CurrentFrame = $frame;
        # write header xyz
        $xmolFile->Append(sprintf "%i \n", $Natoms);
        $xmolFile->Append(sprintf "%s %i \n", "Frame", $frame);
        
        foreach my $atom (@$atoms) {
            # write atom symbol and x-y-z- coordinates
            $xmolFile->Append(sprintf "%s %f  %f  %f \n",
                $atom->ElementSymbol, $atom->X, $atom->Y, $atom->Z);
        }   
    }
    #close trajectory file
    $xmolFile->Close;
    print "转换完成!已生成 trj.txt\n";
}
else {
    print "The " . $doc->Name . " is not a multiframe trajectory file \n";
}


#吸附等温线计算模块
my $sorptionAdsorptionIsotherm = Modules->Sorption->AdsorptionIsotherm;
my $component_H2 = $Documents{"H2-2020.xsd"};
$sorptionAdsorptionIsotherm->AddComponent($component_H2);
$sorptionAdsorptionIsotherm->FugacityStart($component_H2) = 10;
$sorptionAdsorptionIsotherm->FugacityEnd($component_H2) = 1000;
my $results = $sorptionAdsorptionIsotherm->Run($doc, Settings(
        ChargeAssignment => 'Use current',
        Temperature => 50,
        UseFugacityLogScale => 'Yes'));

}

















欢迎光临 计算化学公社 (http://bbs.keinsci.com/) Powered by Discuz! X3.3