-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path5generating k-values.cpp
More file actions
150 lines (137 loc) · 3.19 KB
/
5generating k-values.cpp
File metadata and controls
150 lines (137 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <ctime>
#include <iomanip>
#include <string>
#include <sstream>
using namespace std;
#include "RandNum.h"
CRandNum randNum;
#define RAN randNum.GenRandReal_10()
#define RAN00 randNum.GenRandReal_00()
#define RANDINT randNum.GenRandInt32()
#define Norm randNum.Gaussian_Noise()
const double ktwomean = 0.1;
const double ktwosd = 0.01;
const double konemean = 3;
const double konesd = 0.6;
const double rzero = 2;
const int noofodour = 16;
const int noofconc = 1;
const int noofodourant = 160;
const int noofoutputfileodour=16;
int main()
{
int i;
int j;
int k;
int m;
double kone;
double knegone;
double ktwo;
double knegtwo;
double n[noofodourant];
double chalf;
double maxfr[noofodourant][noofconc];
double maxcond[noofodourant][noofconc];
double fmax;
double maxfmax;
int counter;
double temp;
int badnesscounter;
int totalbad=0;
int totalbadtwo=0;
int totalbadthree=0;
int counterfilename;
int on;
srand(time(NULL));
//generate k-values with parameters from Hill curves as contraints
ifstream inputfileone;
ifstream inputfiletwo;
ifstream inputfilethree;
ifstream inputfilefour;
inputfileone.open("chalf.txt");
inputfilethree.open("fmax.txt");
inputfilefour.open("maxfmax.txt");
inputfilefour>>maxfmax;
inputfilefour.close();
ofstream outputone;
outputone.open("kone.txt");
ofstream outputtwo;
outputtwo.open("ktwo.txt");
ofstream outputthree;
outputthree.open("knegone.txt");
ofstream outputfour;
outputfour.open("knegtwo.txt");
ofstream outputfive;
outputfive.open("totalbad.txt");
// ofstream outputsix;
// outputsix.open("thalfrise.txt");
// ofstream outputseven;
// outputseven.open("thalfdecay.txt");
// ofstream outputeight;
// outputeight.open("tonetenthrise.txt");
// ofstream outputnine;
// outputnine.open("tonetenthdecay.txt");
totalbad=0;
totalbadtwo=0;
inputfiletwo.open("nprime.txt");
for (i=0;i<noofodourant;i++)
{
inputfiletwo>>n[i];
n[i]=n[i]/log(10);
}
inputfiletwo.close();
for (j=0;j<noofodour;j++)
{
for (i=0;i<noofodourant;i++)
{
inputfileone>>chalf;
inputfilethree>>fmax;
ktwo=ktwomean+Norm*ktwosd;
if (fmax>0.02)
knegtwo=ktwo*(rzero/fmax-1);
else knegtwo=50*(1+0.1*Norm);
badnesscounter=0;
do
{
kone = konemean+Norm*konesd;
temp= n[i]*chalf*log(10);
kone=kone*(1+0.25*Norm)/sqrt(exp(temp));
knegone=kone*exp(temp)*(1+ktwo/knegtwo);
if (knegone<0.01)
{
knegone=0.01*(1+0.1*RAN);
if ((kone<5000) and (kone>0.1))
totalbadtwo=totalbadtwo+1;
else
totalbadthree=totalbadthree+1;
}
badnesscounter=badnesscounter+1;
}
while (((kone<0.1) or (kone>5000)) and (badnesscounter<1000));
if (badnesscounter>=2)
{
totalbad=totalbad+1;
if (badnesscounter>=1000)
totalbad=totalbad+1000000;
}
outputone<<kone<<" ";
outputtwo<<ktwo<<" ";
outputthree<<knegone<<" ";
outputfour<<knegtwo<<" ";
}
outputone<<endl;
outputtwo<<endl;
outputthree<<endl;
outputfour<<endl;
}
outputfive<<totalbad<<" "<<totalbadtwo<<" "<<totalbadthree;
outputone.close();
outputtwo.close();
outputthree.close();
outputfour.close();
outputfive.close();
}