由BOD的实验室化验资料估算讲解系数K1时,可以采用最小二乘法。
//"input.txt"BOD化验资料
t(d) y(mg/L)
1 55
2 81
3 102
4 119
5 131
6 140
7 147
8 153
9 159
10 162
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cmath>
void main()
{
using namespace std;
const int N = 10,//天数
M = 100;//最大循环次数
double y[N],t[N],f1[N],f2[N],
Sum11 = 0, Sum22 = 0, Sum12 = 0, Sum1y = 0, Sum2y = 0,
a, d, L0, h, K1;
const double h0 = 0.0001;
ifstream infile;
infile.open("input.txt");
for(int i = 0; i<N; i++)
infile>>t[i]>>y[i];
infile.close();
K1 = 0.5;//假设K1的初始值
ofstream outfile;
outfile.open("output.txt");
for(int k = 0; k < M; k++)
{
for(int i = 0; i<N; i++)
{
f1[i] = 1 - exp(-K1*t[i]);
f2[i] = t[i]*exp(-K1*t[i]);
Sum11 += pow(f1[i],2);
Sum22+= pow(f2[i],2);
Sum12
水环境学——利用最小二乘法对BOD降解好氧系数K1估算
最新推荐文章于 2023-12-03 20:23:36 发布