HeedMatterDef::HeedMatterDef(EnergyMesh* fenergy_mesh, MatterDef* amatter, AtomPhotoAbsCS* faapacs[], double fW, double fF) : W(fW), F(fF), energy_mesh(fenergy_mesh) { mfunname("HeedMatterDef::HeedMatterDef(...)"); matter.put(amatter); check_econd11(matter->qatom(), <= 0, mcerr); long q = matter->qatom(); apacs.put_qel(q); for (long n = 0; n < q; ++n) { apacs[n].put(faapacs[n]); check_econd12(matter->atom(n)->Z(), !=, apacs[n]->get_Z(), mcerr); } check_econd11(F, == 0.0, mcerr); if (W == 0.0) { #ifdef CALC_W_USING_CHARGES double mean_I = 0.0; double d = 0.0; for (long n = 0; n < q; ++n) { mean_I += matter->weight_quan(n) * apacs[n]->get_Z() * apacs[n]->get_I_min(); d += matter->weight_quan(n) * apacs[n]->get_Z(); } W = coef_I_to_W * mean_I / d; #else double mean_I = 0.0; for (long n = 0; n < q; ++n) { mean_I += matter->weight_quan(n) * apacs[n]->get_I_min(); } W = coef_I_to_W * mean_I; #endif } inite_HeedMatterDef(); }
std::ostream& operator<<(std::ostream& file, const GasDef& f) { mfunname("std::ostream& operator << (std::ostream& file, const GasDef& f)"); Ifile << "GasDef: \n"; indn.n += 2; indn.n += 2; file << ((MatterDef&)f); indn.n -= 2; Ifile << "pressure/atmosphere=" << f.pressure() / atmosphere << " pressure/atmosphere * mm_rt_st_in_atmosphere = " << f.pressure() / atmosphere * mm_rt_st_in_atmosphere << '\n'; Ifile << "Z_mean_molec=" << f.Z_mean_molec() << '\n'; file << "qmolec()=" << f.qmolec() << '\n'; indn.n += 2; for (long n = 0; n < f.qmolec(); ++n) { Ifile << "n=" << n << " molec(n)->notation=" << f.molec(n)->notation() << '\n'; indn.n += 2; Ifile << "weight_quan_molec(n)=" << f.weight_quan_molec(n) << " weight_mass_molec(n)=" << f.weight_mass_molec(n) << '\n'; Ifile << "Z_total=" << f.molec(n)->Z_total() << " A_total/(gram/mole)=" << f.molec(n)->A_total() / (gram / mole) << '\n'; indn.n -= 2; } indn.n -= 2; indn.n -= 2; return file; }
/* 1998 - 2004, I. Smirnov */ spin_def::spin_def(float ftotal, float fprojection): total(ftotal), projection(fprojection) { mfunname("spin_def::spin_def(float ftotal, float fprojection)"); check_econd11(total , < 0, mcerr); check_econd12(total , < , projection, mcerr); }
particle_type::particle_type(const char* name, int s) { mfunname("particle_type::particle_type(const char* name, int s)"); //mcout<<"particle_type::particle_type(char* name):\n"; //particle_def::printall(mcout); AbsListNode<particle_def*>* an = NULL; AbsList< particle_def* >& logbook = particle_def::get_logbook(); while ((an = logbook.get_next_node(an)) != NULL) { if (name == an->el->notation) { pardef = an->el; return; } } an = NULL; // to start from beginning while ((an = logbook.get_next_node(an)) != NULL) { if (name == an->el->name) { pardef = an->el; return; } } /* for (n = 0; n < qallapardef; n++) { //mcout<<"name="<<name<<" allapardef[n]->name="<<allapardef[n]->name<<'\n'; if (!strcmp(name, allapardef[n]->name)) { pardef = allapardef[n]; return; } } */ if (s == 0) { mcerr<<"this type of particle is absent, name="<<name<<'\n'; spexit(mcerr); } pardef = NULL; }
double eiparticle::Bethe_Bloch_en_loss(void) { mfunname("double eiparticle::Bethe_Bloch_energy_loss(void)"); const absvol* av = currpos.G_lavol(); // get least address of volume const MatterType* amt = dynamic_cast< const MatterType* >(av); //PassivePtr< MatterDef >* amt = dynamic_cast< PassivePtr< MatterDef >* >(av); //char name[1000]; if(amt == NULL) { //mcout<<"eiparticle::Bethe_Bloch_en_loss: dynamic_cast is not successful, return 0\n"; //av->chname(name); //mcout<<"name="<<name<<'\n'; return 0.0; } else { //mcout<<"eiparticle::Bethe_Bloch_en_loss: dynamic_cast is successful\n"; //av->chname(name); //mcout<<"name="<<name<<'\n'; MatterDef* amd = amt->matdef.get(); double gamma_1 = curr_gamma_1; double betta = lorbetta(gamma_1); double Eloss = Bethe_Bloch_energy_loss(amd->Z_mean() / amd->A_mean(), amd->I_eff(), betta, pardef->charge/eplus); Eloss *= amd->density(); //mcout<<"Eloss/(keV / cm )="<<Eloss/(keV / cm)<<'\n';; return Eloss; } }
//void eiparticle::ionization_loss(void) //{ // mfunname("void eiparticle::ionization_loss(void)"); void eiparticle::physics_after_new_speed(void) { mfunname("void eiparticle::physics_after_new_speed(void)"); double Eloss=Bethe_Bloch_en_loss(); Eloss *= currpos.prange; total_Eloss += Eloss; //mcout<<"total_Eloss/keV="<<total_Eloss/keV<<'\n'; if(s_add_loss == 0) { curr_kin_energy -= Eloss; if(curr_kin_energy <= 0.0) { curr_kin_energy = 0.0; curr_gamma_1 = 0.0; currpos.speed = 0.0; s_life = 0; } else { double resten=mass*pow(speed_of_light, 2); curr_gamma_1=curr_kin_energy / resten; currpos.speed=speed_of_light * lorbetta( curr_gamma_1 ); } } else { curr_kin_energy += Eloss; double resten=mass*pow(speed_of_light, 2); curr_gamma_1=curr_kin_energy / resten; currpos.speed=speed_of_light * lorbetta( curr_gamma_1 ); } }
ulsvolume::ulsvolume(const ulsvolume& f) : absref(f), absvol(f), qsurf(f.qsurf), name(f.name) { mfunname("ulsvolume::ulsvolume(...)"); check_econd12(f.qsurf, >, pqqsurf, mcerr); prec = f.prec; for (int n = 0; n < qsurf; ++n) surf[n].put(f.surf[n].get()); }
// mean charge of molecule double GasDef::Z_mean_molec(void) const { mfunname("double GasDef::Z_mean_molec(void) const "); double s = 0.0; for (long n = 0; n < qmolech; ++n) { s += molech[n]->Z_total() * weight_quan_molech[n]; } return s; }
ulsvolume::ulsvolume(surface* fsurf[pqqsurf], int fqsurf, char* fname, vfloat fprec) : qsurf(fqsurf), name(fname) { mfunname("ulsvolume::ulsvolume(...)"); check_econd12(fqsurf, >, pqqsurf, mcerr); prec = fprec; for (int n = 0; n < qsurf; ++n) surf[n].put(fsurf[n]); }
linexi2B::linexi2B(const linexi2B& lxB): linexi2((linexi2&)lxB) { mfunname("linexi2B::linexi2B(const linexi2B& lxB)"); B=(double**) new double[lxB.qlr*lxB.qlr]; long i,m; for( i=0; i<qlr; i++) for(m=0; m<qlr; m++) B[i][m]=lxB.B[i][m]; }
GasDef::GasDef(const String& fname, const String& fnotation, long fqmolec, const DynLinArr<String>& fmolec_not, const DynLinArr<double>& fweight_volume_molec, double fpressure, double ftemperature, int /*s1*/, int /*s2*/) { // s1 and s2 are to distinguish the constructor mfunname("GasDef::GasDef(...many molecules... Waals)"); DynLinArr<MoleculeDef*> amolec(fqmolec); for (long n = 0; n < fqmolec; ++n) { amolec[n] = MoleculeDef::get_MoleculeDef(fmolec_not[n]); check_econd11a(amolec[n], == NULL, "No molecule with such notation: " << fmolec_not[n] << '\n', mcerr) // Van der Waals correction currently not used. // VanDerVaals* aw = amolec[n]->awls().get(); } // first normalize volumes to total unity DynLinArr<double> fw(fqmolec); // normalized volume weights double s = 0.0; for (long n = 0; n < fqmolec; ++n) { s += fweight_volume_molec[n]; } check_econd11(s, <= 0, mcerr); for (long n = 0; n < fqmolec; ++n) { fw[n] = fweight_volume_molec[n] / s; } // calculate number of molecules or moles and mass of each component DynLinArr<double> fweight_quan_molec(fqmolec); double mass_t = 0.0; double ridberg = k_Boltzmann * Avogadro; // more precise for (long n = 0; n < fqmolec; ++n) { VanDerVaals* aw = amolec[n]->awls().get(); if (aw == NULL) { // ideal gas case fweight_quan_molec[n] = fw[n] * fpressure / (ridberg * ftemperature); double ms = fweight_quan_molec[n] * amolec[n]->A_total(); //Iprint2n(mcout, fweight_quan_molec[n], ms/gram); mass_t += ms; } else { // van der Waals gas case int s_not_single; double number_of_moles = fw[n] * 1.0 / aw->volume_of_mole(ftemperature, // relative to T_k fpressure, s_not_single); check_econd11(s_not_single, == 1, mcerr); fweight_quan_molec[n] = number_of_moles; double ms = fweight_quan_molec[n] * amolec[n]->A_total(); //Iprint2n(mcout, fweight_quan_molec[n], ms/gram); mass_t += ms; } } double density_t = mass_t; *this = GasDef(fname, fnotation, fqmolec, fmolec_not, fweight_quan_molec, fpressure, ftemperature, density_t); }
std::ostream& operator << (std::ostream& file, const MatterType& f) { mfunname("std::ostream& operator << (std::ostream& file, const MatterType& f)"); if (f.matdef.get() == NULL) { Ifile << "MatterType: type is not initialized\n"; } else { Ifile << "MatterType: notation=" << f.matdef->notation() << '\n'; } return file; }
linexi2B::linexi2B(linexi2& lx): linexi2(lx) { mfunname("linexi2B::linexi2B(linexi2& lx)"); B = (double**) new double[lx.qlr*lx.qlr]; long i,m; for( i=0; i<qlr; i++) for(m=0; m<qlr; m++) B[i][m]=(ax[i] - x_mean)*(ax[m] - x_mean)/Dx + 1; }
HeedMatterDef::HeedMatterDef(EnergyMesh* fenergy_mesh, GasDef* agas, MolecPhotoAbsCS* fampacs[], double fW, double fF) : W(fW), F(fF), energy_mesh(fenergy_mesh) { mfunname("HeedMatterDef::HeedMatterDef(...)"); matter.put(agas); check_econd11(agas->qmolec(), <= 0, mcerr); long qat = agas->qatom(); apacs.put_qel(qat); long qmol = agas->qmolec(); long nat = 0; for (long nmol = 0; nmol < qmol; ++nmol) { check_econd12(agas->molec(nmol)->tqatom(), !=, fampacs[nmol]->get_qatom(), mcerr); long qa = agas->molec(nmol)->qatom(); //quantity of different atoms in mol for (long na = 0; na < qa; ++na) { apacs[nat].put(fampacs[nmol]->get_atom(na).getver()); check_econd12(apacs[nat]->get_Z(), !=, agas->molec(nmol)->atom(na)->Z(), mcerr); nat++; } } if (F == 0.0) { #ifdef CALC_W_USING_CHARGES double u = 0.0; double d = 0.0; for (long n = 0; n < qmol; ++n) { u += agas->weight_quan_molec(n) * fampacs[n]->get_total_Z() * fampacs[n]->get_F(); d += agas->weight_quan_molec(n) * fampacs[n]->get_total_Z(); } F = u / d; #else for (long n = 0; n < qmol; ++n) { F += agas->weight_quan_molec(n) * fampacs[n]->get_F(); } #endif } if (W == 0.0) { #ifdef CALC_W_USING_CHARGES double u = 0.0; double d = 0.0; for (long n = 0; n < qmol; ++n) { u += agas->weight_quan_molec(n) * fampacs[n]->get_total_Z() * fampacs[n]->get_W(); d += agas->weight_quan_molec(n) * fampacs[n]->get_total_Z(); } W = u / d; #else for (long n = 0; n < qmol; ++n) { W += agas->weight_quan_molec(n) * fampacs[n]->get_W(); } #endif } inite_HeedMatterDef(); }
GasDef::GasDef(const String& fname, const String& fnotation, const String& fmolec_not, double fpressure, double ftemperature, int s1, int s2) { mfunname("GasDef::GasDef(...1 molecule...)"); DynLinArr<String> fmolec_noth(1, fmolec_not); DynLinArr<double> fweight_volume_molec(1, 1.0); { *this = GasDef(fname, fnotation, 1, fmolec_noth, fweight_volume_molec, fpressure, ftemperature, s1, s2); } }
std::ostream& operator << (std::ostream& file, const HeedDeltaElectronCSType& f) { mfunname("std::ostream& operator << (std::ostream& file, const HeedDeltaElectronCSType& f)"); if (f.hdecs.get() == NULL) { Ifile << "HeedDeltaElectronCSType: type is not initialized\n"; } else { Ifile << "HeedDeltaElectronCSType: ="; f.hdecs->print(file, 1); } return file; }
MatterDef::MatterDef(const String& fname, const String& fnotation, const String& fatom_not, double fdensity, double ftemperature): AtomMixDef(fatom_not), nameh(fname), notationh(fnotation), temperatureh(ftemperature), densityh(fdensity) { mfunname("MatterDef::MatterDef(...1 atom...)"); calc_I_eff(); verify(); MatterDef::get_logbook().append(this); }
double lin_interpolation(double x, double coor[], double arr[], long q) { mfunname("double lin_interpolation(T x, double coor[], double arr[], long q)"); long nstart=find_interval(x , coor, q); if(nstart < 0) return 0.0; return arr[nstart] + (arr[nstart+1] - arr[nstart]) / (coor[nstart+1] - coor[nstart])* (x - coor[nstart]); }
std::ostream& operator << (std::ostream& file, const MatterDef& f) { mfunname("std::ostream& operator << (std::ostream& file, const MatterDef& f)"); Ifile << "MatterDef: name=" << std::setw(10) << f.name() << " notation=" << std::setw(3) << f.notation() << '\n'; indn.n += 2; Ifile << "density/(gram/cm3)=" << f.density() / (gram / cm3) << " temperature/kelvin=" << f.temperature() / kelvin << " I_eff/eV=" << f.I_eff() / eV << '\n'; f.AtomMixDef::print(file, 1); indn.n -= 2; return file; }
double lin_interpolation(double x, DynLinArr< double > coor, DynLinArr< double > arr) { mfunname("double lin_interpolation(T x, DynLinArr< double > coor, DynLinArr< double > arr)"); check_econd12(coor.get_qel() , != , arr.get_qel() , mcerr); long nstart = find_interval(x, coor); if (nstart < 0) return 0.0; return arr[nstart] + (arr[nstart+1] - arr[nstart]) / (coor[nstart+1] - coor[nstart]) * (x - coor[nstart]); }
double PairProd::get_eloss(const double e_cur) const { mfunname("double PairProd::get_eloss(double ecur) const"); double e_loss = k * pran.ran(SRANLUX()) + s; double c; if (e_cur <= V_ratio * wa) { c = DBL_MAX; } else { //c = 1.0 / (1.0 - V_ratio * wa / e_cur); c = 1.0 / (1.0 - pow(V_ratio * wa / e_cur, 2.0)); } return e_loss * c; }
MatterDef::MatterDef(const String& fname, const String& fnotation, long fqatom, const DynLinArr< String >& fatom_not, const DynLinArr< double >& fweight_quan, double fdensity, double ftemperature): AtomMixDef(fqatom, fatom_not, fweight_quan), nameh(fname), notationh(fnotation), temperatureh(ftemperature), densityh(fdensity) { mfunname("MatterDef::MatterDef(...many atoms...)"); calc_I_eff(); verify(); MatterDef::get_logbook().append(this); }
void treat_particle_bank(int s_erase) { mfunname("void treat_particle_bank(int s_erase)"); AbsListNode<ActivePtr<gparticle> >* aln; AbsListNode<ActivePtr<gparticle> >* aln1; aln = particle_bank.get_first_node(); while (aln != NULL) { aln->el->fly(); aln1 = aln->get_next_node(); if (s_erase == 1) particle_bank.erase(aln); aln = aln1; } }
double gasdensity(double temperature, double pressure, DynLinArr<ProtPtr<MoleculeDef> > molec, DynLinArr<double> weight_quan_molec, long qmolec) { mfunname("double gasdensity(...)"); double sw = 0.0; double sa = 0.0; for (long n = 0; n < qmolec; ++n) { sa += weight_quan_molec[n] * molec[n]->A_total(); sw += weight_quan_molec[n]; } double ridberg = k_Boltzmann * Avogadro; // more precise return sa * pressure / (ridberg * temperature * sw); }
GasDef::GasDef(const String& fname, const String& fnotation, const GasDef& gd, double fpressure, double ftemperature, double fdensity) { mfunname("GasDef::GasDef( another GasDef with different pres)"); long fqmolec = gd.qmolec(); DynLinArr<String> fmolec_not(fqmolec); DynLinArr<double> fweight_quan_molec(fqmolec); for (long n = 0; n < fqmolec; ++n) { fmolec_not[n] = gd.molec(n)->notation(); fweight_quan_molec[n] = gd.weight_quan_molec(n); } *this = GasDef(fname, fnotation, fqmolec, fmolec_not, fweight_quan_molec, fpressure, ftemperature, fdensity); }
double double_parab_interpolation (double x, DynLinArr< double > coor, DynLinArr< double > arr) { mfunname("double double_parab_interpolation(T x, DynLinArr< double > coor, DynLinArr< double > arr)"); check_econd12(coor.get_qel() , != , arr.get_qel() , mcerr); long q=coor.get_qel(); long nstart=find_interval(x , coor); if(nstart < 0) return 0.0; if(q == 1) // line { check_econd12(x , != , coor[0] , mcerr); // provided in find_interval return arr[0]; }
MatterDef::MatterDef(const String& fname, const String& fnotation, const String& fatom_not1, double fweight_quan1, const String& fatom_not2, double fweight_quan2, const String& fatom_not3, double fweight_quan3, double fdensity, double ftemperature): AtomMixDef(fatom_not1, fweight_quan1, fatom_not2, fweight_quan2, fatom_not3, fweight_quan3), nameh(fname), notationh(fnotation), temperatureh(ftemperature), densityh(fdensity) { mfunname("MatterDef::MatterDef(...2 atoms...)"); calc_I_eff(); verify(); MatterDef::get_logbook().append(this); }
DynLinArr<double> make_log_mesh_ec(double emin, double emax, long q) { mfunname( "DynLinArr< double > make_log_mesh_ec(double emin, double emax, long q)"); double rk = pow(emax / emin, (1.0 / double(q))); double er = emin; DynLinArr<double> ec(q); double e1; double e2 = er; for (long n = 0; n < q; n++) { e1 = e2; e2 = e2 * rk; ec[n] = (e1 + e2) * 0.5; } return ec; }
GasDef::GasDef(const String& fname, const String& fnotation, const String& fmolec_not1, double fweight_volume_molec1, const String& fmolec_not2, double fweight_volume_molec2, double fpressure, double ftemperature, int s1, int s2) { mfunname("GasDef::GasDef(...2 molecules...)"); DynLinArr<String> fmolec_noth(2); DynLinArr<double> fweight_volume_molec(2, 0.0); fmolec_noth[0] = fmolec_not1; fmolec_noth[1] = fmolec_not2; fweight_volume_molec[0] = fweight_volume_molec1; fweight_volume_molec[1] = fweight_volume_molec2; { *this = GasDef(fname, fnotation, 2, fmolec_noth, fweight_volume_molec, fpressure, ftemperature, s1, s2); } }
int ulsvolume::check_point_inside(const point& fpt, const vec& dir) const { mfunname("ulsvolume::check_point_inside(...)"); check_econd11(qsurf, <= 0, mcerr); for (int n = 0; n < qsurf; n++) { if (!(surf[n].get()->check_point_inside(fpt, dir, prec))) { return 0; } } #ifdef TRACE_find_embed_vol indn.n++; Imcout << "ulsvolume::check_point_inside: the point is in volume\n"; Imcout << "point:" << fpt; print(mcout, 0); indn.n--; #endif return 1; }