diff --git a/.gitignore b/.gitignore
index 4ab3ce4..8697656 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,5 +54,10 @@ dkms.conf
# Machine-specific Configuration File
make.sys
+.idea/
+.vscode/
+cmake-build-debug/
+.DS_Store
+
# Build Output
build/
diff --git a/src/ChainLattice.c b/src/ChainLattice.c
index 4a217db..e7ae7a9 100644
--- a/src/ChainLattice.c
+++ b/src/ChainLattice.c
@@ -29,9 +29,36 @@ along with this program. If not, see .
/**
@brief Setup a Hamiltonian for the Hubbard model on a Chain lattice
@author Mitsuaki Kawamura (The University of Tokyo)
+
+@details This function sets up the Hamiltonian for a 1D chain lattice model.
+It handles three different model types:
+- Spin model
+- Hubbard model
+- Kondo model
+
+The function performs the following steps:
+1. Computes super-cell shape and sites
+2. Validates and stores Hamiltonian parameters
+3. Sets local spin flags and number of sites
+4. Allocates memory for interactions
+5. Sets up transfers and interactions between sites
+
+@param[in,out] StdI Pointer to structure containing model parameters and lattice information
+
+@note The function supports:
+- Nearest neighbor interactions (J0, t0, V0)
+- Second nearest neighbor interactions (J0', t0', V0')
+- Third nearest neighbor interactions (J0'', t0'', V0'')
+- Local terms (magnetic field h, anisotropy Gamma)
+- On-site Coulomb interaction U (for Hubbard model)
+- Kondo coupling J (for Kondo model)
+
+@note The lattice geometry is written to lattice.gp file for visualization
+
+@warning For Kondo model, the number of sites is doubled to account for localized spins
*/
void StdFace_Chain(
- struct StdIntList *StdI//!<[inout]
+ struct StdIntList *StdI //!<[inout] Structure containing model parameters and lattice information
)
{
FILE *fp = NULL;
@@ -238,11 +265,29 @@ void StdFace_Chain(
#endif
StdFace_PrintGeometry(StdI);
}/*void StdFace_Chain*/
-
#if defined(_HPhi)
/**
@brief Setup a Hamiltonian for the generalized Heisenberg model on a Chain lattice
@author Mitsuaki Kawamura (The University of Tokyo)
+
+@details This function sets up a specialized Hamiltonian for the Heisenberg model on a chain lattice
+using the HPhi boost mode. It handles:
+- Magnetic field terms
+- Nearest and next-nearest neighbor interactions
+- Specialized 6-spin interactions
+
+The function performs:
+1. Sets up unit cell and lattice parameters
+2. Writes magnetic field configuration
+3. Writes interaction parameters
+4. Sets up topology and pivot sites
+5. Configures 6-spin interaction lists
+
+@param[in,out] StdI Pointer to structure containing model parameters
+
+@warning
+- S2 must be 1 in Boost mode
+- L must be divisible by 8
*/
void StdFace_Chain_Boost(struct StdIntList *StdI)
{
@@ -327,6 +372,17 @@ void StdFace_Chain_Boost(struct StdIntList *StdI)
}
}
+ /*
+ * Initialize the list_6spin_pair array which defines the spin interactions
+ * For each pivot point:
+ * - First 6 rows (indices 0-5) specify which spins are involved in each interaction
+ * - Last row (index 6) specifies the type of interaction (1 or 2)
+ * - Each column represents one interaction, with 8 total interactions per pivot
+ *
+ * The interactions are arranged in groups:
+ * - Interactions 0-3: Type 1 interactions between adjacent spins
+ * - Interactions 4-7: Type 2 interactions between next-nearest neighbors
+ */
for (ipivot = 0; ipivot < StdI->num_pivot; ipivot++) {
StdI->list_6spin_pair[ipivot][0][0] = 0;
StdI->list_6spin_pair[ipivot][1][0] = 1;
diff --git a/src/FCOrtho.c b/src/FCOrtho.c
index 9e716b6..15ec5d4 100644
--- a/src/FCOrtho.c
+++ b/src/FCOrtho.c
@@ -27,9 +27,24 @@ along with this program. If not, see .
#include
/**
-@brief Setup a Hamiltonian for the Face-Centered Orthorhombic lattice
-@author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Setup a Hamiltonian for the Face-Centered Orthorhombic lattice
+ * @author Mitsuaki Kawamura (The University of Tokyo)
+ *
+ * This function sets up the Hamiltonian for a face-centered orthorhombic lattice.
+ * The lattice has three primitive vectors:
+ * - W vector: (0, L/2, H/2)
+ * - L vector: (W/2, 0, H/2)
+ * - H vector: (W/2, L/2, 0)
+ * where W, L, H are the lengths in each direction.
+ *
+ * The function handles three models:
+ * - Spin model: Heisenberg interactions between localized spins
+ * - Hubbard model: Hopping and Coulomb interactions between itinerant electrons
+ * - Kondo model: Coupling between localized spins and itinerant electrons
+ *
+ * @param StdI [inout] Structure containing model parameters and lattice information
+ * Modified to store the complete Hamiltonian definition
+ */
void StdFace_FCOrtho(
struct StdIntList *StdI//!<[inout]
)
@@ -40,9 +55,14 @@ void StdFace_FCOrtho(
double complex Cphase;
double dR[3];
- /**@brief
- (1) Compute the shape of the super-cell and sites in the super-cell
- */
+ /**
+ * @brief Step 1: Compute the shape of the super-cell and sites in the super-cell
+ *
+ * - Opens XSF file for visualization
+ * - Sets number of sites per unit cell (1 for FCO)
+ * - Defines lattice parameters and primitive vectors
+ * - Initializes site positions
+ */
fp = fopen("lattice.xsf", "w");
/**/
StdI->NsiteUC = 1;
@@ -69,9 +89,14 @@ void StdFace_FCOrtho(
/**/
StdFace_InitSite(StdI, fp, 3);
StdI->tau[0][0] = 0.0; StdI->tau[0][1] = 0.0; ; StdI->tau[0][2] = 0.0;
- /**@brief
- (2) check & store parameters of Hamiltonian
- */
+ /**
+ * @brief Step 2: Check and store Hamiltonian parameters
+ *
+ * Handles different parameters depending on model type:
+ * - Spin model: J (exchange), D (anisotropy), magnetic field
+ * - Hubbard model: t (hopping), U (on-site), V (inter-site)
+ * - Kondo model: Combination of spin and Hubbard parameters
+ */
fprintf(stdout, "\n @ Hamiltonian \n\n");
StdFace_NotUsed_d("K", StdI->K);
StdFace_PrintVal_d("h", &StdI->h, 0.0);
@@ -143,10 +168,13 @@ void StdFace_FCOrtho(
}/*if (model != "spin")*/
fprintf(stdout, "\n @ Numerical conditions\n\n");
- /**@brief
- (3) Set local spin flag (StdIntList::locspinflag) and
- the number of sites (StdIntList::nsite)
- */
+ /**
+ * @brief Step 3: Set local spin flags and number of sites
+ *
+ * - Calculates total number of sites
+ * - Allocates and initializes local spin flags array
+ * - Handles different site counts for Kondo model
+ */
StdI->nsite = StdI->NsiteUC * StdI->NCell;
if (strcmp(StdI->model, "kondo") == 0 ) StdI->nsite *= 2;
StdI->locspinflag = (int *)malloc(sizeof(int) * StdI->nsite);
@@ -160,9 +188,14 @@ void StdFace_FCOrtho(
StdI->locspinflag[iL] = StdI->S2;
StdI->locspinflag[iL + StdI->nsite / 2] = 0;
}
- /**@brief
- (4) Compute the upper limit of the number of Transfer & Interaction and malloc them.
- */
+ /**
+ * @brief Step 4: Calculate memory requirements and allocate arrays
+ *
+ * Computes upper bounds for:
+ * - Number of transfer terms (hopping/field terms)
+ * - Number of interaction terms (exchange/Coulomb terms)
+ * Different calculations done for each model type
+ */
if (strcmp(StdI->model, "spin") == 0 ) {
ntransMax = StdI->nsite * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
nintrMax = StdI->NCell * (StdI->NsiteUC/*D*/ + 6/*J*/ + 3/*J'*/ + 0/*J''*/)
@@ -179,9 +212,15 @@ void StdFace_FCOrtho(
}
/**/
StdFace_MallocInteractions(StdI, ntransMax, nintrMax);
- /**@brief
- (5) Set Transfer & Interaction
- */
+ /**
+ * @brief Step 5: Set up all interactions in the Hamiltonian
+ *
+ * Loops over all unit cells and sets up:
+ * - Local terms (on-site U, magnetic field)
+ * - Nearest neighbor terms along W, L, H directions
+ * - Second nearest neighbor terms
+ * Different terms added depending on model type
+ */
for (kCell = 0; kCell < StdI->NCell; kCell++){
/**/
iW = StdI->Cell[kCell][0];
diff --git a/src/HoneycombLattice.c b/src/HoneycombLattice.c
index 4104184..999721e 100644
--- a/src/HoneycombLattice.c
+++ b/src/HoneycombLattice.c
@@ -1,23 +1,35 @@
-/*
-HPhi-mVMC-StdFace - Common input generator
-Copyright (C) 2015 The University of Tokyo
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+/**
+ * @file HoneycombLattice.c
+ * @brief Implementation of the honeycomb lattice model
+ * @copyright Copyright (C) 2015 The University of Tokyo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-*/
-/**@file
-@brief Standard mode for the honeycomb lattice
-*/
+/**
+ * @brief Standard mode for the honeycomb lattice
+ * @details This file implements the honeycomb lattice model with various interactions:
+ * - Hubbard model
+ * - Heisenberg model
+ * - Kondo lattice model
+ * The lattice has 2 sites per unit cell and supports:
+ * - Nearest neighbor hopping/exchange
+ * - Next nearest neighbor hopping/exchange
+ * - Third nearest neighbor hopping/exchange
+ * - On-site Coulomb interaction
+ * - Magnetic field
+ */
#include "StdFace_vals.h"
#include "StdFace_ModelUtil.h"
#include
@@ -27,9 +39,17 @@ along with this program. If not, see .
#include
/**
-@brief Setup a Hamiltonian for the Hubbard model on a Honeycomb lattice
-@author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Setup a Hamiltonian for the Hubbard/Heisenberg/Kondo model on a Honeycomb lattice
+ * @details This function:
+ * 1. Computes the shape of the super-cell and sites in the super-cell
+ * 2. Checks & stores parameters of the Hamiltonian
+ * 3. Sets local spin flags and number of sites
+ * 4. Computes upper limits for transfers and interactions
+ * 5. Sets up transfers and interactions between sites
+ *
+ * @param[in,out] StdI Pointer to structure containing model parameters
+ * @author Mitsuaki Kawamura (The University of Tokyo)
+ */
void StdFace_Honeycomb(struct StdIntList *StdI)
{
int isite, jsite, kCell, ntransMax, nintrMax;
@@ -38,9 +58,13 @@ void StdFace_Honeycomb(struct StdIntList *StdI)
double complex Cphase;
double dR[3];
- /**@brief
- (1) Compute the shape of the super-cell and sites in the super-cell
- */
+ /**
+ * @brief (1) Compute the shape of the super-cell and sites in the super-cell
+ * @details Sets up:
+ * - Lattice vectors
+ * - Unit cell with 2 sites
+ * - Site positions within unit cell
+ */
#ifdef _HWAVE
if (StdI->lattice_gp == 1)
#endif
@@ -64,9 +88,16 @@ void StdFace_Honeycomb(struct StdIntList *StdI)
StdFace_InitSite(StdI, fp, 2);
StdI->tau[0][0] = 0.0; StdI->tau[0][1] = 0.0; StdI->tau[0][2] = 0.0;
StdI->tau[1][0] = 1.0 / 3.0; StdI->tau[1][1] = 1.0 / 3.0; StdI->tau[1][2] = 0.0;
- /**@brief
- (2) check & store parameters of Hamiltonian
- */
+
+ /**
+ * @brief (2) Check & store parameters of Hamiltonian
+ * @details Handles parameters for:
+ * - Magnetic field
+ * - Exchange couplings (spin model)
+ * - Hopping terms (Hubbard model)
+ * - On-site Coulomb U
+ * - Inter-site Coulomb V
+ */
fprintf(stdout, "\n @ Hamiltonian \n\n");
StdFace_NotUsed_d("K", StdI->K);
StdFace_PrintVal_d("h", &StdI->h, 0.0);
@@ -145,10 +176,13 @@ void StdFace_Honeycomb(struct StdIntList *StdI)
}/*if (model != "spin")*/
fprintf(stdout, "\n @ Numerical conditions\n\n");
- /**@brief
- (3) Set local spin flag (StdIntList::locspinflag) and
- the number of sites (StdIntList::nsite)
- */
+
+ /**
+ * @brief (3) Set local spin flag and number of sites
+ * @details Sets:
+ * - Total number of sites
+ * - Local spin flags for each site
+ */
StdI->nsite = StdI->NsiteUC * StdI->NCell;
if (strcmp(StdI->model, "kondo") == 0 ) StdI->nsite *= 2;
StdI->locspinflag = (int *)malloc(sizeof(int) * StdI->nsite);
@@ -162,9 +196,14 @@ void StdFace_Honeycomb(struct StdIntList *StdI)
StdI->locspinflag[iL] = StdI->S2;
StdI->locspinflag[iL + StdI->nsite / 2] = 0;
}
- /**@brief
- (4) Compute the upper limit of the number of Transfer & Interaction and malloc them.
- */
+
+ /**
+ * @brief (4) Compute upper limit of Transfer & Interaction and malloc them
+ * @details Calculates maximum number of:
+ * - Transfers (hopping/exchange)
+ * - Interactions (Coulomb/exchange)
+ * And allocates memory accordingly
+ */
if (strcmp(StdI->model, "spin") == 0 ) {
ntransMax = StdI->nsite * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
nintrMax = StdI->NCell * (StdI->NsiteUC/*D*/ + 3/*J*/ + 6/*J'*/ + 3/*J''*/)
@@ -182,9 +221,15 @@ void StdFace_Honeycomb(struct StdIntList *StdI)
}
/**/
StdFace_MallocInteractions(StdI, ntransMax, nintrMax);
- /**@brief
- (5) Set Transfer & Interaction
- */
+
+ /**
+ * @brief (5) Set Transfer & Interaction
+ * @details For each unit cell:
+ * - Sets local terms (chemical potential, magnetic field)
+ * - Sets nearest neighbor terms
+ * - Sets next-nearest neighbor terms
+ * - Sets third-nearest neighbor terms
+ */
for (kCell = 0; kCell < StdI->NCell; kCell++) {
/**/
iW = StdI->Cell[kCell][0];
diff --git a/src/Kagome.c b/src/Kagome.c
index 45760cd..5f3e694 100644
--- a/src/Kagome.c
+++ b/src/Kagome.c
@@ -1,23 +1,22 @@
-/*
-HPhi-mVMC-StdFace - Common input generator
-Copyright (C) 2015 The University of Tokyo
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+/**
+ * @file Kagome.c
+ * @brief Standard mode implementation for the kagome lattice model
+ * @copyright Copyright (C) 2015 The University of Tokyo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-*/
-/**@file
-@brief Standard mode for the kagome lattice
-*/
#include "StdFace_vals.h"
#include "StdFace_ModelUtil.h"
#include
@@ -27,11 +26,24 @@ along with this program. If not, see .
#include
/**
-@brief Setup a Hamiltonian for the Kagome lattice
-@author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Setup a Hamiltonian for the Kagome lattice
+ *
+ * This function sets up the Hamiltonian for the Kagome lattice model.
+ * The Kagome lattice is a 2D lattice consisting of corner-sharing triangles.
+ *
+ * The function handles:
+ * - Lattice geometry and unit cell definition
+ * - Nearest and next-nearest neighbor interactions
+ * - Magnetic field terms
+ * - Different model types (spin, Hubbard, Kondo)
+ * - Hopping and interaction parameters
+ *
+ * @param[in,out] StdI Pointer to the StdIntList structure containing model parameters
+ *
+ * @author Mitsuaki Kawamura (The University of Tokyo)
+ */
void StdFace_Kagome(
- struct StdIntList *StdI//!<[inout]
+ struct StdIntList *StdI
)
{
int isite, jsite, isiteUC, kCell, ntransMax, nintrMax;
@@ -40,9 +52,14 @@ void StdFace_Kagome(
double complex Cphase;
double dR[3];
- /**@brief
- (1) Compute the shape of the super-cell and sites in the super-cell
- */
+ /**
+ * @brief Compute the shape of the super-cell and sites in the super-cell
+ *
+ * This section:
+ * - Opens lattice visualization file if needed
+ * - Sets number of sites in unit cell (3 for Kagome)
+ * - Defines lattice parameters and geometry
+ */
#ifdef _HWAVE
if (StdI->lattice_gp == 1)
#endif
@@ -67,9 +84,15 @@ void StdFace_Kagome(
StdI->tau[0][0] = 0.0; StdI->tau[0][1] = 0.0; StdI->tau[0][2] = 0.0;
StdI->tau[1][0] = 0.5; StdI->tau[1][1] = 0.0; StdI->tau[1][2] = 0.0;
StdI->tau[2][0] = 0.0; StdI->tau[2][1] = 0.5; StdI->tau[2][2] = 0.0;
- /**@brief
- (2) check & store parameters of Hamiltonian
- */
+
+ /**
+ * @brief Check and store Hamiltonian parameters
+ *
+ * This section:
+ * - Validates and stores model-specific parameters
+ * - Handles different model types (spin/Hubbard/Kondo)
+ * - Sets up interaction parameters
+ */
fprintf(stdout, "\n @ Hamiltonian \n\n");
/**/
StdFace_NotUsed_d("K", StdI->K);
@@ -143,10 +166,15 @@ void StdFace_Kagome(
}/*if (model != "spin")@@*/
fprintf(stdout, "\n @ Numerical conditions\n\n");
- /**@brief
- (3) Set local spin flag (StdIntList::locspinflag) and
- the number of sites (StdIntList::nsite)
- */
+
+ /**
+ * @brief Set local spin flags and number of sites
+ *
+ * This section:
+ * - Calculates total number of sites
+ * - Allocates and initializes local spin flags
+ * - Handles different model types
+ */
StdI->nsite = StdI->NsiteUC * StdI->NCell;
if (strcmp(StdI->model, "kondo") == 0 ) StdI->nsite *= 2;
StdI->locspinflag = (int *)malloc(sizeof(int) * StdI->nsite);
@@ -160,9 +188,14 @@ void StdFace_Kagome(
StdI->locspinflag[iL] = StdI->S2;
StdI->locspinflag[iL + StdI->nsite / 2] = 0;
}
- /**@brief
- (4) Compute the upper limit of the number of Transfer & Interaction and malloc them.
- */
+
+ /**
+ * @brief Compute interaction limits and allocate memory
+ *
+ * This section:
+ * - Calculates maximum number of transfer and interaction terms
+ * - Allocates memory for interactions based on model type
+ */
if (strcmp(StdI->model, "spin") == 0 ) {//>>
ntransMax = StdI->nsite * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
nintrMax = StdI->NCell * (StdI->NsiteUC/*D*/ + 6/*J*/ + 6/*J'*/)
@@ -179,9 +212,16 @@ void StdFace_Kagome(
}//<<
/**/
StdFace_MallocInteractions(StdI, ntransMax, nintrMax);
- /**@brief
- (5) Set Transfer & Interaction
- */
+
+ /**
+ * @brief Set transfer and interaction terms
+ *
+ * This section:
+ * - Loops over all cells in the lattice
+ * - Sets up nearest and next-nearest neighbor interactions
+ * - Handles boundary conditions and phases
+ * - Sets up hopping terms and Coulomb interactions
+ */
for (kCell = 0; kCell < StdI->NCell; kCell++) {
/**/
iW = StdI->Cell[kCell][0];
@@ -369,11 +409,19 @@ void StdFace_Kagome(
#if defined(_HPhi)
/**
-*
-* Setup a Hamiltonian for the generalized Heisenberg model on a Heisenberg lattice
-*
-* @author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Setup Hamiltonian for generalized Heisenberg model on Kagome lattice with boost
+ *
+ * This function sets up the Hamiltonian for the generalized Heisenberg model
+ * on a Kagome lattice with boost optimization. It handles:
+ * - Validation of input parameters
+ * - Setup of magnetic field terms
+ * - Definition of interaction matrices
+ * - Setup of topology and connectivity
+ *
+ * @param[in,out] StdI Pointer to StdIntList structure containing model parameters
+ *
+ * @author Mitsuaki Kawamura (The University of Tokyo)
+ */
void StdFace_Kagome_Boost(struct StdIntList *StdI)
{
int isite, ipivot, i1, i2;
diff --git a/src/Ladder.c b/src/Ladder.c
index d030ae6..88dfdb7 100644
--- a/src/Ladder.c
+++ b/src/Ladder.c
@@ -1,23 +1,27 @@
-/*
-HPhi-mVMC-StdFace - Common input generator
-Copyright (C) 2015 The University of Tokyo
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-*/
-/**@file
-@brief Standard mode for the Ladder lattice
-*/
+/*! \file Ladder.c
+ * \brief Standard mode for the Ladder lattice
+ * \author Mitsuaki Kawamura (The University of Tokyo)
+ *
+ * This file contains functions to set up Hamiltonians for ladder lattice models.
+ * It supports Heisenberg, Hubbard and Kondo models with various interactions.
+ *
+ * \copyright
+ * Copyright (C) 2015 The University of Tokyo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
#include "StdFace_vals.h"
#include "StdFace_ModelUtil.h"
#include
@@ -26,12 +30,29 @@ along with this program. If not, see .
#include
#include
-/**
-@brief Setup a Hamiltonian for the generalized Heisenberg model on a square lattice
-@author Mitsuaki Kawamura (The University of Tokyo)
-*/
+/*! \brief Setup a Hamiltonian for the generalized Heisenberg model on a ladder lattice
+ *
+ * This function sets up the Hamiltonian parameters for a ladder lattice model.
+ * It supports:
+ * - Heisenberg model with spin interactions
+ * - Hubbard model with electron hopping and interactions
+ * - Kondo model combining localized spins and itinerant electrons
+ *
+ * The ladder geometry consists of:
+ * - Vertical rungs between the two chains
+ * - Nearest and next-nearest neighbor interactions along the chains
+ * - Diagonal interactions between the chains
+ *
+ * \param[in,out] StdI Pointer to the structure containing model parameters
+ *
+ * The function:
+ * 1. Sets up the lattice geometry and parameters
+ * 2. Validates input parameters
+ * 3. Allocates arrays for interactions
+ * 4. Sets up all the interaction terms in the Hamiltonian
+ */
void StdFace_Ladder(
- struct StdIntList *StdI//!<[inout]
+ struct StdIntList *StdI
)
{
FILE *fp = NULL;
@@ -40,14 +61,15 @@ void StdFace_Ladder(
double complex Cphase;
double dR[3];
- /**@brief
- (1) Compute the shape of the super-cell and sites in the super-cell
- */
+ /* Open file for lattice plot if enabled */
#ifdef _HWAVE
if (StdI->lattice_gp == 1)
#endif
fp = fopen("lattice.gp", "w");
- /**/
+
+ /*
+ * 1. Set lattice size and shape parameters
+ */
fprintf(stdout, " @ Lattice Size & Shape\n\n");
StdFace_PrintVal_d("a", &StdI->a, 1.0);
@@ -58,30 +80,41 @@ void StdFace_Ladder(
StdFace_PrintVal_d("Lx", &StdI->direct[1][0], 0.0);
StdFace_PrintVal_d("Ly", &StdI->direct[1][1], StdI->length[1]);
+ /* Required parameters */
StdFace_RequiredVal_i("L", StdI->L);
StdFace_RequiredVal_i("W", StdI->W);
+
+ /* Unused parameters */
StdFace_NotUsed_i("a0W", StdI->box[0][0]);
StdFace_NotUsed_i("a0L", StdI->box[0][1]);
StdFace_NotUsed_i("a1W", StdI->box[1][0]);
StdFace_NotUsed_i("a1L", StdI->box[1][1]);
- /**/
+
+ /* Phase factors */
StdFace_PrintVal_d("phase0", &StdI->phase[0], 0.0);
StdFace_NotUsed_d("phase1", StdI->phase[1]);
StdI->phase[1] = StdI->phase[0];
StdI->phase[0] = 0.0;
- /**/
+
+ /* Set unit cell */
StdI->NsiteUC = StdI->W;
StdI->W = 1;
StdI->direct[0][0] = (double)StdI->NsiteUC;
StdFace_InitSite(StdI, fp, 2);
+
+ /* Initialize site positions */
for (isite = 0; isite < StdI->NsiteUC; isite++){
StdI->tau[isite][0] = (double)isite / (double)StdI->NsiteUC;
- StdI->tau[isite][1] = 0.0; StdI->tau[isite][2] = 0.0;
+ StdI->tau[isite][1] = 0.0;
+ StdI->tau[isite][2] = 0.0;
}
- /**@brief
- (2) check & store parameters of Hamiltonian
- */
+
+ /*
+ * 2. Set Hamiltonian parameters
+ */
fprintf(stdout, "\n @ Hamiltonian \n\n");
+
+ /* Unused coupling parameters */
StdFace_NotUsed_J("J", StdI->JAll, StdI->J);
StdFace_NotUsed_J("J'", StdI->JpAll, StdI->Jp);
StdFace_NotUsed_c("t", StdI->t);
@@ -89,11 +122,15 @@ void StdFace_Ladder(
StdFace_NotUsed_d("V", StdI->V);
StdFace_NotUsed_d("V'", StdI->Vp);
StdFace_NotUsed_d("K", StdI->K);
+
+ /* Magnetic field parameters */
StdFace_PrintVal_d("h", &StdI->h, 0.0);
StdFace_PrintVal_d("Gamma", &StdI->Gamma, 0.0);
StdFace_PrintVal_d("Gamma_y", &StdI->Gamma_y, 0.0);
- /**/
+
+ /* Model specific parameters */
if (strcmp(StdI->model, "spin") == 0 ) {
+ /* Heisenberg model parameters */
StdFace_PrintVal_i("2S", &StdI->S2, 1);
StdFace_PrintVal_d("D", &StdI->D[2][2], 0.0);
StdFace_InputSpin(StdI->J0, StdI->J0All, "J0");
@@ -101,7 +138,8 @@ void StdFace_Ladder(
StdFace_InputSpin(StdI->J2, StdI->J2All, "J2");
StdFace_InputSpin(StdI->J1p, StdI->J1pAll, "J1'");
StdFace_InputSpin(StdI->J2p, StdI->J2pAll, "J2'");
- /**/
+
+ /* Unused electronic parameters */
StdFace_NotUsed_d("mu", StdI->mu);
StdFace_NotUsed_d("U", StdI->U);
StdFace_NotUsed_c("t0", StdI->t0);
@@ -114,8 +152,9 @@ void StdFace_Ladder(
StdFace_NotUsed_d("V2", StdI->V2);
StdFace_NotUsed_d("V1'", StdI->V1p);
StdFace_NotUsed_d("V2'", StdI->V2p);
- }/*if (strcmp(StdI->model, "spin") == 0 )*/
- else {
+
+ } else {
+ /* Electronic model parameters */
StdFace_PrintVal_d("mu", &StdI->mu, 0.0);
StdFace_PrintVal_d("U", &StdI->U, 0.0);
StdFace_InputHopp(StdI->t, &StdI->t0, "t0");
@@ -128,7 +167,8 @@ void StdFace_Ladder(
StdFace_InputCoulombV(StdI->V, &StdI->V2, "V2");
StdFace_InputCoulombV(StdI->V, &StdI->V1p, "V1'");
StdFace_InputCoulombV(StdI->V, &StdI->V2p, "V2'");
- /**/
+
+ /* Unused spin parameters */
StdFace_NotUsed_J("J0", StdI->J0All, StdI->J0);
StdFace_NotUsed_J("J1", StdI->J1All, StdI->J1);
StdFace_NotUsed_J("J2", StdI->J2All, StdI->J2);
@@ -144,16 +184,18 @@ void StdFace_Ladder(
StdFace_PrintVal_i("2S", &StdI->S2, 1);
StdFace_InputSpin(StdI->J, StdI->JAll, "J");
}
- }/*if (model != "spin")*/
+ }
+
fprintf(stdout, "\n @ Numerical conditions\n\n");
- /**@brief
- (3) Set local spin flag (StdIntList::locspinflag) and
- the number of sites (StdIntList::nsite)
- */
+
+ /*
+ * 3. Set local spin flags and number of sites
+ */
StdI->nsite = StdI->L * StdI->NsiteUC;
if (strcmp(StdI->model, "kondo") == 0 ) StdI->nsite *= 2;
StdI->locspinflag = (int *)malloc(sizeof(int) * StdI->nsite);
- /**/
+
+ /* Set local spin flags based on model type */
if (strcmp(StdI->model, "spin") == 0 )
for (isite = 0; isite < StdI->nsite; isite++)StdI->locspinflag[isite] = StdI->S2;
else if (strcmp(StdI->model, "hubbard") == 0 )
@@ -163,17 +205,19 @@ void StdFace_Ladder(
StdI->locspinflag[isite] = StdI->S2;
StdI->locspinflag[isite + StdI->nsite / 2] = 0;
}
- /**@brief
- (4) Compute the upper limit of the number of Transfer & Interaction and malloc them.
- */
+
+ /*
+ * 4. Calculate maximum number of interactions and allocate arrays
+ */
if (strcmp(StdI->model, "spin") == 0 ) {
+ /* For spin model */
ntransMax = StdI->L * StdI->NsiteUC * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
nintrMax = StdI->L * StdI->NsiteUC * (1/*D*/ + 1/*J1*/ + 1/*J1'*/)
* (3 * StdI->S2 + 1) * (3 * StdI->S2 + 1)
+ StdI->L * (StdI->NsiteUC - 1) * (1/*J0*/ + 1/*J2*/ + 1/*J2'*/)
* (3 * StdI->S2 + 1) * (3 * StdI->S2 + 1);
- }/*if (strcmp(StdI->model, "spin") == 0 )*/
- else {
+ } else {
+ /* For electronic models */
ntransMax = StdI->L*StdI->NsiteUC * 2/*spin*/ * (2/*mu+h+Gamma*/ + 2/*t1*/ + 2/*t1'*/)
+ StdI->L*(StdI->NsiteUC - 1) * 2/*spin*/ * (2/*t0*/ + 2/*t2*/ + 2/*t2'*/);
nintrMax = StdI->L*StdI->NsiteUC * 1/*U*/
@@ -183,103 +227,91 @@ void StdFace_Ladder(
if (strcmp(StdI->model, "kondo") == 0) {
ntransMax += StdI->L * StdI->NsiteUC * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
nintrMax += StdI->nsite / 2 * (3 * 1 + 1) * (3 * StdI->S2 + 1);
- }/*if (strcmp(StdI->model, "kondo") == 0)*/
+ }
}
- /**/
+
+ /* Allocate arrays */
StdFace_MallocInteractions(StdI, ntransMax, nintrMax);
- /**@brief
- (5) Set Transfer & Interaction
- */
+
+ /*
+ * 5. Set all interactions
+ */
for (iL = 0; iL < StdI->L; iL++) {
for (isiteUC = 0; isiteUC < StdI->NsiteUC; isiteUC++) {
isite = isiteUC + iL * StdI->NsiteUC;
if (strcmp(StdI->model, "kondo") == 0 ) isite += StdI->L * StdI->NsiteUC;
- /*
- Local term
- */
+
+ /* Local terms */
if (strcmp(StdI->model, "spin") == 0 ) {
StdFace_MagField(StdI, StdI->S2, -StdI->h, -StdI->Gamma, -StdI->Gamma_y, isite);
StdFace_GeneralJ(StdI, StdI->D, StdI->S2, StdI->S2, isite, isite);
- }/*if (strcmp(StdI->model, "spin") == 0 )*/
- else {
+ } else {
StdFace_HubbardLocal(StdI, StdI->mu, -StdI->h, -StdI->Gamma, -StdI->Gamma_y, StdI->U, isite);
if (strcmp(StdI->model, "kondo") == 0 ) {
jsite = isiteUC + iL * StdI->NsiteUC;
StdFace_GeneralJ(StdI, StdI->J, 1, StdI->S2, isite, jsite);
StdFace_MagField(StdI, StdI->S2, -StdI->h, -StdI->Gamma, -StdI->Gamma_y, jsite);
- }/*if (strcmp(StdI->model, "kondo") == 0 )*/
- }/*if (model != "spin")*/
- /*
- Nearest neighbor along the ladder
- */
+ }
+ }
+
+ /* Nearest neighbor along the ladder */
StdFace_SetLabel(StdI, fp, 0, iL, 0, 1, isiteUC, isiteUC, &isite, &jsite, 1, &Cphase, dR);
- /**/
+
if (strcmp(StdI->model, "spin") == 0 ) {
StdFace_GeneralJ(StdI, StdI->J1, StdI->S2, StdI->S2, isite, jsite);
- }/*if (strcmp(StdI->model, "spin") == 0 )*/
- else {
+ } else {
StdFace_Hopping(StdI, Cphase * StdI->t1, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V1, isite, jsite);
- }/*if (model != "spin")*/
- /*
- Second nearest neighbor along the ladder
- */
+ }
+
+ /* Second nearest neighbor along the ladder */
StdFace_SetLabel(StdI, fp, 0, iL, 0, 2, isiteUC, isiteUC, &isite, &jsite, 2, &Cphase, dR);
- /**/
+
if (strcmp(StdI->model, "spin") == 0 ) {
StdFace_GeneralJ(StdI, StdI->J1p, StdI->S2, StdI->S2, isite, jsite);
- }/*if (strcmp(StdI->model, "spin") == 0 )*/
- else {
+ } else {
StdFace_Hopping(StdI, Cphase * StdI->t1p, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V1p, isite, jsite);
- }/*if (model != "spin")*/
- /*
- Across rung
- */
+ }
+
+ /* Interactions across rungs */
if (isiteUC < StdI->NsiteUC - 1) {
- /*
- Vertical
- */
+ /* Vertical */
StdFace_SetLabel(StdI, fp, 0, iL, 0, 0, isiteUC, isiteUC + 1, &isite, &jsite, 1, &Cphase, dR);
- /**/
+
if (strcmp(StdI->model, "spin") == 0 ) {
StdFace_GeneralJ(StdI, StdI->J0, StdI->S2, StdI->S2, isite, jsite);
- }/*if (strcmp(StdI->model, "spin") == 0 )*/
- else {
+ } else {
StdFace_Hopping(StdI, Cphase * StdI->t0, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V0, isite, jsite);
- }/*if (model != "spin")*/
- /*
- Diagonal 1
- */
+ }
+
+ /* Diagonal 1 */
StdFace_SetLabel(StdI, fp, 0, iL, 0, 1, isiteUC, isiteUC + 1, &isite, &jsite, 1, &Cphase, dR);
- /**/
+
if (strcmp(StdI->model, "spin") == 0 ) {
StdFace_GeneralJ(StdI, StdI->J2, StdI->S2, StdI->S2, isite, jsite);
- }/*if (strcmp(StdI->model, "spin") == 0 )*/
- else {
+ } else {
StdFace_Hopping(StdI, Cphase * StdI->t2, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V2, isite, jsite);
- }/*if (model != "spin")*/
- /*
- Diagonal 2
- */
+ }
+
+ /* Diagonal 2 */
StdFace_SetLabel(StdI, fp, 0, iL, 0, -1, isiteUC, isiteUC + 1, &isite, &jsite, 1, &Cphase, dR);
- /**/
+
if (strcmp(StdI->model, "spin") == 0 ) {
StdFace_GeneralJ(StdI, StdI->J2p, StdI->S2, StdI->S2, isite, jsite);
- }/*if (strcmp(StdI->model, "spin") == 0 )*/
- else {
+ } else {
StdFace_Hopping(StdI, Cphase * StdI->t2p, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V2p, isite, jsite);
- }/*if (model != "spin")*/
-
- }/*if (isiteUC < StdI->NsiteUC - 1)*/
+ }
- }/*for (isiteUC = 0; isiteUC < StdI->NsiteUC; isiteUC++)*/
- }/*for (iL = 0; iL < StdI->L; iL++)*/
+ }
+ }
+ }
+ /* Close lattice plot file */
#ifdef _HWAVE
if (StdI->lattice_gp == 1) {
#endif
@@ -288,49 +320,59 @@ void StdFace_Ladder(
#ifdef _HWAVE
}
#endif
+
+ /* Print final geometry information */
StdFace_PrintGeometry(StdI);
-}/*void StdFace_Ladder*/
+}
#if defined(_HPhi)
-/**
-*
-* Setup a Hamiltonian for the generalized Heisenberg model on a square lattice
-*
-* @author Mitsuaki Kawamura (The University of Tokyo)
-*/
+/*! \brief Setup a Hamiltonian for the generalized Heisenberg model on a ladder lattice with boost
+ *
+ * This function sets up a boosted version of the ladder Hamiltonian for HPhi.
+ * It is specialized for S=1/2 Heisenberg models.
+ *
+ * \param[in,out] StdI Pointer to the structure containing model parameters
+ */
void StdFace_Ladder_Boost(struct StdIntList *StdI)
{
int isite, ipivot;
int kintr;
FILE *fp;
+ /* Validate and set parameters */
StdI->W = StdI->NsiteUC;
StdI->NsiteUC = 1;
- /*
- Magnetic field
- */
+
+ /* Open boost definition file */
fp = fopen("boost.def", "w");
+
+ /* Write magnetic field parameters */
fprintf(fp, "# Magnetic field\n");
fprintf(fp, "%25.15e %25.15e %25.15e\n",
-0.5 * StdI->Gamma, -0.5 * StdI->Gamma_y, -0.5 * StdI->h);
- /*
- Interaction
- */
+
+ /* Write interaction parameters */
fprintf(fp, "%d # Number of type of J\n", 5);
+
+ /* J1 - Vertical interactions */
fprintf(fp, "# J 1 (inter chain, vertical)\n");
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J0[0][0], 0.25 * StdI->J0[0][1], 0.25 * StdI->J0[0][2]);
- fprintf(fp, "%25.15e %25.15e %25.15e\n",
+ fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J0[0][1], 0.25 * StdI->J0[1][1], 0.25 * StdI->J0[1][2]);
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J0[0][2], 0.25 * StdI->J0[1][2], 0.25 * StdI->J0[2][2]);
+
+ /* J2 - Nearest neighbor along chain */
fprintf(fp, "# J 2 (Nearest neighbor, along chain)\n");
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J1[0][0], 0.25 * StdI->J1[0][1], 0.25 * StdI->J1[0][2]);
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J1[0][1], 0.25 * StdI->J1[1][1], 0.25 * StdI->J1[1][2]);
- fprintf(fp, "%25.15e %25.15e %25.15e\n",
+ fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J1[0][2], 0.25 * StdI->J1[1][2], 0.25 * StdI->J1[2][2]);
+
+ /* J3 - Second nearest neighbor along chain */
fprintf(fp, "# J 3 (Second nearest neighbor, along chain)\n");
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J1p[0][0], 0.25 * StdI->J1p[0][1], 0.25 * StdI->J1p[0][2]);
@@ -338,6 +380,8 @@ void StdFace_Ladder_Boost(struct StdIntList *StdI)
0.25 * StdI->J1p[0][1], 0.25 * StdI->J1p[1][1], 0.25 * StdI->J1p[1][2]);
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J1p[0][2], 0.25 * StdI->J1p[1][2], 0.25 * StdI->J1p[2][2]);
+
+ /* J4 - Diagonal 1 interactions */
fprintf(fp, "# J 4 (inter chain, diagonal1)\n");
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J2[0][0], 0.25 * StdI->J2[0][1], 0.25 * StdI->J2[0][2]);
@@ -345,6 +389,8 @@ void StdFace_Ladder_Boost(struct StdIntList *StdI)
0.25 * StdI->J2[0][1], 0.25 * StdI->J2[1][1], 0.25 * StdI->J2[1][2]);
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J2[0][2], 0.25 * StdI->J2[1][2], 0.25 * StdI->J2[2][2]);
+
+ /* J5 - Diagonal 2 interactions */
fprintf(fp, "# J 5 (inter chain, diagonal2)\n");
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J2p[0][0], 0.25 * StdI->J2p[0][1], 0.25 * StdI->J2p[0][2]);
@@ -352,9 +398,8 @@ void StdFace_Ladder_Boost(struct StdIntList *StdI)
0.25 * StdI->J2p[0][1], 0.25 * StdI->J2p[1][1], 0.25 * StdI->J2p[1][2]);
fprintf(fp, "%25.15e %25.15e %25.15e\n",
0.25 * StdI->J2p[0][2], 0.25 * StdI->J2p[1][2], 0.25 * StdI->J2p[2][2]);
- /*
- Topology
- */
+
+ /* Validate parameters */
if (StdI->S2 != 1) {
fprintf(stdout, "\n ERROR! S2 must be 1 in Boost. \n\n");
StdFace_exit(-1);
@@ -372,13 +417,17 @@ void StdFace_Ladder_Boost(struct StdIntList *StdI)
fprintf(stdout, "\n ERROR! L < 4 \n\n");
StdFace_exit(-1);
}
+
+ /* Set dimensions */
StdI->W = StdI->L;
StdI->L = 2;
StdI->num_pivot = StdI->W / 2;
- /**/
+
+ /* Write topology information */
fprintf(fp, "# W0 R0 StdI->num_pivot StdI->ishift_nspin\n");
fprintf(fp, "%d %d %d %d\n", StdI->W, StdI->L, StdI->num_pivot, StdI->ishift_nspin);
+ /* Allocate and initialize 6-spin star list */
StdI->list_6spin_star = (int **)malloc(sizeof(int*) * StdI->num_pivot);
for (ipivot = 0; ipivot < StdI->num_pivot; ipivot++) {
StdI->list_6spin_star[ipivot] = (int *)malloc(sizeof(int) * 7);
diff --git a/src/Orthorhombic.c b/src/Orthorhombic.c
index f231ef0..c67a6eb 100644
--- a/src/Orthorhombic.c
+++ b/src/Orthorhombic.c
@@ -1,23 +1,22 @@
-/*
-HPhi-mVMC-StdFace - Common input generator
-Copyright (C) 2015 The University of Tokyo
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+/**
+ * @file Orthorhombic.c
+ * @brief Standard mode for the orthorhombic lattice
+ * @copyright Copyright (C) 2015 The University of Tokyo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-*/
-/**@file
-@brief Standard mode for the orthorhombic lattice
-*/
#include "StdFace_vals.h"
#include "StdFace_ModelUtil.h"
#include
@@ -27,11 +26,22 @@ along with this program. If not, see .
#include
/**
-@brief Setup a Hamiltonian for the Simple Orthorhombic lattice
-@author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Setup a Hamiltonian for the Simple Orthorhombic lattice
+ *
+ * This function sets up the Hamiltonian for a simple orthorhombic lattice.
+ * It handles the following:
+ * - Computes super-cell shape and sites
+ * - Stores Hamiltonian parameters
+ * - Sets local spin flags
+ * - Computes transfer and interaction terms
+ * - Handles different model types (spin, Hubbard, Kondo)
+ * - Sets up nearest neighbor, next-nearest neighbor and third-nearest neighbor interactions
+ *
+ * @param[in,out] StdI Pointer to the StdIntList structure containing model parameters
+ * @author Mitsuaki Kawamura (The University of Tokyo)
+ */
void StdFace_Orthorhombic(
- struct StdIntList *StdI//!<[inout]
+ struct StdIntList *StdI
)
{
int isite, jsite, ntransMax, nintrMax;
@@ -40,9 +50,14 @@ void StdFace_Orthorhombic(
double complex Cphase;
double dR[3];
- /**@brief
- (1) Compute the shape of the super-cell and sites in the super-cell
- */
+ /**
+ * @brief Step 1: Compute super-cell shape and sites
+ *
+ * - Opens lattice visualization file
+ * - Sets number of sites per unit cell
+ * - Prints lattice parameters and dimensions
+ * - Initializes site coordinates
+ */
fp = fopen("lattice.xsf", "w");
/**/
StdI->NsiteUC = 1;
@@ -69,9 +84,15 @@ void StdFace_Orthorhombic(
/**/
StdFace_InitSite(StdI, fp, 3);
StdI->tau[0][0] = 0.0; StdI->tau[0][1] = 0.0; ; StdI->tau[0][2] = 0.0;
- /**@brief
- (2) check & store parameters of Hamiltonian
- */
+
+ /**
+ * @brief Step 2: Check and store Hamiltonian parameters
+ *
+ * Handles different parameter sets depending on model type:
+ * - Spin model: J couplings, magnetic field, anisotropy
+ * - Hubbard model: hopping terms, Coulomb interactions
+ * - Kondo model: combination of both
+ */
fprintf(stdout, "\n @ Hamiltonian \n\n");
StdFace_NotUsed_d("K", StdI->K);
StdFace_PrintVal_d("h", &StdI->h, 0.0);
@@ -145,10 +166,14 @@ void StdFace_Orthorhombic(
}/*if (model != "spin")*/
fprintf(stdout, "\n @ Numerical conditions\n\n");
- /**@brief
- (3) Set local spin flag (StdIntList::locspinflag) and
- the number of sites (StdIntList::nsite)
- */
+
+ /**
+ * @brief Step 3: Set local spin flags and number of sites
+ *
+ * - Calculates total number of sites
+ * - Allocates and initializes local spin flags array
+ * - Handles different models (spin, Hubbard, Kondo)
+ */
StdI->nsite = StdI->NsiteUC * StdI->NCell;
if (strcmp(StdI->model, "kondo") == 0 ) StdI->nsite *= 2;
StdI->locspinflag = (int *)malloc(sizeof(int) * StdI->nsite);
@@ -162,9 +187,15 @@ void StdFace_Orthorhombic(
StdI->locspinflag[iL] = StdI->S2;
StdI->locspinflag[iL + StdI->nsite / 2] = 0;
}
- /**@brief
- (4) Compute the upper limit of the number of Transfer & Interaction and malloc them.
- */
+
+ /**
+ * @brief Step 4: Calculate maximum number of interactions
+ *
+ * Computes upper limits for:
+ * - Number of transfer terms
+ * - Number of interaction terms
+ * Then allocates memory for interactions
+ */
if (strcmp(StdI->model, "spin") == 0 ) {
ntransMax = StdI->nsite * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
nintrMax = StdI->NCell * (StdI->NsiteUC/*D*/ + 3/*J*/ + 6/*J'*/ + 4/*J''*/)
@@ -181,17 +212,23 @@ void StdFace_Orthorhombic(
}
/**/
StdFace_MallocInteractions(StdI, ntransMax, nintrMax);
- /**@brief
- (5) Set Transfer & Interaction
- */
+
+ /**
+ * @brief Step 5: Set up all interactions
+ *
+ * Loops through cells setting up:
+ * - Local terms
+ * - Nearest neighbor interactions
+ * - Next-nearest neighbor interactions
+ * - Third-nearest neighbor interactions
+ */
for (kCell = 0; kCell < StdI->NCell; kCell++){
/**/
iW = StdI->Cell[kCell][0];
iL = StdI->Cell[kCell][1];
iH = StdI->Cell[kCell][2];
- /*
- (1) Local term
- */
+
+ /* Local terms */
isite = kCell;
if (strcmp(StdI->model, "kondo") == 0 ) isite += StdI->NCell;
/**/
@@ -207,9 +244,8 @@ void StdFace_Orthorhombic(
StdFace_MagField(StdI, StdI->S2, -StdI->h, -StdI->Gamma, -StdI->Gamma_y, jsite);
}/*if (strcmp(StdI->model, "kondo") == 0 )*/
}
- /*
- (2) Nearest neighbor along W
- */
+
+ /* Nearest neighbor along W */
StdFace_FindSite(StdI, iW, iL, iH, 1, 0, 0, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0 ) {
@@ -219,9 +255,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->t0, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V0, isite, jsite);
}
- /*
- (3) Nearest neighbor along L
- */
+
+ /* Nearest neighbor along L */
StdFace_FindSite(StdI, iW, iL, iH, 0, 1, 0, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -231,9 +266,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->t1, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V1, isite, jsite);
}
- /*
- (4) Nearest neighbor along H
- */
+
+ /* Nearest neighbor along H */
StdFace_FindSite(StdI, iW, iL, iH, 0, 0, 1, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -243,9 +277,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->t2, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V2, isite, jsite);
}
- /*
- (5) Second nearest neighbor along +L+H
- */
+
+ /* Second nearest neighbor along +L+H */
StdFace_FindSite(StdI, iW, iL, iH, 0, 1, 1, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0 ) {
@@ -255,9 +288,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->t0p, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V0p, isite, jsite);
}
- /*
- (6) Second nearest neighbor along +L-H
- */
+
+ /* Second nearest neighbor along +L-H */
StdFace_FindSite(StdI, iW, iL, iH, 0, 1, -1, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -267,9 +299,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->t0p, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V0p, isite, jsite);
}
- /*
- (7) Second nearest neighbor along +H+W
- */
+
+ /* Second nearest neighbor along +H+W */
StdFace_FindSite(StdI, iW, iL, iH, 1, 0, 1, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -279,9 +310,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->t1p, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V1p, isite, jsite);
}
- /*
- (8) Second nearest neighbor along +H-W
- */
+
+ /* Second nearest neighbor along +H-W */
StdFace_FindSite(StdI, iW, iL, iH, -1, 0, 1, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -291,9 +321,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->t1p, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V1p, isite, jsite);
}
- /*
- (9) Second nearest neighbor along +W+L
- */
+
+ /* Second nearest neighbor along +W+L */
StdFace_FindSite(StdI, iW, iL, iH, 1, 1, 0, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -303,9 +332,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->t2p, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V2p, isite, jsite);
}
- /*
- (10) Second nearest neighbor along +W-L
- */
+
+ /* Second nearest neighbor along +W-L */
StdFace_FindSite(StdI, iW, iL, iH, 1, -1, 0, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -315,9 +343,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->t2p, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->V2p, isite, jsite);
}
- /*
- (11) Third nearest neighbor along +W+L+H
- */
+
+ /* Third nearest neighbor along +W+L+H */
StdFace_FindSite(StdI, iW, iL, iH, 1, 1, 1, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -327,9 +354,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->tpp, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->Vpp, isite, jsite);
}
- /*
- (12) Third nearest neighbor along -W+L+H
- */
+
+ /* Third nearest neighbor along -W+L+H */
StdFace_FindSite(StdI, iW, iL, iH, -1, 1, 1, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -339,9 +365,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->tpp, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->Vpp, isite, jsite);
}
- /*
- (13) Third nearest neighbor along +W-L+H
- */
+
+ /* Third nearest neighbor along +W-L+H */
StdFace_FindSite(StdI, iW, iL, iH, 1, -1, 1, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
@@ -351,9 +376,8 @@ void StdFace_Orthorhombic(
StdFace_Hopping(StdI, Cphase * StdI->tpp, isite, jsite, dR);
StdFace_Coulomb(StdI, StdI->Vpp, isite, jsite);
}
- /*
- (14) Third nearest neighbor along +W+L-H
- */
+
+ /* Third nearest neighbor along +W+L-H */
StdFace_FindSite(StdI, iW, iL, iH, 1, 1, -1, 0, 0, &isite, &jsite, &Cphase, dR);
/**/
if (strcmp(StdI->model, "spin") == 0) {
diff --git a/src/Pyrochlore.c b/src/Pyrochlore.c
index ba365e1..30e397c 100644
--- a/src/Pyrochlore.c
+++ b/src/Pyrochlore.c
@@ -1,23 +1,24 @@
-/*
-HPhi-mVMC-StdFace - Common input generator
-Copyright (C) 2015 The University of Tokyo
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+/**
+ * @file Pyrochlore.c
+ * @brief Standard mode for the pyrochlore lattice
+ * @copyright
+ * HPhi-mVMC-StdFace - Common input generator
+ * Copyright (C) 2015 The University of Tokyo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-*/
-/**@file
-@brief Standard mode for the pyrochlore lattice
-*/
#include "StdFace_vals.h"
#include "StdFace_ModelUtil.h"
#include
@@ -27,11 +28,42 @@ along with this program. If not, see .
#include
/**
-@brief Setup a Hamiltonian for the Pyrochlore structure
-@author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Setup a Hamiltonian for the Pyrochlore structure
+ * @details This function sets up the Hamiltonian for a pyrochlore lattice structure.
+ * It handles both spin and electronic models (Hubbard, Kondo).
+ * The function:
+ * 1. Computes super-cell shape and sites
+ * 2. Checks and stores Hamiltonian parameters
+ * 3. Sets local spin flags
+ * 4. Computes transfer and interaction limits
+ * 5. Sets up transfers and interactions between sites
+ *
+ * The pyrochlore lattice consists of corner-sharing tetrahedra in a 3D structure.
+ * Each unit cell contains 4 sites forming a tetrahedron.
+ *
+ * The lattice parameters are:
+ * - a: Lattice constant
+ * - W,L,H: Cell dimensions along each direction
+ * - tau[4][3]: Positions of the 4 sites within unit cell
+ *
+ * Supported models:
+ * - Spin model: Heisenberg interactions between spins
+ * - Hubbard model: Electron hopping and on-site interactions
+ * - Kondo model: Coupling between localized spins and conduction electrons
+ *
+ * Key parameters:
+ * - J0,J1,J2: Nearest neighbor spin couplings
+ * - t0,t1,t2: Nearest neighbor hoppings
+ * - U: On-site Coulomb interaction
+ * - V: Inter-site Coulomb interaction
+ * - h: Magnetic field
+ * - Gamma: Transverse field
+ *
+ * @param[in,out] StdI Pointer to structure containing model parameters and lattice info
+ * @author Mitsuaki Kawamura (The University of Tokyo)
+ */
void StdFace_Pyrochlore(
- struct StdIntList *StdI//!<[inout]
+ struct StdIntList *StdI//!<[inout] Structure containing model parameters and lattice info
)
{
int isite, jsite, isiteUC, ntransMax, nintrMax;
diff --git a/src/SquareLattice.c b/src/SquareLattice.c
index 9aae45a..df8a5e0 100644
--- a/src/SquareLattice.c
+++ b/src/SquareLattice.c
@@ -27,9 +27,12 @@ along with this program. If not, see .
#include
/**
-@brief Setup a Hamiltonian for the square lattice
-@author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Setup a Hamiltonian for the square lattice
+ * @details Initializes and configures a Hamiltonian for a square/tetragonal lattice system.
+ * Sets up the lattice geometry, boundary conditions, and interaction parameters.
+ * @param[in,out] StdI Pointer to structure containing model parameters and lattice information
+ * @author Mitsuaki Kawamura (The University of Tokyo)
+ */
void StdFace_Tetragonal(struct StdIntList *StdI)
{
int isite, jsite, ntransMax, nintrMax;
diff --git a/src/StdFace_ModelUtil.h b/src/StdFace_ModelUtil.h
index 017340b..01189d3 100644
--- a/src/StdFace_ModelUtil.h
+++ b/src/StdFace_ModelUtil.h
@@ -15,71 +15,380 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
+
+/**
+ * @file StdFace_ModelUtil.h
+ * @brief Utility functions for constructing models in standard mode
+ * @author Mitsuaki Kawamura (The University of Tokyo)
+ *
+ * This file contains declarations for utility functions used in constructing
+ * various lattice models and handling interactions in standard mode.
+ */
+
#include
#include
+/**
+ * @brief MPI Abortation wrapper
+ * @param[in] errorcode Error code to exit with
+ */
void StdFace_exit(int errorcode);
+/**
+ * @brief Add interaction term to the list
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] intr0 Interaction strength
+ * @param[in] site1 First site index
+ * @param[in] spin1 First spin index
+ * @param[in] site2 Second site index
+ * @param[in] spin2 Second spin index
+ * @param[in] site3 Third site index
+ * @param[in] spin3 Third spin index
+ * @param[in] site4 Fourth site index
+ * @param[in] spin4 Fourth spin index
+ */
void StdFace_intr(struct StdIntList *StdI, double complex intr0,
int site1, int spin1, int site2, int spin2,
int site3, int spin3, int site4, int spin4);
+/**
+ * @brief Add hopping term between sites
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] trans0 Hopping amplitude
+ * @param[in] isite Source site index
+ * @param[in] jsite Target site index
+ * @param[in] dR Distance vector between sites
+ */
void StdFace_Hopping(struct StdIntList *StdI, double complex trans0, int isite, int jsite, double *dR);
+
+/**
+ * @brief Add transfer term between sites with spin
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] trans0 Transfer amplitude
+ * @param[in] isite Source site index
+ * @param[in] ispin Source spin index
+ * @param[in] jsite Target site index
+ * @param[in] jspin Target spin index
+ */
void StdFace_trans(struct StdIntList *StdI,double complex trans0,int isite,int ispin,int jsite,int jspin);
+
+/**
+ * @brief Add local Hubbard terms
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] mu0 Chemical potential
+ * @param[in] h0 Magnetic field
+ * @param[in] Gamma0 Gamma field strength
+ * @param[in] Gamma0_y Y-component of Gamma field
+ * @param[in] U0 On-site Coulomb interaction
+ * @param[in] isite Site index
+ */
void StdFace_HubbardLocal(struct StdIntList *StdI, double mu0, double h0,
double Gamma0, double Gamma0_y, double U0, int isite);
+
+/**
+ * @brief Add magnetic field terms
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] S2 Twice the spin value
+ * @param[in] h Magnetic field strength
+ * @param[in] Gamma Gamma field strength
+ * @param[in] Gamma_y Y-component of Gamma field
+ * @param[in] isite Site index
+ */
void StdFace_MagField(struct StdIntList *StdI, int S2, double h, double Gamma, double Gamma_y, int isite);
+/**
+ * @brief Add Coulomb interaction between sites
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] V Coulomb interaction strength
+ * @param[in] isite First site index
+ * @param[in] jsite Second site index
+ */
void StdFace_Coulomb(struct StdIntList *StdI, double V, int isite, int jsite);
+
+/**
+ * @brief Add general exchange interaction
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] J Exchange coupling matrix
+ * @param[in] Si2 Twice the spin value for site i
+ * @param[in] Sj2 Twice the spin value for site j
+ * @param[in] isite First site index
+ * @param[in] jsite Second site index
+ */
void StdFace_GeneralJ(struct StdIntList *StdI, double J[3][3],
int Si2, int Sj2, int isite, int jsite);
+/**
+ * @brief Print double value with name
+ * @param[in] valname Name of the value
+ * @param[in] val Pointer to value
+ * @param[in] val0 Default value
+ */
void StdFace_PrintVal_d(char* valname, double *val, double val0);
+
+/**
+ * @brief Print two double values with name
+ * @param[in] valname Name of the values
+ * @param[in] val Pointer to values
+ * @param[in] val0 First default value
+ * @param[in] val1 Second default value
+ */
void StdFace_PrintVal_dd(char* valname, double *val, double val0, double val1);
+
+/**
+ * @brief Print complex value with name
+ * @param[in] valname Name of the value
+ * @param[in] val Pointer to value
+ * @param[in] val0 Default value
+ */
void StdFace_PrintVal_c(char* valname, double complex *val, double complex val0);
+
+/**
+ * @brief Print integer value with name
+ * @param[in] valname Name of the value
+ * @param[in] val Pointer to value
+ * @param[in] val0 Default value
+ */
void StdFace_PrintVal_i(char* valname, int *val, int val0);
+/**
+ * @brief Print warning for unused double parameter
+ * @param[in] valname Name of unused parameter
+ * @param[in] val Value of unused parameter
+ */
void StdFace_NotUsed_d(char* valname, double val);
+
+/**
+ * @brief Print warning for unused integer parameter
+ * @param[in] valname Name of unused parameter
+ * @param[in] val Value of unused parameter
+ */
void StdFace_NotUsed_i(char* valname, int val);
+
+/**
+ * @brief Print warning for unused complex parameter
+ * @param[in] valname Name of unused parameter
+ * @param[in] val Value of unused parameter
+ */
void StdFace_NotUsed_c(char* valname, double complex val);
+
+/**
+ * @brief Print warning for unused exchange parameter
+ * @param[in] valname Name of unused parameter
+ * @param[in] JAll Scalar exchange value
+ * @param[in] J Exchange matrix
+ */
void StdFace_NotUsed_J(char* valname, double JAll, double J[3][3]);
+/**
+ * @brief Check if required integer parameter is set
+ * @param[in] valname Name of parameter
+ * @param[in] val Value to check
+ */
void StdFace_RequiredVal_i(char* valname, int val);
+
+/**
+ * @brief Initialize spin nearest neighbor interactions
+ * @param[out] J Output exchange matrix
+ * @param[in] JAll Scalar exchange value
+ * @param[in] J0 Input exchange matrix
+ * @param[in] J0All Input scalar exchange value
+ * @param[in] J0name Name of exchange parameter
+ */
void StdFace_InputSpinNN(double J[3][3], double JAll, double J0[3][3], double J0All, char *J0name);
+
+/**
+ * @brief Initialize spin interactions
+ * @param[out] Jp Output exchange matrix
+ * @param[in] JpAll Scalar exchange value
+ * @param[in] Jpname Name of exchange parameter
+ */
void StdFace_InputSpin(double Jp[3][3], double JpAll, char *Jpname);
+
+/**
+ * @brief Initialize Coulomb interaction
+ * @param[in] V Input Coulomb strength
+ * @param[out] V0 Output Coulomb strength
+ * @param[in] V0name Name of Coulomb parameter
+ */
void StdFace_InputCoulombV(double V, double *V0, char *V0name);
+
+/**
+ * @brief Initialize hopping parameter
+ * @param[in] t Input hopping
+ * @param[out] t0 Output hopping
+ * @param[in] t0name Name of hopping parameter
+ */
void StdFace_InputHopp(double complex t, double complex *t0, char *t0name);
+/**
+ * @brief Initialize lattice sites
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] fp File pointer for output
+ * @param[in] dim Lattice dimension
+ */
void StdFace_InitSite(struct StdIntList *StdI, FILE *fp, int dim);
+
+/**
+ * @brief Set site labels and connections
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] fp File pointer for output
+ * @param[in] iW Width index
+ * @param[in] iL Length index
+ * @param[in] diW Width displacement
+ * @param[in] diL Length displacement
+ * @param[in] isiteUC First unit cell site
+ * @param[in] jsiteUC Second unit cell site
+ * @param[out] isite Output first site index
+ * @param[out] jsite Output second site index
+ * @param[in] connect Connection type
+ * @param[out] Cphase Complex phase factor
+ * @param[out] dR Distance vector
+ */
void StdFace_SetLabel(struct StdIntList *StdI, FILE *fp,
int iW, int iL, int diW, int diL, int isiteUC, int jsiteUC,
int *isite, int *jsite, int connect, double complex *Cphase, double *dR);
+
+/**
+ * @brief Print geometry information
+ * @param[in] StdI Structure containing model parameters
+ */
void StdFace_PrintGeometry(struct StdIntList *StdI);
+
+/**
+ * @brief Allocate memory for interactions
+ * @param[in,out] StdI Structure containing model parameters
+ * @param[in] ntransMax Maximum number of transfer terms
+ * @param[in] nintrMax Maximum number of interaction terms
+ */
void StdFace_MallocInteractions(struct StdIntList *StdI, int ntransMax, int nintrMax);
+
+/**
+ * @brief Find site indices in lattice
+ * @param[in] StdI Structure containing model parameters
+ * @param[in] iW Width index
+ * @param[in] iL Length index
+ * @param[in] iH Height index
+ * @param[in] diW Width displacement
+ * @param[in] diL Length displacement
+ * @param[in] diH Height displacement
+ * @param[in] isiteUC First unit cell site
+ * @param[in] jsiteUC Second unit cell site
+ * @param[out] isite Output first site index
+ * @param[out] jsite Output second site index
+ * @param[out] Cphase Complex phase factor
+ * @param[out] dR Distance vector
+ */
void StdFace_FindSite(struct StdIntList *StdI,
int iW, int iL, int iH, int diW, int diL, int diH,
int isiteUC, int jsiteUC,
int *isite, int *jsite, double complex *Cphase, double *dR);
+
+/**
+ * @brief Print XSF format output
+ * @param[in] StdI Structure containing model parameters
+ */
void StdFace_PrintXSF(struct StdIntList *StdI);
+/**
+ * @brief Initialize tetragonal lattice
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Tetragonal(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize chain lattice
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Chain(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize ladder lattice
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Ladder(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize triangular lattice
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Triangular(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize honeycomb lattice
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Honeycomb(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize kagome lattice
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Kagome(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize orthorhombic lattice
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Orthorhombic(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize face-centered orthorhombic lattice
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_FCOrtho(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize pyrochlore lattice
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Pyrochlore(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize from Wannier90 input
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Wannier90(struct StdIntList *StdI);
#if defined(_HPhi)
+/**
+ * @brief Initialize chain lattice with boost
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Chain_Boost(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize ladder lattice with boost
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Ladder_Boost(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize honeycomb lattice with boost
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Honeycomb_Boost(struct StdIntList *StdI);
+
+/**
+ * @brief Initialize kagome lattice with boost
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Kagome_Boost(struct StdIntList *StdI);
#elif defined(_mVMC)
+/**
+ * @brief Generate orbital information
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_generate_orb(struct StdIntList *StdI);
+
+/**
+ * @brief Handle projections
+ * @param[in,out] StdI Structure containing model parameters
+ */
void StdFace_Proj(struct StdIntList *StdI);
+
+/**
+ * @brief Print Jastrow factors
+ * @param[in] StdI Structure containing model parameters
+ */
void PrintJastrow(struct StdIntList *StdI);
#endif
diff --git a/src/StdFace_vals.h b/src/StdFace_vals.h
index ccbe97f..799c47f 100644
--- a/src/StdFace_vals.h
+++ b/src/StdFace_vals.h
@@ -1,26 +1,36 @@
-/*
-HPhi-mVMC-StdFace - Common input generator
-Copyright (C) 2015 The University of Tokyo
+/**
+ * @file StdFace_vals.h
+ * @brief Variables used in the Standard mode
+ *
+ * @details
+ * This file defines the StdIntList structure which contains all the variables and parameters
+ * used in the Standard mode of HPhi-mVMC-StdFace. These variables are passed as a pointer
+ * to the structure.
+ *
+ * @copyright
+ * HPhi-mVMC-StdFace - Common input generator
+ * Copyright (C) 2015 The University of Tokyo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-*/
-/**@file
-@brief Variables used in the Standard mode.
-These variables are passed as a pointer of the structure(StdIntList).
-*/
#include
+/**
+ * @struct StdIntList
+ * @brief Main structure containing all parameters and variables for Standard mode
+ */
struct StdIntList {
/*
Initial (undefined)
diff --git a/src/Wannier90.c b/src/Wannier90.c
index c836108..1d1ad7b 100644
--- a/src/Wannier90.c
+++ b/src/Wannier90.c
@@ -1,3 +1,17 @@
+/**
+ * @file Wannier90.c
+ * @brief Functions for handling Wannier90 input files and generating Hamiltonians
+ * @author Mitsuaki Kawamura (The University of Tokyo)
+ *
+ * This file contains functions for reading and processing Wannier90 input files
+ * to generate Hamiltonians for the HPhi/mVMC codes. The main functions are:
+ * - geometry_W90(): Reads Wannier90 geometry file
+ * - read_W90(): Reads Wannier90 hopping/interaction files
+ * - read_density_matrix(): Reads density matrix file
+ * - PrintUHFinitial(): Prints initial UHF guess
+ * - StdFace_Wannier90(): Main function to setup Wannier90 Hamiltonian
+ */
+
/*
HPhi-mVMC-StdFace - Common input generator
Copyright (C) 2015 The University of Tokyo
@@ -15,9 +29,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-/**@file
-@brief Standard mode for wannier90
-*/
+
#include "StdFace_vals.h"
#include "StdFace_ModelUtil.h"
#include
@@ -27,6 +39,11 @@ along with this program. If not, see .
#include
#include "setmemory.h"
+/**
+ * @brief Calculate inverse of 3x3 matrix
+ * @param cutoff_Rvec Input 3x3 matrix
+ * @param inverse_matrix Output inverse matrix
+ */
void _calc_inverse_matrix(double cutoff_Rvec[][3], double inverse_matrix[][3]) {
double NMatrix[3][3] = {{},
{}};
@@ -63,6 +80,12 @@ void _calc_inverse_matrix(double cutoff_Rvec[][3], double inverse_matrix[][3]) {
}
}
+/**
+ * @brief Check if point is inside unit cell box
+ * @param rvec Vector to check
+ * @param inverse_matrix Inverse of lattice vectors
+ * @return 1 if inside box, 0 if outside
+ */
int _check_in_box(int *rvec, double inverse_matrix[][3])
{
double judge_vec[3]={};
@@ -77,11 +100,14 @@ int _check_in_box(int *rvec, double inverse_matrix[][3])
}
/**
-@brief Read Geometry file for wannier90
-@author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Read Wannier90 geometry file
+ * @param StdI [in,out] Structure containing model parameters
+ *
+ * Reads lattice vectors and Wannier center positions from geometry file.
+ * Sets StdI->direct (lattice vectors) and StdI->tau (Wannier centers).
+ */
static void geometry_W90(
- struct StdIntList *StdI//!<[inout]
+ struct StdIntList *StdI
)
{
int isite, ii, ierr;
@@ -123,23 +149,37 @@ static void geometry_W90(
printf(" Wannier centres:\n");
for (isite = 0; isite < StdI->NsiteUC; isite++) printf(" %10.5f %10.5f %10.5f\n",
StdI->tau[isite][0], StdI->tau[isite][1], StdI->tau[isite][2]);
-}/*static void geometry_W90(struct StdIntList *StdI) */
+}
+
/**
- @brief Read Wannier90 hamiltonian file (*_hr)
- @author Mitsuaki Kawamura (The University of Tokyo)
+ * @brief Read Wannier90 hopping/interaction file
+ * @param StdI [in,out] Structure containing model parameters
+ * @param filename Input filename
+ * @param cutoff Threshold for matrix elements
+ * @param cutoff_R Cutoff for R vectors
+ * @param cutoff_Rvec Cutoff vectors for unit cell
+ * @param cutoff_length Real space cutoff length
+ * @param itUJ Type of interaction (0:t, 1:U, 2:J)
+ * @param NtUJ [out] Number of terms
+ * @param tUJindx [out] Indices for terms
+ * @param lambda Scaling factor
+ * @param tUJ [out] Matrix elements
+ *
+ * Reads hopping or interaction matrix elements from Wannier90 file.
+ * Applies cutoffs and stores non-zero terms.
*/
static void read_W90(
- struct StdIntList *StdI,//!<[inout]
- char *filename,//!<[in] Input file name
- double cutoff,//!<[in] Threshold for the Hamiltonian
+ struct StdIntList *StdI,
+ char *filename,
+ double cutoff,
int *cutoff_R,
double cutoff_Rvec[][3],
double cutoff_length,
int itUJ,
int *NtUJ,
- int ***tUJindx,//!<[out] R, band index of matrix element
+ int ***tUJindx,
double lambda,
- double complex **tUJ//!<[out] Matrix element
+ double complex **tUJ
)
{
FILE *fp;
@@ -339,16 +379,21 @@ static void read_W90(
free_d_1d_allocate(Weight_tot);
free_i_1d_allocate(Model_lattice);
free_i_1d_allocate(Band_lattice);
-}/*static int read_W90(struct StdIntList *StdI, char *model)*/
-
+}
/**
- @brief Read RESPACK Density-matrix file (*_dr.dat)
- @author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Read RESPACK density matrix file
+ * @param StdI [in,out] Structure containing model parameters
+ * @param filename Input filename
+ * @return 5D array containing density matrix elements
+ *
+ * Reads density matrix elements from RESPACK file.
+ * Returns array indexed by [R1][R2][R3][i][j] where R are lattice vectors
+ * and i,j are orbital indices.
+ */
static double complex***** read_density_matrix(
- struct StdIntList *StdI,//!<[inout]
- char *filename//!<[in] Input file name
+ struct StdIntList *StdI,
+ char *filename
)
{
FILE *fp;
@@ -447,11 +492,19 @@ static double complex***** read_density_matrix(
free(indx_tot);
return DenMat;
-}/*static int read_W90(struct StdIntList *StdI, char *model)*/
+}
+
/**
-@brief Print the initial guess of UHF
-@author Mitsuaki Kawamura (The University of Tokyo)
-*/
+ * @brief Print initial UHF guess to file
+ * @param StdI Structure containing model parameters
+ * @param NtUJ Number of terms for each interaction type
+ * @param tUJ Matrix elements
+ * @param DenMat Density matrix elements
+ * @param tUJindx Indices for interaction terms
+ *
+ * Writes initial UHF guess to initial.def file.
+ * Uses density matrix elements to construct initial guess.
+ */
static void PrintUHFinitial(
struct StdIntList *StdI,
int *NtUJ,
diff --git a/src/dry.c b/src/dry.c
index 70d2085..d989401 100644
--- a/src/dry.c
+++ b/src/dry.c
@@ -33,15 +33,23 @@ void usage(const char *prog)
int main(int argc, char *argv[])
{
+ /**
+ * @brief Return status code indicating success/failure
+ */
int status = 0;
+
if (argc < 2) {
+ /* Print version and usage if no arguments provided */
printVersion();
- usage(argv[0]);
+ usage(argv[0]);
status = 1;
} else if (strcmp(argv[1], "-v") == 0) {
+ /* Print version if -v flag specified */
printVersion();
} else {
+ /* Process input file */
StdFace_main(argv[1]);
}
+
return status;
}
diff --git a/src/export_wannier90.c b/src/export_wannier90.c
index 93f1089..48abc59 100644
--- a/src/export_wannier90.c
+++ b/src/export_wannier90.c
@@ -1,3 +1,13 @@
+/**
+ * @file export_wannier90.c
+ * @brief Functions for exporting model data in Wannier90 format
+ *
+ * This file contains functions to export lattice geometry and interaction parameters
+ * in a format compatible with Wannier90. The main functions are:
+ * - ExportGeometry() - Exports lattice vectors and orbital positions
+ * - ExportInteraction() - Exports hopping and interaction parameters
+ */
+
#include
#include
#include
@@ -10,6 +20,12 @@
// #undef NDEBUG
+/**
+ * @brief Macro for fatal error handling
+ *
+ * Prints error message with function name, file and line number,
+ * then exits program with error status.
+ */
#define fatal(fmt,...) \
do { \
fprintf(stderr, "ERROR: %s: " fmt " in %s:%d\n", \
@@ -22,20 +38,30 @@
int is_export_all = 1; /* default for exportall parameter */
/* parameters */
-static const double eps = 1.0e-8;
+static const double eps = 1.0e-8; /**< Small number for floating point comparisons */
-/* type declarations */
+/**
+ * @brief Structure to store interaction parameters between orbitals
+ */
typedef struct {
- int r[3]; /* relative coordinate */
- int a, b; /* orbit index */
- int s, t; /* extension: spin dependence */
- double complex v; /* value */
+ int r[3]; /**< Relative coordinate between orbitals */
+ int a, b; /**< Orbital indices */
+ int s, t; /**< Spin indices */
+ double complex v; /**< Interaction strength */
} IntrItem;
/**
- @brief Print geometry data in Wannier90 geom format
-*/
+ * @brief Write geometry data to file in Wannier90 format
+ *
+ * @param StdI Standard input parameters containing geometry info
+ * @param fname Output filename
+ *
+ * Writes:
+ * - Primitive lattice vectors
+ * - Number of orbitals per unit cell
+ * - Orbital positions in fractional coordinates
+ */
void WriteGeometry(struct StdIntList *StdI, char *fname)
{
FILE *fp = fopen(fname, "w");
@@ -65,8 +91,18 @@ void WriteGeometry(struct StdIntList *StdI, char *fname)
}
/**
- @brief Print interaction coefficient data in Wannier90 (-like) format
-*/
+ * @brief Write interaction parameters to file in Wannier90 format
+ *
+ * @param nintr_table Number of interaction terms
+ * @param intr_table Array of interaction parameters
+ * @param nsiteuc Number of sites per unit cell
+ * @param nspin Number of spin states
+ * @param fname Output filename
+ * @param tagname Tag identifying interaction type
+ *
+ * Writes interaction parameters between orbitals in Wannier90 format.
+ * Handles both spin-dependent and spin-independent cases.
+ */
void WriteWannier90(int nintr_table, IntrItem *intr_table,
int nsiteuc, int nspin,
char *fname, char *tagname)
@@ -226,8 +262,15 @@ void WriteWannier90(int nintr_table, IntrItem *intr_table,
}
/**
- @bridf unfold site from [0, N] to [-N/2, N/2]
-*/
+ * @brief Convert site coordinates from [0,N] to [-N/2,N/2] range
+ *
+ * @param StdI Standard input parameters
+ * @param v_in Input coordinates
+ * @param v_out Output coordinates
+ *
+ * Unfolds coordinates from positive range to centered around zero.
+ * Used to get relative distances between sites.
+ */
void unfold_site(struct StdIntList *StdI, int v_in[3], int v_out[3])
{
int v[3];
@@ -264,10 +307,18 @@ void unfold_site(struct StdIntList *StdI, int v_in[3], int v_out[3])
}
/**
- @brief generate key as a pair for interaction table
- ordered = 0 -> as-is
- ordered = 1 -> i < j
-*/
+ * @brief Generate key for interaction table entry
+ *
+ * @param keylen Length of key (1, 2 or 4)
+ * @param index_out Output key array
+ * @param index Input indices
+ * @param ordered Whether to order indices
+ *
+ * Creates key from indices based on keylen:
+ * - keylen=1: i
+ * - keylen=2: (i,j)
+ * - keylen=4: (i,s,j,t) for spin-dependent case
+ */
void generate_key(int keylen, int *index_out, int *index, int ordered)
{
if (keylen == 1) { /* i */
@@ -308,8 +359,12 @@ void generate_key(int keylen, int *index_out, int *index, int ordered)
}
/**
- @brief copy key data
-*/
+ * @brief Copy key data between arrays
+ *
+ * @param keylen Length of key
+ * @param dst_key Destination array
+ * @param src_key Source array
+ */
void store_key(int keylen, int *dst_key, int *src_key)
{
for (int k = 0; k < keylen; ++k) {
@@ -319,8 +374,13 @@ void store_key(int keylen, int *dst_key, int *src_key)
}
/**
- @brief test whether two keys are same
-*/
+ * @brief Compare two keys for equality
+ *
+ * @param keylen Length of keys
+ * @param key_a First key
+ * @param key_b Second key
+ * @return 1 if keys are equal, 0 otherwise
+ */
int is_equal_key(int keylen, int *key_a, int *key_b)
{
for (int k = 0; k < keylen; ++k) {
@@ -330,8 +390,12 @@ int is_equal_key(int keylen, int *key_a, int *key_b)
}
/**
- @brief make string representation of a key
-*/
+ * @brief Convert key to string representation
+ *
+ * @param keylen Length of key
+ * @param key Key array
+ * @return String representation of key
+ */
char *to_string_key(int keylen, int *key)
{
static char buf[1024];
@@ -350,8 +414,20 @@ char *to_string_key(int keylen, int *key)
}
/**
- @brief make table compact by accumulating entries of the same key
-*/
+ * @brief Accumulate interaction table entries with same key
+ *
+ * @param keylen Length of key
+ * @param ntbl Number of input entries
+ * @param tbl_index Input indices
+ * @param tbl_value Input values
+ * @param ntbl_out Number of output entries
+ * @param tbl_index_out Output indices
+ * @param tbl_value_out Output values
+ * @param ordered Whether to order indices
+ *
+ * Combines entries with same key by adding their values.
+ * Eliminates entries with zero value.
+ */
void accumulate_list(int keylen,
int ntbl, int **tbl_index, double complex *tbl_value,
int *ntbl_out, int **tbl_index_out, double complex *tbl_value_out,
@@ -430,8 +506,15 @@ void accumulate_list(int keylen,
}
/**
- @brief Print interaction coefficient of StdFace internal data structure (complex array)
-*/
+ * @brief Export interaction coefficients from complex array
+ *
+ * @param StdI Standard input parameters
+ * @param ntbl Number of interaction terms
+ * @param tbl_index Interaction indices
+ * @param tbl_value Interaction values
+ * @param fname Output filename
+ * @param tagname Tag identifying interaction type
+ */
void ExportInter(struct StdIntList *StdI,
int ntbl, int **tbl_index, double complex *tbl_value,
char *fname, char *tagname)
@@ -553,8 +636,17 @@ void ExportInter(struct StdIntList *StdI,
}
/**
- @brief Print interaction coefficient of StdFace internal data structure (real array)
-*/
+ * @brief Export interaction coefficients from real array
+ *
+ * @param StdI Standard input parameters
+ * @param ntbl Number of interaction terms
+ * @param tbl_index Interaction indices
+ * @param tbl_value Interaction values
+ * @param fname Output filename
+ * @param tagname Tag identifying interaction type
+ *
+ * Converts real array to complex and calls ExportInter()
+ */
void ExportInterReal(struct StdIntList *StdI,
int ntbl, int **tbl_index, double *tbl_value,
char *fname, char *tagname)
@@ -575,8 +667,16 @@ void ExportInterReal(struct StdIntList *StdI,
}
/**
- @brief Print coefficient of transfer term
-*/
+ * @brief Export transfer (hopping) coefficients
+ *
+ * @param StdI Standard input parameters
+ * @param ntbl Number of transfer terms
+ * @param tbl_index Transfer indices
+ * @param tbl_value Transfer values
+ * @param fname Output filename
+ * @param tagname Tag identifying transfer type
+ * @param spin_dep Whether transfer is spin-dependent
+ */
void ExportTransfer(struct StdIntList *StdI,
int ntbl, int **tbl_index, double complex *tbl_value,
char *fname, char *tagname, int spin_dep)
diff --git a/src/export_wannier90.h b/src/export_wannier90.h
index 6da3db4..a6bfed5 100644
--- a/src/export_wannier90.h
+++ b/src/export_wannier90.h
@@ -5,7 +5,37 @@
#if defined(_HWAVE)
+/**
+ * Export geometry data in Wannier90 format
+ *
+ * Parameters
+ * ----------
+ * StdI : struct StdIntList*
+ * Standard input parameters containing lattice geometry information
+ * including primitive vectors, number of sites per unit cell,
+ * and orbital positions
+ *
+ * Notes
+ * -----
+ * Writes lattice vectors and orbital positions to a file in the format
+ * required by Wannier90
+ */
void ExportGeometry(struct StdIntList *StdI);
+
+/**
+ * Export interaction parameters in Wannier90 format
+ *
+ * Parameters
+ * ----------
+ * StdI : struct StdIntList*
+ * Standard input parameters containing interaction terms between
+ * orbitals, including hopping and correlation parameters
+ *
+ * Notes
+ * -----
+ * Writes interaction parameters between orbitals to a file in the
+ * format required by Wannier90
+ */
void ExportInteraction(struct StdIntList *StdI);
#endif
diff --git a/src/setmemory.c b/src/setmemory.c
index 770efd4..325d0a2 100644
--- a/src/setmemory.c
+++ b/src/setmemory.c
@@ -1,89 +1,89 @@
-/*
-HPhi-mVMC-StdFace - Common input generator
-Copyright (C) 2015 The University of Tokyo
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-*/
-//
-// Created by Kazuyoshi Yoshimi on 2019-01-09.
-//
+/**
+ * @file setmemory.c
+ * @brief Memory allocation utilities for arrays of various types
+ * @copyright
+ * HPhi-mVMC-StdFace - Common input generator
+ * Copyright (C) 2015 The University of Tokyo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
#include "setmemory.h"
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of unsigned integers
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
unsigned int *ui_1d_allocate(const long unsigned int N){
unsigned int *A;
A = (unsigned int*)calloc((N),sizeof(unsigned int));
return A;
}
-///
-/// \brief Function to free 1d array (int)
-/// \param A Pointer of 1d array A
+/**
+ * @brief Free 1D array of unsigned integers
+ * @param A Pointer to array to free
+ */
void free_ui_1d_allocate(unsigned int *A){
free(A);
}
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of long unsigned integers
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
long unsigned int *lui_1d_allocate(const long unsigned int N){
long unsigned int *A;
A = (long unsigned int*)calloc((N),sizeof(long unsigned int));
return A;
}
-///
-/// \brief Function to free 1d array (int)
-/// \param A Pointer of 1d array A
+/**
+ * @brief Free 1D array of long unsigned integers
+ * @param A Pointer to array to free
+ */
void free_lui_1d_allocate(long unsigned int *A){
free(A);
}
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of long integers
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
long int *li_1d_allocate(const long unsigned int N){
long int *A;
A = (long int*)calloc((N),sizeof(long int));
return A;
}
-///
-/// \brief Function to free 1d array (int)
-/// \param A Pointer of 1d array A
+/**
+ * @brief Free 1D array of long integers
+ * @param A Pointer to array to free
+ */
void free_li_1d_allocate(long int *A){
free(A);
}
-///
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 2D array of long integers
+ * @param N Number of rows
+ * @param M Number of columns
+ * @return Pointer to allocated array, initialized to zero
+ */
long int **li_2d_allocate(const long unsigned int N, const long unsigned int M) {
long int **A;
long unsigned int int_i;
@@ -92,45 +92,43 @@ long int **li_2d_allocate(const long unsigned int N, const long unsigned int M)
for (int_i = 0; int_i < N; int_i++) {
A[int_i] = A[0] + int_i * M;
}
- //memset(A[0], 0, sizeof(long int)*M*N);
return A;
}
-///
-/// \brief Function to free 2d array (int)
-/// \param A Pointer of 2d array A
+
+/**
+ * @brief Free 2D array of long integers
+ * @param A Pointer to array to free
+ */
void free_li_2d_allocate(long int **A){
free(A[0]);
free(A);
}
-
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of integers
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
int *i_1d_allocate(const long unsigned int N){
int *A;
A = (int*)calloc((N),sizeof(int));
- //memset(A, 0, sizeof(int)*N);
return A;
}
-///
-/// \brief Function to free 1d array (int)
-/// \param A Pointer of 1d array A
+/**
+ * @brief Free 1D array of integers
+ * @param A Pointer to array to free
+ */
void free_i_1d_allocate(int *A){
free(A);
}
-
-///
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 2D array of integers
+ * @param N Number of rows
+ * @param M Number of columns
+ * @return Pointer to allocated array, initialized to zero
+ */
int **i_2d_allocate(const long unsigned int N, const long unsigned int M) {
int **A;
long unsigned int int_i;
@@ -139,22 +137,25 @@ int **i_2d_allocate(const long unsigned int N, const long unsigned int M) {
for (int_i = 0; int_i < N; int_i++) {
A[int_i] = A[0] + int_i * M;
}
- //memset(A[0], 0, sizeof(int)*M*N);
return A;
}
-///
-/// \brief Function to free 2d array (int)
-/// \param A Pointer of 2d array A
+
+/**
+ * @brief Free 2D array of integers
+ * @param A Pointer to array to free
+ */
void free_i_2d_allocate(int **A){
free(A[0]);
free(A);
}
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 3D array of integers
+ * @param N First dimension size
+ * @param M Second dimension size
+ * @param L Third dimension size
+ * @return Pointer to allocated array, initialized to zero
+ */
int***i_3d_allocate(const long unsigned int N, const long unsigned int M, const long unsigned int L){
long unsigned int int_i, int_j;
int*** A;
@@ -170,40 +171,41 @@ int***i_3d_allocate(const long unsigned int N, const long unsigned int M, const
return A;
}
-///
-/// \brief Function to free 3d array (int)
-/// \param A A pointer of 3d array A
+/**
+ * @brief Free 3D array of integers
+ * @param A Pointer to array to free
+ */
void free_i_3d_allocate(int ***A){
free(A[0][0]);
free(A[0]);
free(A);
}
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of doubles
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
double *d_1d_allocate(const long unsigned int N){
double *A;
A = (double*)calloc((N),sizeof(double));
return A;
}
-///
-/// \brief Function to free 1d array (double)
-/// \param A Pointer of 1d array A
+
+/**
+ * @brief Free 1D array of doubles
+ * @param A Pointer to array to free
+ */
void free_d_1d_allocate(double *A){
free(A);
}
-
-///
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 2D array of doubles
+ * @param N Number of rows
+ * @param M Number of columns
+ * @return Pointer to allocated array, initialized to zero
+ */
double **d_2d_allocate(const long unsigned int N, const long unsigned int M){
long unsigned int int_i;
double **A;
@@ -215,39 +217,40 @@ double **d_2d_allocate(const long unsigned int N, const long unsigned int M){
return A;
}
-///
-/// \brief Function to free 2d array (double)
-/// \param A Pointer of 2d array A
+/**
+ * @brief Free 2D array of doubles
+ * @param A Pointer to array to free
+ */
void free_d_2d_allocate(double **A){
free(A[0]);
free(A);
}
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of complex doubles
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
double complex *cd_1d_allocate(const long unsigned int N){
double complex*A;
A = (double complex*)calloc((N),sizeof(double complex));
return A;
}
-///
-/// \brief Function to free 1d array (double complex)
-/// \param A Pointer of 1d array A
+
+/**
+ * @brief Free 1D array of complex doubles
+ * @param A Pointer to array to free
+ */
void free_cd_1d_allocate(double complex *A){
free(A);
}
-
-///
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 2D array of complex doubles
+ * @param N Number of rows
+ * @param M Number of columns
+ * @return Pointer to allocated array, initialized to zero
+ */
complex double **cd_2d_allocate(const long unsigned int N, const long unsigned int M){
long unsigned int int_i;
complex double **A;
@@ -259,19 +262,22 @@ complex double **cd_2d_allocate(const long unsigned int N, const long unsigned i
return A;
}
-///
-/// \brief Function to free 2d array (complex double)
-/// \param A Pointer of 2d array A
+/**
+ * @brief Free 2D array of complex doubles
+ * @param A Pointer to array to free
+ */
void free_cd_2d_allocate(double complex**A){
free(A[0]);
free(A);
}
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 3D array of complex doubles
+ * @param N First dimension size
+ * @param M Second dimension size
+ * @param L Third dimension size
+ * @return Pointer to allocated array, initialized to zero
+ */
double complex***cd_3d_allocate(const long unsigned int N, const long unsigned int M, const long unsigned int L){
long unsigned int int_i, int_j;
double complex***A;
@@ -287,9 +293,10 @@ double complex***cd_3d_allocate(const long unsigned int N, const long unsigned i
return A;
}
-///
-/// \brief Function to free 3d array (complex double)
-/// \param A A pointer of 3d array A
+/**
+ * @brief Free 3D array of complex doubles
+ * @param A Pointer to array to free
+ */
void free_cd_3d_allocate(double complex***A){
free(A[0][0]);
free(A[0]);
diff --git a/src/setmemory.h b/src/setmemory.h
index c99fb54..83ebb1c 100644
--- a/src/setmemory.h
+++ b/src/setmemory.h
@@ -1,23 +1,23 @@
-/*
-HPhi-mVMC-StdFace - Common input generator
-Copyright (C) 2015 The University of Tokyo
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-*/
-//
-// Created by Kazuyoshi Yoshimi on 2019-01-09.
-//
+/**
+ * @file setmemory.h
+ * @brief Memory allocation utilities for arrays of various types
+ * @copyright
+ * HPhi-mVMC-StdFace - Common input generator
+ * Copyright (C) 2015 The University of Tokyo
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
#ifndef MVMC_SETMEMORY_H
#define MVMC_SETMEMORY_H
@@ -26,160 +26,168 @@ along with this program. If not, see .
#include
#include
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of unsigned integers
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
unsigned int *ui_1d_allocate(const long unsigned int N);
-///
-/// \brief Function to free 1d array (int)
-/// \param A Pointer of 1d array A
+/**
+ * @brief Free 1D array of unsigned integers
+ * @param A Pointer to array to free
+ */
void free_ui_1d_allocate(unsigned int *A);
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of long integers
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
long int *li_1d_allocate(const long unsigned int N);
-///
-/// \brief Function to free 1d array (int)
-/// \param A Pointer of 1d array A
+/**
+ * @brief Free 1D array of long integers
+ * @param A Pointer to array to free
+ */
void free_li_1d_allocate(long int *A);
-///
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 2D array of long integers
+ * @param N Number of rows
+ * @param M Number of columns
+ * @return Pointer to allocated array, initialized to zero
+ */
long int **li_2d_allocate(const long unsigned int N, const long unsigned int M);
-///
-/// \brief Function to free 2d array (int)
-/// \param A Pointer of 2d array A
-void free_li_2d_allocate(long int **A);
+/**
+ * @brief Free 2D array of long integers
+ * @param A Pointer to array to free
+ */
+void free_li_2d_allocate(long int **A);
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of long unsigned integers
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
long unsigned int *lui_1d_allocate(const long unsigned int N);
-///
-/// \brief Function to free 1d array (int)
-/// \param A Pointer of 1d array A
+/**
+ * @brief Free 1D array of long unsigned integers
+ * @param A Pointer to array to free
+ */
void free_lui_1d_allocate(long unsigned int *A);
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of integers
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
int *i_1d_allocate(const long unsigned int N);
-///
-/// \brief Function to free 1d array (int)
-/// \param A Pointer of 1d array A
+/**
+ * @brief Free 1D array of integers
+ * @param A Pointer to array to free
+ */
void free_i_1d_allocate(int *A);
-
-///
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 2D array of integers
+ * @param N Number of rows
+ * @param M Number of columns
+ * @return Pointer to allocated array, initialized to zero
+ */
int **i_2d_allocate(const long unsigned int N, const long unsigned int M);
-///
-/// \brief Function to free 2d array (int)
-/// \param A Pointer of 2d array A
-void free_i_2d_allocate(int **A);
+/**
+ * @brief Free 2D array of integers
+ * @param A Pointer to array to free
+ */
+void free_i_2d_allocate(int **A);
-///
-/// \brief Allocation for A[N][M][L]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array A
-/// \param L [in] The size of the array A
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 3D array of integers
+ * @param N First dimension size
+ * @param M Second dimension size
+ * @param L Third dimension size
+ * @return Pointer to allocated array, initialized to zero
+ */
int ***i_3d_allocate(const long unsigned int N, const long unsigned int M, const long unsigned int L);
-///
-/// \brief Function to free 3d array (int)
-/// \param A Pointer of 3d array A
+
+/**
+ * @brief Free 3D array of integers
+ * @param A Pointer to array to free
+ */
void free_i_3d_allocate(int ***A);
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \param A [in,out] Array to allocate
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of doubles
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
double *d_1d_allocate(const long unsigned int N);
-///
-/// \brief Function to free 1d array (double)
-/// \param A Pointer of 1d array A
+/**
+ * @brief Free 1D array of doubles
+ * @param A Pointer to array to free
+ */
void free_d_1d_allocate(double *A);
-
-///
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 2D array of doubles
+ * @param N Number of rows
+ * @param M Number of columns
+ * @return Pointer to allocated array, initialized to zero
+ */
double **d_2d_allocate(const long unsigned int N, const long unsigned int M);
-///
-/// \brief Function to free 2d array (double)
-/// \param A Pointer of 2d array A
-void free_d_2d_allocate(double **A);
+/**
+ * @brief Free 2D array of doubles
+ * @param A Pointer to array to free
+ */
+void free_d_2d_allocate(double **A);
-///
-/// \brief Allocation for A[N]
-/// \param N [in] The size of the array A
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 1D array of complex doubles
+ * @param N Size of array to allocate
+ * @return Pointer to allocated array, initialized to zero
+ */
complex double *cd_1d_allocate(const long unsigned int N);
-///
-/// \brief Function to free 1d array (complex double)
-/// \param A Pointer of 2d array A
+/**
+ * @brief Free 1D array of complex doubles
+ * @param A Pointer to array to free
+ */
void free_cd_1d_allocate(double complex*A);
-///
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 2D array of complex doubles
+ * @param N Number of rows
+ * @param M Number of columns
+ * @return Pointer to allocated array, initialized to zero
+ */
complex double **cd_2d_allocate(const long unsigned int N, const long unsigned int M);
-///
-/// \brief Function to free 2d array (complex double)
-/// \param A Pointer of 2d array A
+/**
+ * @brief Free 2D array of complex doubles
+ * @param A Pointer to array to free
+ */
void free_cd_2d_allocate(double complex**A);
-//
-/// \brief Allocation for A[N][M]
-/// \param N [in] The size of the array A
-/// \param M [in] The size of the array M
-/// \return A Pointer to array A
-/// \author Kazuyoshi Yoshimi (University of Tokyo)
+/**
+ * @brief Allocate 3D array of complex doubles
+ * @param N First dimension size
+ * @param M Second dimension size
+ * @param L Third dimension size
+ * @return Pointer to allocated array, initialized to zero
+ */
double complex***cd_3d_allocate(const long unsigned int N, const long unsigned int M, const long unsigned int L);
-///
-/// \brief Function to free 3d array (complex double)
-/// \param A A pointer of 3d array A
+
+/**
+ * @brief Free 3D array of complex doubles
+ * @param A Pointer to array to free
+ */
void free_cd_3d_allocate(double complex***A);
#endif //MVMC_SETMEMORY_H