版块导航
正在加载中...
客户端APP下载
登录
注册
帖子
帖子
用户
本版
应《网络安全法》要求,自2017年10月1日起,未进行实名认证将不得使用互联网跟帖服务。为保障您的帐号能够正常使用,请尽快对帐号进行手机号验证,感谢您的理解与支持!
24小时热门版块排行榜
>
论坛更新日志
(482)
>
虫友互识
(40)
>
考博
(32)
>
学术会议
(27)
>
论文投稿
(25)
>
导师招生
(24)
>
找工作
(13)
>
教师之家
(11)
>
硕博家园
(11)
>
论文道贺祈福
(8)
>
考研
(8)
>
公派出国
(7)
>
博后之家
(3)
>
基金申请
(3)
>
文献求助
(2)
>
招聘信息布告栏
(1)
小木虫论坛-学术科研互动平台
»
计算模拟区
»
分子模拟
»
Monte Carlo
»
【原创】MAPS中构筑超晶胞的python程序
5
1/1
返回列表
查看: 767 | 回复: 2
只看楼主
@他人
存档
新回复提醒
(忽略)
收藏
在APP中查看
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖
zyj8119
木虫
(著名写手)
模拟EPI: 10
应助: 65
(初中生)
贵宾: 0.003
金币: 915.1
散金: 1440
红花: 35
帖子: 2936
在线: 1329.4小时
虫号: 664177
注册: 2008-11-29
性别: GG
专业: 理论和计算化学
[交流]
【原创】MAPS中构筑超晶胞的python程序
已有2人参与
CODE:
#!/usr/bin/python
###########################################################################
# buildCluster.py - description
# -------------------------------
# begin : Fri Dec 15 16:11:04 CET 2006
# copyright : (C) 2006 by Scienomics
# email : Joerg-Ruediger.Hill@scienomics.com
###########################################################################
#
###########################################################################
# #
# This program and all subroutines, data, and files used by it are #
# protected by copyright and hence may not be used, copied, modified #
# transmitted, inspected, or executed by any means including the use #
# of electronic data processing equipment, xerography, or any other #
# methods without the express written permission of the copyright #
# holder. #
# #
# Copyright (C) 2006 Scienomics S. A. #
# #
###########################################################################
#
# $Id: buildCluster.py,v 1.10 2010/03/29 15:15:56 jrh Exp $
# $Log: buildCluster.py,v $
# Revision 1.10 2010/03/29 15:15:56 jrh
# Moved to new way of retrieving plugin objects
#
# Revision 1.9 2008/10/20 09:25:06 lperi
# Clear undo stack (bug 2562).
#
# Revision 1.8 2008/10/14 15:21:17 jrh
# Fixed bug 2520
#
# Revision 1.7 2008/01/16 12:21:18 jrh
# Moved to Qt4
#
# Revision 1.6 2007/01/16 10:28:26 jrh
# Removed automatic creation of cell since this might crash
#
# Revision 1.5 2006/12/15 16:07:31 jrh
# Added header and documentation
#
#
import Maps
import MapsChemistryDataModel
import MapsViewer
from PyQt4 import *
class ClusterBuilder:
""" This class implements a cluster generating algorithm
by cutting atoms from a periodic system based on a
distance criterion. The class takes either the active
molecule or asks the user to load a molecule if no
active molecule is found, puts a molecule into a box
at density 1.0 if the system is not periodic already,
and builds a cluster by copying all atoms which are
within 5 Ang from the central atom to a new model.
"""
app=Maps.MapsApp.getContainer()
cdm=MapsChemistryDataModel.ChemistryDataModel.get()
viewerPlugin=MapsViewer.ViewerPlugin.get()
project=None
molecule=None
def loadMolecule(self):
activeViewer=self.viewerPlugin.getActiveViewer()
if activeViewer != None:
self.molecule=activeViewer.getMolecule()
projectName=self.cdm.findProjectNameForMolecule(self.molecule)
self.project=self.cdm.findProjectByName(projectName)
QtGui.qApp.processEvents()
return(0)
else:
QtGui.QMessageBox.information(self.app, "Note", "Please load a molecule from the\nfollowing dialog.")
# Load a molecule from an existing file
dialog=self.app.fileDialog
dialog.setFileMode(QtGui.QFileDialog.ExistingFile)
dialog.setWindowTitle("Open file")
filters=QtCore.QStringList()
filters.append("All files (*)")
dialog.setFilters(filters)
dialog.selectFile("")
if dialog.exec_(Maps.FileDialog.DATA) == QtGui.QDialog.Accepted:
fileName=str(dialog.selectedFiles()[0])
self.app.openDocumentFile(fileName, None, "")
projects=self.cdm.getProjects()
self.project=projects[0]
molecules=self.project.getMolecules()
self.molecule=molecules[0]
self.viewerPlugin.start(self.molecule)
QtGui.qApp.processEvents()
return(0)
else:
return(1)
def createSuperCell(self):
# Create a 3 x 3 x 3 super cell. If the system is not periodic tell
# the user and exit
if not self.molecule.isPeriodic():
QtGui.QMessageBox.information(self.app, "Note", "Please use a periodic system with this script.")
return(0);
else:
cell=self.molecule.getActiveConformation().getUnitcell()
cell.setDuplicate(3, 3, 3, 1)
cell.makeSuperCell(1)
QtGui.qApp.processEvents()
return(1)
def cutCluster(self):
# Cut a cluster by finding the atom closest to the center of the
# super cell and including all atoms at a distance of up to
# 5.0 Ang from this atom
center=self.molecule.calculateCenterOfGravity(self.molecule.atoms)
min=100.0
centerAtom=None
for atom in self.molecule.atoms:
pos=atom.getCoordinates()
diff=pos-center
if diff.abs() < min:
min=diff.abs()
centerAtom=atom
viewer=self.viewerPlugin.getActiveViewer()
# Clear the undo stack to prevent a discontinuity
# in the recorded editing actions which could
# cause a crash
viewer.clearUndoStack()
viewer.setSelectionMode(MapsViewer.Viewer.DISTANCE, 5.0)
viewer.selectAtoms(centerAtom, 1)
viewer.copy()
# Create a new model in the same project and paste the cluster
# in there
cluster=MapsChemistryDataModel.Molecule(self.cdm)
cluster.setName("Cluster")
self.project.addMolecule(cluster)
self.viewerPlugin.start(cluster)
clusterViewer=self.viewerPlugin.getActiveViewer()
clusterViewer.paste()
clusterViewer.centerMolecule()
clusterViewer.getMoleculeRenderer().setSelection(cluster.atoms, 0)
QtGui.qApp.processEvents()
def run(self):
if not self.loadMolecule():
if self.createSuperCell():
self.cutCluster()
#-------------------------
if __name__ == '__main__':
builder=ClusterBuilder()
builder.run()
回复此楼
» 本帖已获得的红花(最新10朵)
liuying287
» 猜你喜欢
售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急
已经有4人回复
售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急
已经有6人回复
为什么资助数各大高校都创新高,自己申请怎么就这么难
已经有15人回复
科研人应该花精力去思考如何解决问题,而不是去凝练问题
已经有14人回复
要骂人了,新模版改版就是要淡化问题凝练这种虚的东西,结果有个评委还在说凝练得不够
已经有17人回复
基金系统什么内容也没有
已经有10人回复
学科评审组评审是指会评吗?
已经有5人回复
面上合作单位盖章
已经有9人回复
面上函评意见出来了,像什么等级?
已经有17人回复
小白求助 投论文要求的highlights应该如何写
已经有4人回复
高级回复
好好学习,天天向上。
1楼
2010-12-26 17:30:30
已阅
回复此楼
关注TA
给TA发消息
送TA红花
TA的回帖
juwendy
铁虫
(正式写手)
应助: 2
(幼儿园)
金币: 4898.8
帖子: 422
在线: 399.4小时
虫号: 796719
注册: 2009-06-18
专业: 岩土与基础工程
顶一个,支持楼主。
回复此楼
高级回复
3楼
2012-03-22 21:09:32
已阅
回复此楼
关注TA
给TA发消息
送TA红花
TA的回帖
查看全部 3 个回答
查看全部 3 个回答
如果回帖内容含有宣传信息,请如实选中。否则帐号将被全论坛禁言
普通表情
龙
兔
虎
猫
高级回复
(可上传附件)
百度网盘
|
360云盘
|
千易网盘
|
华为网盘
在新窗口页面中打开自己喜欢的网盘网站,将文件上传后,然后将下载链接复制到帖子内容中就可以了。
最具人气热帖推荐
[查看全部]
作者
回/看
最后发表
[
博后之家
]
售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急
+3
ero8OE6tv9cu
2026-09-02
6/300
2026-09-02 23:59
by
rM1TE0WVDIIY
[
基金申请
]
为什么资助数各大高校都创新高,自己申请怎么就这么难
+14
Kittylucky
2026-08-27
15/750
2026-09-02 19:35
by
liumei0601
[
基金申请
]
科研人应该花精力去思考如何解决问题,而不是去凝练问题
+7
瞬息宇宙
2026-09-01
14/700
2026-09-02 17:33
by
ma0526
[
基金申请
]
要骂人了,新模版改版就是要淡化问题凝练这种虚的东西,结果有个评委还在说凝练得不够
+9
瞬息宇宙
2026-08-31
17/850
2026-09-02 14:04
by
anjeeshine
[
基金申请
]
基金系统什么内容也没有
30
+4
winsaint
2026-08-27
10/500
2026-09-02 11:35
by
大不刘6
[
基金申请
]
学科评审组评审是指会评吗?
+5
瞬息宇宙
2026-08-31
5/250
2026-09-02 10:13
by
雨冰共舞
[
基金申请
]
面上合作单位盖章
+6
ssyjh
2026-08-27
9/450
2026-09-01 20:01
by
huagongfeihu
[
基金申请
]
面上函评意见出来了,像什么等级?
20
+4
Tsingking1
2026-08-27
17/850
2026-09-01 19:51
by
超级无敌华子
[
论文投稿
]
小白求助 投论文要求的highlights应该如何写
5
+3
l1963982152
2026-08-29
4/200
2026-09-01 09:04
by
北京莱茵编辑
[
基金申请
]
麻烦专家们看看评委们的意见(F口面上)
+7
gdd2018
2026-08-28
12/600
2026-09-01 08:32
by
尼古拉斯小虫
[
基金申请
]
面上意见出来了
+12
黄鸟于飞Chao
2026-08-29
23/1150
2026-08-31 18:57
by
黄鸟于飞Chao
[
基金申请
]
能否申诉?
+7
echo8914667
2026-08-30
8/400
2026-08-31 17:00
by
yihongxu
[
基金申请
]
中青基了要发朋友圈吗?
+7
349506619
2026-08-28
7/350
2026-08-31 13:39
by
冼亮淀粉酶
[
基金申请
]
29号明天会评吗
+4
笨笨唐
2026-08-28
4/200
2026-08-31 09:30
by
huixian257
[
基金申请
]
为什么到现在没收到通知?
+5
tannykie
2026-08-29
5/250
2026-08-30 21:05
by
purplejack
[
基金申请
]
有没有仍没收到信息的
+7
德尚中行
2026-08-27
8/400
2026-08-30 20:52
by
purplejack
[
考博
]
找导师
+6
yuanjiabao
2026-08-29
7/350
2026-08-30 14:40
by
生科新手
[
基金申请
]
我就是申请一个面上项目而已,这评审意见是按照杰青的条件评的吧?
+6
gouxfjh
2026-08-28
11/550
2026-08-30 07:57
by
gouxfjh
[
基金申请
]
国自然评审意见
+13
wangmingqi
2026-08-28
19/950
2026-08-29 10:22
by
Poppy1104
[
基金申请
]
2026年叶企孙基金
+4
bud_bud
2026-08-27
7/350
2026-08-29 07:23
by
foolishmani
信息提示
关闭
请填处理意见
关闭
确定