void mainLoop0(InputNgType::Readable& io, ParametersDmrgSolverType& dmrgSolverParams, InputCheck& inputCheck, const PsimagLite::String& list) { typedef typename MySparseMatrix::value_type ComplexOrRealType; typedef PsimagLite::Geometry<ComplexOrRealType, InputNgType::Readable, ProgramGlobals> GeometryType; GeometryType geometry(io); int tmp = 0; try { io.readline(tmp,"UseSu2Symmetry="); } catch (std::exception&) {} bool su2 = (tmp > 0); PsimagLite::String targetting=inputCheck.getTargeting(dmrgSolverParams.options); if (targetting!="GroundStateTargetting" && su2) throw PsimagLite::RuntimeError("SU(2) supports only GroundStateTargetting"); if (su2) { mainLoop1<GeometryType,ModelHelperSu2,MySparseMatrix> (geometry,targetting,io,dmrgSolverParams, list); return; } if (targetting=="GroundStateTargetting") { mainLoop1<GeometryType,ModelHelperLocal,MySparseMatrix> (geometry,targetting,io,dmrgSolverParams, list); } else if (targetting=="TimeStepTargetting") { mainLoop1<GeometryType,ModelHelperLocal,MySparseMatrixComplex> (geometry,targetting,io,dmrgSolverParams, list); } else { mainLoop1<GeometryType,ModelHelperLocal,MySparseMatrix> (geometry,targetting,io,dmrgSolverParams, list); } }
int main(int argc,char *argv[]) { typedef PsimagLite::Concurrency ConcurrencyType; ConcurrencyType concurrency(&argc,&argv,1); InputCheck inputCheck; PsimagLite::String filename=""; int opt = 0; OperatorOptions options; PsimagLite::String strUsage(argv[0]); if (utils::basename(strUsage) == "operator") options.enabled = true; strUsage += " -f filename [-k] [-p precision] [-V] [whatToMeasure]"; int precision = 6; bool keepFiles = false; bool versionOnly = false; /* PSIDOC DmrgDriver \begin{itemize} \item[-f] {[}Mandatory, String{]} Input to use. \item[-p] [Optional, Integer] Digits of precision for printing. \item[whatToMeasure] {[}Optional, String{]} What to measure in-situ \item[-l] {[}Optional, String{]} Without this option std::cout is redirected to a file. This option with the string ``?'' prints name of such log file. This option with the string ``-'' writes std::cout to terminal. In other cases, string is the name of the file to redirect std::cout to. \item[-k] [Optional] Keep untar files \end{itemize} */ /* PSIDOC OperatorDriver The arguments to the \verb!operator! executable are as follows. \begin{itemize} \item[-f] [Mandatory, String] Input to use. The Model= line is very important in input.inp. \item[-s] [Optional, Integer] Site for operator. Meaningful only for Models where the Hilbert space depends on the site (different kinds of atoms). Defaults to 0. \item[-l] [Mandatory, String] The label or name for this operator. This is model dependent. For example to obtain $c_{\uparrow}$ for the Hubbard model, say \begin{verbatim} ./operator -l c -f input.inp\end{verbatim} See the function naturalOperator for each Model. \item[-d] [Optional, Integer] Degree of freedom (spin, orbital or combination of both) to use. This is model dependent. For example to obtain $c_\downarrow$ for the Hubbard model, say \begin{verbatim}./operator -l c -d 1 -f input.inp\end{verbatim} See the function naturalOperator for each Model. Defaults to 0. \item[-t] [Optional, Void] Transpose the operator. For example to obtain $c^\dagger_\uparrow$ for a Hubbard model, say \begin{verbatim}./operator -l c -t -f input.inp\end{verbatim} \end{itemize} */ while ((opt = getopt(argc, argv,"f:s:l:d:F:o:p:tkV")) != -1) { switch (opt) { case 'f': filename = optarg; break; case 'o': std::cerr<<argv[0]<<": Omit the \"-o\". It's not needed anymore.\n"; std::cerr<<"\t Write the insitu measurements at the end of the command line\n"; return 1; case 's': options.site = atoi(optarg); break; case 'l': options.label = optarg; break; case 'd': options.dof = atoi(optarg); break; case 't': options.transpose = true; break; case 'k': keepFiles = true; break; case 'F': std::cerr<<argv[0]<<": Omit the \"-F\". It's not needed anymore.\n"; std::cerr<<"\t It is implied by the label: n=bosonic, c=fermionic, etc\n"; return 2; case 'p': precision = atoi(optarg); std::cout.precision(precision); std::cerr.precision(precision); break; case 'V': versionOnly = true; options.label = "-"; break; default: inputCheck.usageMain(strUsage); return 1; } } // sanity checks here if (filename=="" && !versionOnly) { inputCheck.usageMain(strUsage); return 1; } PsimagLite::String insitu = (optind < argc) ? argv[optind] : ""; if (!options.enabled && options.label != "-") { bool queryOnly = (options.label == "?"); if (options.label == "" || options.label == "?") { options.label = ArchiveFilesType::coutName(filename); if (queryOnly) { std::cout<<options.label<<"\n"; return 0; } } GlobalCoutStream.open(options.label.c_str()); if (!GlobalCoutStream || GlobalCoutStream.bad() || !GlobalCoutStream.good()) { PsimagLite::String str(argv[0]); str += ": Could not redirect std::cout to " + options.label + "\n"; throw PsimagLite::RuntimeError(str); } std::cerr<<argv[0]<<" ATTENTION: All standard output now sent to "; std::cerr<<options.label<<"\n"; std::cerr.flush(); GlobalCoutBuffer = std::cout.rdbuf(); //save old buf std::cout.rdbuf(GlobalCoutStream.rdbuf()); //redirect std::cout to file atexit(restoreCoutBuffer); } // print license if (ConcurrencyType::root() && !options.enabled) { std::cout<<ProgramGlobals::license; Provenance provenance; std::cout<<provenance; } if (versionOnly) return 0; InputNgType::Writeable ioWriteable(filename,inputCheck); InputNgType::Readable io(ioWriteable); ParametersDmrgSolverType dmrgSolverParams(io, false); ArchiveFilesType af(dmrgSolverParams,filename,options.enabled,options.label); if (insitu!="") dmrgSolverParams.insitu = insitu; if (dmrgSolverParams.options.find("minimizeDisk") != PsimagLite::String::npos) dmrgSolverParams.options += ",noSaveWft,noSaveStacks,noSaveData"; #ifndef USE_PTHREADS inputCheck.checkForThreads(dmrgSolverParams.nthreads); #endif ConcurrencyType::npthreads = dmrgSolverParams.nthreads; registerSignals(); PsimagLite::String targeting = inputCheck.getTargeting(dmrgSolverParams.options); bool isComplex = (dmrgSolverParams.options.find("useComplex") != PsimagLite::String::npos); if (targeting=="TimeStepTargetting") isComplex = true; if (isComplex) { mainLoop0<MySparseMatrixComplex, CvectorSizeType>(io,dmrgSolverParams,targeting,options); } else { mainLoop0<MySparseMatrixReal, CvectorSizeType>(io,dmrgSolverParams,targeting,options); } if (options.enabled) return 0; af.deletePackedFiles(); if (!keepFiles) ArchiveFilesType::staticDelete(); }
int main(int argc,char *argv[]) { typedef PsimagLite::Concurrency ConcurrencyType; ConcurrencyType concurrency(&argc,&argv,1); InputCheck inputCheck; PsimagLite::String filename=""; int opt = 0; PsimagLite::String strUsage(argv[0]); strUsage += " -f filename"; PsimagLite::String insitu(""); while ((opt = getopt(argc, argv,"f:o:")) != -1) { switch (opt) { case 'f': filename = optarg; break; case 'o': if (insitu=="") { insitu = optarg; } else { insitu += ","; insitu += optarg; } break; default: inputCheck.usageMain(strUsage); return 1; } } // sanity checks here if (filename=="") { inputCheck.usageMain(strUsage); return 1; } // print license if (ConcurrencyType::root()) { std::cerr<<ProgramGlobals::license; Provenance provenance; std::cout<<provenance; } InputNgType::Writeable ioWriteable(filename,inputCheck); InputNgType::Readable io(ioWriteable); ParametersDmrgSolverType dmrgSolverParams(io); if (insitu!="") dmrgSolverParams.insitu = insitu; #ifndef USE_PTHREADS inputCheck.checkForThreads(dmrgSolverParams.nthreads); #endif ConcurrencyType::npthreads = dmrgSolverParams.nthreads; #ifdef USE_COMPLEX std::cerr<<argv[0]<<" EXPERIMENTAL option complex is in use\n"; mainLoop0<MySparseMatrixC>(io,dmrgSolverParams,inputCheck); #else mainLoop0<MySparseMatrixReal>(io,dmrgSolverParams,inputCheck); #endif }
void mainLoop0(InputNgType::Readable& io, const ParametersDmrgSolverType& dmrgSolverParams, InputCheck& inputCheck) { typedef typename MySparseMatrix::value_type ComplexOrRealType; typedef PsimagLite::Geometry<ComplexOrRealType, InputNgType::Readable, ProgramGlobals> GeometryType; GeometryType geometry(io); bool su2=false; if (dmrgSolverParams.options.find("useSu2Symmetry")!=PsimagLite::String::npos) su2=true; PsimagLite::String targetting=inputCheck.getTargeting(dmrgSolverParams.options); if (targetting!="GroundStateTargetting" && su2) throw PsimagLite::RuntimeError("SU(2)" " supports only GroundStateTargetting for now (sorry!)\n"); if (su2) { if (dmrgSolverParams.targetQuantumNumbers[2]>0) { mainLoop<GeometryType,ModelHelperSu2,VectorWithOffsets,TargetingGroundState, MySparseMatrix>(geometry,dmrgSolverParams,io); } else { mainLoop<GeometryType,ModelHelperSu2,VectorWithOffset,TargetingGroundState, MySparseMatrix>(geometry,dmrgSolverParams,io); } return; } if (targetting=="TimeStepTargetting") { mainLoop<GeometryType,ModelHelperLocal,VectorWithOffsets,TargetingTimeStep, MySparseMatrixComplex>(geometry,dmrgSolverParams,io); return; } if (targetting=="DynamicTargetting") { mainLoop<GeometryType,ModelHelperLocal,VectorWithOffsets,TargetingDynamic, MySparseMatrix>(geometry,dmrgSolverParams,io); return; } if (targetting=="AdaptiveDynamicTargetting") { mainLoop<GeometryType,ModelHelperLocal,VectorWithOffsets,TargetingAdaptiveDynamic, MySparseMatrix>(geometry,dmrgSolverParams,io); return; } if (targetting=="CorrectionVectorTargetting") { mainLoop<GeometryType,ModelHelperLocal,VectorWithOffsets,TargetingCorrectionVector, MySparseMatrix>(geometry,dmrgSolverParams,io); return; } if (targetting=="CorrectionTargetting") { mainLoop<GeometryType,ModelHelperLocal,VectorWithOffsets,TargetingCorrection, MySparseMatrix>(geometry,dmrgSolverParams,io); return; } if (targetting=="MettsTargetting") { mainLoop<GeometryType,ModelHelperLocal,VectorWithOffsets,MettsTargetting, MySparseMatrix>(geometry,dmrgSolverParams,io); return; } mainLoop<GeometryType,ModelHelperLocal,VectorWithOffset,TargetingGroundState, MySparseMatrix>(geometry,dmrgSolverParams,io); }
int main(int argc,char *argv[]) { typedef PsimagLite::Concurrency ConcurrencyType; ConcurrencyType concurrency(&argc,&argv,1); InputCheck inputCheck; PsimagLite::String filename=""; int opt = 0; OperatorOptions options; PsimagLite::String strUsage(argv[0]); if (utils::basename(strUsage) == "operator") options.enabled = true; strUsage += " -f filename"; PsimagLite::String insitu(""); int precision = 6; /* PSIDOC OperatorDriver The arguments to the \verb!operator! executable are as follows. \begin{itemize} \item[-f] [Mandatory, String] Input to use. The Model= line is very important in input.inp. \item[-s] [Optional, Integer] Site for operator. Meaningful only for Models where the Hilbert space depends on the site (different kinds of atoms). Defaults to 0. \item[-l] [Mandatory, String] The label or name for this operator. This is model dependent. For example to obtain $c_{\uparrow}$ for the Hubbard model, say \begin{verbatim} ./operator -l c -f input.inp -F -1\end{verbatim} See the function naturalOperator for each Model. \item[-d] [Optional, Integer] Degree of freedom (spin, orbital or combination of both) to use. This is model dependent. For example to obtain $c_\downarrow$ for the Hubbard model, say \begin{verbatim}./operator -l c -d 1 -f input.inp -F -1\end{verbatim} See the function naturalOperator for each Model. Defaults to 0. \item[-F] [Mandatory, 1 or -1] If this operator commutes on \emph{different} sites say 1 here. If it anticommutes on \emph{different} sites say -1. \item[-t] [Optional, Void] Transpose the operator. For example to obtain $c^\dagger_\uparrow$ for a Hubbard model, say \begin{verbatim}./operator -l c -t -f input.inp -F -1\end{verbatim} \end{itemize} */ while ((opt = getopt(argc, argv,"f:o:s:l:d:F:p:t")) != -1) { switch (opt) { case 'f': filename = optarg; break; case 'o': if (insitu=="") { insitu = optarg; } else { insitu += ","; insitu += optarg; } break; case 's': options.site = atoi(optarg); break; case 'l': options.label = optarg; break; case 'd': options.dof = atoi(optarg); break; case 't': options.transpose = true; break; case 'F': options.fermionicSign = atoi(optarg); break; case 'p': precision = atoi(optarg); std::cout.precision(precision); std::cerr.precision(precision); break; default: inputCheck.usageMain(strUsage); return 1; } } // sanity checks here if (filename=="") { inputCheck.usageMain(strUsage); return 1; } // print license if (ConcurrencyType::root()) { std::cerr<<ProgramGlobals::license; Provenance provenance; std::cerr<<provenance; } InputNgType::Writeable ioWriteable(filename,inputCheck); InputNgType::Readable io(ioWriteable); ParametersDmrgSolverType dmrgSolverParams(io); if (insitu!="") dmrgSolverParams.insitu = insitu; #ifndef USE_PTHREADS inputCheck.checkForThreads(dmrgSolverParams.nthreads); #endif ConcurrencyType::npthreads = dmrgSolverParams.nthreads; registerSignals(); #ifdef USE_COMPLEX std::cerr<<argv[0]<<" EXPERIMENTAL option complex is in use\n"; mainLoop0<MySparseMatrixC>(io,dmrgSolverParams,inputCheck,options); #else mainLoop0<MySparseMatrixReal>(io,dmrgSolverParams,inputCheck,options); #endif }
void mainLoop0(InputNgType::Readable& io, const ParametersDmrgSolverType& dmrgSolverParams, InputCheck& inputCheck, const OperatorOptions& opOptions) { typedef typename MySparseMatrix::value_type ComplexOrRealType; typedef PsimagLite::Geometry<ComplexOrRealType, InputNgType::Readable, ProgramGlobals> GeometryType; GeometryType geometry(io); int tmp = 0; try { io.readline(tmp,"UseSu2Symmetry="); } catch (std::exception&) {} bool su2 = (tmp > 0); PsimagLite::String targetting=inputCheck.getTargeting(dmrgSolverParams.options); if (targetting!="GroundStateTargetting" && su2) { PsimagLite::String str("SU(2) supports only GroundStateTargetting (sorry!)\n"); throw PsimagLite::RuntimeError(str); } if (su2) { mainLoop1<GeometryType, ModelHelperSu2, TargetingGroundState, MySparseMatrix>(geometry,dmrgSolverParams,io,opOptions); return; } #ifdef USE_COMPLEX if (targetting != "TimeStepTargetting" && targetting != "GroundStateTargetting") { PsimagLite::String str("USE_COMPLEX not allowed for "); str += targetting + "\n"; throw PsimagLite::RuntimeError(str); } #endif if (targetting=="TimeStepTargetting") { mainLoop1<GeometryType,ModelHelperLocal,TargetingTimeStep, MySparseMatrixComplex>(geometry,dmrgSolverParams,io,opOptions); return; } if (targetting=="DynamicTargetting") { mainLoop1<GeometryType,ModelHelperLocal,TargetingDynamic, MySparseMatrix>(geometry,dmrgSolverParams,io,opOptions); return; } if (targetting=="AdaptiveDynamicTargetting") { mainLoop1<GeometryType,ModelHelperLocal,TargetingAdaptiveDynamic, MySparseMatrix>(geometry,dmrgSolverParams,io,opOptions); return; } if (targetting=="CorrectionVectorTargetting") { mainLoop1<GeometryType,ModelHelperLocal,TargetingCorrectionVector, MySparseMatrix>(geometry,dmrgSolverParams,io,opOptions); return; } if (targetting=="CorrectionTargetting") { mainLoop1<GeometryType,ModelHelperLocal,TargetingCorrection, MySparseMatrix>(geometry,dmrgSolverParams,io,opOptions); return; } if (targetting=="MettsTargetting") { mainLoop1<GeometryType,ModelHelperLocal,MettsTargetting, MySparseMatrix>(geometry,dmrgSolverParams,io,opOptions); return; } if (targetting=="TargetingAncilla") { mainLoop1<GeometryType,ModelHelperLocal,TargetingTimeStep, MySparseMatrix>(geometry,dmrgSolverParams,io,opOptions); return; } mainLoop1<GeometryType,ModelHelperLocal,TargetingGroundState, MySparseMatrix>(geometry,dmrgSolverParams,io,opOptions); }