VBA实现的马斯京根推流示例

马斯京根模型是一种有效的河道推流方法,在水文预报中有着广泛的应用,这一模型参数较少(c1,c2,c3),而且实现简单,这里水文工具集给出一个VBA实现的马斯京根模型的一个示例,如果需要对不同数据进行推流,可以更改里面的河道入流过程及模型参数,具体源代码如下:

Public Sub MSJG_ex()

    Dim I(M)    'M为时段段个数
    Dim O(M)
    Dim strfile As String
    strfile = "D:\test3.txt"
    Const c0 = -0.251
    Const c1 = 0.876
    Const c2 = 0.375

    '举的例子
    I(1) = 2050: I(2) = 2860
    I(3) = 4300: I(4) = 4820
    I(5) = 4700: I(6) = 4350
    I(7) = 3750: I(8) = 3200
    I(9) = 2700: I(10) = 2400
    I(11) = 2200: I(12) = 2050
    Open strfile For Output As #1

    For j = 1 To M
        O(1) = I(1)
        O(j + 1) = c0 * I(j + 1) + c1 * I(j) + c2 * O(j)
        Print #1, Format(O(j + 1), "###0.00")
    Next j
    Close #1

End Sub


发表评论

You must be logged in to post a comment.