水利水能规划——兴利调节模拟计算法

//兴利调节模拟计算.cpp
//通过额定供水量(此程序中为固定值)求有效库容
//或通过有效库容求额定供水量(求得结果为定值)
//来水过程已知,从已经划分好水利年的入库流量读取
//用水保证率已知
#include "stdafx.h"
#include <fstream>
#include<iostream>
#include<iomanip>

int T;//系列资料长度,单位:年
int DestroyYear, DestroyMonth;//用水不足,破坏
double 	M,//额定用水流量系列,单位:m/s
    Vx;//兴利库容,单位:(m/s*月)
double P,//用水保证率
	S[13],//兴利库容存水量,单位:(m/s*月)
	X[12],//来水流量系列,单位:m/s
	D[12];//库泄流量(实际用水量+超过最大过水能力的弃水)系列,单位:m/s
int Judge;//判断数
double Value, Left, Right;//待求值及其阈值
int Num;//试算次数

void main()
{
	using namespace std;
	ofstream outfile;
	outfile.open("outfile.txt");
	cout<<"输入系列长度(年):"<<endl;
	cin>>T;
	cout<<"求有效库容请输入,求额定用水流量输入:"<<endl;
	cin>>Judge;
	cout<<"请输入已知的效库容(m/s*月)或额定用水流量的值:"<<endl;
	if(Judge == 0)//求有效库容
	{
		cin>>M;
		outfile<<setw(10)<<"有效库容"<<setw(10)<<"供水保证率"<<endl;
	}
    if(Judge == 1) //额定用水流量
	{
		cin>>Vx;
		outfile<<setw(10)<<"额定用水流量"<<setw(10)<<"供水保证率"<<endl;
	}
	cout<<"输入待求值的下限:"<<endl;
	cin>>Left;
	cout<<"输入待求值的上限:"<<endl;
	cin>>Right;
	cout<<"输入试算次数:"<<endl;
	cin>>Num;
	for(int n = 0; n <= Num; n++)
	{//等差试算有效库容
		ifstream infile_X;
		infile_X.open("infile_X.txt");
		Value = (Right - Left)/Num*n + Left;
		if(Judge == 0) Vx = Value;
		else M = Value;
		S[0] = DestroyYear = 0;
		for(int year = 0; year < T; year++)
		{
			DestroyMonth = 0;
			for(int t = 0; t < 12; t ++)
			{//读入已按水利年分配的月来水流量
				infile_X>>X[t];
				if(S[t]+X[t] < M)
				{//破坏月
					D[t] = S[t]+X[t];
					DestroyMonth++;
				}
				else 
					if (S[t]+X[t]< M + Vx)
					D[t] = M;//正常供水段,未蓄满
					else D[t] = S[t] + X[t] - Vx;//加大泄水段,已蓄满
				S[t + 1] = S[t] + X[t] - D[t];
				if(t == 11) S[0] = S[t + 1];
			}
			if(DestroyMonth > 0) DestroyYear++;
		}
		infile_X.close();
		P = 1 - (double)DestroyYear/T;
		outfile<<setw(10)<<Value<<setw(10)<<P<<endl;		
	}
	outfile.close();
}


输入文件:"infile_X.txt"

717 615 265 1500 215 162 191 136 107 104 120 312
545 1540 410 873 1510 1110 621 288 165 85 130 450
483 592 590 958 236 182 797 369 115 190 127 133
783 1440 1600 2860 1480 142 195 91 139 100
  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值