python 构建双层2H堆垛,2R堆垛

一、双层2H 堆垛

准备好单层2H相TMDs(p6m2)的POSCAR  

python  2H.py

#2H.py
#2023-11-29 wnw,The codes only applies to Monolayer to bilayer 2H-MX2,and thanks for the help of Xiao-Huan,Lv.
# before begin,you must prepare the POSCAR of Monolayer 2H MX2 (M=Mo,X=S,Se2:)


import numpy as np
# 读取文件 POSCAR
with open("POSCAR", "r") as f:
    lines = f.readlines()
d = float(input("请输入 M-M 间距,(建议6.1 Ang):"))
#原子数*2
lines[6] = " ".join([str(int(float(x) * 2)) for x in lines[6].split()]) + "\n"

# 复制第10行到最后一行 V2(x,y)=Te1(x,y); V2(z)= V1(z)+d/C d是V-V c轴间距
last_line = lines[9]
last_line = last_line.split()
last_line[2] = str(float(lines[8].split()[2]) + d / float(lines[4].split()[2]))
last_line = " ".join(last_line) + "\n"
lines.append(last_line)
# 复制第9行到最后一行 Te3(x,y)=V1(x,y); T3(z)=T1(z)+d/C
last_line = lines[8]
last_line = last_line.split(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值