4步出图!相互作用能/结合能脚本:用法、视频、注解、代码全文!
4步出图!相互作用能/结合能脚本:用法、视频、注解、代码全文!
jisuancailiao
计算材料学科研论坛,欢迎新手、专家、大师以及业余爱好者。
【DFT入门资料下载】
呕血整理 | 50篇DFT计算开山级必引论文集,MS、VASP、QE、Gaussian、CP2K等经典之作!
下载链接!36小时MS教学视频:建模、自由能、过渡态、吸附能、结合能、能带、态密度、光学、声子、溶剂化计算等!
10000个晶体结构CIF文件:MOF、MXenes、催化、电池、二维材料、钙钛矿、金属、纳米管等
炸裂!32个MS脚本,自由能/台阶图计算和绘制、界面电荷分布、差分电荷密度计算、批量提交作业等!
研究两层(如无机表面与溶液、无机表面与聚合物、聚合物与聚合物)之间的相互作用时,需要跑 分子动力学 ,并对其中每一帧的两层结构分别拆开进行能量计算,并执行上述减法。
轨迹长达数万帧时, 手动操作可能得算1年,利用脚本只需不到1分钟 。
全脚本展示:
#!perl
# Author: Stephen Todd
# This script calculates the interaction energy between two layers in a structure.
# The layers have to be defined as sets called Layer 1 and Layer 2 - these are the
# default names assigned by the Layer builder.
# This also uses the default settings for Forcite - ie Universal with current charges.
# You should change the settings if you want to use another forcefield or summation method.
# This script also assumes that the surface area is in the AB-plane.
# A study table is produced containing the layers, energies, interaction energy, and then
# the interaction energy per angstrom^2.
# Note. The input trajectory should have a large vaccuum, greater than the
# cut-off you are using in the non-bond calculation.
use
strict
;
use
MaterialsScript
qw
(:
all
);
#################################################################################
# Begin user editable settings
#
my $filename =
"Layer"
;
# Name of the trajectory without extension
my $energySettings = [
  CurrentForcefield => 
"COMPASS"
]; 
# Change the ff if needed
Modules->Forcite->ChangeSettings( $energySettings );
#
# End user editable settings
#################################################################################
# Defines the trajectory document
my $doc = $Documents{
"$filename.xtd"
};
# Create a new study table to hold the structures and energies and set the headings
my $newStudyTable = Documents->New(
"$filename"
.
"_IntEnergy.std"
);
my $calcSheet = $newStudyTable->Sheets->Item(
0
);
$calcSheet->ColumnHeading(
0
) =
"$filename Cell"
;
$calcSheet->ColumnHeading(
1
) =
"Energy of  $filename Cell"
;
$calcSheet->ColumnHeading(
2
) =
"Layer 1"
;
$calcSheet->ColumnHeading(
3
) =
"Energy of Layer 1"
;
$calcSheet->ColumnHeading(
4
) =
"Layer 2"
;
$calcSheet->ColumnHeading(
5
) =
"Energy of layer 2"
;
$calcSheet->ColumnHeading(
6
) =
"Interaction Energy"
;
$calcSheet->ColumnHeading(
7
) =
"Interaction Energy per angstrom^2"
;
# Get the total number of frames in the trajectory
my $numFrames = $doc->Trajectory->NumFrames;
print
"Calculating interaction energy for $numFrames frames on $filename trajectory
"
;
# Calculates the area of the surface based on the surface being in the A-B plane
my $length1 = $doc->Lattice3D->LengthA;
my $length2 = $doc->Lattice3D->LengthB;
my $surfaceArea = $length1 * $length2;
print
"The surface area is $surfaceArea angstroms^2
"
;
# Initialise Forcite. If you want to change the settings, you can load them or
# use a change settings command here.
my $forcite = Modules->Forcite;
# Starts to loop over the frames in the trajectory
for
( my $count=
1
; $count<=$numFrames; $count++) {
print
"Calculating energy for frame $count
"
;
# Define the frame of the trajectory
$doc->Trajectorys->Item(
0
)->CurrentFrame = $count;
# Create three documents to hold the temporary layers
my $allDoc = Documents->New(
"all.xsd"
);
my $layer1Doc = Documents->New(
"Layer1.xsd"
);
my $layer2Doc = Documents->New(
"Layer2.xsd"
);
# Create a copy of the structure in temporary documents and delete
# the layers that you don’t need.
$allDoc->CopyFrom($doc);
$layer1Doc->CopyFrom($doc);
$layer1Doc->DisplayRange->Sets(
"Layer 2"
)->Atoms->Delete;
$layer2Doc->CopyFrom($doc);
$layer2Doc->DisplayRange->Sets(
"Layer 1"
)->Atoms->Delete;
# Put the structures in a study table for safekeeping
$calcSheet->Cell($count
-1
,
0
) = $allDoc;
$calcSheet->Cell($count
-1
,
2
) = $layer1Doc;
$calcSheet->Cell($count
-1
,
4
) = $layer2Doc;
#Calculate the energies for all the layers and put in the study table
$forcite->Calculation->Run($allDoc, [Task =>
’Energy’
]);
$calcSheet->Cell($count
-1
,
1
) = $allDoc->PotentialEnergy;
$forcite->Calculation->Run($layer1Doc, [Task =>
’Energy’
]);
$calcSheet->Cell($count
-1
,
3
) = $layer1Doc->PotentialEnergy;
$forcite->Calculation->Run($layer2Doc, [Task =>
’Energy’
]);
$calcSheet->Cell($count
-1
,
5
) = $layer2Doc->PotentialEnergy;
# Calculate the Interaction Energy from the cells in the Study Table
my $totalEnergy = $calcSheet->Cell($count
-1
,
1
);
my $layer1Energy = $calcSheet->Cell($count
-1
,
3
);
my $layer2Energy = $calcSheet->Cell($count
-1
,
5
);
my $interactionEnergy = $totalEnergy - ($layer1Energy + $layer2Energy);
$calcSheet->Cell($count
-1
,
6
) = $interactionEnergy;
my $interactionEnergyArea = $interactionEnergy / $surfaceArea;
$calcSheet->Cell($count
-1
,
7
) = $interactionEnergyArea;
# Discard the temporary documents
$allDoc->Discard;
$layer1Doc->Discard;
$layer2Doc->Discard;
}
print
"Calculation complete.
"
;
Materials Studio
领取方式
公众号后台留言“ 脚本 ”,下载该脚本及配合使用案例。
长按识别二维码回复: 脚本
长按识别二维码回复: 脚本
长按识别二维码回复: 脚本
长按识别二维码回复“脚本”,免费获取
- 
			2023年血糖新标准公布,不是3.9-6.1,快来看看你的血糖正常吗? 2023-02-07
- 
			2023年各省最新电价一览!8省中午执行谷段电价! 2023-01-03
- 
			GB 55009-2021《燃气工程项目规范》(含条文说明),2022年1月1日起实施 2021-11-07
- 
			PPT导出高分辨率图片的四种方法 2022-09-22
- 
			2023年最新!国家电网27家省级电力公司负责人大盘点 2023-03-14
- 
			全国消防救援总队主官及简历(2023.2) 2023-02-10
- 
			盘点 l 中国石油大庆油田现任领导班子 2023-02-28
- 
			我们的前辈!历届全国工程勘察设计大师完整名单! 2022-11-18
- 
			关于某送变电公司“4·22”人身死亡事故的快报 2022-04-26
