void HeedMatterDef::replace_epsi12(const String& file_name) { mfunnamep("void HeedMatterDef::replace_epsi12(const String& file_name)"); #ifdef USE_STLSTRING std::ifstream file(file_name.c_str()); #else std::ifstream file(hist_file_name); #endif if (!file) { funnw.ehdr(mcerr); mcerr << "cannot open file " << file_name << std::endl; spexit(mcerr); } else { mcout << "file " << file_name << " is opened" << std::endl; } long qe = 0; // number of points in input mesh file >> qe; check_econd11(qe, <= 2, mcerr); DynLinArr<double> ener(qe); DynLinArr<double> eps1(qe); DynLinArr<double> eps2(qe); for (long ne = 0; ne < qe; ++ne) { file >> ener[ne] >> eps1[ne] >> eps2[ne]; check_econd11(eps2[ne], < 0.0, mcerr); if (ne > 0) { check_econd12(ener[ne], <, ener[ne - 1], mcerr); } }
FunNameStack& FunNameStack::operator=(const FunNameStack& f) { if (this == &(FunNameStack::instance())) { mcerr << "ERROR in FunNameStack& FunNameStack::operator=(const FunNameStack& f)\n"; mcerr << "Attempt to copy to operative FunNameStack\n"; mcerr << "You don't need and should not initialize main FunNameStack directly\n"; mcerr << "If you want to change its parameters, use FunNameStack::instance()\n"; Iprintn(mcout, this); Iprintn(mcout, &(FunNameStack::instance())); Iprintn(mcout, (*this)); Iprintn(mcout, (FunNameStack::instance())); spexit(mcerr); } #ifdef USE_BOOST_MULTITHREADING #ifdef USE_TOGETHER_WITH_CLEAN_NEW #if defined( MAINTAIN_KEYNUMBER_LIST ) && defined( USE_BOOST_MULTITHREADING ) MemoriseIgnore::instance().ignore(); #else s_ignore_keynumberlist = 1; #endif #endif if (namestack != NULL) delete namestack; namestack = new AbsList< NameStack > (*(f.namestack)); #ifdef USE_TOGETHER_WITH_CLEAN_NEW #if defined( MAINTAIN_KEYNUMBER_LIST ) && defined( USE_BOOST_MULTITHREADING ) MemoriseIgnore::instance().not_ignore(); #else s_ignore_keynumberlist = 0; #endif #endif #else qname = f.qname; #endif s_init = f.s_init; s_act = f.s_act; s_print = f.s_print; nmode = f.nmode; #ifdef USE_BOOST_MULTITHREADING #else int n; for (n = 0; n < f.qname; n++) { if (nmode == 0) { name[n] = f.name[n]; } else { int l = strlen(f.name[n]) + 1; #ifdef USE_TOGETHER_WITH_CLEAN_NEW s_ignore_keynumberlist = 1; #endif name[n] = new char[l]; strcpy(name[n],f.name[n]); #ifdef USE_TOGETHER_WITH_CLEAN_NEW s_ignore_keynumberlist = 0; #endif } } #endif return *this; }
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; }
basis::basis(const vec &pex, const vec &pey, const vec &pez, const String& pname) { pvecerror("basis::basis(vec &pex, vec &pey, vec &pez, char pname[12])"); if (!check_perp(pex,pey,vprecision) || !check_perp(pex,pez,vprecision) || !check_perp(pey,pez,vprecision)) { mcerr<<"ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n" <<"the vectors are not perpendicular\n"; mcerr<<" pex,pey,pez:\n"; mcerr<<pex<<pey<<pez; mcerr<<"name="<<pname<<'\n'; spexit(mcerr); } //if(length(pex)!=vfloat(1.0) || // length(pey)!=vfloat(1.0) || // length(pez)!=vfloat(1.0) ) if (not_apeq(length(pex), vfloat(1.0)) || not_apeq(length(pey), vfloat(1.0)) || not_apeq(length(pez), vfloat(1.0))) { mcerr<<"ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n" <<"the vectors are not of unit length\n"; mcerr<<" pex,pey,pez:\n"; mcerr<<pex<<pey<<pez; mcerr<<"name="<<pname<<'\n'; spexit(mcerr); } if (not_apeq(pex||pey , pez, vprecision)) { mcerr<<"ERROR in basis::basis(vec &pex, vec &pey, vec &pez) : \n"; mcerr<<"wrong direction of pez\n"; mcerr<<" pex,pey,pez:\n"; mcerr<<pex<<pey<<pez; mcerr<<"name="<<pname<<'\n'; spexit(mcerr); } name = pname; ex = pex; ey = pey; ez = pez; }
void MatterDef::verify(const String& fname, const String& fnotation) { mfunnamep("void MatterDef::verify(const String& fname, const String& fnotation)"); AbsList< MatterDef* >& logbook = MatterDef::get_logbook(); AbsListNode<MatterDef*>* an = NULL; while ((an = logbook.get_next_node(an)) != NULL) { if (an->el->nameh == fname || an->el->notationh == fnotation) { funnw.ehdr(mcerr); mcerr << "cannot initialize two matters " << "with the same name or notation\n"; mcerr << "name=" << fname << " notation=" << fnotation << '\n'; spexit(mcerr); } } }
void MatterDef::verify(void) { mfunnamep("void MatterDef::verify(void)"); if (nameh == "none" && notationh == "none") return; AbsList< MatterDef* >& logbook = MatterDef::get_logbook(); AbsListNode<MatterDef*>* an = NULL; while ((an = logbook.get_next_node(an)) != NULL) { if (an->el->nameh == nameh || an->el->notationh == notationh) { funnw.ehdr(mcerr); mcerr << "cannot initialize two matters " << "with the same name or notation\n"; mcerr << "name=" << nameh << " notation=" << notationh << '\n'; spexit(mcerr); } } }
double lorgamma_1(double betta) { if(betta==0.0) return 0.0; if(betta>=1.0) { mcout<<"double lorgamma_1(double betta): ERROR: betta>=1.0, betta=" <<betta<<"\n"; spexit(mcerr); } betta*=betta; double g2_1=betta/(1-betta); //cout<<"g2_1="<<g2_1<<'\n'; double gam=sqrt(g2_1+1); //cout<<"gam="<<gam<<'\n'; return g2_1/(gam+1); }
vec vec::up_new(const basis *fabas_new) { // it is assumed that fabas_new is derivative from old pvecerrorp("vec vec::up_new((const basis *pbas)"); vec r; //check_econd11(fabas_new , ==NULL, mcerr); // not compiled in IRIX, reason is unkown if (fabas_new == NULL) { funnw.ehdr(mcerr); mcerr<<"fabas_new==NULL\n"; spexit(mcerr); } vec ex = fabas_new->Gex(); vec ey = fabas_new->Gey(); vec ez = fabas_new->Gez(); r.x = x * ex.x + y * ex.y + z * ex.z; r.y = x * ey.x + y * ey.y + z * ey.z; r.z = x * ez.x + y * ez.y + z * ez.z; return r; }
void FunNameStack::remove_thread_stack(void) { //long nret = 0; pthread_t id = pthread_self(); AbsListNode< NameStack >* an=NULL; int s_found = 0; an = namestack->get_first_node(); while( an != NULL) { if(pthread_equal(an->el.id, id)) { s_found = 1; break; } an = an->get_next_node(); //nret++; } if(s_found == 0) // new thread is detected { mcerr<<"ERROR in void FunNameStack::remove_thread_stack(void) const:\n"; mcerr<<"new thread is detected\n"; Iprintn(mcerr, id); spexit(mcerr); } #ifdef USE_TOGETHER_WITH_CLEAN_NEW #if defined( MAINTAIN_KEYNUMBER_LIST ) && defined( USE_BOOST_MULTITHREADING ) MemoriseIgnore::instance().ignore(); #else s_ignore_keynumberlist = 1; // to avoid report from delete at deletion #endif #endif namestack->remove(an); #ifdef USE_TOGETHER_WITH_CLEAN_NEW #if defined( MAINTAIN_KEYNUMBER_LIST ) && defined( USE_BOOST_MULTITHREADING ) MemoriseIgnore::instance().not_ignore(); #else s_ignore_keynumberlist = 0; // to avoid report from delete at deletion #endif #endif }
HeedMatterDef::HeedMatterDef(EnergyMesh* fenergy_mesh, const String& gas_notation, MolecPhotoAbsCS* fampacs[], double fW, double fF) : W(fW), F(fF), energy_mesh(fenergy_mesh) { mfunnamep("HeedMatterDef::HeedMatterDef(...)"); MatterDef* amat = MatterDef::get_MatterDef(gas_notation); GasDef* agas = dynamic_cast<GasDef*>(amat); if (agas == NULL) { funnw.ehdr(mcerr); mcerr << "notation supplied as the gas notation is not appear " << "to be related to gas \n"; mcerr << "gas_notation=" << gas_notation << '\n'; spexit(mcerr); } 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, long fqmolec, const DynLinArr<String>& fmolec_not, const DynLinArr<double>& fweight_quan_molec, double fpressure, double ftemperature, double fdensity) : pressureh(fpressure), qmolech(fqmolec), molech(fqmolec), weight_quan_molech(fqmolec), weight_mass_molech(fqmolec) { mfunname("GasDef::GasDef(...many molecules...)"); // Finding pointers to all molec. by notations for (long k = 0; k < fqmolec; ++k) { MoleculeDef* amd = MoleculeDef::get_MoleculeDef(fmolec_not[k]); check_econd11a(amd, == NULL, "No molecule with such notation: " << fmolec_not[k] << '\n', mcerr) molech[k].put(amd); if (amd == NULL) { mcerr << "cannot find molecule with notation " << fmolec_not[k] << "\nIn particular, check the sequence of initialization\n"; spexit(mcerr); } } double s = 0.0; for (long n = 0; n < fqmolec; ++n) { weight_quan_molech[n] = fweight_quan_molec[n]; check_econd11(weight_quan_molech[n], <= 0, mcerr); s += weight_quan_molech[n]; } check_econd11(s, <= 0, mcerr); if (s != 1.0) { for (long n = 0; n < fqmolec; ++n) { weight_quan_molech[n] /= s; } } for (long n = 0; n < fqmolec; ++n) { weight_mass_molech[n] = weight_quan_molech[n] * molech[n]->A_total(); } s = 0.0; for (long n = 0; n < fqmolec; ++n) { s += weight_mass_molech[n]; } check_econd11(s, <= 0, mcerr); if (s != 1.0) { for (long n = 0; n < fqmolec; ++n) { weight_mass_molech[n] /= s; } } long qat = 0; DynLinArr<String> fatom_not(1000); DynLinArr<double> weight_qa(1000, 0.0); for (long k = 0; k < fqmolec; ++k) { for (long n = 0; n < molech[k]->qatom(); ++n) { /* This is originally designed to avoid duplication of an atom in the list if it presents twice in different moleculas. But it appears that the same atom in different moleculas can have different features related to position and sensitivity of external shell. In particular it affects on ionization. This difference can be used in inherited and related classes. Therefore such reduction of the list can produce problems. Therefore this is excluded by commenting off this passage, and also by commenting off mark2. for (i = 0; i < qat; i++) { if (molech[k]->atom(n)->notation() == fatom_not[i]) { weight_qa[i] += fweight_quan_molec[k] * molech[k]->weight_quan(n); goto mark2; } } */ fatom_not[qat] = molech[k]->atom(n)->notation(); weight_qa[qat] = fweight_quan_molec[k] * molech[k]->qatom_ps(n); //mcout << "qat=" << qat << " fatom_not[qat]=" << fatom_not[qat] // << " weight_qa[qat]=" << weight_qa[qat] << '\n'; ++qat; //mark2: ; } } if (fdensity < 0.0) { fdensity = gasdensity(ftemperature, fpressure, molech, weight_quan_molech, qmolech); } verify(fname, fnotation); { *((MatterDef*)this) = MatterDef(fname, fnotation, qat, fatom_not, weight_qa, fdensity, ftemperature); } }
int ulsvolume::range_ext(trajestep& fts, int s_ext) const { mfunnamep("int ulsvolume::range_ext(trajestep& fts, int s_ext) const"); check_econd11(qsurf, <= 0, mcerr); #ifdef DEBUG_ulsvolume_range_ext mcout << "ulsvolume::range_ext, START, s_ext=" << s_ext << " qsurf=" << qsurf << '\n'; mcout << fts; #endif vfloat crange[pqcrossurf]; point cpt[pqcrossurf]; int fs_ext[pqcrossurf]; int n, m, nc; int s = 0; // sign of crossing if (s_ext == 1) { for (n = 0; n < qsurf; n++) { int qc = surf[n].get()->range(fts, crange, cpt, fs_ext); for (m = 0; m < qc; m++) { if (fs_ext[m] == 1) { s = 1; // The last minute change, it was 0 somewhy instead of m fts.mrange = crange[m]; // reduce the range fts.mpoint = cpt[m]; break; // take only the first exit point, it should be closest } else if (fs_ext[m] == 0) { if (!(surf[n] .get()->check_point_inside(fts.currpos, fts.dir, prec))) { funnw.ehdr(mcerr); mcerr << "\nshould never happen\n" << "It may happen if you call this function with s_ext==1\n" << "for point outside the volume\n"; spexit(mcerr); } } else if (fs_ext[m] == 2) break; // don't know what to do, safe to ignore } } if (s == 1) { fts.s_prec = 0; } return s; } else { // for if(s_ext==1) int ss = 0; // sign that there is cross with any of the surfaces for (n = 0; n < qsurf; n++) { #ifdef DEBUG_ulsvolume_range_ext Iprintn(mcout, n); #endif int qc = surf[n].get()->range(fts, crange, cpt, fs_ext); #ifdef DEBUG_ulsvolume_range_ext mcout << "ulsvolume::range_ext: qc=" << qc << "\n"; surf[n]->print(mcout, 1); #endif for (nc = 0; nc < qc; nc++) // loop by crossing points { #ifdef DEBUG_ulsvolume_range_ext mcout << "nc=" << nc << " fs_ext[nc]=" << fs_ext[nc] << '\n'; #endif if (fs_ext[nc] == 0) // thus ignoring exitted surfaces { s = 1; for (m = 0; m < qsurf; m++) // scan other surfaces and verify that { // the crossing point is inside if (m != n) { if (surf[m].get()->check_point_inside1(cpt[nc], fs_ext[nc], prec) == 0) { #ifdef DEBUG_ulsvolume_range_ext mcout << "m=" << m << '\n'; mcout << "Since the point is outside of the other surface, " << "it can not be border of volume\n"; #endif s = 0; break; } } } #ifdef DEBUG_ulsvolume_range_ext Iprintn(mcout, s); #endif if (s == 1) { #ifdef DEBUG_ulsvolume_range_ext mcout << "The crossing point is inside all other surfaces, \n" << "so it is good crossing point\n"; #endif ss = 1; fts.mrange = crange[nc]; fts.mpoint = cpt[nc]; break; // since points are ordered, go to next surface, // may be there is nearer crossing point } } } } if (ss == 1) { fts.s_prec = 0; } #ifdef DEBUG_ulsvolume_range_ext mcout << "ulsvolume::range_ext: at the end\n"; print(mcout, 1); mcout << "ss=" << ss << '\n'; #endif return ss; } }