GSI_Toolbox 1.0.0 A toolbox for Gas-Surface Interaction simulations

Loading...
Searching...
No Matches
Gas.h
1
9template <typename T>
10 class Gas {
11
12 private:
13 T density;
14 T temperature;
15 T molar_mass;
16 T speed;
17
18 public:
19
25 Gas() : density(0.0), temperature(0.0), molar_mass(0.0), speed(0.0) {}
26
37 Gas(T density, T temperature, T molar_mass, T speed) : density(density), temperature(temperature), molar_mass(molar_mass), speed(speed) {}
38
46 Gas(const Gas<T>& other) : density(other.density), temperature(other.temperature), molar_mass(other.molar_mass), speed(other.speed) {}
47
56 Gas(Gas<T>&& other) : density(other.density), temperature(other.temperature), molar_mass(other.molar_mass), speed(other.speed) {
57 other.density = 0.0;
58 other.temperature = 0.0;
59 other.molar_mass = 0.0;
60 other.speed = 0.0;
61 }
62
68 ~Gas() {
69 density = 0.0;
70 temperature = 0.0;
71 molar_mass = 0.0;
72 speed = 0.0;
73 }
74
83 Gas& operator=(const Gas& other) {
84 density = other.density;
85 temperature = other.temperature;
86 molar_mass = other.molar_mass;
87 speed = other.speed;
88 return *this;
89 }
90
99 Gas& operator=(Gas&& other) {
100 density = other.density;
101 temperature = other.temperature;
102 molar_mass = other.molar_mass;
103 speed = other.speed;
104
105 other.density = 0.0;
106 other.temperature = 0.0;
107 other.molar_mass = 0.0;
108 other.speed = 0.0;
109 return *this;
110 }
111
120 Matrix<T> get_thermal_velocity();
121
127 T get_temperature() const { return temperature; }
128
134 T get_density() const { return density; }
135
141 T get_molar_mass() const { return molar_mass; }
142
148 T get_speed() const { return speed; }
149};
150
159template <typename T>
160 Matrix<T> Gas<T>::get_thermal_velocity() {
161 // Set up random number generation
162 std::random_device rd;
163 std::seed_seq fullSeed{rd(), rd(), rd(), rd(), rd(), rd(), rd(), rd()};
164 std::mt19937 rng(fullSeed);
165 std::normal_distribution<T> normDist(0.0f, 1.0f);
166
167 // Compute the thermal velocities in each direction
168 T v_x = sqrt(R_gas * temperature / molar_mass) * normDist(rng);
169 T v_y = sqrt(R_gas * temperature / molar_mass) * normDist(rng);
170 T v_z = sqrt(R_gas * temperature / molar_mass) * normDist(rng);
171
172 // Return the thermal velocity as a 3x1 matrix
173 Matrix<T> vel(3, 1, {v_x, v_y, v_z});
174 return vel;
175}
Gas
Class representing a Gas with properties such as density, temperature, molar mass,...
Definition Gas.h:10
Gas::Gas
Gas()
Default constructor for the Gas class.
Definition Gas.h:25
Gas::Gas
Gas(Gas< T > &&other)
Move constructor for the Gas class.
Definition Gas.h:56
Gas::get_molar_mass
T get_molar_mass() const
Returns the molar mass of the gas.
Definition Gas.h:141
Gas::get_density
T get_density() const
Returns the density of the gas.
Definition Gas.h:134
Gas::get_thermal_velocity
Matrix< T > get_thermal_velocity()
Computes the thermal velocity of the gas in three dimensions.
Definition Gas.h:160
Gas::get_temperature
T get_temperature() const
Returns the temperature of the gas.
Definition Gas.h:127
Gas::~Gas
~Gas()
Destructor for the Gas class.
Definition Gas.h:68
Gas::Gas
Gas(T density, T temperature, T molar_mass, T speed)
Parameterized constructor for the Gas class.
Definition Gas.h:37
Gas::operator=
Gas & operator=(Gas &&other)
Move assignment operator for the Gas class.
Definition Gas.h:99
Gas::get_speed
T get_speed() const
Returns the speed of the gas.
Definition Gas.h:148
Gas::operator=
Gas & operator=(const Gas &other)
Copy assignment operator for the Gas class.
Definition Gas.h:83
Gas::Gas
Gas(const Gas< T > &other)
Copy constructor for the Gas class.
Definition Gas.h:46
Matrix
This class implements a matrix object used for linear algebra and vectorized operations.
Definition Matrix.h:25