计算化学公社
标题:
请问gromacs能计算材料的热导率吗?怎么计算呢?
[打印本页]
作者Author:
Lisy
时间:
2025-12-28 11:09
标题:
请问gromacs能计算材料的热导率吗?怎么计算呢?
请问gromacs能计算材料的热导率吗?怎么计算呢?
作者Author:
yuzc
时间:
2025-12-28 19:08
老老实实用LAMMPS吧,GROMACS做rNEMD麻烦死了。
脚本可以直接参考radonpy:
#########################################################
## NEMD with kinetic energy exchange (RNEMD)
##########################################################
fix NVE all nve
fix mp all thermal/conductivity ${exchg} ${axis} ${slab}
# Generate temperature profile of layers
compute layers all chunk/atom bin/1d ${axis} lower ${invslab} units reduced
fix 2 all ave/chunk ${Nevery} ${Nfreq} ${exchg} layers temp density/mass file ${Tprof} norm sample
# Output
dump 1 all custom 1000 ${dumpf} id type mol xs ys zs ix iy iz
dump 2 all xtc 1000 ${xtcf}
dump_modify 2 unwrap yes
restart 100000 ${rstf1} ${rstf2}
variable heatflux equal (f_mp*${kcal2j}/${NA})/(2*${Jarea}*${ang2m}*${ang2m}) # J/m^2 = Ws/m^2
thermo_style custom step time temp press enthalpy etotal ke pe ebond eangle edihed eimp evdwl ecoul elong etail vol lx ly lz density pxx pyy pzz pxy pxz pyz f_mp v_heatflux
thermo_modify flush yes
thermo ${exchg}
run ${NStep}
"""
if decomp:
in_strings += """
##########################################################
## Component decomposition of heat flux
##########################################################
# heat flux preparation
compute KE all ke/atom
compute PE all pe/atom
compute Spair all stress/atom NULL pair
compute Sbond all stress/atom NULL bond
compute Sangle all centroid/stress/atom NULL angle
compute Sdihed all centroid/stress/atom NULL dihedral
compute Simpro all centroid/stress/atom NULL improper
compute Skspac all stress/atom NULL kspace
compute Sfix all stress/atom NULL fix
"""
if decomp_intermol:
in_strings += """
compute Spairer all stress/atom NULL interpair
compute Spairra all stress/atom NULL intrapair
"""
in_strings += """
# Generate empty vector
group empty type 99999
compute KENULL empty ke/atom
compute PENULL empty pe/atom improper
compute STNULL empty stress/atom NULL improper
######################## Cell half-left ########################
### |//| | | | |**| | | | | ### |//| cold slab
### |//| | | | |**| | | | | ### |**| hot slab
### |//| | | | |**| | | | | ###
### |//| | | | |**| | | | | ###
### |//| | | | |**| | | | | ###
### <---------> ###
### heat flux decomposition of this reagion
#####################################################################
# left cell information
group halfL dynamic all region lhalf every ${Nevery} # Nevery=ave/time Nevery
#1st term eivi
compute lF1ke halfL heat/flux KE PENULL STNULL
compute lF1pe halfL heat/flux KENULL PE STNULL
#2nd term Sivi
compute lFpair halfL heat/flux KENULL PENULL Spair
compute lFbond halfL heat/flux KENULL PENULL Sbond
compute lFangle halfL heat/flux KENULL PENULL Sangle
compute lFdihed halfL heat/flux KENULL PENULL Sdihed
compute lFimpro halfL heat/flux KENULL PENULL Simpro
compute lFkspac halfL heat/flux KENULL PENULL Skspac
compute lFfix halfL heat/flux KENULL PENULL Sfix
"""
if decomp_intermol:
in_strings += """
compute lFpairer halfL heat/flux KENULL PENULL Spairer
compute lFpairra halfL heat/flux KENULL PENULL Spairra
fix 20 halfL ave/time ${Nevery} ${Nfreq} ${exchg} c_lF1ke[${idx}] c_lF1pe[${idx}] c_lFpair[${idx}] c_lFpairer[${idx}] c_lFpairra[${idx}] c_lFbond[${idx}] c_lFangle[${idx}] c_lFdihed[${idx}] c_lFimpro[${idx}] c_lFkspac[${idx}] c_lFfix[${idx}] file ${lJprof}
"""
else:
in_strings += """
fix 20 halfL ave/time ${Nevery} ${Nfreq} ${exchg} c_lF1ke[${idx}] c_lF1pe[${idx}] c_lFpair[${idx}] c_lFbond[${idx}] c_lFangle[${idx}] c_lFdihed[${idx}] c_lFimpro[${idx}] c_lFkspac[${idx}] c_lFfix[${idx}] file ${lJprof}
"""
in_strings += """
######################## Cell half-right #######################
### |//| | | | |**| | | | | ### |//| cold slab
### |//| | | | |**| | | | | ### |**| hot slab
### |//| | | | |**| | | | | ###
### |//| | | | |**| | | | | ###
### |//| | | | |**| | | | | ###
### <---------> ###
### heat flux decomposition of this reagion
#####################################################################
# right cell information
group halfR dynamic all region rhalf every ${Nevery}
#1st term eivi
compute rF1ke halfR heat/flux KE PENULL STNULL
compute rF1pe halfR heat/flux KENULL PE STNULL
#2nd term Sivi
compute rFpair halfR heat/flux KENULL PENULL Spair
compute rFbond halfR heat/flux KENULL PENULL Sbond
compute rFangle halfR heat/flux KENULL PENULL Sangle
compute rFdihed halfR heat/flux KENULL PENULL Sdihed
compute rFimpro halfR heat/flux KENULL PENULL Simpro
compute rFkspac halfR heat/flux KENULL PENULL Skspac
compute rFfix halfR heat/flux KENULL PENULL Sfix
"""
if decomp_intermol:
in_strings += """
compute rFpairer halfR heat/flux KENULL PENULL Spairer
compute rFpairra halfR heat/flux KENULL PENULL Spairra
fix 30 halfR ave/time ${Nevery} ${Nfreq} ${exchg} c_rF1ke[${idx}] c_rF1pe[${idx}] c_rFpair[${idx}] c_rFpairer[${idx}] c_rFpairra[${idx}] c_rFbond[${idx}] c_rFangle[${idx}] c_rFdihed[${idx}] c_rFimpro[${idx}] c_rFkspac[${idx}] c_rFfix[${idx}] file ${rJprof}
"""
else:
in_strings += """
fix 30 halfR ave/time ${Nevery} ${Nfreq} ${exchg} c_rF1ke[${idx}] c_rF1pe[${idx}] c_rFpair[${idx}] c_rFbond[${idx}] c_rFangle[${idx}] c_rFdihed[${idx}] c_rFimpro[${idx}] c_rFkspac[${idx}] c_rFfix[${idx}] file ${rJprof}
"""
in_strings += """
##########################################################
## RNEMD with kinetic energy exchange in decomposition
##########################################################
thermo_style custom step time temp press enthalpy etotal ke pe ebond eangle edihed eimp evdwl ecoul elong etail vol lx ly lz density pxx pyy pzz pxy pxz pyz f_mp v_heatflux
thermo_modify flush yes
thermo ${exchg}
run ${NStepd}
"""
in_strings += """
write_dump all custom ${ldumpf} id x y z xu yu zu vx vy vz fx fy fz modify sort id
write_data ${ldataf}
quit
"""
复制代码
Green-Kubo法:优点,准;缺点,需要很长的平衡时间;
##########################################################
log ${logf} append
units real
atom_style full
boundary p p p
bond_style ${bondst}
angle_style ${anglest}
dihedral_style ${dihedst}
improper_style ${improst}
pair_style ${pairst} ${cutoff1} ${cutoff2}
pair_modify mix arithmetic
special_bonds amber
neighbor 2.0 bin
neigh_modify delay 0 every 1 check yes
kspace_style pppm 1e-6
read_data ${dataf}
velocity all create ${Ttemp} ${seed} mom yes rot yes dist gaussian
##########################################################
## Thermal conductivity calculation by Green-Kubo method
##########################################################
timestep ${TimeSt}
compute kpKE all ke/atom # KE_i
compute kpPE all pe/atom # PE_i
compute kpStress all centroid/stress/atom NULL virial # S_i
compute kpflux all heat/flux kpKE kpPE kpStress
# x, y, z components of JE
variable kpJx equal c_kpflux[1]/vol
variable kpJy equal c_kpflux[2]/vol
variable kpJz equal c_kpflux[3]/vol
# Compute the autocorrelation function
fix JJ all ave/correlate ${kpsample} ${kpcorrlen} ${kpdump} c_kpflux[1] c_kpflux[2] c_kpflux[3] type auto file ${autocorrf} overwrite ave running
variable kpscale equal ${conv}*(${kpsample}*dt)/${Ttemp}/${Ttemp}/vol/${kB}
variable kappaxx equal trap(f_JJ[3])*${kpscale}
variable kappayy equal trap(f_JJ[4])*${kpscale}
variable kappazz equal trap(f_JJ[5])*${kpscale}
variable kappa equal (v_kappaxx+v_kappayy+v_kappazz)/3.0 # in isotropic system, getting the average
fix kappa all ave/time ${kpdump} 1 ${kpdump} v_kappaxx v_kappayy v_kappazz v_kappa ave one file ${kappaf}
fix NVT1 all nvt temp ${Ttemp} ${Ttemp} 100
# Output
dump 1 all custom 1000 ${dumpf} id type mol x y z vx vy vz
dump 2 all xtc 1000 ${xtcf}
dump_modify 2 unwrap yes
restart 100000 ${rstf1} ${rstf2}
thermo_style custom step time temp press enthalpy etotal ke pe ebond eangle edihed eimp evdwl ecoul elong etail vol lx ly lz density pxx pyy pzz pxy pxz pyz v_kpJx v_kpJy v_kpJz
thermo 1000
run ${NStep}
write_dump all custom ${ldumpf} id x y z xu yu zu vx vy vz fx fy fz modify sort id
write_data ${ldataf}
quit
"""
复制代码
欢迎光临 计算化学公社 (http://bbs.keinsci.com/)
Powered by Discuz! X3.3