From 243e01dac84287b7fac80f41871746f9520ea121 Mon Sep 17 00:00:00 2001 From: Daniel Pozsar Date: Tue, 12 Nov 2024 13:32:58 +0100 Subject: [PATCH] ran simple test, fdf input works --- .pickle | Bin 8228 -> 8228 bytes Fe3GeTe2_fdf_test.pickle | Bin 0 -> 8326 bytes README.md | 1 + input.fdf | 28 ++++----- src/grogupy/grogu.py | 60 ++++---------------- src/grogupy/io.py | 24 +++++--- src/grogupy/magnetism.py | 55 +++++++++++------- test.ipynb | 120 +++++++++++++++++++++++++-------------- 8 files changed, 154 insertions(+), 134 deletions(-) create mode 100644 Fe3GeTe2_fdf_test.pickle diff --git a/.pickle b/.pickle index 8b8a2762ebe96f63343a5779be37eea95d98732a..212aab1e99749da18acbf1270bcbe53ab773d511 100644 GIT binary patch delta 145 zcmZ4Du*6}5hrIdQ3Z65kmUH)T6{nVz7Q~li=B7?@xBu{a*}}x=_8vZu_{6-F_y}h= zn9O&M>d)rSKTNKdSCRb@F>&6{kk>t2+3`T#Fcm*mT$rD@oNe*}c^MA-Kf8B&CV4KL j{6t1v{VlO(UL*= delta 145 zcmZ4Du*6}5hrIcRHM@#+zq0jk6{nVz7Q~li=B7?@xBql-L(CZl#~wb9_{6-F_y}h= zn9R@f9>4aA=TEMeSCRd#XZc1a>Prt-c05owOvUe>5MPFkN|O)B%Wya_u>Cw0ebaUF i6L}@M;#8mcQ(EJCI8uQ|LM(D9&VA`zC=gv*ss{ks3_TG5 diff --git a/Fe3GeTe2_fdf_test.pickle b/Fe3GeTe2_fdf_test.pickle new file mode 100644 index 0000000000000000000000000000000000000000..e9dd0e479183dff64dbd39703eb93db7401903c3 GIT binary patch literal 8326 zcmcJU4Lnp?AIHadYgJ-XXv^AIO?C@x|-RFKje?RA(d(QuV@BNuqL?kR^AIKo z_(FDs*iImf=0)4hKqq*ifvAIBtWY52vt_8rPAufu@!66ItSL_8JKJp|BO-B3UnrHR z1|MeI*~EfPED0)>*v9cVF@)#AVooG$F*KowhYBQY2~Q}%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+Nlz6*Q`Gj%$-dWRsCZ8zG zZ&usF^~u_k3s!R+1CXb=^)YYc{-A8-{84uIlTXVhS+evAHT80kmA4r?pB?}jFS7Knr}!g2eqkHu-IaqP-UZHvGjcHYlHEPm zk}#zG*^-i3lfr;7v_nw~>*qgtG_MJA0@kNzU51?OX`{=NAt!a)oQ4c_?7_*?+DnWm z4LR9o<@(^nfEwVx*L?MARud>R&vp!eocy?B;;@Wkc>w!@r!|6^hY&L;y6=4Q>bmQ5 z+fA+DR$Z*^>=r#8cB4%wDS z((AX}XU{?boi_bHhcZIJDarFfLznSj*TP%NtLw%h-`w01m6s9%+AC?z=Ep)njqjJ! z^cT)UYNn4G*VI1<7+Ply*U=49&DgH*9Se(ulQ;Li1dUW`P0iONpCk_2>0n&;FW}VlaNv?BSCD*3v*eh~ zD-~iNTc6|z*9M;X>P-*-R6KQpmFqHgz5`S|>haxM66lAxzEj58{k!<@aq?aRPCWd= z9_o8p{S%xxADmYhzhNfe4;dab`7j-^OZK^Vhi(LRZXZzk%HJF4OGbNM8Q=qo>x6!c z8HV8BKX@Ht6&fH;bl;ob2Qk6M;6h6e*;wSnua7sqsvHTz)3c<7w{4J(HS-6Sz8#}_ z5?!2}t#A3lO#hZfoGdOeuF0MK8*=Yb`}$zqK4NTT^m2@T zy2?f0`Q(uFGoz~0yO2?7LEN_&_aeu)$qP>`IHP=YAN?*)e;;M}#V`R+5QmbRoXjNT{Dz`hjoB&f2H_<@fFH_wP2bT-^f7gMLU zANM_4a-sn6zXU{h;ThDyA-5eVcB|=dF sD^e;@jt+Oq;AW&4`XL8%TXflG3??ll_JATf>#qO%%)1dUq*B}e0#KdXHvj+t literal 0 HcmV?d00001 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='