Compare commits

...

7 Commits

Binary file not shown.

@ -5,21 +5,9 @@ OutputFile ./Fe3GeTe2_notebook
ScfOrientation [ 0 0 1 ] ScfOrientation [ 0 0 1 ]
%block XCF_Rotation %block XCF_Rotation
1 0 0 1 0 0 0 1 0 0 0 1
0 1 0 0 1 0 1 0 0 0 0 1
0 0 1 0 0 1 1 0 0 0 1 0
%endblock XCFRotation
%block XCF_Rotation
0 1 0
1 0 0
0 0 1
%endblock XCFRotation
%block XCF_Rotation
0 0 1
1 0 0
0 1 0
%endblock XCFRotation %endblock XCFRotation
%block MagneticEntites # atom index and orbital index %block MagneticEntites # atom index and orbital index
@ -28,6 +16,18 @@ ScfOrientation [ 0 0 1 ]
5 2 5 2
%endblock MagneticEntites %endblock MagneticEntites
%block MagneticEntites
Claster 4 5 # this is a list of atoms
AtomShell 3 2 # this is one atom and shell index
AtomShell 4 2 # this is one atom and shell index
AtomShell 5 2 # this is one atom and shell index
AtomOrbital 3 # this is one atom and orbital index
ExplicitOrbital # this is a slice of orbital index
%endblock MagneticEntites
%Pairsblock # MagneticEntites index ai and aj, supercell offset %Pairsblock # MagneticEntites index ai and aj, supercell offset
0 1 0 0 0 0 1 0 0 0
0 2 0 0 0 0 2 0 0 0

@ -5,3 +5,4 @@ sisl==0.14.3
netCDF4==1.7.2 netCDF4==1.7.2
openmpi openmpi
mpi4py mpi4py
threadpoolctl

@ -275,17 +275,3 @@ def onsite_projection(matrix, idx1, idx2):
""" """
return matrix[..., idx1, :][..., idx2] return matrix[..., idx1, :][..., idx2]
def onsite_projection(matrix, idx):
"""_summary_
Args:
matrix (_type_): _description_
idx (_type_): _description_
Returns:
_type_: _description_
"""
return matrix[..., idx, :][..., idx]

@ -15,14 +15,18 @@ default_args = dict(
kset=2, kset=2,
kdirs="xyz", kdirs="xyz",
ebot=None, ebot=None,
automatic_ebot=False,
eset=42, eset=42,
esetp=1000, esetp=1000,
calculate_charge=True, calculate_charge=False,
charges=[], charges=[],
parallel_solver_for_Gk=True, parallel_solver_for_Gk=False,
parallel_size=None,
padawan_mode=True,
) )
# parser = ArgumentParser() # parser = ArgumentParser()
# parser.add_argument('--input' , dest = 'infile' , default=None , help = 'Input file name') # parser.add_argument('--input' , dest = 'infile' , default=None , help = 'Input file name')
# parser.add_argument('--output' , dest = 'outfile', default=None , help = 'Output file name') # parser.add_argument('--output' , dest = 'outfile', default=None , help = 'Output file name')
@ -31,6 +35,7 @@ default_args = dict(
# parser.add_argument('--ebot' , dest = 'ebot' , default = None , type=float, help = 'Bottom energy of the contour') # parser.add_argument('--ebot' , dest = 'ebot' , default = None , type=float, help = 'Bottom energy of the contour')
# parser.add_argument('--eset' , dest = 'eset' , default = 42 , type=int , help = 'Number of energy points on the contour') # parser.add_argument('--eset' , dest = 'eset' , default = 42 , type=int , help = 'Number of energy points on the contour')
# parser.add_argument('--eset-p' , dest = 'esetp' , default = 1000 , type=int , help = 'Parameter tuning the distribution on the contour') # parser.add_argument('--eset-p' , dest = 'esetp' , default = 1000 , type=int , help = 'Parameter tuning the distribution on the contour')
# cmd_line_args = parser.parse_args() # cmd_line_args = parser.parse_args()
@ -107,6 +112,9 @@ def print_parameters(simulation_parameters):
if simulation_parameters["calculate_charge"]: if simulation_parameters["calculate_charge"]:
print("The calculated charge of the Hamiltonian in the quantization axes: ") print("The calculated charge of the Hamiltonian in the quantization axes: ")
print(simulation_parameters["charges"]) print(simulation_parameters["charges"])
print(
"================================================================================================================================================================"
)
def print_atoms_and_pairs(magnetic_entities, pairs): def print_atoms_and_pairs(magnetic_entities, pairs):
@ -173,20 +181,21 @@ def print_atoms_and_pairs(magnetic_entities, pairs):
f"{pair['tags'][0]} {pair['tags'][1]} {pair['Ruc']} d [Ang] {pair['dist']}" f"{pair['tags'][0]} {pair['tags'][1]} {pair['Ruc']} d [Ang] {pair['dist']}"
) )
# print magnetic parameters # print magnetic parameters
print("Isotropic: ", pair["J_iso"]) print("Isotropic: ", pair["J_iso"], " # Tr[J] / 3")
print("DMI: ", pair["D"]) print("")
print("Symmetric-anisotropy: ", pair["J_S"]) print("DMI: ", pair["D"], " # Dx, Dy, Dz")
print("J: ", pair["J"].flatten()) print("")
print("Energies for debugging: ")
print(np.array(pair["energies"]))
print( print(
"J_ii for debugging: (check if this is the same as in calculate_exchange_tensor)" "Symmetric-anisotropy: ",
pair["J_S"],
" # J_S = J - J_iso * I > Jxx, Jyy, Jxy, Jxz, Jyz",
) )
o1, o2, o3 = pair["energies"]
print(np.array([o2[-1], o3[0], o1[0]]))
print("Test J_xx = E(y,z) = E(z,y)")
print(o2[-1], o3[-1])
print("") print("")
print("J: # Jxx, Jxy, Jxz, Jyx, Jyy, Jyz, Jzx, Jzy, Jzz")
print(pair["J"])
print(
"----------------------------------------------------------------------------------------------------------------------------------------------------------------"
)
print( print(
"================================================================================================================================================================" "================================================================================================================================================================"
@ -223,3 +232,68 @@ def print_runtime_information(times):
print( print(
f"Calculate energies and magnetic components: {times['end_time'] - times['green_function_inversion_time']:.3f} s" f"Calculate energies and magnetic components: {times['end_time'] - times['green_function_inversion_time']:.3f} s"
) )
def print_job_description(simulation_parameters):
"""_summary_
Args:
simulation_parameters (_type_): _description_
"""
print(
"================================================================================================================================================================"
)
print("Input file: ")
print(simulation_parameters["infile"])
print("Output file: ")
print(simulation_parameters["outfile"])
print(
"Number of nodes in the parallel cluster: ",
simulation_parameters["parallel_size"],
)
if simulation_parameters["parallel_solver_for_Gk"]:
print("solver used for Greens function calculation: parallel")
else:
print("solver used for Greens function calculation: sequential")
print(
"================================================================================================================================================================"
)
print("Cell [Ang]: ")
print(simulation_parameters["cell"])
print(
"================================================================================================================================================================"
)
print("DFT axis: ")
print(simulation_parameters["scf_xcf_orientation"])
print("Quantization axis and perpendicular rotation directions:")
for ref in simulation_parameters["ref_xcf_orientations"]:
print(ref["o"], " --» ", ref["vw"])
print(
"================================================================================================================================================================"
)
print("Parameters for the contour integral:")
print("Number of k points: ", simulation_parameters["kset"])
print("k point directions: ", simulation_parameters["kdirs"])
if simulation_parameters["automatic_ebot"]:
print(
"Ebot: ",
simulation_parameters["ebot"],
" WARNING: This was automatically determined!",
)
else:
print("Ebot: ", simulation_parameters["ebot"])
print("Eset: ", simulation_parameters["eset"])
print("Esetp: ", simulation_parameters["esetp"])
print(
"================================================================================================================================================================"
)
if simulation_parameters["calculate_charge"]:
print(
"Charge calculation required: True WARNING: This causes a slowdown, because we have to use the complete Greens function!"
)
else:
print("Charge calculation required: False")
print(
"================================================================================================================================================================"
)

@ -70,7 +70,10 @@ def calculate_exchange_tensor(pair):
D[2] = np.mean([energies[2, 1], -energies[2, 2]]) D[2] = np.mean([energies[2, 1], -energies[2, 2]])
J_iso = np.trace(J) / 3 J_iso = np.trace(J) / 3
J_S = (J - J_iso * np.eye(3)).flatten() # based on the grogu output pdf
# traceless symmetric exchange matrix:
# Jxx, Jyy, Jxy, Jxz, Jyz
J_S = np.array([J[0, 0] - J_iso, J[1, 1] - J_iso, J[0, 1], J[0, 2], J[1, 2]])
return J_iso, J_S, D, J return J_iso, J_S, D, J

@ -2,7 +2,58 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'architecture': 'armv8',\n",
" 'filepath': '/Users/danielpozsar/Documents/oktatás/elte/phd/grogu_project/.venv/lib/python3.9/site-packages/numpy/.dylibs/libopenblas64_.0.dylib',\n",
" 'internal_api': 'openblas',\n",
" 'num_threads': 1,\n",
" 'prefix': 'libopenblas',\n",
" 'threading_layer': 'pthreads',\n",
" 'user_api': 'blas',\n",
" 'version': '0.3.21'},\n",
" {'architecture': 'neoversen1',\n",
" 'filepath': '/Users/danielpozsar/Documents/oktatás/elte/phd/grogu_project/.venv/lib/python3.9/site-packages/scipy/.dylibs/libopenblas.0.dylib',\n",
" 'internal_api': 'openblas',\n",
" 'num_threads': 1,\n",
" 'prefix': 'libopenblas',\n",
" 'threading_layer': 'pthreads',\n",
" 'user_api': 'blas',\n",
" 'version': '0.3.27'}]\n"
]
}
],
"source": [
"from threadpoolctl import threadpool_info\n",
"from pprint import pprint\n",
"import numpy\n",
"\n",
"pprint(threadpool_info())"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"os.environ[\"OMP_NUM_THREADS\"] = \"1\" # export OMP_NUM_THREADS=1\n",
"os.environ[\"OPENBLAS_NUM_THREADS\"] = \"1\" # export OPENBLAS_NUM_THREADS=1\n",
"os.environ[\"MKL_NUM_THREADS\"] = \"1\" # export MKL_NUM_THREADS=1\n",
"os.environ[\"VECLIB_MAXIMUM_THREADS\"] = \"1\" # export VECLIB_MAXIMUM_THREADS=1\n",
"os.environ[\"NUMEXPR_NUM_THREADS\"] = \"1\" # export NUMEXPR_NUM_THREADS=1"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -12,6 +63,13 @@
"0.14.3\n", "0.14.3\n",
"1.24.4\n" "1.24.4\n"
] ]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[Daniels-Air:88431] shmem: mmap: an error occurred while determining whether or not /var/folders/yh/dx7xl94n3g52ts3td8qcxjcc0000gn/T//ompi.Daniels-Air.501/jf.0/455868416/sm_segment.Daniels-Air.501.1b2c0000.0 could be created.\n"
]
} }
], ],
"source": [ "source": [
@ -45,16 +103,45 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 22, "execution_count": 32,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"[{'o': array([1., 0., 0.]),\n",
" 'vw': array([[0., 1., 0.],\n",
" [0., 0., 1.]])},\n",
" {'o': array([0., 1., 0.]),\n",
" 'vw': array([[1., 0., 0.],\n",
" [0., 0., 1.]])},\n",
" {'o': array([0., 0., 1.]),\n",
" 'vw': array([[1., 0., 0.],\n",
" [0., 1., 0.]])}]"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"sisl.io.Sile(\"input.fdf\").read(\"scfOrientation\")" "fdf = sisl.io.fdfSileSiesta(\"input.fdf\")\n",
"rotations = fdf.get(\"XCF_Rotation\")\n",
"my_rot = []\n",
"for rot in rotations:\n",
" dat = np.array(rot.split(), dtype=float)\n",
" o = dat[:3]\n",
" vw = dat[3:]\n",
" vw = vw.reshape(2, 3)\n",
" my_rot.append(dict(o=o, vw=vw))\n",
"\n",
"my_rot"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 23, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -107,7 +194,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 24, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -139,10 +226,20 @@
"Ebot: -13\n", "Ebot: -13\n",
"Eset: 300\n", "Eset: 300\n",
"Esetp: 1000\n", "Esetp: 1000\n",
"================================================================================================================================================================\n",
"Setup done. Elapsed time: 2435.031293583 s\n",
"================================================================================================================================================================\n" "================================================================================================================================================================\n"
] ]
},
{
"ename": "KeyError",
"evalue": "'calculate_charge'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[5], line 43\u001b[0m\n\u001b[1;32m 40\u001b[0m uc_in_sc_idx \u001b[38;5;241m=\u001b[39m dh\u001b[38;5;241m.\u001b[39mlattice\u001b[38;5;241m.\u001b[39msc_index([\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m0\u001b[39m])\n\u001b[1;32m 42\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m rank \u001b[38;5;241m==\u001b[39m root_node:\n\u001b[0;32m---> 43\u001b[0m \u001b[43mprint_parameters\u001b[49m\u001b[43m(\u001b[49m\u001b[43msimulation_parameters\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 44\u001b[0m times[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msetup_time\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m timer()\n\u001b[1;32m 45\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSetup done. Elapsed time: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mtimes[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124msetup_time\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m s\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[0;32m~/Documents/oktatás/elte/phd/grogu_project/src/grogu_magn/io.py:116\u001b[0m, in \u001b[0;36mprint_parameters\u001b[0;34m(simulation_parameters)\u001b[0m\n\u001b[1;32m 112\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mEsetp: \u001b[39m\u001b[38;5;124m\"\u001b[39m, simulation_parameters[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mesetp\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m 113\u001b[0m \u001b[38;5;28mprint\u001b[39m(\n\u001b[1;32m 114\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m================================================================================================================================================================\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 115\u001b[0m )\n\u001b[0;32m--> 116\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[43msimulation_parameters\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcalculate_charge\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m:\n\u001b[1;32m 117\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThe calculated charge of the Hamiltonian in the quantization axes: \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 118\u001b[0m \u001b[38;5;28mprint\u001b[39m(simulation_parameters[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcharges\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n",
"\u001b[0;31mKeyError\u001b[0m: 'calculate_charge'"
]
} }
], ],
"source": [ "source": [
@ -198,7 +295,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 25, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -259,7 +356,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 26, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -288,7 +385,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 27, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -327,7 +424,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 29, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -395,7 +492,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -537,7 +634,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -866,7 +963,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -905,7 +1002,14 @@
"Isotropic -41.9627\n", "Isotropic -41.9627\n",
"DMI 1.1205 -1.9532 0.0018386\n", "DMI 1.1205 -1.9532 0.0018386\n",
"Symmetric-anisotropy 0.26007 -0.00013243 0.12977 -0.069979 -0.042066\n", "Symmetric-anisotropy 0.26007 -0.00013243 0.12977 -0.069979 -0.042066\n",
"--------------------------------------------------------------------------------\n" "--------------------------------------------------------------------------------\n",
"\n",
"\n",
"On-site meV\n",
"----------------------------------------\n",
"Fe4\n",
"0.16339\t0.16068\t0\t0\t0\t0\n",
"========================================\n"
] ]
}, },
{ {

@ -18,6 +18,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
import os
os.environ["OMP_NUM_THREADS"] = "1" # export OMP_NUM_THREADS=1
os.environ["OPENBLAS_NUM_THREADS"] = "1" # export OPENBLAS_NUM_THREADS=1
os.environ["MKL_NUM_THREADS"] = "1" # export MKL_NUM_THREADS=1
os.environ["VECLIB_MAXIMUM_THREADS"] = "1" # export VECLIB_MAXIMUM_THREADS=1
os.environ["NUMEXPR_NUM_THREADS"] = "1" # export NUMEXPR_NUM_THREADS=1
from timeit import default_timer as timer from timeit import default_timer as timer
# runtime information # runtime information
@ -38,7 +48,7 @@ from src.grogu_magn import *
###################################################################### ######################################################################
###################################################################### ######################################################################
path = ( infile = (
"/Users/danielpozsar/Downloads/nojij/Fe3GeTe2/monolayer/soc/lat3_791/Fe3GeTe2.fdf" "/Users/danielpozsar/Downloads/nojij/Fe3GeTe2/monolayer/soc/lat3_791/Fe3GeTe2.fdf"
) )
outfile = "./Fe3GeTe2_notebook" outfile = "./Fe3GeTe2_notebook"
@ -60,6 +70,15 @@ pairs = [
dict(ai=1, aj=2, Ruc=np.array([-3, 0, 0])), dict(ai=1, aj=2, Ruc=np.array([-3, 0, 0])),
] ]
simulation_parameters = default_args simulation_parameters = default_args
simulation_parameters["infile"] = infile
simulation_parameters["outfile"] = outfile
simulation_parameters["kset"] = 20
simulation_parameters["kdirs"] = "xy"
simulation_parameters["eset"] = 600
simulation_parameters["esetp"] = 10000
fdf = sisl.io.fdfSileSiesta("input.fdf")
fdf.get("XCF_Rotation")
###################################################################### ######################################################################
###################################################################### ######################################################################
@ -72,14 +91,17 @@ size = comm.Get_size()
rank = comm.Get_rank() rank = comm.Get_rank()
root_node = 0 root_node = 0
# include parallel size in simulation parameters
simulation_parameters["parallel_size"] = size
# check versions for debugging # check versions for debugging
if rank == root_node: if rank == root_node:
try: try:
print(sisl.__version__) print("sisl version: ", sisl.__version__)
except: except:
print("sisl version unknown.") print("sisl version unknown.")
try: try:
print(np.__version__) print("numpy version: ", np.__version__)
except: except:
print("numpy version unknown.") print("numpy version unknown.")
@ -92,6 +114,7 @@ if simulation_parameters["ebot"] is None:
try: try:
eigfile = simulation_parameters["infile"][:-3] + "EIG" eigfile = simulation_parameters["infile"][:-3] + "EIG"
simulation_parameters["ebot"] = read_siesta_emin(eigfile) - 0.1 simulation_parameters["ebot"] = read_siesta_emin(eigfile) - 0.1
simulation_parameters["automatic_ebot"] = True
except: except:
print("Could not determine ebot.") print("Could not determine ebot.")
print("Parameter was not given and .EIG file was not found.") print("Parameter was not given and .EIG file was not found.")
@ -109,7 +132,16 @@ simulation_parameters["cell"] = fdf.read_geometry().cell
uc_in_sc_idx = dh.lattice.sc_index([0, 0, 0]) uc_in_sc_idx = dh.lattice.sc_index([0, 0, 0])
if rank == root_node: if rank == root_node:
print_parameters(simulation_parameters) print("\n\n\n\n\n")
print(
"#################################################################### JOB INFORMATION ###########################################################################"
)
print_job_description(simulation_parameters)
print(
"################################################################################################################################################################"
)
print("\n\n\n\n\n")
times["setup_time"] = timer() times["setup_time"] = timer()
print(f"Setup done. Elapsed time: {times['setup_time']} s") print(f"Setup done. Elapsed time: {times['setup_time']} s")
print( print(
@ -186,7 +218,7 @@ wkset = np.ones(len(kset)) / len(kset)
kpcs = np.array_split(kset, size) kpcs = np.array_split(kset, size)
# use progress bar if available # use progress bar if available
if tqdm_imported: if rank == root_node and tqdm_imported:
kpcs[root_node] = tqdm(kpcs[root_node], desc="k loop") kpcs[root_node] = tqdm(kpcs[root_node], desc="k loop")
if rank == root_node: if rank == root_node:
@ -236,8 +268,8 @@ for i, orient in enumerate(simulation_parameters["ref_xcf_orientations"]):
for mag_ent in magnetic_entities: for mag_ent in magnetic_entities:
idx = mag_ent["spin_box_indices"] idx = mag_ent["spin_box_indices"]
# fill up the perturbed potentials (for now) based on the on-site projections # fill up the perturbed potentials (for now) based on the on-site projections
mag_ent["Vu1"][i].append(onsite_projection(Vu1, idx)) mag_ent["Vu1"][i].append(onsite_projection(Vu1, idx, idx))
mag_ent["Vu2"][i].append(onsite_projection(Vu2, idx)) mag_ent["Vu2"][i].append(onsite_projection(Vu2, idx, idx))
if rank == root_node: if rank == root_node:
times["reference_rotations_time"] = timer() times["reference_rotations_time"] = timer()
@ -252,26 +284,30 @@ if rank == root_node:
# requirements of the Greens function calculations # requirements of the Greens function calculations
if rank == root_node: if rank == root_node:
print("Starting matrix inversions.") print("Starting matrix inversions.")
print(f"Total number of k points: {kset.shape[0]}") if simulation_parameters["padawan_mode"]:
print(f"Number of energy samples per k point: {simulation_parameters['eset']}") print("Padawan mode: ")
print(f"Total number of directions: {len(hamiltonians)}") print(f"Total number of k points: {kset.shape[0]}")
print( print(f"Number of energy samples per k point: {simulation_parameters['eset']}")
f"Total number of matrix inversions: {kset.shape[0] * len(hamiltonians) * simulation_parameters['eset']}" print(f"Total number of directions: {len(hamiltonians)}")
) print(
print(f"The shape of the Hamiltonian and the Greens function is {NO}x{NO}={NO*NO}") f"Total number of matrix inversions: {kset.shape[0] * len(hamiltonians) * simulation_parameters['eset']}"
# https://stackoverflow.com/questions/70746660/how-to-predict-memory-requirement-for-np-linalg-inv )
# memory is O(64 n**2) for complex matrices print(
memory_size = getsizeof(hamiltonians[0]["H"].base) / 1024 f"The shape of the Hamiltonian and the Greens function is {NO}x{NO}={NO*NO}"
print( )
f"Memory taken by a single Hamiltonian is: {getsizeof(hamiltonians[0]['H'].base) / 1024} KB" # https://stackoverflow.com/questions/70746660/how-to-predict-memory-requirement-for-np-linalg-inv
) # memory is O(64 n**2) for complex matrices
print(f"Expected memory usage per matrix inversion: {memory_size * 32} KB") memory_size = getsizeof(hamiltonians[0]["H"].base) / 1024
print( print(
f"Expected memory usage per k point for parallel inversion: {memory_size * len(hamiltonians) * simulation_parameters['eset'] * 32} KB" f"Memory taken by a single Hamiltonian is: {getsizeof(hamiltonians[0]['H'].base) / 1024} KB"
) )
print( print(f"Expected memory usage per matrix inversion: {memory_size * 32} KB")
f"Expected memory usage on root node: {len(np.array_split(kset, size)[0]) * memory_size * len(hamiltonians) * simulation_parameters['eset'] * 32 / 1024} MB" print(
) f"Expected memory usage per k point for parallel inversion: {memory_size * len(hamiltonians) * simulation_parameters['eset'] * 32} KB"
)
print(
f"Expected memory usage on root node: {len(np.array_split(kset, size)[0]) * memory_size * len(hamiltonians) * simulation_parameters['eset'] * 32 / 1024} MB"
)
print( print(
"================================================================================================================================================================" "================================================================================================================================================================"
) )
@ -311,7 +347,7 @@ for k in kpcs[rank]:
# store the Greens function slice of the magnetic entities # store the Greens function slice of the magnetic entities
for mag_ent in magnetic_entities: for mag_ent in magnetic_entities:
idx = mag_ent["spin_box_indices"] idx = mag_ent["spin_box_indices"]
mag_ent["Gii_tmp"][i] += onsite_projection(Gk, idx) * wk mag_ent["Gii_tmp"][i] += onsite_projection(Gk, idx, idx) * wk
for pair in pairs: for pair in pairs:
# add phase shift based on the cell difference # add phase shift based on the cell difference
@ -411,14 +447,20 @@ if rank == root_node:
pair["J"] = J * sisl.unit_convert("eV", "meV") pair["J"] = J * sisl.unit_convert("eV", "meV")
times["end_time"] = timer() times["end_time"] = timer()
print("\n\n\n\n\n")
print( print(
"##################################################################### GROGU OUTPUT #############################################################################" "##################################################################### GROGU OUTPUT #############################################################################"
) )
print_parameters(simulation_parameters) print_parameters(simulation_parameters)
print_atoms_and_pairs(magnetic_entities, pairs) print_atoms_and_pairs(magnetic_entities, pairs)
print(
"################################################################################################################################################################"
)
print_runtime_information(times) print_runtime_information(times)
print("")
# remove unwanted stuff before saving
pairs, magnetic_entities = remove_clutter_for_save(pairs, magnetic_entities) pairs, magnetic_entities = remove_clutter_for_save(pairs, magnetic_entities)
# create output dictionary with all the relevant data # create output dictionary with all the relevant data
results = dict( results = dict(
@ -428,4 +470,7 @@ if rank == root_node:
runtime=times, runtime=times,
) )
# save results
save_pickle(simulation_parameters["outfile"], results) save_pickle(simulation_parameters["outfile"], results)
print("\n\n\n\n\n")

Loading…
Cancel
Save