Execution Flow¶
High-Level Flow¶
The execution flow of StdFace follows a linear pipeline:
CLI Invocation
│
▼
┌─────────────────────┐
│ main() in dry.c │ ─── Argument parsing
└─────────┬───────────┘
│
▼
┌─────────────────────┐
│ StdFace_main() │ ─── Core processing
│ in StdFace_main.c │
└─────────┬───────────┘
│
├──► Input file parsing
│
├──► Lattice construction
│
└──► Output file generation
│
▼
Configuration files
for target solver
Source reference: src/dry.c, src/StdFace_main.c
CLI Entry Point¶
The main() function in src/dry.c handles:
int main(int argc, char *argv[])
{
int status = 0;
if (argc < 2) {
printVersion(); // Display version
usage(argv[0]); // Show usage
status = 1;
} else if (strcmp(argv[1], "-v") == 0) {
printVersion(); // Version flag
} else {
StdFace_main(argv[1]); // Process input file
}
return status;
}
Behavior:
No arguments: Print version and usage, exit with status 1
-vflag: Print version onlyInput file provided: Dispatch to
StdFace_main()
Source reference: src/dry.c:34-47
StdFace_main() Processing¶
The StdFace_main() function (lines 2454-3066 of src/StdFace_main.c)
performs the following steps:
1. Initialization¶
struct StdIntList *StdI;
StdI = (struct StdIntList *)malloc(sizeof(struct StdIntList));
StdFace_ResetVals(StdI);
Allocates the central
StdIntListstructureInitializes all fields to default/sentinel values via
StdFace_ResetVals()
Source reference: src/StdFace_main.c:2459-2471
2. Input File Parsing¶
The input file is parsed line by line:
while (fgets(ctmpline, 256, fp) != NULL) {
TrimSpaceQuote(ctmpline);
// Skip comments and empty lines
if (strncmp(ctmpline, "//", 2) == 0) continue;
if (ctmpline[0] == '\0') continue;
keyword = strtok(ctmpline, "=");
value = strtok(NULL, "=");
Text2Lower(keyword);
// Match keyword and store value
if (strcmp(keyword, "lattice") == 0) StoreWithCheckDup_sl(...);
else if (strcmp(keyword, "model") == 0) StoreWithCheckDup_sl(...);
// ... many more keyword handlers
}
Key parsing functions:
Function |
Purpose |
|---|---|
|
Remove whitespace and quotes from line |
|
Convert keyword to lowercase |
|
Store integer with duplicate check |
|
Store double with duplicate check |
|
Store complex with duplicate check |
|
Store string with duplicate check |
|
Store string (lowercase) with check |
Source reference: src/StdFace_main.c:2482-2776 (parsing loop)
3. Model Validation¶
After parsing, the model type is validated and normalized:
if (strcmp(StdI->model, "fermionhubbard") == 0
|| strcmp(StdI->model, "hubbard") == 0)
strcpy(StdI->model, "hubbard\0");
else if (strcmp(StdI->model, "spin") == 0)
strcpy(StdI->model, "spin\0");
else if (strcmp(StdI->model, "kondolattice") == 0
|| strcmp(StdI->model, "kondo") == 0)
strcpy(StdI->model, "kondo\0");
// Grand canonical variants set StdI->lGC = 1
Supported models:
hubbard/fermionhubbard(canonical or grand canonical)spin(canonical or grand canonical)kondo/kondolattice(canonical or grand canonical)
Source reference: src/StdFace_main.c:2795-2830
4. Lattice Construction¶
Based on the lattice keyword, the appropriate constructor is called:
if (strcmp(StdI->lattice, "chain") == 0)
StdFace_Chain(StdI);
else if (strcmp(StdI->lattice, "square") == 0
|| strcmp(StdI->lattice, "tetragonal") == 0)
StdFace_Tetragonal(StdI);
else if (strcmp(StdI->lattice, "honeycomb") == 0)
StdFace_Honeycomb(StdI);
// ... other lattice types
Each lattice constructor:
Sets up site geometry
Defines neighbor relationships
Computes hopping and interaction terms
Populates
StdI->trans[]andStdI->intr[]arrays
Source reference: src/StdFace_main.c:2915-2945
5. Mode-Specific Output Generation¶
Output generation differs based on the compile-time mode:
HPhi mode (_HPhi defined):
#if defined(_HPhi)
PrintLocSpin(StdI);
PrintTrans(StdI);
PrintInteractions(StdI);
CheckModPara(StdI);
PrintModPara(StdI);
PrintExcitation(StdI);
PrintCalcMod(StdI);
CheckOutputMode(StdI);
Print1Green(StdI);
Print2Green(StdI);
PrintNamelist(StdI);
#endif
mVMC mode (_mVMC defined):
Similar structure but includes variational parameters
Generates Jastrow, Gutzwiller, orbital files
UHF mode (_UHF defined):
Simpler output; no Green’s function files
HWAVE mode (_HWAVE defined):
Two sub-modes:
uhfr(real-space) oruhfk/rpa(k-space)K-space modes call
ExportGeometry()andExportInteraction()
Source reference: src/StdFace_main.c:2960-3040
6. Cleanup¶
Memory allocated during processing is freed:
free(StdI->locspinflag);
for (ktrans = 0; ktrans < StdI->ntrans; ktrans++) {
free(StdI->transindx[ktrans]);
}
free(StdI->transindx);
free(StdI->trans);
// ... similar for other arrays
free(StdI);
Source reference: src/StdFace_main.c:3050-3065
Mode-Specific Behavior¶
The same source code behaves differently based on compile-time defines:
Mode |
Key Differences |
|---|---|
|
Full output including spectrum calculation parameters, TPQ settings, Green’s functions |
|
Includes variational parameters (Jastrow, Gutzwiller), sublattice settings for symmetry |
|
Mean-field settings, iteration parameters, mixing |
|
Two sub-modes: real-space (like UHF) or k-space (Wannier90-style export) |
The mode affects:
Which keywords are valid in the input file
What output files are generated
Which calculation parameters are required
Source reference: src/StdFace_main.c:2664-2774 (mode-specific keywords)
Error Handling¶
Errors are handled by the StdFace_exit() function:
Prints error message to stdout
Calls
exit()with the provided status code
Common error conditions:
Missing required parameters
Invalid keyword values
Unsupported model/lattice combinations
File open failures
Error messages are printed to stdout (not stderr). This is the observed pattern in the codebase.
Source reference: src/StdFace_ModelUtil.h (StdFace_exit),
src/StdFace_main.c (usage examples)