Lammps剪切作用的两种实现方法及对比—Deform以及Velocity

本文详细介绍了使用Lammps进行剪切作用模拟的两种方法,包括Fix deform和Velocity的实现步骤及应力应变分析,提供了完整的In文件代码示例,并附带Python后处理绘图代码和数据下载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

关注 M r . m a t e r i a l   , \color{Violet} \rm Mr.material\ , Mr.material , 更 \color{red}{更} 多 \color{blue}{多} 精 \color{orange}{精} 彩 \color{green}{彩}


主要专栏内容包括:
  †《LAMMPS小技巧》: ‾ \textbf{ \underline{\dag《LAMMPS小技巧》:}}  LAMMPS小技巧》: 主要介绍采用分子动力学( L a m m p s Lammps Lammps)模拟相关安装教程、原理以及模拟小技巧(难度: ★ \bigstar
  ††《LAMMPS实例教程—In文件详解》: ‾ \textbf{ \underline{\dag\dag《LAMMPS实例教程—In文件详解》:}}  ††LAMMPS实例教程—In文件详解》: 主要介绍采用分子动力学( L a m m p s Lammps Lammps)模拟相关物理过程模拟。(包含:热导率计算、定压比热容计算,难度: ★ \bigstar ★ \bigstar ★ \bigstar
  †††《Lammps编程技巧及后处理程序技巧》: ‾ \textbf{ \underline{\dag\dag\dag《Lammps编程技巧及后处理程序技巧》:}}  †††Lammps编程技巧及后处理程序技巧》: 主要介绍针对分子模拟的动力学过程(轨迹文件)进行后相关的处理分析(需要一定编程能力。难度: ★ \bigstar ★ \bigstar ★ \bigstar ★ \bigstar ★ \bigstar )。
  ††††《分子动力学后处理集成函数—Matlab》: ‾ \textbf{ \underline{\dag\dag\dag\dag《分子动力学后处理集成函数—Matlab》:}}  ††††《分子动力学后处理集成函数—Matlab》: 主要介绍针对后处理过程中指定函数,进行包装,方便使用者直接调用(需要一定编程能力,难度: ★ \bigstar ★ \bigstar ★ \bigstar ★ \bigstar )。
  †††††《SCI论文绘图—Python绘图常用模板及技巧》: ‾ \textbf{ \underline{\dag\dag\dag\dag\dag《SCI论文绘图—Python绘图常用模板及技巧》:}}  †††††SCI论文绘图—Python绘图常用模板及技巧》: 主要介绍针对处理后的数据可视化,并提供对应的绘图模板(需要一定编程能力,难度: ★ \bigstar ★ \bigstar ★ \bigstar ★ \bigstar )。
  ††††††《分子模拟—Ovito渲染案例教程》: ‾ \textbf{ \underline{\dag\dag\dag\dag\dag\dag《分子模拟—Ovito渲染案例教程》:}}  ††††††《分子模拟—Ovito渲染案例教程》: 主要采用 O v i t o \rm Ovito Ovito软件,对 L a m m p s \rm Lammps Lammps 生成的轨迹文件进行渲染(难度: ★ \bigstar ★ \bigstar )。

  专栏说明(订阅后可浏览对应专栏全部博文): ‾ \color{red}{\textbf{ \underline{专栏说明(订阅后可浏览对应专栏全部博文):}}}  专栏说明(订阅后可浏览对应专栏全部博文):
注意: \color{red} 注意: 注意:如需只订阅某个单独博文,请联系博主邮箱咨询。 l a m m p s _ m a t e r i a l s @ 163. c o m \rm lammps\_materials@163.com lammps_materials@163.com

♠ \spadesuit † \dag 开源后处理集成程序:请关注专栏《LAMMPS后处理——MATLAB子函数合集整理》
♠ \spadesuit † \dag † \dag 需要付费定制后处理程序请邮件联系: l a m m p s _ m a t e r i a l s @ 163. c o m \rm lammps\_materials@163.com lammps_materials@163.com


宏观上常见的测量材料力学性能的方法包括纳米压痕、拉伸(压缩)实验、剪切实验、冲击实验以及疲劳实验。 纳米压痕实验通过记录压头加载以及卸载阶段的力-位移曲线来测量材料的硬度、杨氏模量、硬化效应以及蠕变行为。 拉伸、压缩以及剪切实验可通过应力-应变曲线得到材料的拉伸弹性模量、剪切模型以及五种强度。宏观实验难以准确描述材料塑性变形阶段,尤其是与塑性变形有关的内部位错运动只能在原子尺度下观察到。因此借助分子动力学手段可探讨小尺度下材料微观结构以及位错对于其力学性能影响的作用机制。因此下面介绍了如何在LAMMPS中实现常见的材料力学性能测量手段。

该文章由 D r . B I N B O \rm \color{Violet} Dr.BINBO Dr.BINBO 撰写,主要介绍 l a m m p s \color{Violet} lammps lammps 实现剪切作用(两种方法) ♡ \heartsuit

N O T E   ! ! ! ‾ \rm \underline {NOTE\ !!!} NOTE !!! 力 \color{red}{力} 学 \color{blue}{学} 专 \color{orange}{专} 题 \color{green}{题}

感谢 \rm 感谢 感谢 ♡ \heartsuit D r . B I N B O \rm \color{Violet} Dr.BINBO Dr.BINBO ♡ \heartsuit 提供的力学相关博文!这里做简单整理为小专题 : \rm 提供的力学相关博文!这里做简单整理为小专题: 提供的力学相关博文!这里做简单整理为小专题:
《力学专题—纳米压痕、单轴压缩、剪切行为的 L A M M P S 模拟》 ‾ \rm \color{red}\underline {《力学专题—纳米压痕、单轴压缩、剪切行为的LAMMPS模拟》} 《力学专题纳米压痕、单轴压缩、剪切行为的LAMMPS模拟》:

† \dag 《Lammps计算纳米压痕—包含全部In文件》
† \dag † \dag 《石墨烯复合材料单轴压缩-应力应变曲线以及弹性模量计算(包含in文件)》
† \dag † \dag † \dag 《Lammps剪切作用的两种实现方法及对比—Deform以及Velocity》


专栏浏览《LAMMPS实例教程—In文件详解》
请添加图片描述


一、Fix deform实现剪切作用

请添加图片描述

1. 初始设置—达到平衡态

############################################################################
################################# Deform method ##########################
############################################################################

#------------------------------Model settings--------------------------
clear
shell               mkdir output ./output/minimize ./output/relax ./output/shear ./output/data

#------------------------------Basic settings--------------------------
units               metal
dimension           3  
boundary            p p p        
atom_style          atomic

variable            Temp equal 300          	# desired temperature
variable            tstp equal 0.001            # timestep
variable            tdamp equal 100*${tstp}     # damping parameters # 
variable            pdamp equal 1000*${tstp}    # for NPT ensemble   #
variable            dump_every equal 1000       
variable            equi_step equal 10000

read_data           Ni_supercell.lmp

#----------------------------------------- Force Field ------------------------------------
pair_style          eam             
pair_coeff          * * Ni_u3.eam

#--------------------------------------------- Minimization ---------------------------------------
thermo              100
timestep            ${tstp}
thermo_style        custom step temp etotal pe ke pxy

# compute specific quantities
compute             pot_energy all pe/atom
dump                min all custom ${dump_every} ./output/minimize/dump_minimize.*.lammpstrj id type x y z c_pot_energy 

min_style           cg
minimize            1.0e-6 1.0e-6 10000 10000

write_data          ./output/minimize/mini.data

#------------------------------------------ equilibrium -------------------------------
undump              min
reset_timestep      0

compute             new3d all temp
compute             new2d all temp/partial 0 1 1

velocity            all create ${Temp} 12345 units box
fix				    1 all npt temp ${Temp} ${Temp} ${tdamp} iso 0.0 0.0 ${pdamp}
fix_modify          1 temp new3d

thermo              1000
thermo_modify       temp new3d
run                 ${equi_step} 

write_data          ./output/relax/equil.data
write_restart       ./output/relax/equil.restart

2. Deform剪切实现—xy方向

#------------------------------------------- shear in xy plane -------------------------------------
reset_timestep      0
unfix               1

change_box          all triclinic

variable            tmpx equal lx
variable            tmpy equal ly
variable            tmpz equal lz
variable            L0x equal ${tmpx}
variable            L0y equal ${tmpy}
variable            L0z equal ${tmpz}

# In units metal, pressure is in [bars]; sxz is in GPa

variable            srate equal 0.01           
variable            final_strain equal 0.4
variable            dyna_step equal ${final_strain}/(${srate}*${tstp})

variable            sxy equal "-pxy/10000"          # calculate shear stress
variable            strain equal ${srate}*step*${tstp}        # calculate shear strain

# deformation starts!
#fix				    1 all nve
#fix                 2 all temp/rescale 1 ${Temp} ${Temp} ${tdamp} 0.5
fix				2 all npt temp ${Temp} ${Temp} ${tdamp} iso 0.0 0.0 ${pdamp}
fix_modify          2 temp new2d

fix                 3 all deform 1 xy erate ${srate} remap x

dump                result all custom ${dump_every} ./output/shear/dump.*.lammps id type x y z
fix                 def1 all print 100 "${strain} ${sxy}" file ./output/data/Shear_data.txt screen no
thermo_style 	    custom step press pe pxx pyy pzz pxy pxz pyz v_strain v_sxy
run                 ${dyna_step}
write_data          ./output/shear/shear_end.*.data
write_restart       ./output/shear/shear_end.*.restart

print "-------------------------------- All done! -----------------------------------------"

3. Deform剪切实现—应力应变分析

请添加图片描述

二、Velocity 实现剪切作用

请添加图片描述

1. 初始设置—达到平衡态

############################################################################
################################# Velocity method ##########################
############################################################################

#------------------------------Model settings--------------------------
clear
shell               mkdir output ./output/minimize ./output/relax ./output/shear ./output/data

#------------------------------Basic settings--------------------------
units               metal
dimension           3  
boundary            s s p        
atom_style          atomic

variable            Temp equal 10          	# desired temperature
variable            tstp equal 0.001            # timestep
variable            tdamp equal 100*${tstp}     # damping parameters # 
variable            pdamp equal 1000*${tstp}    # for NPT ensemble   #
variable            dump_every equal 1000       
variable            equi_step equal 10000


read_data           Ni_supercell.lmp

variable            size_x equal xhi-xlo
variable            size_y equal yhi-ylo
variable            size_z equal zhi-zlo

variable            layer_thickness equal 0.1*${size_y}
variable            upper_layer_limit  equal  ${size_y}-${layer_thickness}
variable            lower_layer_limit  equal  ${layer_thickness}

# Define regions
region              upper block INF INF ${upper_layer_limit} INF INF INF units box          
region              lower block INF INF INF ${lower_layer_limit} INF INF units box 

# Define groups
group               upper region upper
group               lower region lower
group               boundary union upper lower
group               mobile subtract all boundary

#----------------------------------------- Force Field ------------------------------------
pair_style          eam             
pair_coeff          * * Ni_u3.eam

#--------------------------------------------- Minimization ---------------------------------------
thermo              100
timestep            ${tstp}
thermo_style        custom step temp etotal pe ke pxz

# fix boundary group


# compute specific quantities
compute             pot_energy all pe/atom
compute             stress all stress/atom NULL
dump                min all custom ${dump_every} ./output/minimize/dump_minimize.*.lammpstrj id type x y z c_pot_energy 


min_style           cg
minimize            1.0e-6 1.0e-6 10000 10000

write_data          ./output/minimize/mini.data

#------------------------------------------ equilibrium -------------------------------
undump              min
reset_timestep      0

compute             new3d mobile temp
compute             new2d mobile temp/partial 0 1 1

velocity            mobile create ${Temp} 12345 units box


#fix				1 all npt temp ${Temp} ${Temp} ${tdamp} aniso 0.0 0.0 ${pdamp}
fix				1 all nve
fix                 0 boundary setforce 0.0 0.0 0.0
fix                 2 mobile temp/rescale 10 ${Temp} ${Temp} 10.0 1.0
fix_modify          2 temp new3d

#fix_modify          1 temp new3d

thermo              1000
thermo_modify       temp new3d
run                 ${equi_step} 

write_data          ./output/relax/equil.data
write_restart       ./output/relax/equil.restart

2. Velocity—剪切实现

#------------------------------------------- shear in xy plane -------------------------------------
#change_box          all boundary s s p

reset_timestep      0
unfix               1

#fix				1 all nvt temp ${Temp} ${Temp} ${tdamp}
#fix_modify          1 temp new3d

#run				10000
#reset_timestep      0
#unfix               1

variable            tmpx equal lx
variable            tmpy equal ly
variable            tmpz equal lz
variable            L0x equal ${tmpx}
variable            L0y equal ${tmpy}
variable            L0z equal ${tmpz}

variable        	vol_ini equal v_L0x*v_L0y*v_L0z
print "Initial volumn, vol = ${vol_ini}"
# In units metal, pressure is in [bars]; sxx, syy, szz are in GPa
compute         	2 mobile stress/atom NULL
compute         	strsxy mobile reduce sum c_2[4]
variable        	unit equal 1E-4

#variable        	sxy equal ${unit}*(c_strsxy/v_vol_ini)
variable            deltaL  equal  (lx-${L0x})
variable            sxy equal "-pxy/10000"          # calculate shear stress
variable            strain equal v_deltaL/ly        # calculate shear strain

variable            srate equal 0.01           
variable            vx equal ${srate}*${L0y}
variable            final_strain equal 0.3
#variable            dyna_step equal ${final_strain}/(${srate}*${tstp})
variable			dyna_step equal 15000

# deformation starts!
fix				1 all nve
fix                 2 mobile temp/rescale 10 ${Temp} ${Temp} 10.0 1.0
fix_modify          2 temp new2d

velocity            upper set 2.0 0.0 0.0 units box
velocity            mobile ramp vx 0.0 2.0 y ${lower_layer_limit} ${upper_layer_limit} sum yes units box

dump                result all custom ${dump_every} ./output/shear/dump.*.lammps id type x y z
fix                 def1 all print 1000 "${strain} ${sxy}" file ./output/data/Shear_data.txt screen no
#
fix                 def1 all ave/time 100 10 1000 v_strain v_sxy file ./output/data/Shear_data.txt
thermo_style 	    custom step press pe pxx pyy pzz pxy pxz pyz v_strain v_sxy
run                 ${dyna_step}
write_data          ./output/shear/shear_end.*.data
write_restart       ./output/shear/shear_end.*.restart

print "-------------------------------- All done! -----------------------------------------"

3. Velocity 剪切实现—应力应变分析

请添加图片描述

三、全部代码-剪切作用

1. Deform 方法

############################################################################
################################# Deform method ##########################
############################################################################

#------------------------------Model settings--------------------------
clear
shell               mkdir output ./output/minimize ./output/relax ./output/shear ./output/data

#------------------------------Basic settings--------------------------
units               metal
dimension           3  
boundary            p p p        
atom_style          atomic

variable            Temp equal 300          	# desired temperature
variable            tstp equal 0.001            # timestep
variable            tdamp equal 100*${tstp}     # damping parameters # 
variable            pdamp equal 1000*${tstp}    # for NPT ensemble   #
variable            dump_every equal 1000       
variable            equi_step equal 10000

read_data           Ni_supercell.lmp

#----------------------------------------- Force Field ------------------------------------
pair_style          eam             
pair_coeff          * * Ni_u3.eam

#--------------------------------------------- Minimization ---------------------------------------
thermo              100
timestep            ${tstp}
thermo_style        custom step temp etotal pe ke pxy

# compute specific quantities
compute             pot_energy all pe/atom
dump                min all custom ${dump_every} ./output/minimize/dump_minimize.*.lammpstrj id type x y z c_pot_energy 

min_style           cg
minimize            1.0e-6 1.0e-6 10000 10000

write_data          ./output/minimize/mini.data

#------------------------------------------ equilibrium -------------------------------
undump              min
reset_timestep      0

compute             new3d all temp
compute             new2d all temp/partial 0 1 1

velocity            all create ${Temp} 12345 units box
fix				    1 all npt temp ${Temp} ${Temp} ${tdamp} iso 0.0 0.0 ${pdamp}
fix_modify          1 temp new3d

thermo              1000
thermo_modify       temp new3d
run                 ${equi_step} 

write_data          ./output/relax/equil.data
write_restart       ./output/relax/equil.restart

#------------------------------------------- shear in xy plane -------------------------------------
reset_timestep      0
unfix               1

change_box          all triclinic

variable            tmpx equal lx
variable            tmpy equal ly
variable            tmpz equal lz
variable            L0x equal ${tmpx}
variable            L0y equal ${tmpy}
variable            L0z equal ${tmpz}

# In units metal, pressure is in [bars]; sxz is in GPa

variable            srate equal 0.01           
variable            final_strain equal 0.4
variable            dyna_step equal ${final_strain}/(${srate}*${tstp})

variable            sxy equal "-pxy/10000"          # calculate shear stress
variable            strain equal ${srate}*step*${tstp}        # calculate shear strain

# deformation starts!
#fix				    1 all nve
#fix                 2 all temp/rescale 1 ${Temp} ${Temp} ${tdamp} 0.5
fix				2 all npt temp ${Temp} ${Temp} ${tdamp} iso 0.0 0.0 ${pdamp}
fix_modify          2 temp new2d

fix                 3 all deform 1 xy erate ${srate} remap x

dump                result all custom ${dump_every} ./output/shear/dump.*.lammps id type x y z
fix                 def1 all print 100 "${strain} ${sxy}" file ./output/data/Shear_data.txt screen no
thermo_style 	    custom step press pe pxx pyy pzz pxy pxz pyz v_strain v_sxy
run                 ${dyna_step}
write_data          ./output/shear/shear_end.*.data
write_restart       ./output/shear/shear_end.*.restart

print "-------------------------------- All done! -----------------------------------------"

2. Velocity 方法

############################################################################
################################# Velocity method ##########################
############################################################################

#------------------------------Model settings--------------------------
clear
shell               mkdir output ./output/minimize ./output/relax ./output/shear ./output/data

#------------------------------Basic settings--------------------------
units               metal
dimension           3  
boundary            s s p        
atom_style          atomic

variable            Temp equal 10          	# desired temperature
variable            tstp equal 0.001            # timestep
variable            tdamp equal 100*${tstp}     # damping parameters # 
variable            pdamp equal 1000*${tstp}    # for NPT ensemble   #
variable            dump_every equal 1000       
variable            equi_step equal 10000


read_data           Ni_supercell.lmp

variable            size_x equal xhi-xlo
variable            size_y equal yhi-ylo
variable            size_z equal zhi-zlo

variable            layer_thickness equal 0.1*${size_y}
variable            upper_layer_limit  equal  ${size_y}-${layer_thickness}
variable            lower_layer_limit  equal  ${layer_thickness}

# Define regions
region              upper block INF INF ${upper_layer_limit} INF INF INF units box          
region              lower block INF INF INF ${lower_layer_limit} INF INF units box 

# Define groups
group               upper region upper
group               lower region lower
group               boundary union upper lower
group               mobile subtract all boundary

#----------------------------------------- Force Field ------------------------------------
pair_style          eam             
pair_coeff          * * Ni_u3.eam

#--------------------------------------------- Minimization ---------------------------------------
thermo              100
timestep            ${tstp}
thermo_style        custom step temp etotal pe ke pxz

# fix boundary group


# compute specific quantities
compute             pot_energy all pe/atom
compute             stress all stress/atom NULL
dump                min all custom ${dump_every} ./output/minimize/dump_minimize.*.lammpstrj id type x y z c_pot_energy 


min_style           cg
minimize            1.0e-6 1.0e-6 10000 10000

write_data          ./output/minimize/mini.data

#------------------------------------------ equilibrium -------------------------------
undump              min
reset_timestep      0

compute             new3d mobile temp
compute             new2d mobile temp/partial 0 1 1

velocity            mobile create ${Temp} 12345 units box


#fix				1 all npt temp ${Temp} ${Temp} ${tdamp} aniso 0.0 0.0 ${pdamp}
fix				1 all nve
fix                 0 boundary setforce 0.0 0.0 0.0
fix                 2 mobile temp/rescale 10 ${Temp} ${Temp} 10.0 1.0
fix_modify          2 temp new3d

#fix_modify          1 temp new3d

thermo              1000
thermo_modify       temp new3d
run                 ${equi_step} 

write_data          ./output/relax/equil.data
write_restart       ./output/relax/equil.restart

#------------------------------------------- shear in xy plane -------------------------------------
#change_box          all boundary s s p

reset_timestep      0
unfix               1

#fix				1 all nvt temp ${Temp} ${Temp} ${tdamp}
#fix_modify          1 temp new3d

#run				10000
#reset_timestep      0
#unfix               1

variable            tmpx equal lx
variable            tmpy equal ly
variable            tmpz equal lz
variable            L0x equal ${tmpx}
variable            L0y equal ${tmpy}
variable            L0z equal ${tmpz}

variable        	vol_ini equal v_L0x*v_L0y*v_L0z
print "Initial volumn, vol = ${vol_ini}"
# In units metal, pressure is in [bars]; sxx, syy, szz are in GPa
compute         	2 mobile stress/atom NULL
compute         	strsxy mobile reduce sum c_2[4]
variable        	unit equal 1E-4

#variable        	sxy equal ${unit}*(c_strsxy/v_vol_ini)
variable            deltaL  equal  (lx-${L0x})
variable            sxy equal "-pxy/10000"          # calculate shear stress
variable            strain equal v_deltaL/ly        # calculate shear strain

variable            srate equal 0.01           
variable            vx equal ${srate}*${L0y}
variable            final_strain equal 0.3
#variable            dyna_step equal ${final_strain}/(${srate}*${tstp})
variable			dyna_step equal 15000

# deformation starts!
fix				1 all nve
fix                 2 mobile temp/rescale 10 ${Temp} ${Temp} 10.0 1.0
fix_modify          2 temp new2d

velocity            upper set 2.0 0.0 0.0 units box
velocity            mobile ramp vx 0.0 2.0 y ${lower_layer_limit} ${upper_layer_limit} sum yes units box

dump                result all custom ${dump_every} ./output/shear/dump.*.lammps id type x y z
fix                 def1 all print 1000 "${strain} ${sxy}" file ./output/data/Shear_data.txt screen no
#
fix                 def1 all ave/time 100 10 1000 v_strain v_sxy file ./output/data/Shear_data.txt
thermo_style 	    custom step press pe pxx pyy pzz pxy pxz pyz v_strain v_sxy
run                 ${dyna_step}
write_data          ./output/shear/shear_end.*.data
write_restart       ./output/shear/shear_end.*.restart

print "-------------------------------- All done! -----------------------------------------"

四、Python绘图代码

1. Python 代码

具体请参考 :《I论文—Python绘图模板及技巧(未完成)》

import os
def make_save_file(filepath,filename,savename):
    # filepath 存储路径; filename:创建文件夹的名字 savename:存储图片的名字
    save_path = filepath+os.sep+filename+os.sep+savename
    all_path  = filepath+os.sep+filename
    if not os.path.exists(all_path):
        os.mkdir(all_path)
    plt.savefig(save_path,dpi=150)
filepath = r"PureNi_shear"
font1 = {'family': 'Times New Roman',
             'weight': 'bold',
             'size': 22,
             }
font2 = {'family': 'Times New Roman',
             'weight': 'normal',
             'size': 11,
             }
# Global setting
# ----------------------------------------------------------------------#
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# coding:utf-8
import pylab
import matplotlib.ticker as plticker
from matplotlib.pyplot import MultipleLocator
import xlrd
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import math
from scipy import optimize
plt.style.use('science')
# ----------------------------------------------------------------------#
# ----------------------------------------------------------------------#
def setup(ax,x_label,y_label):
    # 边框线的线宽设置
    width = 1.5
    ax.spines['top'].set_linewidth(width)
    ax.spines['bottom'].set_linewidth(width)
    ax.spines['left'].set_linewidth(width)
    ax.spines['right'].set_linewidth(width)
    # 边框上的ticks的出现
    ax.tick_params(top='on', bottom='on', left='on', right='on', direction='in')
    # 边框上的ticks对应的lable,即数字的尺寸
    ax.tick_params(labelsize=20,pad=6)
    #ax.yaxis.set_ticks_position('right')
    ax.tick_params(which='major', width=1.50, length=6)
    ax.tick_params(which='minor', width=0.75, length=0)
    # 边框上的ticks的出现的间隔
    locx = plticker.MultipleLocator(base=0.1) # this locator puts ticks at regular intervals
    ax.xaxis.set_major_locator(locx)
    locy = plticker.MultipleLocator(base=10) # this locator puts ticks at regular intervals
    ax.yaxis.set_major_locator(locy)
    # 边框上的注释labels
    labels = ax.get_xticklabels() + ax.get_yticklabels()
    [label.set_fontname('Times New Roman') for label in labels]
    # 边框上的注释labels距离坐标轴的距离
    xAxisLable = x_label 
    yAxisLable = y_label
    ax.set_xlabel(xAxisLable, font1, labelpad=5)
    ax.set_ylabel(yAxisLable, font1, labelpad=5)
# ----------------------------------------------------------------------#
# 读取excel
excel_path = r"out.xlsx"
work_sheet = xlrd.open_workbook(excel_path);

# sheet的数量
sheet_num = work_sheet.nsheets;
# 获取sheet name
sheet_name = []
for sheet in work_sheet.sheets():
    sheet_name.append(sheet.name)
# ----------------------------------------------------------------------#
# ----------------------------------------------------------------------#
for sheet_num in range(100):
    # 选取sheet
    now_sheet = work_sheet.sheets()[0]
    
    #now_sheet_ref = work_sheet.sheets()[3]
    # sheet的行
    row = now_sheet.nrows
    # sheet的列
    ncol = now_sheet.ncols
    #----------------------------------------------------------------------#
    #----------------------------------------------------------------------#
    font1 = {'family': 'Times New Roman',
             'weight': 'bold',
             'size': 18,
             }
    font2 = {'family': 'Times New Roman',
             'weight': 'normal',
             'size': 11,
             }
    #----------------------------------------------------------------------#     
    # temp
    deform_strain        = now_sheet.col_values(0)
    deform_strain_matrix =  deform_strain[1:]

    deform_stress        = now_sheet.col_values(1)
    deform_stress_matrix = list(filter(None, deform_stress[1:])) 
    
    velocity_strain        = now_sheet.col_values(2)
    velocity_strain_matrix = list(filter(None, velocity_strain[1:]))

    velocity_stress        = now_sheet.col_values(3)
    velocity_stress_matrix = list(filter(None, velocity_stress[1:]))       
    
    markersize = 10  
    linewidth = 1
    markevery =2
    alpha =0.5
    p_1 = dict(marker='o',color = 'r',linestyle = 'none',markevery=markevery,markerfacecolor='r',markersize=markersize,linewidth=linewidth,alpha=alpha)
    p_2 = dict(marker='s',color = 'b',linestyle = 'none',markevery=markevery,markerfacecolor='none',markersize=markersize,linewidth=linewidth,alpha=alpha)

    #----------------------------------------------------------------------#
     
    fig, axe = plt.subplots(1, 1, figsize=(5,5))

    axe.plot(deform_strain_matrix[0:sheet_num],  deform_stress_matrix[0:sheet_num],**p_1,label='Deform method')   
    #axe.plot(velocity_strain_matrix,  velocity_stress_matrix,**p_2,label='Velocity method')
    plt.axvline(deform_strain_matrix[sheet_num],color='k',lw=2,linestyle='dashed')
    
    axe.set_ylim(0, 20)
    axe.set_xlim(0, 0.2)
    setup(axe,r'Sheer strain',r'$\rm Stress\ /Gpa$')
       
    axe.legend(loc='best', frameon=False, \
                  labelspacing=0.3)
    axe.legend(bbox_to_anchor=(0.4, 1), \
                  loc='upper left', borderaxespad=0.,fontsize='xx-large')

    # 图片保存
    filename = "deform"
    savename = str(sheet_num)+".jpg"
    make_save_file(filepath,filename,savename)
    # ----------------------------------------------------------------------#

plt.show()

2. 数据下载

1. 数据处理下载

链接:(请点击)
提取码:9rpj

2. 全部代码(包含In文件)下载

链接:(请点击)
提取码:kh4v

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mr. Material

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值