diff --git a/.pickle b/.pickle index 8b8a276..212aab1 100644 Binary files a/.pickle and b/.pickle differ diff --git a/Fe3GeTe2_fdf_test.pickle b/Fe3GeTe2_fdf_test.pickle new file mode 100644 index 0000000..e9dd0e4 Binary files /dev/null and b/Fe3GeTe2_fdf_test.pickle differ diff --git a/README.md b/README.md index 268ebd6..eddf555 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/input.fdf b/input.fdf index be77065..75ee45e 100644 --- a/input.fdf +++ b/input.fdf @@ -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 diff --git a/src/grogupy/grogu.py b/src/grogupy/grogu.py index ec93cb0..2aac3fb 100644 --- a/src/grogupy/grogu.py +++ b/src/grogupy/grogu.py @@ -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 = process_input_args( + DEFAULT_ARGUMENTS, fdf_arguments, command_line_arguments, ACCEPTED_INPUTS ) - 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 # - #################################################################################################### - + print(simulation_parameters) main(simulation_parameters, magnetic_entities, pairs) diff --git a/src/grogupy/io.py b/src/grogupy/io.py index dd67f35..11ff50c 100644 --- a/src/grogupy/io.py +++ b/src/grogupy/io.py @@ -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 diff --git a/src/grogupy/magnetism.py b/src/grogupy/magnetism.py index 2024bc4..5067d30 100644 --- a/src/grogupy/magnetism.py +++ b/src/grogupy/magnetism.py @@ -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. diff --git a/test.ipynb b/test.ipynb index 8c33de4..4e25d39 100644 --- a/test.ipynb +++ b/test.ipynb @@ -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='