- 积分
- 28504
- 回帖
- 0
- 西莫币
-
- 贡献
-
- 威望
-
- 存款
-
- 阅读权限
- 120
- 最后登录
- 1970-1-1
该用户从未签到
|
楼主 |
发表于 2014-3-21 09:51
|
显示全部楼层
异步启动永磁同步电机设计程序 (vb源码分享)福利1:b-h曲线查询:https://bbs.simol.cn/thread-131886-1-1.html
b-h曲线查询方法简介:
1、读入b-h曲线文件到二维数组
1、采用拉格朗日插值法查询值
'load B-H CURVE file读入b-h曲线文件到二维数组
Dim a() As String
Dim b() As String
Dim i As Integer
i = 0
'''read text
Open App.Path & "\" & "BH_" & materialfe & ".TXT" For Input As #1
On Error GoTo h
Do While Not EOF(1)
ReDim Preserve a(i)
ReDim Preserve b(i)
Input #1, a(i), b(i)
i = i + 1
Loop
h:
Close #1
'''load into variable
ReDim Preserve bh_fe(UBound(a), 1)
For i = 0 To UBound(a)
bh_fe(i, 0) = CDbl(a(i))
bh_fe(i, 1) = CDbl(b(i))
'show b-h curve
'Formmain.Text_output.Text = Formmain.Text_output.Text & bh_fe(i, 1) & "," & bh_fe(i, 2) & vbCrLf
Next
'插值算法
'lagrangeczfun 拉格朗日插值法
Public Function lag(a() As Double, ByVal u As Double) As Double 'a(1,n)存储n+1个节点,u为插值点
Dim i As Integer, j As Integer, n As Integer
Dim l As Double, v As Double
v = 0
n = UBound(a, 1)
l = bh_fe(2, 0)
s = materialfe
l = br_20
For j = 0 To n
l = 1
For i = 0 To n
If (i <> j) Then
l = l * (u - a(i, 0)) / (a(j, 0) - a(i, 0))
Else
End If
Next i
v = v + l * a(j, 1)
Next j
lag = v
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''
'磁化曲线查询
Public Function b2h(b As Double) As Double 'lookup b-h curve
b2h = lag(bh_fe(), b)
End Function |
|