-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdroplet.cpp
140 lines (112 loc) · 2.67 KB
/
droplet.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
#include <math.h>
#include "droplet.hpp"
int Droplet::num_droplets = 0;
Droplet::Droplet() {
_multi = 0;
_rcubed = _solute = _density = 0.;
_mass = _volume = 0.;
num_droplets++;
}
Droplet::Droplet(long multi, double rcubed, double solute,
double density) {
_multi = multi;
_rcubed = rcubed;
_solute = solute;
_density = density;
_radius = pow(rcubed, constants::third);
_volume = (4.*M_PI/3.)*_rcubed;
_mass = _volume*_density;
num_droplets++;
}
Droplet::Droplet(const Droplet &d) {
_multi = d._multi;
_rcubed = d._rcubed;
_solute = d._solute;
_density = d._density;
_radius = d._radius;
_volume = d._volume;
_mass = d._mass;
num_droplets++;
}
Droplet::~Droplet() {
--num_droplets;
}
void Droplet::set_droplet(long multi, double rcubed, double solute) {
_multi = multi;
_rcubed = rcubed;
_solute = solute;
_radius = pow(rcubed, constants::third);
_volume = (4.*M_PI/3.)*rcubed;
}
//
//double Droplet::get_mass() const {
// return _mass;
//}
//
//long Droplet::_multi const {
// return _multi;
//}
//
//double Droplet::get_radius() const {
// return pow(_rcubed, 1./3.);
//}
//
//double Droplet::get_solute() const {
// return _solute;
//}
//
//double Droplet::get_volume() const {
// return _volume;
//}
double Droplet::get_terminal_v() const {
// BEARD, 1976
double mass = this->_mass;
double r = this->_radius;
double d = 2.*r*1e6; // diameter, m -> micron
double x = mass * 1e3; // convert kg -> g
double alpha, x_to_beta;
if (d <= 134.43)
{
alpha = 4.5795e5;
x_to_beta = pow(x, 2.*constants::third);
}
else if (134.43 < d <= 1511.64)
{
alpha = 4962.0;
x_to_beta = pow(x, constants::third);
}
else if (1511.64 < d <= 3477.84)
{
alpha = 1732.0;
x_to_beta = pow(x, constants::third/2.);
}
else
{
alpha = 917.0;
x_to_beta = 1.0;
}
return (1e-2 * alpha * x_to_beta); // from cm/s -> m/s
}
Droplet & Droplet::operator= (const Droplet & other) {
if (this == &other)
return *this;
_multi = other._multi;
_rcubed = other._rcubed;
_solute = other._solute;
_density = other._density;
_radius = other._radius;
_volume = other._volume;
_mass = other._mass;
return *this;
}
bool operator< (const Droplet & d1, const Droplet & d2) {
return (d1._multi < d2._multi);
}
// Basic string output
std::ostream &operator<<(std::ostream &os, const Droplet &d) {
os << "Droplet( "
<< "multi=" << d._multi << ", "
<< "radius=" << d._radius*1e6 << " micron"
<< " )";
return os;
}