-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathElasticity.h
280 lines (251 loc) · 10.6 KB
/
Elasticity.h
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
//
// Created by Ryan.Zurrin001 on 12/15/2021.
//
#ifndef PHYSICSFORMULA_ELASTICITY_H
#define PHYSICSFORMULA_ELASTICITY_H
// class for doing physics problems
// author: Ryan Zurrin
// last Modified: 10/11/2020
#include <iostream>
#include <vector>
#include <cmath>
#include "Constants.h"
using namespace std;
//static object counter for Elasticity class
static int elasticity_objectCount = 0;
static struct Elastic_Moduli // all units are multiplied by(10^9 N/m^2)
{
///<young's modulus, Shear modulus, Bulk modulus>
vector<double> aluminum{70e9, 25e9, 75e9};
///<young's modulus, Shear modulus, Bulk modulus>
vector<double> bone_tension{
16 * pow(10, 9), 80 * pow(10, 9), 8 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<double> bone_compression{
9 * pow(10, 9), 0 * pow(10, 9), 0 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<double> brass{
90 * pow(10, 9), 35 * pow(10, 9), 75 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<double> brick{15 * pow(10, 9), 0 * pow(10, 9), 0 * pow(10, 9)};
///<young's modulus, Shear modulus, Bulk modulus>
vector<double> concrete{
20 * pow(10, 9), 0 * pow(10, 9), 0 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<double> glass{
70 * pow(10, 9), 20 * pow(10, 9), 30 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<double> granite{
45 * pow(10, 9), 20 * pow(10, 9), 45 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> hair_human{
10 * pow(10, 9), 0 * pow(10, 9), 0 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> hardwood{
25 * pow(10, 9), 10 * pow(10, 9), 0 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> cast_iron{
100 * pow(10, 9), 40 * pow(10, 9), 90 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> lead{16 * pow(10, 9), 5 * pow(10, 9), 50 * pow(10, 9)};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> marble{
60 * pow(10, 9), 20 * pow(10, 9), 70 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> nylon{5 * pow(10, 9), 0 * pow(10, 9), 0 * pow(10, 9)};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> polystyrene{
3 * pow(10, 9), 0 * pow(10, 9), 0 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> silk{6 * pow(10, 9), 0 * pow(10, 9), 0 * pow(10, 9)};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> spider_thread{
3 * pow(10, 9), 0 * pow(10, 9), 0 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> steel{
210 * pow(10, 9), 80 * pow(10, 9), 130 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> tendon{1 * pow(10, 9), 0 * pow(10, 9), 0 * pow(10, 9)};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> acetone{
0 * pow(10, 9), 0 * pow(10, 9), 0.7 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> ethanol{
0 * pow(10, 9), 0 * pow(10, 9), 0.9 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> glycerin{
0 * pow(10, 9), 0 * pow(10, 9), 4.5 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> mercury{
0 * pow(10, 9), 0 * pow(10, 9), 25 * pow(10, 9)
};
///<young's modulus, Shear modulus, Bulk modulus>
vector<long double> water{0 * pow(10, 9), 0 * pow(10, 9), 2.2 * pow(10, 9)};
} moduli;
class Elasticity
{
public:
static void countShow() { std::cout << "elasticity count: " << elasticity_objectCount << std::endl; }
void setElasticityVal(long double val) { _elasticityVal = val; }
Elasticity* _ptrElastic;
/**
* structure: Elastic_Moduli vector
* components: <young's modulus, Shear modulus, Bulk modulus> Y_, S, B
* purpose: store data on elastic moduli for using in physics calculations
* returns: specified component value
*/
// default constructor
Elasticity()
{
_ptrElastic = nullptr;
_elasticityVal = 0.0;
countIncrease();
//countShow();
}
Elasticity(long double val)
{
_ptrElastic = nullptr;
_elasticityVal = 0.0;
countIncrease();
}
// copy constructor
Elasticity(const Elasticity& e)
{
_ptrElastic = e._ptrElastic;
_elasticityVal = e._elasticityVal;
countIncrease();
//countShow();
}
// copy assignment operator
Elasticity& operator=(const Elasticity& r)
{
if (this != &r)
{
_ptrElastic = r._ptrElastic;
_elasticityVal = r._elasticityVal;
countIncrease();
//countShow();
}
return *this;
}
/**
* method: cross_sectional(const long double radius)
* arguments: radius
* purpose: calculates the cross sectional, which is used in many elasticity problems
* returns: long double, cross sectional
*/
static long double cross_sectional_area(const long double radius)
{ return constants::PI * (radius * radius); }
/**
* Returns the calculated deformation of an object which is used in hooks law equation
* @param appliedForce the force in newtons
* @param modulus <young's modulus, Shear modulus, Bulk modulus> values can be accessed by .moduli.
* @param crossSectionalArea
* @param original *
* @returns the deformation
*/
static long double deformations(const long double appliedForce, const long double modulus, const long double diameter, const long double original)
{ return (1 / modulus) * (appliedForce / (constants::PI * (diameter * diameter)) * original); }
/**
* method: stress_usingY(const long double YoungsModulus, const long double strain)
* arguments: 1)YoungsModulus 2)strain
* purpose: calculates the stress which is defined as the ratio of force to area
* returns: long double, stress
*/
static long double stress_usingY(const long double youngsModulus, const long double strain)
{ return youngsModulus * strain; }
/**
* method: stress_usingF(const long double force, const long double area)
* arguments: 1)force 2)area = PI*r^2
* purpose: calculates the stress which is defined as the ratio of force to area
* returns: long double, stress
*/
static long double stress_usingF(const long double force, const long double area)
{ return force / area; }
/**
* method: strain(const long double change_in_length, const long double total_length)
* arguments: 1)change_in_length 2)total_length
* purpose: calculates the strain which is defined as the ratio of the change in length to length
* returns: long double, strain
*/
static long double strain(const long double change_in_length, const long double total_length)
{ return change_in_length / total_length; }
/// <summary>
/// Uses Hookes law to find the force applied
/// </summary>
/// <param name="k">The force constant.</param>
/// <param name="x">The deformation from starting point.</param>
/// <returns>force applied</returns>
static long double hookes_law(const long double k, const long double x)
{ return k * x; }
/**
* method: deforming_force(const long double modulus, const long double crossSectionalArea, const long double originalLength, const long double amountDeformed)
* arguments: 1)modulus 2)crossSectionalArea 3)originalLength 4)amountDeformed
* purpose: calculates the force required to bend or deform a something depending on the material
* returns: long double, deforming force
*/
static long double deforming_force(const long double modulus, const long double crossSectionalArea, const long double originalLength, const long double amountDeformed)
{ return ((modulus) * (crossSectionalArea) / (originalLength)) * amountDeformed; }
/**
* Returns the total displacement to the side of an object due to a sheering force.
* @param length total length of the object
* @param diameter of object
* @param forceN in newtons
* @param sheerModuli for the material being measured
* @returns displacement of a material to side due to sheering force
*/
static long double displacement_side_sheer_force(const long double length, const long double diameter, const long double forceN, const long double sheerModuli)
{
return (1 / sheerModuli) * (4.0 / (constants::PI * (diameter *
diameter))) * forceN * length;
}
/**
* @brief Returns the amount of compression an object undergoes, such as weight on a steel beam
* @param length is the length of the object
* @param crossSectionalArea is the area as if it was sliced in half
* @param youngsModulus is the modulus used in this equation
* @param force is the amount of force being applied
* @returns the compression amount in meters
*/
static long double compression(const long double length, const long double crossSectionalArea, const long double youngsModulus, const long double force)
{
return (force * length) / (youngsModulus * crossSectionalArea);
}
/**
* @brief Returns the maximum force something will take before it fails
* @param compressiveStrength is dependant on the material used
* @param crossSectionalArea is the area of a cross section of the object
* @returns the max force before failure will occur
*/
static long double max_support_force(const long double compressiveStrength, const long double crossSectionalArea)
{
return compressiveStrength * crossSectionalArea;
}
~Elasticity()
{
delete _ptrElastic;
countDecrease();
//countShow();
}
private:
static void countIncrease() { elasticity_objectCount += 1; }
static void countDecrease() { elasticity_objectCount -= 1; }
long double _elasticityVal;
};
#endif //PHYSICSFORMULA_ELASTICITY_H