FMMSolver::FMMSolver(const Grid& g, Vect<real_t>& phi, bool HA) { _phi = φ _dim = CheckDimension(g); if (_dim==3) _theFM = new FMM3D(g,_phi,HA); else _theFM = new FMM2D(g,_phi,HA); }
/** Set up histogram with specified data sets. */ Analysis::RetType Analysis_Hist::Setup(ArgList& analyzeArgs, AnalysisSetup& setup, int debugIn) { debug_ = debugIn; // Keywords std::string histname = analyzeArgs.GetStringKey("name"); outfilename_ = analyzeArgs.GetStringKey("out"); if (outfilename_.empty()) { mprinterr("Error: Hist: No output filename specified.\n"); return Analysis::ERR; } traj3dName_ = analyzeArgs.GetStringKey("traj3d"); traj3dFmt_ = TrajectoryFile::WriteFormatFromString( analyzeArgs.GetStringKey("trajfmt"), TrajectoryFile::AMBERTRAJ ); parmoutName_ = analyzeArgs.GetStringKey("parmout"); // Create a DataFile here so any DataFile arguments can be processed. If it // turns out later that native output is needed the DataFile will be removed. outfile_ = setup.DFL().AddDataFile(outfilename_, analyzeArgs); if (outfile_==0) return Analysis::ERR; Temp_ = analyzeArgs.getKeyDouble("free",-1.0); if (Temp_!=-1.0) calcFreeE_ = true; else calcFreeE_ = false; gnuplot_ = analyzeArgs.hasKey("gnu"); if (analyzeArgs.hasKey("norm")) normalize_ = NORM_SUM; else if (analyzeArgs.hasKey("normint")) normalize_ = NORM_INT; else normalize_ = NO_NORM; circular_ = analyzeArgs.hasKey("circular"); nativeOut_ = analyzeArgs.hasKey("nativeout"); if ( analyzeArgs.Contains("min") ) { default_min_ = analyzeArgs.getKeyDouble("min", 0.0); minArgSet_ = true; } if ( analyzeArgs.Contains("max") ) { default_max_ = analyzeArgs.getKeyDouble("max", 0.0); maxArgSet_ = true; } default_step_ = analyzeArgs.getKeyDouble("step", 0.0) ; default_bins_ = analyzeArgs.getKeyInt("bins", -1); calcAMD_ = false; std::string amdname = analyzeArgs.GetStringKey("amd"); if (!amdname.empty()) { DataSet* ds = setup.DSL().GetDataSet( amdname ); if (ds == 0) { mprinterr("Error: AMD data set %s not found.\n", amdname.c_str()); return Analysis::ERR; } if (ds->Ndim() != 1) { mprinterr("Error: AMD data set must be 1D.\n"); return Analysis::ERR; } amddata_ = (DataSet_1D*)ds; calcAMD_ = true; } // Treat all remaining arguments as dataset names. Do not set up dimensions // yet since the data sets may not be fully populated. ArgList dsetNames = analyzeArgs.RemainingArgs(); for ( ArgList::const_iterator setname = dsetNames.begin(); setname != dsetNames.end(); ++setname) { if (CheckDimension( *setname, setup.DSL() )) return Analysis::ERR; } // histdata contains the DataSets to be histogrammed if (histdata_.empty()) { mprinterr("Error: Hist: No datasets specified.\n"); return Analysis::ERR; } // Total # of dimensions for the histogram is the number of sets to be binned. N_dimensions_ = histdata_.size(); if (!nativeOut_) { switch ( N_dimensions_ ) { case 1: hist_ = setup.DSL().AddSet( DataSet::DOUBLE, histname, "Hist"); break; case 2: hist_ = setup.DSL().AddSet( DataSet::MATRIX_DBL, histname, "Hist"); break; // TODO: GRID_DBL case 3: hist_ = setup.DSL().AddSet( DataSet::GRID_FLT, histname, "Hist"); break; default: // FIXME: GET N DIMENSION CASE! mprintf("Warning: Histogram dimension > 3. DataSet/DataFile output not supported.\n"); nativeOut_ = true; } } // traj3d only supported with 3D histograms if (!traj3dName_.empty() && N_dimensions_ != 3) { mprintf("Warning: 'traj3d' only supported with 3D histograms.\n"); traj3dName_.clear(); parmoutName_.clear(); } if (!nativeOut_) { // DataFile output. Add DataSet to DataFile. if (hist_ == 0) { mprinterr("Error: Could not set up histogram data set.\n"); return Analysis::ERR; } outfile_->AddDataSet( hist_ ); } else { // Native output. Remove DataFile from DataFileList outfile_ = setup.DFL().RemoveDataFile( outfile_ ); native_ = setup.DFL().AddCpptrajFile( outfilename_, "Histogram output" ); if (native_ == 0) return Analysis::ERR; } mprintf("\tHist: %s: Set up for %zu dimensions using the following datasets:\n", outfilename_.c_str(), N_dimensions_); mprintf("\t[ "); for (std::vector<DataSet_1D*>::iterator ds=histdata_.begin(); ds!=histdata_.end(); ++ds) mprintf("%s ",(*ds)->legend()); mprintf("]\n"); if (calcAMD_) mprintf("\tPopulating bins using AMD boost from data set %s\n", amddata_->legend()); if (calcFreeE_) mprintf("\tFree energy in kcal/mol will be calculated from bin populations at %f K.\n",Temp_); if (nativeOut_) mprintf("\tUsing internal routine for output. Data will not be stored on the data set list.\n"); //if (circular_ || gnuplot_) { // mprintf("\tWarning: gnuplot and/or circular specified; advanced grace/gnuplot\n"); // mprintf("\t formatting disabled.\n");*/ if (circular_) mprintf("\tcircular: Output coordinates will be wrapped.\n"); if (gnuplot_ && outfile_ == 0) mprintf("\tgnuplot: Output will be in gnuplot-readable format.\n"); //} if (normalize_ == NORM_SUM) mprintf("\tnorm: Sum over bins will be normalized to 1.0.\n"); else if (normalize_ == NORM_INT) mprintf("\tnormint: Integral over bins will be normalized to 1.0.\n"); if (!traj3dName_.empty()) { mprintf("\tPseudo-trajectory will be written to '%s' with format %s\n", traj3dName_.c_str(), TrajectoryFile::FormatString(traj3dFmt_)); if (!parmoutName_.empty()) mprintf("\tCorresponding pseudo-topology will be written to '%s'\n", parmoutName_.c_str()); } return Analysis::OK; }