(T,P) 300 310 320 330 340 350 F
3400 1 1 1 1 1 1
3300 1 1 1 1 1 1
3200 1 1 0.95 0.95 0.95 0.9
3100 1 0.95 0.9 0.85 0.85 0.8
3000 0.95 0.9 0.85 0.82 0.81 0.8
2900 0.9 0.85 0.8 0.8 0.75 0.73
2800 0.85 0.8 0.75 0.73 0.72 0.7
psia
目前我有这张桌子。目标是输入温度(例如,320 F),然后搜索从1到0.95的第一液体馏分变化,并使用二分法找出压力。以下是我的代码。他们没有工作。我真的需要有人为我纠正它。非常感谢!
Sub Linear()
Dim aksheet As Worksheet
Set aksheet = ThisWorkbook.Sheets("Sheet1")
Dim i As Integer
Dim LastRow As Long
Dim LastCol As Long
Dim c As Long
Dim Tin As Double
Dim Pout As Double
With aksheet
LastRow = aksheet.Range("A9").End(xlUp).Row
LastCol = aksheet.Range("H1").End(xlToLeft).Column
'input temperature
Tin = aksheet.Range("B25").Value
itemp = 0
For i = 1 To LastCol - 1
T(i) = Cells(1, i + 1).Value
Next
If Tin - T(6) > 0 Then
MsgBox ("Input temperature is too high")
ElseIf Tin - T(1) < 0 Then
MsgBox ("Input Temperature is too low")
End If
FirstRow = 1
For c = FirstRow To LastRow
If Tin = T(i) And .Cells(c, i).Value < 1 Then
interp = (0.99, .Cells (c,i),.Cells(c+1,i),.Cells(c,1),.Cells(c+1,1))
End If
Next c
End With
Range("B30").Value = Pb
End Sub
Function interp(Xin, T1, T2, P1, P2) As Double
interp = P1 + (P2 - P1) * (Tin - T1) / (T2 - T1)
End Function