int pmap::read_params(const std::string fname, const int argc, std::vector<std::string> &argv){ //TODO: need locations for input files: numerical input //TODO: need to add an auxilliary variable to accept user variables. Right now everything gets put to standard files paramVec general_opts, time_opts, wf_opts, field_opts, run_opts, plot_opts; boost::shared_ptr<int> ndim_def(new int), charges_def(new int), field_def(new int); defMap dist_map, traj_map, inwf_map, inpot_map, field_map, weight_map, sim_map, int_map; boost::assign::insert(int_map) (1,"Null integrator, does nothing") (3,"Symplectic Integrator") (4,"Adaptive Runge-Kutta") ; boost::assign::insert(sim_map) (0, "None") #ifdef OPENMP_FOUND (1, "OpenMP") #endif #ifdef MPI_FOUND (2, "MPI ") #endif ; boost::assign::insert(dist_map) (1,"Monte-Carlo") (2,"linear") (3,"staged-linear (not implemented)") ; boost::assign::insert(weight_map) (1,"Unit weight") (2,"ADK atomic rate with gaussian weight") ; boost::assign::insert(traj_map) (1,"Check parameters only") (2,"Build ICs only") (3,"run trajectories only") (4,"run binning only") (5,"everything") (6,"everything from 3") (7,"everything from 4") ; boost::assign::insert(inwf_map) (1,"Hydrogen atom like") (2,"Hydrogen molecule like") (3,"GAMESS checkpoint file") (4,"anything on a grid") ; boost::assign::insert(inpot_map) (1,"Hydrogen atom like") (2,"Hydrogen molecule like") (3,"GAMESS checkpoint file") (4,"anything on a grid") (5,"null potential") ; boost::assign::insert(field_map) (1,"constant cosine field") (2,"static field") (3,"gaussian envelope") (4,"sine squard envelope") (5,"numerical form") ; general_opts.push_back(intRunPtr(new intRun("The Number of dimensions to be used in the calculation", "ndim", 4, 100, 1))); general_opts.push_back(intListPtr(new intList("The number of trajectories in each dimension. comma separated list.", "dims", "1,1,1,1",ndim_def))); general_opts.push_back(statePtr(new state_param("The number of trajectories in each dimension. comma separated list.", "dist-type", 1, dist_map))); general_opts.push_back(statePtr(new state_param("Type of run", "run-type", 5, traj_map))); general_opts.push_back(intRunPtr(new intRun("Number of stages for staged-linear distribution(not implemented)", "id-stages", 1, 100, 1))); general_opts.push_back(filePtr( new file_param("Input file, expects serialized results of previous run", "input_file", "in.dat"))); general_opts.push_back(filePtr( new file_param("Output file, either serialized results of current run or results of whole run. If empty, then results will print to stdout for results of whole run.", "output_file", "out.dat"))); time_opts.push_back(doubleRunPtr(new doubleRun("Start time of the simulation, can be negative", "tinitial", 0, 10E10, -10E10))); time_opts.push_back(doubleRunPtr(new doubleRun("Finish time of the simulation, can be negative", "tfinal", 100, 10E10, -10E10))); time_opts.push_back(doubleRunPtr(new doubleRun("Initial time step", "dt", 0.01, 10E10, -10E10))); wf_opts.push_back(statePtr(new state_param("Type of initial wave-function", "wf-type", 1, inwf_map))); wf_opts.push_back(statePtr(new state_param("Type of initial potential", "pot-type", 1, inpot_map))); wf_opts.push_back(statePtr(new state_param("Type of ionization weight function", "weight-func", 2, weight_map))); wf_opts.push_back(doubleListPtr(new doubleList("charge on core(s). list of numbers for each core only needed for H-like and H2-like potential. 1 is for singly ionized etc.", "charges", "1",charges_def))); wf_opts.push_back(doubleRunPtr(new doubleRun("Smoothing parameter to avoid coulomb singularity. Should be small and is only needed when using analytic potentials.", "smoothing", 1E-4, 10E10, -10E10))); wf_opts.push_back(doubleRunPtr(new doubleRun("Internuclear separation in atomic units, only needed for analytic potentials", "rnuc", 0.0, 10E10, -10E10))); wf_opts.push_back(doubleRunPtr(new doubleRun("x-y plane orientation of molecule", "phi-nuc", 0.0, 10E10, -10E10))); wf_opts.push_back(doubleRunPtr(new doubleRun("alignment of molecule wrt the z-axis.", "theta-nuc", 0.0, 10E10, -10E10))); wf_opts.push_back(doubleRunPtr(new doubleRun("ionization potential of target, given in atomic units", "ip", 0.5, 10E10, -10E10))); wf_opts.push_back(doubleRunPtr(new doubleRun("state of atomic or molecular system (not implemented)", "state", 0.01, 10E10, -10E10))); wf_opts.push_back(doubleRunPtr(new doubleRun("escape range: the distance from the origin which an electron can consider being ionized", "escape-range", 1E-5, 10E10, 0))); field_opts.push_back(intRunPtr(new intRun("Number of fields, every option below is given as a comma separated list of options for each field. Currently only 1 field is allowed", "nfield", 1, 100, 1))); field_opts.push_back(statePtr(new state_param("Type of fields", "env", 1,field_map))); field_opts.push_back(doubleListPtr(new doubleList("Field strengths given in atomic units", "ef", "0.01",field_def))); field_opts.push_back(doubleListPtr(new doubleList("frequencies given in atomic units", "omega", "0.057",field_def))); field_opts.push_back(doubleListPtr(new doubleList("FWHM of envelope, ignored for static or constant field.", "fwhm", "0",field_def))); field_opts.push_back(doubleListPtr(new doubleList("initial CE phase of each field given in degrees", "ce", "0",field_def))); field_opts.push_back(intListPtr(new intList("polarization direction, 1 = x, 2 = y, 3 = z,", "pol", "3",field_def))); run_opts.push_back(intRunPtr(new intRun("Number of concurrent trajectories using OpenMP", "nthreads", 1, 100, 1))); run_opts.push_back(intRunPtr(new intRun("Number of nodes using MPI", "mklthreads", 1, 100, 1))); run_opts.push_back(doubleRunPtr(new doubleRun("Absolute error", "abserr", 1.E-9, 10E10, -10E10))); run_opts.push_back(doubleRunPtr(new doubleRun("Relative error", "relerr", 1E-7, 10E10, -10E10))); run_opts.push_back(statePtr(new state_param("Type of parallel run", "parallel", 0, sim_map))); run_opts.push_back(statePtr(new state_param("Type of integrator to use", "int-type", 4, int_map))); plot_opts.push_back(intRunPtr(new intRun("Number of bins in final distrbution", "plot-nums", 256, 10E6, 1))); plot_opts.push_back(doubleRunPtr(new doubleRun("absolute range of saved distribution in atomic units of momentum", "plot-ranges", 6., 10E10, 0))); std::vector<boost::shared_ptr<po::options_description> > opts_desc; opts_desc.push_back(boost::shared_ptr<po::options_description>(new po::options_description("Generic Options"))); opts_desc.push_back(boost::shared_ptr<po::options_description>(new po::options_description("Time Grid"))); opts_desc.push_back(boost::shared_ptr<po::options_description>(new po::options_description("Wave function and potential"))); opts_desc.push_back(boost::shared_ptr<po::options_description>(new po::options_description("Field options"))); opts_desc.push_back(boost::shared_ptr<po::options_description>(new po::options_description("Plotting specific options"))); opts_desc.push_back(boost::shared_ptr<po::options_description>(new po::options_description("Run specific options"))); opts_desc[0]->add_options() ("help", "displays help message"); opts_desc[0]->add_options() ("help-glog", "displays help messages for google glog, the logging interface"); opts_desc[5]->add_options() ("no-build", "builds the initial conditions on the fly, without holding entire set in memory"); opts_desc[5]->add_options() ("no-bin", "do not create distribution while running trajectories, bining of distribution is done in separate step, not valid when doing parallel calculations"); opts_desc[5]->add_options() ("no-store", "do not store trajectories separately just add them to the distribution(mutually exclusive with no-bin, this takes precedence)"); opts_desc[5]->add_options() ("binary", "serialize in binary(OS-dependent), if not set serializes to text(default)"); opts_desc[5]->add_options() ("watch", "turns on observer for RK integrator...lots of output!"); std::vector<paramVec> opts; opts.push_back(general_opts); opts.push_back(time_opts); opts.push_back(wf_opts); opts.push_back(field_opts); opts.push_back(plot_opts); opts.push_back(run_opts); for(std::size_t i=0;i<opts.size();++i){ foreach(paramPtr m, opts[i]){ m->genParam(*(opts_desc[i])); } }
/* * 上线接口 */ void ImAdapter::online(int userId, bool isLongOnline, std::string onlineIp){ /* * 按uid在池子中找到map,再在map中搜寻离线请求对象 */ size_t poolIndex = getPoolIndex(userId); unique_lock<shared_mutex> lock(userPoolMutex_[poolIndex]); UserOnlineStateMap& subPool = userOnlineStateMaps[poolIndex]; UserOnlineStateMap::iterator it = subPool.find(userId); if(it != subPool.end()){ /* * 已经存在的离线请求对象的情况 */ UserOnlineStatePtr statePtr = it->second; //如果用户存在且im在线,此条件一直为真 if(statePtr->imState == ONLINE){ // 将缓冲状态置为在线 statePtr->cushionState = ONLINE; // 更新登录IP statePtr->onlineIp = onlineIp; // 打印日志,特别说明more,表明是在离线请求受到缓冲的情况下进行的上线操作 LOG_INFO("ON|M|"<<userId); // 离线请求缓冲的情况下上线行为不立即引发对IM对象上线接口的调用 }else if(statePtr->imState == OFFLINE){ //此种状态不存在 } }else{ /* * map中不存在uid对应的离线请求对象时,需要新建 */ // 新建离线请求对象 UserOnlineStatePtr statePtr(new UserOnlineState); /* * 初始化工作 */ // 初始化其uid statePtr->userId = userId; // 在线状态初始化为在线 statePtr->imState = ONLINE; statePtr->cushionState = ONLINE; // 离线请求总数初始化为0 statePtr->offlineCount = 0; // 更新登录IP statePtr->onlineIp = onlineIp; /* * 初始化结束 */ // 离线请求对象放入池子的所属map,不进入离线缓冲队列 subPool[userId] = statePtr; /* * 日志打印 */ // 打印日志,输出上线用户的uid LOG_INFO("ON|N|"<<userId); /* * 调用im接口通知上线,上线请求行为不进行缓冲 */ //此处调用im借口上线 iMGateForPhoneAdapter_.online(userId); } }