void PicParams::readSpecies(InputData &ifile) { bool ok; for (int ispec = 0; ispec < ifile.nComponents("Species"); ispec++) { SpeciesStructure tmpSpec; ifile.extract("species_type",tmpSpec.species_type,"Species",ispec); if(tmpSpec.species_type.empty()) { ERROR("For species #" << ispec << " empty species_type"); } ifile.extract("initPosition_type",tmpSpec.initPosition_type ,"Species",ispec); if (tmpSpec.initPosition_type.empty()) { ERROR("For species #" << ispec << " empty initPosition_type"); } else if ( (tmpSpec.initPosition_type!="regular")&&(tmpSpec.initPosition_type!="random") ) { ERROR("For species #" << ispec << " bad definition of initPosition_type " << tmpSpec.initPosition_type); } ifile.extract("initMomentum_type",tmpSpec.initMomentum_type ,"Species",ispec); if ( (tmpSpec.initMomentum_type=="mj") || (tmpSpec.initMomentum_type=="maxj") ) { tmpSpec.initMomentum_type="maxwell-juettner"; } if ( (tmpSpec.initMomentum_type!="cold") && (tmpSpec.initMomentum_type!="maxwell-juettner") && (tmpSpec.initMomentum_type!="rectangular") ) { ERROR("For species #" << ispec << " bad definition of initMomentum_type"); } tmpSpec.c_part_max = 1.0;// default value ifile.extract("c_part_max",tmpSpec.c_part_max,"Species",ispec); if( !ifile.extract("mass",tmpSpec.mass ,"Species",ispec) ) { ERROR("For species #" << ispec << ", mass not defined."); } tmpSpec.dynamics_type = "norm"; // default value if (!ifile.extract("dynamics_type",tmpSpec.dynamics_type ,"Species",ispec) ) WARNING("For species #" << ispec << ", dynamics_type not defined: assumed = 'norm'."); if (tmpSpec.dynamics_type!="norm"){ ERROR("dynamics_type different than norm not yet implemented"); } tmpSpec.time_frozen = 0.0; // default value ifile.extract("time_frozen",tmpSpec.time_frozen ,"Species",ispec); if (tmpSpec.time_frozen > 0 && \ tmpSpec.initMomentum_type!="cold") { WARNING("For species #" << ispec << " possible conflict between time-frozen & not cold initialization"); } tmpSpec.radiating = false; // default value ifile.extract("radiating",tmpSpec.radiating ,"Species",ispec); if (tmpSpec.dynamics_type=="rrll" && (!tmpSpec.radiating)) { WARNING("For species #" << ispec << ", dynamics_type='rrll' forcing radiating=True"); tmpSpec.radiating=true; } if (!ifile.extract("bc_part_type_west",tmpSpec.bc_part_type_west,"Species",ispec) ) ERROR("For species #" << ispec << ", bc_part_type_west not defined"); if (!ifile.extract("bc_part_type_east",tmpSpec.bc_part_type_east,"Species",ispec) ) ERROR("For species #" << ispec << ", bc_part_type_east not defined"); if (nDim_particle>1) { if (!ifile.extract("bc_part_type_south",tmpSpec.bc_part_type_south,"Species",ispec) ) ERROR("For species #" << ispec << ", bc_part_type_south not defined"); if (!ifile.extract("bc_part_type_north",tmpSpec.bc_part_type_north,"Species",ispec) ) ERROR("For species #" << ispec << ", bc_part_type_north not defined"); } // for thermalizing BCs on particles check if thermT is correctly defined bool thermTisDefined=false; if ( (tmpSpec.bc_part_type_west=="thermalize") || (tmpSpec.bc_part_type_east=="thermalize") ){ thermTisDefined=ifile.extract("thermT",tmpSpec.thermT,"Species",ispec); if (!thermTisDefined) ERROR("thermT needs to be defined for species " <<ispec<< " due to x-BC thermalize"); } if ( (nDim_particle==2) && (!thermTisDefined) && (tmpSpec.bc_part_type_south=="thermalize" || tmpSpec.bc_part_type_north=="thermalize") ) { thermTisDefined=ifile.extract("thermT",tmpSpec.thermT,"Species",ispec); if (!thermTisDefined) ERROR("thermT needs to be defined for species " <<ispec<< " due to y-BC thermalize"); } if (thermTisDefined) { if (tmpSpec.thermT.size()==1) { tmpSpec.thermT.resize(3); for (unsigned int i=1; i<3;i++) tmpSpec.thermT[i]=tmpSpec.thermT[0]; } } else { tmpSpec.thermT.resize(3); for (unsigned int i=0; i<3;i++) tmpSpec.thermT[i]=0.0; } tmpSpec.ionization_model = "none"; // default value ifile.extract("ionization_model", tmpSpec.ionization_model, "Species",ispec); ok = ifile.extract("atomic_number", tmpSpec.atomic_number, "Species",ispec); if( !ok && tmpSpec.ionization_model!="none" ) { ERROR("For species #" << ispec << ", `atomic_number` not found => required for the ionization model ."); } tmpSpec.isTest = false; // default value ifile.extract("isTest",tmpSpec.isTest ,"Species",ispec); if (tmpSpec.ionization_model!="none" && (!tmpSpec.isTest)) { ERROR("Disabled for now : test & ionized"); } // Species geometry // ---------------- // Density bool ok1, ok2; ok1 = extractOneProfile(ifile, "nb_density" , tmpSpec.dens_profile, ispec); ok2 = extractOneProfile(ifile, "charge_density", tmpSpec.dens_profile, ispec); if( ok1 && ok2 ) ERROR("For species #" << ispec << ", cannot define both `nb_density` and `charge_density`."); if( !ok1 && !ok2 ) ERROR("For species #" << ispec << ", must define `nb_density` or `charge_density`."); if( ok1 ) tmpSpec.density_type = "nb"; if( ok2 ) tmpSpec.density_type = "charge"; // Number of particles per cell if( !extractOneProfile(ifile, "n_part_per_cell", tmpSpec.ppc_profile, ispec) ) ERROR("For species #" << ispec << ", n_part_per_cell not found or not understood"); // Charge if( !extractOneProfile(ifile, "charge", tmpSpec.charge_profile, ispec) ) ERROR("For species #" << ispec << ", charge not found or not understood"); // Mean velocity vector<ProfileStructure*> vecMvel; extractVectorOfProfiles(ifile, "mean_velocity", vecMvel, ispec); tmpSpec.mvel_x_profile = *(vecMvel[0]); tmpSpec.mvel_y_profile = *(vecMvel[1]); tmpSpec.mvel_z_profile = *(vecMvel[2]); // Temperature vector<ProfileStructure*> vecTemp; extractVectorOfProfiles(ifile, "temperature", vecTemp, ispec); tmpSpec.temp_x_profile = *(vecTemp[0]); tmpSpec.temp_y_profile = *(vecTemp[1]); tmpSpec.temp_z_profile = *(vecTemp[2]); // Save the Species params // ----------------------- species_param.push_back(tmpSpec); } }