Skip to content

Instantly share code, notes, and snippets.

@synodriver
Created June 14, 2022 14:46
Show Gist options
  • Save synodriver/5023a02229204a4c5975d9f85829e094 to your computer and use it in GitHub Desktop.
Save synodriver/5023a02229204a4c5975d9f85829e094 to your computer and use it in GitHub Desktop.
"""
Copyright (c) 2008-2021 synodriver <[email protected]>
"""
import numpy as np
YIELD_STRESS = 400 # 屈服强度400Mpa
def main():
data = np.loadtxt("data.csv", delimiter=",") # 读取应力应变曲线 第一列应力 第二列应变
for i in range(data.shape[0]):
if data[i][1] > YIELD_STRESS:
youndsmodule = data[i - 1][1] / data[i - 1][0]
break
print(f"杨氏模量为 {youndsmodule}")
print("以下是屈服应力和塑性应变")
with open("output.csv", "w") as f:
for i in range(data.shape[0]):
if data[i][1] > YIELD_STRESS:
qufuyingli = data[i][1]
suxingyingbian = data[i][0] - qufuyingli / youndsmodule
f.write(f"{qufuyingli} {round(suxingyingbian, 5)}\n")
pass
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment