-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab_4.cpp
192 lines (176 loc) · 12.7 KB
/
lab_4.cpp
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include <iostream>
#include <math.h>
#include <fstream>
using namespace std;
const double alpha = 17.06 * pow(10, -6); // alpha for temperature 100 C
const double T1 = 100;
const double T2 = 0;
//const double r1 = 0.015; //mm
//const double r2 = 0.020; //mm
//const double p1 = 15 * pow(10, 6); // MPa pressure number 1
//const double p2 = 0; // MPa pressure number 2
//const double elasticity = 100000 * pow(10,6);
//const double coefPua = 0.35;
//const double points = 11;
/**********************************************UTILITY*FUNCTIONS*********************************************/
double T_class (double r, double r1, double r2){ // T(r) for classical variant
double res = (T1 - T2) * (r2 - r)/(r2 - r1);
return res;
}
double T_log (double r, double r1, double r2){ // T(r) for logarithmical variant
double res = ((T1 - T2)/log(r2/r1)) * log(r2/r);
return res;
}
double module_class (double elasticity, double coefPua, double r1, double r2){ // first (class.) module. Was made only for convinient calculatings
double res = (elasticity*alpha*(T1 - T2))/(3*(1-coefPua) * (r2 - r1));
return res;
}
double module_log (double elasticity, double coefPua, double r1, double r2){ // first (log.) module. Was made only for convinient calculatings.
double res = (-1)*(elasticity*alpha*(T1 - T2))/(2*(1-coefPua) * log(r2/r1));
return res;
}
/*******************************************ENDING OF UTILITY FUNCTIONS************************************************/
//
//
/**********************************BEGINING OF MAIN FUNCTIONS (CLASSICAL VARIANTS)*****************************************/
double rad_tension_class (double r, double r1, double r2, double elasticity, double coefPua){
double delta = module_class(elasticity, coefPua, r1, r2);
double delta1 = (r - (pow(r1, 3))/(r*r) - (1 - (r1*r1)/(r*r))*(pow(r2, 3) - pow(r1, 3))/(r2*r2 - r1*r1));
//cout << endl << delta1 << endl << endl;
return delta * delta1;
}
double tan_tension_class (double r, double r1, double r2, double elasticity, double coefPua){
double delta = module_class(elasticity, coefPua, r1, r2);
double delta1 = (2*r + (pow(r1, 3))/(r*r) - (1 + (r1*r1)/(r*r))*(pow(r2, 3) - pow(r1, 3))/(r2*r2 - r1*r1));
//cout << endl << delta1 << endl << endl;
return delta * delta1;
}
double axis_tension_class (double r, double r1, double r2, double elasticity, double coefPua){
double delta = module_class(elasticity, coefPua, r1, r2);
double delta1 = (3*r - (2*(pow(r2, 3) - pow(r1, 3)))/(r2*r2 - r1*r1));
//cout << endl << delta1 << endl << endl;
return delta * delta1;
}
/**********************************ENDING OF MAIN FUNCTIONS (CLASSICAL VARIANTS)*****************************************/
//
//
//
/*****************************************BEGINING OF MAIN FUNCTIONS (LOG VARIANTS)*************************************/
double rad_tension_log (double r, double r1, double r2, double elasticity, double coefPua){
double delta = module_log(elasticity, coefPua, r1, r2);
double delta1 = (log(r2/r) + ((r1*r1)/(r2*r2 - r1*r1)) * (1 - (r2*r2)/(r*r)) * log(r2/r1));
//cout << endl << delta1 << endl << endl;
return delta * delta1;
}
double tan_tension_log (double r, double r1, double r2, double elasticity, double coefPua){
double delta = module_log(elasticity, coefPua, r1, r2);
double delta1 = (1 - log(r2/r) - ((r1*r1)/(r2*r2 - r1*r1)) * (1 + (r2*r2)/(r*r)) * log(r2/r1));
//cout << endl << delta1 << endl << endl;
return delta * delta1;
}
double axis_tension_log (double r, double r1, double r2, double elasticity, double coefPua){
double delta = module_log(elasticity, coefPua, r1, r2);
double delta1 = (1 - 2*log(r2/r) - (2*(r1*r1)/(r2*r2 - r1*r1)) * log(r2/r1));
//cout << endl << delta1 << endl << endl;
return delta * delta1;
}
/**********************************ENDING OF MAIN FUNCTIONS (LOG VARIANTS)*****************************************/
double fourth_formule_tension (double a, double b, double c){
double p = pow(2, -0.5);
double first = pow((a-b),2);
double second = pow((a-c),2);
double third = pow((b-c),2);
double main = pow(first+second+third, 0.5);
return p * main;
}
//double moving (double r, double r1, double r2, double p1, double p2, double coefPua, double elasticity){
// double res1 = (1 - coefPua)/elasticity;
// double res2 = (1 + coefPua)/elasticity;
// double delta = ((pow(r1, 2)*p1) - (pow(r2, 2)*p2))/(r2*r2-r1*r1);
// double delta1 = ((pow(r1, 2) * pow(r2, 2) * (p1 - p2))/(r2*r2-r1*r1));
// double delta2 = (1/(r*r));
// return res1 * delta + (delta1 * delta2) * res2;
//}
//
//double equivalent_tension (double ten1, double ten2){
// double res = ten2 * ten2 - ten1 * ten2 + ten1 * ten1;
// double result = 1/(pow(2, 0.5)) * pow(res, 0.5);
// return result;
//}
int main(){
double r1, r2, p1, p2, elasticity, coefPua, points;
double element[7];
std::ifstream in("input.txt");
std::ofstream out("output.txt");
std::ofstream out_sub("subtension.txt");
std::ofstream out_plus("plustension.txt");
for (int i = 0; i < 7; i++){
in >> element[i];
}
in.close();
double rad_2[(int)element[6]], rad_t_2[(int)element[6]], tan_t_2[(int)element[6]], mov_t_2[(int)element[6]], const_2[(int)element[6]], equil_t_2[(int)element[6]], max_equil_t_4th;
ifstream inner("result2.txt");
for (int i = 0; i < 12; i++){
if (i < 11){
inner >> rad_2[i];
inner >> rad_t_2[i];
inner >> tan_t_2[i];
inner >> mov_t_2[i];
inner >> const_2[i];
inner >> equil_t_2[i];
}
else if (i == 11){
inner >> max_equil_t_4th;
}
}
inner.close();
// std::cout << "Calculating for class variant:\n";
// std::cout << " Radial tension is : " << rad_tension_class((element[0]+element[1])/2, element[0], element[1], element[4], element[5]) << std::endl;
// std::cout << " Tangential tension is : " << tan_tension_class((element[0]+element[1])/2, element[0], element[1], element[4], element[5]) << std::endl;
// std::cout << " Axis tension is : " << axis_tension_class((element[0]+element[1])/2, element[0], element[1], element[4], element[5]) << std::endl;
// std::cout << "Calculating for log variant:\n";
// std::cout << " Radial tension is : " << rad_tension_log((element[0]+element[1])/2, element[0], element[1], element[4], element[5]) << std::endl;
// std::cout << " Tangential tension is : " << tan_tension_log((element[0]+element[1])/2, element[0], element[1], element[4], element[5]) << std::endl;
// std::cout << " Axis tension is : " << axis_tension_log((element[0]+element[1])/2, element[0], element[1], element[4], element[5]) << std::endl;
out << "========================================================================================================================================================================================================" << std::endl;
out << "Radius Rad tension Tang tension Axis tension Log Rad tension Log Tang tension Log Axis tension" << std::endl;
double radius = element[0];
double equi = 0;
for (int i = 0; i < element[6]; i++){
// if (radius!=0.020 && radius!=0.015){
// out << radius <<" " << rad_tension_class(radius, r1, r2, elasticity, coefPua) << " "<<tan_tension_class(radius, r1, r2, elasticity, coefPua)<<" "<<axis_tension_class(radius, r1, r2, elasticity, coefPua)<<" "<<rad_tension_log(radius, r1, r2, elasticity, coefPua) << " " << tan_tension_log(radius, r1, r2, elasticity, coefPua) << " " << axis_tension_class(radius, r1, r2, elasticity, coefPua) << std::endl;
// }
if(radius==0.020){
out << radius <<" " << rad_tension_class(radius, element[0], element[1], element[4], element[5]) << " "<<tan_tension_class(radius, element[0], element[1], element[4], element[5])<<" "<<axis_tension_class(radius, element[0], element[1], element[4], element[5])<<" "<<rad_tension_log(radius, element[0], element[1], element[4], element[5]) <<" " << tan_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << axis_tension_class(radius, element[0], element[1], element[4], element[5]) << std::endl;
}
else if(radius==0.015){
out << radius <<" " << rad_tension_class(radius, element[0], element[1], element[4], element[5]) << " "<<tan_tension_class(radius, element[0], element[1], element[4], element[5])<<" "<<axis_tension_class(radius, element[0], element[1], element[4], element[5])<<" "<<rad_tension_log(radius, element[0], element[1], element[4], element[5]) <<" " << tan_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << axis_tension_class(radius, element[0], element[1], element[4], element[5]) << std::endl;
}
// if (equivalent_tension (rad_tension(radius, r1, r2, p1, p2), tan_tension(radius, r1, r2, p1, p2)) > equi){
// equi = equivalent_tension (rad_tension(radius, r1, r2, p1, p2), tan_tension(radius, r1, r2, p1, p2));
// }
if (radius != 0.020 && radius != 0.015){
out << radius <<" " << rad_tension_class(radius, element[0], element[1], element[4], element[5]) << " "<<tan_tension_class(radius, element[0], element[1], element[4], element[5])<<" "<<axis_tension_class(radius, element[0], element[1], element[4], element[5])<<" "<<rad_tension_log(radius, element[0], element[1], element[4], element[5]) <<" " << tan_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << axis_tension_class(radius, element[0], element[1], element[4], element[5]) << std::endl;
}
radius+=(0.005/9);
}
// out << std::endl << std::endl << "Max equivalent tension using 4th theory of strength is " << equi;
out.close();
radius = element[0];
cout << "Subtractions of class. and log. tensions: " << endl;
for (int i = 0; i < element[6]; i++){
out_sub << rad_tension_class(radius, element[0], element[1], element[4], element[5]) - rad_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << tan_tension_class(radius, element[0], element[1], element[4], element[5]) - tan_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << axis_tension_class(radius, element[0], element[1], element[4], element[5]) - axis_tension_log(radius, element[0], element[1], element[4], element[5]) << endl;
cout << rad_tension_class(radius, element[0], element[1], element[4], element[5]) - rad_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << tan_tension_class(radius, element[0], element[1], element[4], element[5]) - tan_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << axis_tension_class(radius, element[0], element[1], element[4], element[5]) - axis_tension_log(radius, element[0], element[1], element[4], element[5]) << endl;
radius+=(0.005/9);
}
out_sub.close();
cout << endl << endl;
radius = element[0];
cout << "Additions of class. and log. tensions: " << endl;
for (int i = 0; i < element[6]; i++){
out_plus << rad_tension_class(radius, element[0], element[1], element[4], element[5]) + rad_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << tan_tension_class(radius, element[0], element[1], element[4], element[5]) + tan_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << axis_tension_class(radius, element[0], element[1], element[4], element[5]) + axis_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << fourth_formule_tension(rad_tension_class(radius, element[0], element[1], element[4], element[5]) + rad_tension_log(radius, element[0], element[1], element[4], element[5]), tan_tension_class(radius, element[0], element[1], element[4], element[5]) + tan_tension_log(radius, element[0], element[1], element[4], element[5]), axis_tension_class(radius, element[0], element[1], element[4], element[5]) + axis_tension_log(radius, element[0], element[1], element[4], element[5])) << endl;
cout << rad_tension_class(radius, element[0], element[1], element[4], element[5]) + rad_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << tan_tension_class(radius, element[0], element[1], element[4], element[5]) + tan_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << axis_tension_class(radius, element[0], element[1], element[4], element[5]) + axis_tension_log(radius, element[0], element[1], element[4], element[5]) << " " << fourth_formule_tension(rad_tension_class(radius, element[0], element[1], element[4], element[5]) + rad_tension_log(radius, element[0], element[1], element[4], element[5]), tan_tension_class(radius, element[0], element[1], element[4], element[5]) + tan_tension_log(radius, element[0], element[1], element[4], element[5]), axis_tension_class(radius, element[0], element[1], element[4], element[5]) + axis_tension_log(radius, element[0], element[1], element[4], element[5])) << endl;
radius+=(0.005/9);
}
out_plus.close();
}