limengde2001 发表于 2014-3-21 09:50

异步启动永磁同步电机设计程序 (vb源码分享)福利1:b-h曲线查询

异步启动永磁同步电机设计程序 (vb源码分享)福利1:b-h曲线查询

主贴见:https://bbs.simol.cn/thread-131885-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

limengde2001 发表于 2014-3-21 15:33

备注:拉格朗日插值当数据太多,会在中间值产生很大偏差,最好分段插值。又因为电机硅钢片b-h表很详细。
所以解决上述问题的方法是把查询的值近似到节点。上述最后一段查询代码要稍加修改。

tjxlms130 发表于 2014-6-16 09:49

谢谢,东西很好,我要学习

dream-ttt 发表于 2017-3-29 08:25

感谢楼主分享源码{:1_562:}

LZY112233 发表于 2019-4-13 15:52

{:1_561:}好东西,真的值得拥有

dream-ttt 发表于 2022-8-9 08:26

谢谢李工分享源码{:1_494:}
页: [1]
查看完整版本: 异步启动永磁同步电机设计程序 (vb源码分享)福利1:b-h曲线查询