数据处理-拉伸中的strain-stress曲线
生活随笔
收集整理的這篇文章主要介紹了
数据处理-拉伸中的strain-stress曲线
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
- 基本步驟
- 軟件推薦
- 代碼部分
- 草圖輸出
- 福利
主要記錄科研中遇到的通用數據處理過程
源代碼下載:Deformation of Amorphous Polyethylene,不過里面的data不是以文件形式提供的,不太方便。
所以可以從我的資源里下載:deformTest.tar.gz,里面含有基本的源數據和對應的處理py腳本。
基本步驟
軟件推薦
IDE部分建議使用Spyder,界面和Matlab類似。
代碼部分
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jan 8 12:37:24 2021@author: yuanbaoqiangThis is a simple py to handle the data in multi txt files, mainly including three steps:1. ENSURE YOUR DATA FILES2. OBTAIN YOUR DATA3. PLOT """# Import modules you need to deal with your files # glob,os ---> file processing import glob,os # pandas ----> data processing import pandas as pd # matplotlib ----> plot import matplotlib.pyplot as plt######################################################## # 1. FIND THE PATH, AND LOAD NEEDED FILES IN THIS PATH# To get the py file's absolute path path=os.getcwd() # Add all .txt files in the path above file=glob.glob(os.path.join("*.txt")) # Sort all .txt files you have added file.sort() # You can also sort all files by using the keyword in your file name with the lamba experession below # file.sort(key = lambda x: int(x[13:-4])) print('You have added ' + str(len(file)) + ' files, and they are ' + str(file))# Define a empty list # List named "df" is to store your data in every file seperately in a dataframe element df = [] # List named "names" is to define column names of every dataframe names = [] names1 = ['strain', 'pxx', 'pyy', 'pzz', 'lx', 'ly', 'lz' , 'temp']; names2 = ['strain', 'epair', 'ebond', 'eangle', 'edihed'] names.append(names1) names.append(names2)######################################################## # 2. OBTAIN THE DATA IN FILES YOU HAVE LOADED# Traverse the list and obtain the needed frame in each file i = 0 for f in file:# Official interpretation about "pandas.read_csv", which is the most "read" command I have used# https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.htmldf.append(pd.read_csv(f, delim_whitespace=True, names=names[i], skiprows=[0]))i = i + 1######################################################## # 3. JUST PLOT USING THE DATA YOU NEEDED# Plot a simple graph, and you can see a rough prototype like the "strain-stress" curve in the paper: # 10.1016/j.polymer.2010.10.009 plt.plot(df[0][:]['strain'], df[0][:]['pxx'])草圖輸出
不含數據的處理,只是一個基本草圖輸出,但從趨勢來看是和論文大致相同的。
10.1016/j.polymer.2010.10.009論文中的圖:
福利
本群在lammps學習過程中給予了我莫大的幫助,群里很活躍,歡迎小伙伴的加入~
歡迎加入qq群:698671585
歡迎關注群主的公眾號,lammps_zhushou,文章持續更新中~
總結
以上是生活随笔為你收集整理的数据处理-拉伸中的strain-stress曲线的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自写app与树莓派制作智能小车
- 下一篇: 高通骁龙660/骁龙662/骁龙665/