Skip to content

Commit

Permalink
multiple solvers and toml input parser (#74)
Browse files Browse the repository at this point in the history
This PR changes the config file of solid_dmft to the toml format and allows to use multiple solvers within a single calculation. Requires dft_tools from commit b355173 on the unstable branch or later.

- The following input parameters can now be a list per impurity:
    - `general_params`: U, J, U_prime, ratio_F4_F2, h_int_type, enforce_off_diag, dc_type
    - `advanced_params`: dc_U, dc_J, dc_fixed_occ, map_solver_struct, pick_solver_struct, mapped_solver_struct_degeneracies
- Multiple solvers can be used, which only solve the impurity problems specified in `idx_impurities`
    - general parameter `solver_type` moved to solver section and renamed to `type`
    - general parameter `n_l` moved to solver section
    - general parameter `measure_chi` moved to solver section
    - general parameter `delta_interface` moved to solver section
- All possible input parameters are defined in the `python/solid_dmft/io_tools/default.toml`
- according to toml format the config file is now called .toml (instead of .ini), and boolean are not capitalized, strings are given with quotes and lists are given with brackets.
- Documentation of the input is now generated from `python/solid_dmft/io_tools/documentation.txt`
- For an example, refer to the new integration test (see below)
- Updated interface to python scripts wrapping solid_dmft: new routine `main.run_dmft` that expects the params as python dictionaries, which are then supplemented with the defaults etc equivalent to what happens when reading in a toml file

- the existence of the parameter `general_params['beta']` now determines if a imaginary- or real-frequency grid is used within solid_dmft
- Bug fix: Slater interaction for p orbitals can now be constructed
- Renaming of solver parameters for the different solvers is now moved to `solver.py`. The idea is that every other part of solid_dmft should care as little as possible what solvers are used, with the details abstracted by the SolverStructure class
    - In `solver.py`, all solver parameters that are passed to the triqs solver are transferred to a dict `triqs_solver_params`. When adding new triqs solver parameter to solid_dmft in the future, they also need to be added within solver.py.
- In the determination of the block structure, the largely unused parameter `general_params['block_suppress_orbital_symm']` removed. Its behavior can be replaced by using `advanced_params['mapped_solver_struct_degeneracies']`
- Integration tests: previously existing tests updated, new tests added. One with ftps solver (requires installation of ftps, otherwise just passes without doing anything) and one with a combination of CT-HYB and Hartree solver
- Unit tests: added test for toml-related functionality
- `read_config.py` removed and the functionality for dealing with the dicts from reading a toml file moved to `postproc_toml_dict.py`
- `io_tools/verify_input_params.py` contains all checks of the input params that the code performs before starting the DMFT calculations
- Updated the documentation of the input parameters

---------

Co-authored-by: Alexander Hampel <[email protected]>
  • Loading branch information
merkelm and the-hampel committed Feb 27, 2024
1 parent 047c7d3 commit 8beb46d
Show file tree
Hide file tree
Showing 67 changed files with 2,429 additions and 2,874 deletions.
10 changes: 5 additions & 5 deletions doc/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ Input/Output

Further details for running
===========================

.. toctree::
:maxdepth: 1

md_notes/docker.md
md_notes/run_locally.md
md_notes/run_cluster.md
Expand All @@ -57,10 +57,10 @@ Module reference manual
dft_managers
dmft_cycle
dmft_tools
io_tools
postprocessing
read_config
util






37 changes: 16 additions & 21 deletions doc/input_output/DMFT_input/generate_doc_from_comments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@
green='\033[1;32m'
wipe="\033[1m\033[0m"

echo -e "${green}Extracting the comments from read_config.py file${wipe}"
echo -e "${green}Extracting the comments from io_tools/documentation.txt file${wipe}"
buildfolder="../../.."
docfile="$buildfolder/python/solid_dmft/read_config.py"
docfile="$buildfolder/python/solid_dmft/io_tools/documentation.txt"

awk '/---XXX---start/{flag=1; c=0} flag; /---XXX/&& ++c==2{flag=0}' $docfile | tail -n +2 | head -n -2 > python_comments.txt

#from the python comments
#from the documentation file
echo "Generating .rst syntax from the python syntax"
sed 's/\(.*\) :\s*\(.*\)/\n.. admonition:: \1 \n :class: intag \n \n \*\*type=\*\* \2\n/g' python_comments.txt > matches_comments.txt
sed 's/\(.*\) :\s*\(.*\)/\n.. admonition:: \1 \n :class: intag \n \n \*\*type\*\* = \2\n/g' $docfile > matches_comments.txt

#add blank line after type
#sed -i 's/\(\*type=.*\),/\1 \n\n /g' matches_comments.txt
#sed -i 's/\(\*type=.*\),/\1 \n\n /g' matches_comments.txt

# make 'optional' and 'default' bold
sed -i 's/,.*\(\optional\)/; \*\*\1\*\*/g' matches_comments.txt
sed -i 's/,.*\(\default=\)/; \*\*\1\*\* /g' matches_comments.txt
# make 'mandatory' and 'default' bold
sed -i 's/,.*\(\mandatory\)/; \*\*\1\*\*/g' matches_comments.txt
sed -i 's/,.*\(\default\)/; \*\*\1\*\* /g' matches_comments.txt

# grep all admonitions and store them in a file
# grep all admonitions and store them in a file

echo "Generating input page"
cat > input.rst << EOF
Expand All @@ -51,7 +49,7 @@ EOF
#
# awk '/\[ SECTION \]/{flag=1; c=0} flag; /\[ /&& ++c==2{flag=0}'
# matches from the pattern '[ SECTION ]'(note, two spaces are important) up to either the next occurence of
# '[ ', which is the next group, or the end of the file
# '[ ', which is the next group, or the end of the file
#
#
# the second part takes the divided section and extracts a list out of it:
Expand Down Expand Up @@ -99,7 +97,7 @@ cat > general.rst << EOF
[general]: General parameters
-----------------------------
Includes the majority of the parameters
Frequently used parameters that apply to the whole simulation.
EOF
Expand All @@ -113,10 +111,9 @@ cat > solver.rst << EOF
[solver]: solver specific parameters
------------------------------------
Here are the parameters that are uniquely dependent on the solver chosen. Below a list of the supported solvers:
Here are the parameters that are uniquely dependent on the solver chosen. Some parameters are used within solid_dmft and some are passed directly into the triqs solver.
To see which parameters were passed to the solver for a given calculation, look at the triqs_solver_params in DMFT_input/solver in the h5 archive.
Solver-specific parameters are listed in the respective sections.
EOF
Expand All @@ -125,16 +122,14 @@ echo -e "\n" >> solver.rst
cat solver.tmp >> solver.rst
##############



###############
cat > dft.rst << EOF
[dft]: DFT related inputs
-------------------------
List of parameters that relate to the DFT calculation, useful mostly when doing CSC.
List of parameters for the DFT calculation in charge-self-consistent calculations.
The parameters are ignored in one-shot calculations.
EOF
Expand All @@ -149,7 +144,7 @@ cat > advanced.rst << EOF
[advanced]: Advanced inputs
---------------------------
Advanced parameters, do not modify default value unless you know what you are doing
Advanced parameters, do not modify the default value unless you know what you are doing.
EOF
Expand Down
44 changes: 0 additions & 44 deletions doc/tutorials/Ce2O3_csc_w90/dmft_config.ini

This file was deleted.

44 changes: 44 additions & 0 deletions doc/tutorials/Ce2O3_csc_w90/dmft_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[general]
seedname = "ce2o3"
jobname = "b10-U6.46-J0.46"
csc = true

eta = 0.5
n_iw = 100
n_tau = 5001

n_iter_dmft_first = 2
n_iter_dmft_per = 1
n_iter_dmft = 5

block_threshold = 1e-03

h_int_type = "density_density"
U = 6.46
J = 0.46
beta = 10
prec_mu = 0.1

sigma_mix = 1.0
g0_mix = 1.0
dc_type = 0
dc = true
dc_dmft = true
calc_energies = true

h5_save_freq = 1

[solver]
type = "hubbardI"
n_l = 15
store_solver = false
measure_G_l = false
measure_density_matrix = true

[dft]
dft_code = "qe"
n_cores = 10
mpi_env = "default"
projector_type = "w90"
dft_exec = "pw.x"
w90_tolerance = 1e-1
45 changes: 22 additions & 23 deletions doc/tutorials/Ce2O3_csc_w90/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@
"### DMFT\n",
"\n",
"1. Wannier90Converter: [ce2o3.inp](./dft_input/ce2o3.inp)\n",
"2. solid_dmft: [dmft_config.ini](./dmft_config.ini)\n",
"2. solid_dmft: [dmft_config.toml](./dmft_config.toml)\n",
"\n",
"Here we'll discuss the most important input flags for solid_dmft:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"id": "165c087b",
"metadata": {},
"outputs": [
Expand All @@ -133,12 +133,10 @@
"output_type": "stream",
"text": [
"[general]\n",
"seedname = ce2o3\n",
"jobname = b10-U6.46-J0.46\n",
"csc = True\n",
"#dft_mu = 0.\n",
"solver_type = hubbardI\n",
"n_l = 15\n",
"seedname = \"ce2o3\"\n",
"jobname = \"b10-U6.46-J0.46\"\n",
"csc = true\n",
"\n",
"eta = 0.5\n",
"n_iw = 100\n",
"n_tau = 5001\n",
Expand All @@ -149,7 +147,7 @@
"\n",
"block_threshold = 1e-03\n",
"\n",
"h_int_type = density_density\n",
"h_int_type = \"density_density\"\n",
"U = 6.46\n",
"J = 0.46\n",
"beta = 10\n",
Expand All @@ -158,30 +156,31 @@
"sigma_mix = 1.0\n",
"g0_mix = 1.0\n",
"dc_type = 0\n",
"dc = True\n",
"dc_dmft = True\n",
"calc_energies = True\n",
"dc = true\n",
"dc_dmft = true\n",
"calc_energies = true\n",
"\n",
"h5_save_freq = 1\n",
"\n",
"[solver]\n",
"store_solver = False\n",
"measure_G_l = False\n",
"measure_density_matrix = True\n",
"type = \"hubbardI\"\n",
"n_l = 15\n",
"store_solver = false\n",
"measure_G_l = false\n",
"measure_density_matrix = true\n",
"\n",
"[dft]\n",
"dft_code = qe\n",
"dft_code = \"qe\"\n",
"n_cores = 10\n",
"mpi_env = default\n",
"projector_type = w90\n",
"dft_exec = \n",
"w90_exec = wannier90.x\n",
"mpi_env = \"default\"\n",
"projector_type = \"w90\"\n",
"dft_exec = \"pw.x\"\n",
"w90_tolerance = 1.e-1\n"
]
}
],
"source": [
"!cat ./dmft_config.ini"
"!cat ./dmft_config.toml"
]
},
{
Expand Down Expand Up @@ -509,7 +508,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -523,7 +522,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
[general]
seedname = nno
jobname = NNO_lowT
seedname = "nno"
jobname = "NNO_lowT"

enforce_off_diag = False
enforce_off_diag = false
block_threshold = 0.001

solver_type = cthyb
n_iw = 2001
n_tau = 20001

prec_mu = 0.001

h_int_type = density_density
h_int_type = "density_density"
U = 8.0
J = 1.0

# temperature ~290 K
beta = 40

magnetic = True
magmom = -0.3, 0.3
afm_order = True
magnetic = true
magmom = [-0.3, 0.3]
afm_order = true

n_iter_dmft = 14

g0_mix = 0.9

dc_type = 0
dc = True
dc_dmft = False
dc = true
dc_dmft = false

load_sigma = False
path_to_sigma = pre_AFM.h5
load_sigma = false
path_to_sigma = "pre_AFM.h5"

[solver]
type = "cthyb"
length_cycle = 2000
n_warmup_cycles = 5e+3
n_cycles_tot = 1e+7
imag_threshold = 1e-5

perform_tail_fit = True
perform_tail_fit = true
fit_max_moment = 6
fit_min_w = 10
fit_max_w = 16
measure_density_matrix = True
measure_density_matrix = true

Loading

0 comments on commit 8beb46d

Please sign in to comment.