首页 > 解决方案 > 如何使用 python 求解 csv 文件上的两个不同的依赖方程?

问题描述

我是 Python 新手,正在尝试使用 Jupyter notebook 从 .csv 表中读取数据并进行计算。在 csv 文件中,我有单独的列,它们是彼此的功能;换句话说,必须找到一个来解决另一个。在第 22 部分中,计算了 X 的值,并基于此我试图计算取决于 X 的值的“a”的值:公式此外,需要找到“a”才能计算“a'”。我正在尝试使用隐式类型函数,因为我不确定还能使用什么,但它给了我 NAN 值。基本上,我想做的是同时求解两个隐式类型方程,这是行不通的。Jupyter 输出

# In[1]:


import numpy as np
import pandas as pd
import matplotlib.pyplot as plt


# In[11]:


#Data Taken from Tutorial slide
#Section foil: [DU 97-W-300]
u = 12.0 #flow velocity
d = 150 #diameter
Z = 3 #number of blades
tsr = 7 #tip speed ratio
R = d/2
ang_speed = (tsr * u)/ R

###Step 1
#Reading Airfoil data from file
data = pd.read_csv("data.csv")
data['L/D ratio'] = data['C(Lift)']/data['C(Drag)']
data


# In[16]:


x = data['AoA']
z = data['C(Drag)']
y = data['C(Lift)']
plt.plot(x, y)
plt.plot(x, z)
plt.title("Angle of attack, Drag and Lift coeficcient relation")
plt.xlabel('Angle of attack')
plt.legend(["C(lift)", "C(drag)", "AoA"])
plt.ylabel('C(lift) and C(drag)')
plt.show()


# In[17]:


###PART I - Inviscid design

#So as to maximize power, the code will find the MAX value of the Lift to Drag ratio by using *idxmax()* function
design_ratio = data['L/D ratio'][data['L/D ratio'].idxmax()] 

#Here the code finds the design angle of attack value of the same row number
design_angle = data['AoA'][data['L/D ratio'].idxmax()] 

#Here the code finds the design angle of attack value of the same row number
design_lift = data['C(Lift)'][data['L/D ratio'].idxmax()] 


print("The design Lift to Drag ratio is : %.2f " %design_ratio)
print("The design Angle of attack is : %d" %design_angle)
print("The design Lift Coefficient is equal to : %.2f" %design_lift)


# In[22]:


#Reading discretized r/R ratio data from file
part1 = pd.read_csv('part1.csv') #Part1 file contains discretized values of r/R
part1['X'] = (part1['r/R']*R*ang_speed)/u
part1['X'] = (part1['a'])
part1

标签: pythonpandascsvimplicit-conversion

解决方案


推荐阅读