9using CLHEP::k_Boltzmann;
14 long fqmolec,
const std::vector<std::string>& fmolec_not,
15 const std::vector<double>& fweight_quan_molec,
double fpressure,
16 double ftemperature,
double fdensity)
17 : pressureh(fpressure),
19 molech(fqmolec, nullptr),
20 weight_quan_molech(fqmolec),
21 weight_mass_molech(fqmolec) {
22 mfunname(
"GasDef::GasDef(...many molecules...)");
25 for (
long k = 0; k < fqmolec; ++k) {
28 "No molecule with such notation: " << fmolec_not[k] <<
'\n',
31 mcerr <<
"cannot find molecule with notation " << fmolec_not[k]
32 <<
"\nIn particular, check the sequence of initialization\n";
38 for (
long n = 0; n < fqmolec; ++n) {
39 weight_quan_molech[n] = fweight_quan_molec[n];
41 s += weight_quan_molech[n];
45 for (
long n = 0; n < fqmolec; ++n) {
46 weight_quan_molech[n] /= s;
49 for (
long n = 0; n < fqmolec; ++n) {
50 weight_mass_molech[n] = weight_quan_molech[n] * molech[n]->A_total();
53 for (
long n = 0; n < fqmolec; ++n) {
54 s += weight_mass_molech[n];
58 for (
long n = 0; n < fqmolec; ++n) {
59 weight_mass_molech[n] /= s;
64 std::vector<std::string> fatom_not(1000);
65 std::vector<double> weight_qa(1000, 0.0);
66 for (
long k = 0; k < fqmolec; ++k) {
67 for (
long n = 0; n < molech[k]->qatom(); ++n) {
85 fatom_not[qat] = molech[k]->atom(n)->notation();
86 weight_qa[qat] = fweight_quan_molec[k] * molech[k]->qatom_ps(n);
96 for (
long n = 0; n < qmolech; ++n) {
97 sa += weight_quan_molech[n] * molech[n]->A_total();
98 sw += weight_quan_molech[n];
100 const double rydberg = k_Boltzmann * Avogadro;
101 fdensity = sa * fpressure / (rydberg * ftemperature * sw);
106 fdensity, ftemperature);
111 long fqmolec,
const std::vector<std::string>& fmolec_not,
112 const std::vector<double>& fweight_volume_molec,
113 double fpressure,
double ftemperature,
int ,
int ) {
115 mfunname(
"GasDef::GasDef(...many molecules... Waals)");
116 std::vector<MoleculeDef*> amolec(fqmolec);
117 for (
long n = 0; n < fqmolec; ++n) {
120 "No molecule with such notation: " << fmolec_not[n] <<
'\n',
126 std::vector<double> fw(fqmolec);
129 for (
long n = 0; n < fqmolec; ++n) {
130 s += fweight_volume_molec[n];
133 for (
long n = 0; n < fqmolec; ++n) {
134 fw[n] = fweight_volume_molec[n] / s;
138 std::vector<double> fweight_quan_molec(fqmolec);
140 constexpr double rydberg = k_Boltzmann * Avogadro;
141 for (
long n = 0; n < fqmolec; ++n) {
145 fweight_quan_molec[n] = fw[n] * fpressure / (rydberg * ftemperature);
146 double ms = fweight_quan_molec[n] * amolec[n]->A_total();
152 double number_of_moles =
154 fpressure, s_not_single);
156 fweight_quan_molec[n] = number_of_moles;
157 double ms = fweight_quan_molec[n] * amolec[n]->A_total();
162 double density_t = mass_t;
163 *
this =
GasDef(fname, fnotation, fqmolec, fmolec_not, fweight_quan_molec,
164 fpressure, ftemperature, density_t);
168 const std::string& fmolec_not,
double fpressure,
169 double ftemperature,
double fdensity) {
170 mfunname(
"GasDef::GasDef(...1 molecule...)");
171 std::vector<std::string> fmolec_noth(1, fmolec_not);
172 std::vector<double> fweight_quan_molec(1, 1.0);
174 *
this =
GasDef(fname, fnotation, 1, fmolec_noth, fweight_quan_molec,
175 fpressure, ftemperature, fdensity);
180 const std::string& fmolec_not,
double fpressure,
181 double ftemperature,
int s1,
int s2) {
182 mfunname(
"GasDef::GasDef(...1 molecule...)");
183 std::vector<std::string> fmolec_noth(1, fmolec_not);
184 std::vector<double> fweight_volume_molec(1, 1.0);
186 *
this =
GasDef(fname, fnotation, 1, fmolec_noth, fweight_volume_molec,
187 fpressure, ftemperature, s1, s2);
192 const std::string& fmolec_not1,
double fweight_quan_molec1,
193 const std::string& fmolec_not2,
double fweight_quan_molec2,
194 double fpressure,
double ftemperature,
double fdensity) {
195 mfunname(
"GasDef::GasDef(...2 molecules...)");
196 std::vector<std::string> fmolec_noth(2);
197 std::vector<double> fweight_quan_molec(2, 0.0);
198 fmolec_noth[0] = fmolec_not1;
199 fmolec_noth[1] = fmolec_not2;
200 fweight_quan_molec[0] = fweight_quan_molec1;
201 fweight_quan_molec[1] = fweight_quan_molec2;
203 *
this =
GasDef(fname, fnotation, 2, fmolec_noth, fweight_quan_molec,
204 fpressure, ftemperature, fdensity);
209 const std::string& fmolec_not1,
double fweight_volume_molec1,
210 const std::string& fmolec_not2,
double fweight_volume_molec2,
211 double fpressure,
double ftemperature,
int s1,
int s2) {
212 mfunname(
"GasDef::GasDef(...2 molecules...)");
213 std::vector<std::string> fmolec_noth(2);
214 std::vector<double> fweight_volume_molec(2, 0.0);
215 fmolec_noth[0] = fmolec_not1;
216 fmolec_noth[1] = fmolec_not2;
217 fweight_volume_molec[0] = fweight_volume_molec1;
218 fweight_volume_molec[1] = fweight_volume_molec2;
220 *
this =
GasDef(fname, fnotation, 2, fmolec_noth, fweight_volume_molec,
221 fpressure, ftemperature, s1, s2);
226 const std::string& fmolec_not1,
double fweight_quan_molec1,
227 const std::string& fmolec_not2,
double fweight_quan_molec2,
228 const std::string& fmolec_not3,
double fweight_quan_molec3,
229 double fpressure,
double ftemperature,
double fdensity) {
230 mfunname(
"GasDef::GasDef(...3 molecules...)");
231 std::vector<std::string> fmolec_noth(3);
232 std::vector<double> fweight_quan_molec(3, 0.0);
233 fmolec_noth[0] = fmolec_not1;
234 fmolec_noth[1] = fmolec_not2;
235 fmolec_noth[2] = fmolec_not3;
236 fweight_quan_molec[0] = fweight_quan_molec1;
237 fweight_quan_molec[1] = fweight_quan_molec2;
238 fweight_quan_molec[2] = fweight_quan_molec3;
240 *
this =
GasDef(fname, fnotation, 3, fmolec_noth, fweight_quan_molec,
241 fpressure, ftemperature, fdensity);
246 const std::string& fmolec_not1,
double fweight_volume_molec1,
247 const std::string& fmolec_not2,
double fweight_volume_molec2,
248 const std::string& fmolec_not3,
double fweight_volume_molec3,
249 double fpressure,
double ftemperature,
int s1,
int s2) {
250 mfunname(
"GasDef::GasDef(...3 molecules...)");
251 std::vector<std::string> fmolec_noth(3);
252 std::vector<double> fweight_volume_molec(3, 0.0);
253 fmolec_noth[0] = fmolec_not1;
254 fmolec_noth[1] = fmolec_not2;
255 fmolec_noth[2] = fmolec_not3;
256 fweight_volume_molec[0] = fweight_volume_molec1;
257 fweight_volume_molec[1] = fweight_volume_molec2;
258 fweight_volume_molec[2] = fweight_volume_molec3;
260 *
this =
GasDef(fname, fnotation, 3, fmolec_noth, fweight_volume_molec,
261 fpressure, ftemperature, s1, s2);
266 const GasDef& gd,
double fpressure,
double ftemperature,
268 mfunname(
"GasDef::GasDef( another GasDef with different pres)");
269 long fqmolec = gd.
qmolec();
270 std::vector<std::string> fmolec_not(fqmolec);
271 std::vector<double> fweight_quan_molec(fqmolec);
272 for (
long n = 0; n < fqmolec; ++n) {
273 fmolec_not[n] = gd.
molec(n)->notation();
276 *
this =
GasDef(fname, fnotation, fqmolec, fmolec_not, fweight_quan_molec,
277 fpressure, ftemperature, fdensity);
282 mfunname(
"double GasDef::Z_mean_molec(void) const ");
284 for (
long n = 0; n < qmolech; ++n) {
285 s += molech[n]->Z_total() * weight_quan_molech[n];
291 if (l > 0) file << (*this);
295 mfunname(
"std::ostream& operator << (std::ostream& file, const GasDef& f)");
296 Ifile <<
"GasDef: \n";
301 constexpr double mm_rt_st_in_atmosphere = 760.;
304 const double patm = f.
pressure() / CLHEP::atmosphere;
305 Ifile <<
"pressure/atmosphere=" << patm
306 <<
" pressure/atmosphere * mm_rt_st_in_atmosphere = "
307 << patm * mm_rt_st_in_atmosphere <<
'\n';
310 file <<
"qmolec()=" << f.
qmolec() <<
'\n';
312 for (
long n = 0; n < f.
qmolec(); ++n) {
313 Ifile <<
"n=" << n <<
" molec(n)->notation=" << f.
molec(n)->notation()
319 <<
" A_total/(gram/mole)=" << f.
molec(n)->A_total() / (CLHEP::gram / CLHEP::mole)
#define check_econd11(a, signb, stream)
#define check_econd11a(a, signb, add, stream)
double Z_mean_molec() const
Mean charge of molecules in this gas.
void print(std::ostream &file, int l=0) const
const std::vector< double > & weight_quan_molec() const
const std::vector< double > & weight_mass_molec() const
const std::vector< MoleculeDef * > & molec() const
void verify()
Check that there is no matter with the same name in the container.
static MoleculeDef * get_MoleculeDef(const std::string &fnotation)
Helper class for Van-der-Waals equation.
double volume_of_mole(double T, double p, int &s_not_single)
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)