Materials Studio脚本使用,索引值无效怎么解决

qq_42708916 2022-08-01 16:58:48

程序:

#!perl

use strict;
use Getopt::Long;
use MaterialsScript qw(:all);
#Edited by HUASUAN-YANG, contact Wechat ID "Nininncole" to learn more

my $hex="63726561746564206279204855415355414e2d59414e472c207468697320697320612070617274206f66204855415355414e204d6174657269616c732053747564696f20747261696e696e6720636f75727365732e20506c6561736520636f6e746163742057656368617420494420274e696e696e6e636f6c652720666f72206d6f726520696e666f726d6174696f6e2e";
my $str = pack('H*', $hex);
print "$str \n";

my $doc=$Documents{"Layer.xsd"};
my $field = $doc->AsymmetricUnit->Fields("CASTEP SCF local potential"); # or "CASTEP density difference from atoms" 
my $fieldProbe = $field->CreateFieldProbe([ProbeMode => "NearestGridPoint"]);

my $xExtent = $field->GridExtent1;# - $insideField;
my $yExtent = $field->GridExtent2;# - $insideField;
my $zExtent = $field->GridExtent3;# - $insideField;

for (my $z=0; $z<$zExtent; ++$z) {
    my $coorz = $z*$doc->SymmetryDefinition->LengthC/$zExtent;
    my $xyfieldtotal = 0;
    for (my $y=0; $y<$yExtent; ++$y) {
        for (my $x=0; $x<$xExtent; ++$x) {
            $fieldProbe->ProbeVoxelPosition = Point(X => $x, Y => $y, Z => $z);
            #print $fieldProbe->FieldValue;
            $xyfieldtotal = $xyfieldtotal + $fieldProbe->FieldValue;
        }
    }
    my $ave=$xyfieldtotal/$xExtent/$yExtent;
    print "$coorz  $ave\n"
}
$fieldProbe->HasFieldLock = "No";

 运行结果:

The index value is invalid (function/property "Fields") at -e line 13.

 

...全文
42 1 打赏 收藏 举报
写回复
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
tanqth 08-02

怎么发到DELPHI区了

  • 打赏
  • 举报
回复
发帖
Delphi

5138

社区成员

Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
帖子事件
创建了帖子
2022-08-01 16:58
社区公告
暂无公告