| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 386 人关注过本帖
标题:好吧,表示太菜了,新手再来求大神指点~
取消只看楼主 加入收藏
liu141231893
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-10-29
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:0 
好吧,表示太菜了,新手再来求大神指点~
Private Sub Form_click()
    Dim a As String
    Dim i As Integer
    Dim kk As Integer
    Dim j As Double
    Dim he!
    Dim v1!, v2!, v3!
    Dim z!(), v!()            '水库水位和库容曲线
    Dim zx!(), qx!()        '下游水位和流量关系
    Dim ql!(), qxx!()            '上游来水和下游需水
    Dim capacity!, bzcl!, kn!       '装机容量,保证出力,出力系数
    Dim minlever!, diaoduchu!, diaodumo!    '死水位,调度初水位,调度末水位
    Dim sum1!
    Dim ht#()       '调度线
    Dim s!, s1!
    Dim n!(), n1!(), n2!(), n3!()     '中间过程发电量
    Dim qq1 As Double
    Dim qq2 As Double
    i = 0
    Open App.Path & "\z-v.txt" For Input As #1
        'Input #1, a
        Do While Not EOF(1)
            i = i + 1
            ReDim Preserve z(i), v(i)
            Input #1, z(i), v(i)
            'Print z(i), v(i)
        Loop
        Close 1
        
    i = 0
    Open App.Path & "\z-q.txt" For Input As #2
        Do While Not EOF(2)
            i = i + 1
            ReDim Preserve zx(i), qx(i)
            Input #2, zx(i), qx(i)
            Print zx(i), qx(i)
        Loop
        Close 2
        
    i = 0
    Open App.Path & "\上游来水.txt" For Input As #3
        Do While Not EOF(3)
            i = i + 1
            ReDim Preserve ql(i)
            Input #3, ql(i)
            'Print ql(i)
        Loop
        Close 3
        
    i = 0
    Open App.Path & "\下游需水.txt" For Input As #4
        Do While Not EOF(4)
            i = i + 1
            ReDim Preserve qxx(i)
            Input #4, qxx(i)
            'Print qxx(i)
        Loop
        Close 4
            
    capacity = 32
    bzcl = 12.8
    kn = 0.8
    minlever = 135
    buchang = 0.1
    diaoduchu =160
    diaodumo = 160
   
    sum1 = UBound(ql)
    'Print sum1
    ReDim ht(sum1 + 1), n(sum1 + 1), n3(sum1 + 1), qx(sum1), qfd(sum1), qql(sum1)
    kk = (160 - minlever) / buchang
   
    For i = 1 To sum1 + 1
        ht(i) = diaoduchu
        n(i) = 0
        'Print n(i)
    Next i
    s = 0
    s1 = 0
    Do
    For i = 2 To sum1 - 1 Step 1
        For j = 160 To minlever Step -buchang
            kk = (160 - j) / buchang
            v1 = cha(z(), v(), ht(i - 1))
            v2 = cha(z(), v(), j)
            v3 = cha(z(), v(), ht(i + 1))
                                           '第一次调用cha函数
            qq1 = (v1 - v2) * 38.58 + ql(i - 1)         '38.58=(10^8/30*24*3600)
            qq2 = (v2 - v3) * 38.58 + ql(i)
            h1 = (ht(i - 1) + j) / 2 - cha(qx(), zx(), qq1)
            h2 = (ht(i + 1) + j) / 2 - cha(qx(), zx(), qq2)
                                    '第二次调用cha函数
            n1(kk + 1) = kn * qq1 * h1 / 10000
            n2(kk + 1) = kn * qq2 * h2 / 10000
            
            If n1(kk + 1) > capacity Then
                n1(kk + 1) = capatity
            End If
            If qq1 < qxx(i) Or n1(kk + 1) < bzcl Then
                n1(kk + 1) = -10000000
            End If
            If n2(kk + 1) > capacity Then
                n2(kk + 1) = capatity
            End If
            If qq2 < qxx(i) Or n2(kk + 1) < bzcl Then
                n2(kk + 1) = -10000000
            End If
            
            no = n1(kk + 1) + n2(kk + 1)
            If no > n(i - 1) + n(i) Then
                n(i - 1) = n1(kk + 1)
                n(i) = n2(kk + 1)
                ht(i) = j
                x = n1(kk + 1)
                y = n2(kk + 1)
            End If
            Next j
            s = s + x
            Next i
            s = s + y
            
            he = Abs(s - s1) / s
            s1 = s
            Loop While he > 0.01
            For i = 1 To sum1 - 1 Step 1
                Print ht(i)
            Next
            
            
End Sub

Public Function cha!(x!(), y!(), a#)
    Dim zhi As Single
    n = UBound(x)
    For i = 1 To n
        Debug.Print x(2)
    Next
    If x(1) >= a Then
    zhi = y(1)
    ElseIf x(n) < a Then
        zhi = y(n)
    Else
   
    For i = 1 To n
        If x(i) > a Or x(i) = a Then
        ml = i
        Exit For
        End If
    Next i
    zhi = y(ml - 1) + (y(ml) - y(ml - 1)) * (a - x(ml - 1)) / (x(ml) - x(ml - 1))
    End If
    cha = zhi
End Function

'如上面程序所示我在调用第二次cha函数时,显示x!()的ubound及n为12,可是我的txt格式里的数据只有7个,为什么n会等于12呢,求大神指点。。。

[ 本帖最后由 liu141231893 于 2014-10-29 17:00 编辑 ]
搜索更多相关主题的帖子: 流量 capacity 
2014-10-29 16:58
快速回复:好吧,表示太菜了,新手再来求大神指点~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017353 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved