ran simple test, fdf input works

class-solution
Daniel Pozsar 2 months ago
parent 8240d7bbd9
commit 243e01dac8

Binary file not shown.

Binary file not shown.

@ -24,6 +24,7 @@ More on the theoretical background can be seen on [arXiv](https://arxiv.org/abs/
- logging
- fdf atom input
- orbital indexing must be correct
- check on the validity of magnetic entities input
## Building wheel

@ -1,8 +1,8 @@
InputFile /Users/danielpozsar/Downloads/nojij/Fe3GeTe2/monolayer/soc/lat3_791/Fe3GeTe2.fdf # comment test
OutputFile ./Fe3GeTe2_notebook # comment test
OutputFile ./Fe3GeTe2_fdf_test # comment test
ScfXcfOrientation [ 0 0 1 ] # comment test
ScfXcfOrientation 0 0 1 # comment test
# comment test
%block XCF_Rotation # comment test
1 0 0 0 1 0 0 0 1 # comment test
@ -11,16 +11,18 @@ ScfXcfOrientation [ 0 0 1 ] # comment test
%endblock XCFRotation # comment test
%block MagneticEntities # comment test
Cluster 4 5 # this is a list of atoms
Atom 3 # this MUST BE one atom else error
AtomShell 3 2 # this is one atom and shell index
AtomShell 4 2 3 # this is one atom and shell index
AtomShell 5 2 # this is one atom and shell index
AtomOrbital 3 7 2 4 # this is one atom and orbital index
Orbitals 2 1 4 9 # this is a slice of orbital index
AtomShell 3 2
AtomShell 4 2
AtomShell 5 2
%endblock MagneticEntities
# Cluster 4 5 # this is a list of atoms
# Atom 3 # this MUST BE one atom else error
# AtomShell 3 2 # this is one atom and its shell sub-index
# AtomShell 4 1 2 # this is one atom and its shell sub-index
# AtomShell 5 2 # this is one atom and its shell sub-index
# AtomOrbital 3 7 2 4 # this is one atom and its orbital sub-index
# Orbitals 2 1 4 9 # this is a slice of orbital index
%block Pairs # MagneticEntities index ai and aj, supercell offset
@ -35,10 +37,10 @@ Orbitals 2 1 4 9 # this is a slice of orbital index
1 2 -3 0 0 # comment test
%endblock Pairs
INTEGRAL.Kset 3
INTEGRAL.Kset 10
INTEGRAL.Kdirs xy
INTEGRAL.Ebot -13 # comment test
INTEGRAL.Eset 300 # comment test
INTEGRAL.Ebot None # comment test
INTEGRAL.Eset 600 # comment test
INTEGRAL.Esetp 1000 # comment test
GREEN.ParallelSolver False # comment test

@ -131,7 +131,9 @@ def parse_command_line() -> dict:
help="If it is on it turns on extra helpful information for new users",
)
# convert to dictionary
cmd_line_args = parser.parse_args()
cmd_line_args = vars(cmd_line_args)
return cmd_line_args
@ -181,7 +183,7 @@ def main(simulation_parameters: dict, magnetic_entities: list, pairs: list) -> N
for orientation in simulation_parameters["ref_xcf_orientations"]:
o1: np.array = orientation["vw"][0]
o2: np.array = orientation["vw"][1]
orientation["vw"].append((o1 + o2) / np.sqrt(2))
orientation["vw"] = np.vstack((orientation["vw"], (o1 + o2) / np.sqrt(2)))
# read sile
fdf = sisl.get_sile(simulation_parameters["infile"])
@ -525,55 +527,15 @@ def main(simulation_parameters: dict, magnetic_entities: list, pairs: list) -> N
if __name__ == "__main__":
# loading parameters
# command_line_arguments = parse_command_line()
# fdf_arguments, magnetic_entities, pairs = read_grogupy_fdf(
# command_line_arguments["grogupy_infile"]
# )
command_line_arguments = parse_command_line()
command_line_arguments = dict(command_line_arguments)
fdf_arguments, magnetic_entities, pairs = read_grogupy_fdf(
command_line_arguments["grogupy_infile"]
)
# combine the inputs to a single dictionary
# simulation_parameters: Final[dict] = process_input_args(
# DEFAULT_ARGUMENTS, fdf_arguments, command_line_arguments, ACCEPTED_INPUTS
# )
####################################################################################################
# This is the input file for now #
####################################################################################################
magnetic_entities: list = [
dict(atom=3, l=2),
dict(atom=4, l=2),
dict(atom=5, l=2),
]
pairs: list = [
dict(ai=0, aj=1, Ruc=np.array([0, 0, 0])),
dict(ai=0, aj=2, Ruc=np.array([0, 0, 0])),
dict(ai=1, aj=2, Ruc=np.array([0, 0, 0])),
dict(ai=0, aj=2, Ruc=np.array([-1, -1, 0])),
dict(ai=1, aj=2, Ruc=np.array([-1, -1, 0])),
dict(ai=0, aj=2, Ruc=np.array([-1, 0, 0])),
dict(ai=1, aj=2, Ruc=np.array([-1, 0, 0])),
dict(ai=1, aj=2, Ruc=np.array([-2, 0, 0])),
dict(ai=1, aj=2, Ruc=np.array([-3, 0, 0])),
]
simulation_parameters: dict = dict()
simulation_parameters["infile"] = (
"/Users/danielpozsar/Downloads/nojij/Fe3GeTe2/monolayer/soc/lat3_791/Fe3GeTe2.fdf"
)
simulation_parameters["outfile"] = "./"
simulation_parameters["scf_xcf_orientation"] = np.array([0, 0, 1])
simulation_parameters["ref_xcf_orientations"] = [
dict(o=np.array([1, 0, 0]), vw=[np.array([0, 1, 0]), np.array([0, 0, 1])]),
dict(o=np.array([0, 1, 0]), vw=[np.array([1, 0, 0]), np.array([0, 0, 1])]),
dict(o=np.array([0, 0, 1]), vw=[np.array([1, 0, 0]), np.array([0, 1, 0])]),
]
simulation_parameters["kset"] = 10
simulation_parameters["kdirs"] = "xy"
simulation_parameters["ebot"] = None
simulation_parameters["eset"] = 600
simulation_parameters["esetp"] = 1000
simulation_parameters["parallel_solver_for_Gk"] = False
simulation_parameters["padawan_mode"] = True
####################################################################################################
# This is the input file for now #
####################################################################################################
simulation_parameters = process_input_args(
DEFAULT_ARGUMENTS, fdf_arguments, command_line_arguments, ACCEPTED_INPUTS
)
print(simulation_parameters)
main(simulation_parameters, magnetic_entities, pairs)

@ -60,7 +60,9 @@ def read_grogupy_fdf(path: str) -> tuple[dict, list, list]:
ScfXcfOrientation = fdf.get("ScfXcfOrientation")
if ScfXcfOrientation is not None:
fdf_arguments["scf_xcf_orientation"] = np.array(ScfXcfOrientation)
fdf_arguments["scf_xcf_orientation"] = np.array(
ScfXcfOrientation.split()[:3], dtype=float
)
XCF_Rotation = fdf.get("XCF_Rotation")
if XCF_Rotation is not None:
@ -76,30 +78,34 @@ def read_grogupy_fdf(path: str) -> tuple[dict, list, list]:
Kset = fdf.get("INTEGRAL.Kset")
if Kset is not None:
fdf_arguments["kset"] = Kset
fdf_arguments["kset"] = int(Kset)
Kdirs = fdf.get("INTEGRAL.Kdirs")
if Kdirs is not None:
fdf_arguments["kdirs"] = Kdirs
# This is permitted because it means automatic Ebot definition
fdf_arguments["ebot"] = fdf.get("INTEGRAL.Ebot")
ebot = fdf.get("INTEGRAL.Ebot")
try:
fdf_arguments["ebot"] = float(ebot)
except:
fdf_arguments["ebot"] = None
Eset = fdf.get("INTEGRAL.Eset")
if Eset is not None:
fdf_arguments["eset"] = Eset
fdf_arguments["eset"] = int(Eset)
Esetp = fdf.get("INTEGRAL.Esetp")
if Esetp is not None:
fdf_arguments["esetp"] = Esetp
fdf_arguments["esetp"] = float(Esetp)
ParallelSolver = fdf.get("GREEN.ParallelSolver")
if ParallelSolver is not None:
fdf_arguments["parallel_solver_for_Gk"] = ParallelSolver
fdf_arguments["parallel_solver_for_Gk"] = bool(ParallelSolver)
PadawanMode = fdf.get("PadawanMode")
if PadawanMode is not None:
fdf_arguments["padawan_mode"] = PadawanMode
fdf_arguments["padawan_mode"] = bool(PadawanMode)
Pairs = fdf.get("Pairs")
if Pairs is not None:
@ -187,12 +193,12 @@ def process_input_args(
default_arguments = DEFAULT_ARGUMENTS.copy()
# iterate over fdf_arguments and update default arguments
for key, value in fdf_arguments.values():
for key, value in fdf_arguments.items():
if value is not None and key in accepted_inputs:
default_arguments[key] = value
# iterate over command_line_arguments and update default arguments
for key, value in command_line_arguments.values():
for key, value in command_line_arguments.items():
if value is not None and key in accepted_inputs:
default_arguments[key] = value

@ -86,6 +86,14 @@ def parse_magnetic_entity(
) -> np.array:
"""Function to define orbital indexes of a given magnetic entity.
There are five possible input types:
1. Cluster: a list of atoms
2. Atom: must be only one atom
3. AtomShell: one atom and a list of shells indexed in the atom
4. AtomOrbital: one atom and a list of orbitals indexed in the atom
5. Orbitals: a list of orbitals indexed in the Hamiltonian
Everything else raises an Exception.
Args:
dh : sisl.physics.Hamiltonian
Hamiltonian from sisl
@ -102,28 +110,37 @@ def parse_magnetic_entity(
"""
# the case for the Orbitals keyword
if atom is None:
return orb
# case where we deal with more than one atom defining the magnetic entity
if type(atom) == list:
dat = []
if atom is None and l is None:
orbital_indexes = orb
# the case for the Cluster keyword
elif isinstance(atom, list) and l is None and orb is None:
orbital_indexes = []
for a in atom:
a_orb_idx = dh.geometry.a2o(a, all=True)
if (
type(l) == int
): # if specified we restrict to given l angular momentum channel inside each atom
a_orb_idx = a_orb_idx[[o.l == l for o in dh.geometry.atoms[a].orbitals]]
dat.append(a_orb_idx)
orbital_indexes = np.hstack(dat)
# case where we deal with a single atom magnetic entity
elif type(atom) == int:
orbital_indexes.append(a_orb_idx)
orbital_indexes = np.array(orbital_indexes).flatten()
# the case for the Atom keyword
elif isinstance(atom, int) and l is None and orb is None:
orbital_indexes = dh.geometry.a2o(atom, all=True)
# the case for the Atomshell keyword
elif isinstance(atom, int) and l is not None and orb is None:
orbital_indexes = dh.geometry.a2o(atom, all=True)
# make sure l is a list for the following step
if isinstance(l, int):
l = [l]
mask = [orbital.l in l for orbital in dh.geometry.atoms[atom].orbitals]
orbital_indexes = orbital_indexes[mask]
# the case for the AtomOrbital keyword
elif isinstance(atom, int) and l is None and orb is not None:
orbital_indexes = dh.geometry.a2o(atom, all=True)
if (
type(l) == int
): # if specified we restrict to given l angular momentum channel
orbital_indexes = orbital_indexes[
[o.l == l for o in dh.geometry.atoms[atom].orbitals]
]
# make sure orb is a list for the following step
if isinstance(orb, int):
orb = [orb]
orbital_indexes = orbital_indexes[orb]
return orbital_indexes # numpy array containing integers labeling orbitals associated to a magnetic entity.

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [
{
@ -31,7 +31,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"[Daniels-MacBook-Air.local:67208] shmem: mmap: an error occurred while determining whether or not /var/folders/yh/dx7xl94n3g52ts3td8qcxjcc0000gn/T//ompi.Daniels-MacBook-Air.501/jf.0/2623209472/sm_segment.Daniels-MacBook-Air.501.9c5b0000.0 could be created.\n"
"[Daniels-Air:70184] shmem: mmap: an error occurred while determining whether or not /var/folders/yh/dx7xl94n3g52ts3td8qcxjcc0000gn/T//ompi.Daniels-Air.501/jf.0/3256680448/sm_segment.Daniels-Air.501.c21d0000.0 could be created.\n"
]
}
],
@ -65,61 +65,32 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"({'infile': '/Users/danielpozsar/Downloads/nojij/Fe3GeTe2/monolayer/soc/lat3_791/Fe3GeTe2.fdf',\n",
" 'outfile': './Fe3GeTe2_notebook',\n",
" 'scf_xcf_orientation': array('[ 0 0 1 ]', dtype='<U9'),\n",
" 'ref_xcf_orientations': [{'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.]])}],\n",
" 'kset': 3,\n",
" 'kdirs': 'xy',\n",
" 'ebot': -13,\n",
" 'eset': 300,\n",
" 'esetp': 1000,\n",
" 'parallel_solver_for_Gk': False,\n",
" 'padawan_mode': True},\n",
" [{'atom': [4, 5]},\n",
" {'atom': 3},\n",
" {'atom': 3, 'l': [2]},\n",
" {'atom': 4, 'l': [2, 3]},\n",
" {'atom': 5, 'l': [2]},\n",
" {'atom': 3, 'orb': [7, 2, 4]},\n",
" {'orb': [2, 1, 4, 9]}],\n",
" [{'ai': 0, 'aj': 1, 'Ruc': array([0, 0, 0])},\n",
" {'ai': 0, 'aj': 2, 'Ruc': array([0, 0, 0])},\n",
" {'ai': 1, 'aj': 2, 'Ruc': array([0, 0, 0])},\n",
" {'ai': 0, 'aj': 2, 'Ruc': array([-1, -1, 0])},\n",
" {'ai': 1, 'aj': 2, 'Ruc': array([-1, -1, 0])},\n",
" {'ai': 0, 'aj': 2, 'Ruc': array([-1, 0, 0])},\n",
" {'ai': 1, 'aj': 2, 'Ruc': array([-1, 0, 0])},\n",
" {'ai': 1, 'aj': 2, 'Ruc': array([-2, 0, 0])},\n",
" {'ai': 1, 'aj': 2, 'Ruc': array([-3, 0, 0])}])"
"array([[ 0., 1., 0.],\n",
" [ 0., 0., 1.],\n",
" [ 100., 1000., 100.]])"
]
},
"execution_count": 5,
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"read_grogupy_fdf(\"input.fdf\")"
"asd = read_grogupy_fdf(\"input.fdf\")[0][\"ref_xcf_orientations\"][0][\"vw\"]\n",
"\n",
"asd2 = np.array([100, 1000, 100])\n",
"np.vstack((asd, asd2))"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@ -172,9 +143,44 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"================================================================================================================================================================\n",
"Input file: \n",
"/Users/danielpozsar/Downloads/nojij/Fe3GeTe2/monolayer/soc/lat3_791/Fe3GeTe2.fdf\n",
"Output file: \n",
"./Fe3GeTe2_notebook.pickle\n",
"Number of nodes in the parallel cluster: 1\n",
"================================================================================================================================================================\n",
"Cell [Ang]: \n",
"[[ 3.79100000e+00 0.00000000e+00 0.00000000e+00]\n",
" [-1.89550000e+00 3.28310231e+00 0.00000000e+00]\n",
" [ 1.25954923e-15 2.18160327e-15 2.05700000e+01]]\n",
"================================================================================================================================================================\n",
"DFT axis: \n",
"[0 0 1]\n",
"Quantization axis and perpendicular rotation directions:\n",
"[1 0 0] --» [array([0, 1, 0]), array([0, 0, 1])]\n",
"[0 1 0] --» [array([1, 0, 0]), array([0, 0, 1])]\n",
"[0 0 1] --» [array([1, 0, 0]), array([0, 1, 0])]\n",
"================================================================================================================================================================\n",
"Parameters for the contour integral:\n",
"Number of k points: 3\n",
"k point directions: xy\n",
"Ebot: -13\n",
"Eset: 300\n",
"Esetp: 1000\n",
"================================================================================================================================================================\n",
"Setup done. Elapsed time: 37.226331 s\n",
"================================================================================================================================================================\n"
]
}
],
"source": [
"# MPI parameters\n",
"comm = MPI.COMM_WORLD\n",
@ -226,6 +232,32 @@
" )"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n",
"[0 0 0 0]\n"
]
}
],
"source": [
"orbs = []\n",
"magnetic_entities = read_grogupy_fdf(\"input.fdf\")[1]\n",
"for mag_ent in magnetic_entities:\n",
" orbs.append(parse_magnetic_entity(dh, **mag_ent))\n",
"\n",
"\n",
"asd = dh.o2a(orbs[6])\n",
"print(len(asd))\n",
"print(asd)"
]
},
{
"cell_type": "code",
"execution_count": null,

Loading…
Cancel
Save