updated standard output and return array

class-solution
Daniel Pozsar 3 months ago
parent 545848b298
commit 8246a6a1ab

@ -23,7 +23,6 @@ from pprint import pprint
import numpy as np
from scipy.special import roots_legendre
from sisl import unit_convert
# Pauli matrices
tau_x = np.array([[0, 1], [1, 0]])
@ -228,38 +227,7 @@ def calculate_exchange_tensor(pair):
return J_ii.sum() / 3, np.concatenate([J_ii[:2] - J_ii.sum() / 3, J_S]).flatten(), D
def print_pair_atomic_indices(pair, magnetic_entities, dh):
atomic_indices = ""
# iterate over the two magnetic entities in a pair
for mag_ent in [magnetic_entities[pair["ai"]], magnetic_entities[pair["aj"]]]:
# get atoms of magnetic entity
atoms_idx = mag_ent["atom"]
# if orbital is not set use all
if "l" not in mag_ent.keys():
mag_ent["l"] = "all"
orbitals = mag_ent["l"]
# if magnetic entity contains one atoms
if isinstance(atoms_idx, int):
atomic_indices += f"[{atoms_idx}]{dh.atoms[atoms_idx].tag}({orbitals})"
# if magnetic entity contains more than one atoms
if isinstance(atoms_idx, list):
# iterate over atoms
atom_group = "{"
for atom_idx in atoms_idx:
atom_group += f"[{atom_idx}]{dh.atoms[atom_idx].tag}({orbitals})--"
# end {} of the atoms in the magnetic entity
atomic_indices += atom_group[:-2] + "}"
# separate magnetic entities
atomic_indices += " "
return atomic_indices
def print_output(simulation_parameters, magnetic_entities, pairs, dh, times):
print(
"##################################################################### GROGU OUTPUT #############################################################################"
)
def print_parameters(simulation_parameters):
print(
"================================================================================================================================================================"
)
@ -272,11 +240,8 @@ def print_output(simulation_parameters, magnetic_entities, pairs, dh, times):
print(
"================================================================================================================================================================"
)
try:
print("Cell [Ang]: ")
print(simulation_parameters["geom"].cell)
except:
print("Geometry could not be read.")
print("Cell [Ang]: ")
print(simulation_parameters["cell"])
print(
"================================================================================================================================================================"
)
@ -288,19 +253,19 @@ def print_output(simulation_parameters, magnetic_entities, pairs, dh, times):
print(
"================================================================================================================================================================"
)
print("number of k points: ", simulation_parameters["kset"])
print("k point directions: ", simulation_parameters["kdirs"])
print(
"================================================================================================================================================================"
)
print("Parameters for the contour integral:")
print("Number of k points: ", simulation_parameters["kset"])
print("k point directions: ", simulation_parameters["kdirs"])
print("Ebot: ", simulation_parameters["ebot"])
print("Eset: ", simulation_parameters["eset"])
print("Esetp: ", simulation_parameters["esetp"])
print(
"================================================================================================================================================================"
)
print("Atomic informations: ")
def print_atoms_and_pairs(magnetic_entities, pairs):
print("Atomic information: ")
print(
"----------------------------------------------------------------------------------------------------------------------------------------------------------------"
)
@ -312,30 +277,10 @@ def print_output(simulation_parameters, magnetic_entities, pairs, dh, times):
)
# iterate over magnetic entities
for mag_ent in magnetic_entities:
# get atoms of magnetic entity
atoms_idx = mag_ent["atom"]
# if orbital is not set use all
if "l" not in mag_ent.keys():
mag_ent["l"] = "all"
orbitals = mag_ent["l"]
# if magnetic entity contains one atom
if isinstance(atoms_idx, int):
# iterate over atoms
for tag, xyz in zip(mag_ent["tags"], mag_ent["xyz"]):
# coordinates and tag
x, y, z = dh.xyz[atoms_idx]
print(
f"[{atoms_idx}]{dh.atoms[atoms_idx].tag}({orbitals}) {x} {y} {z}"
)
# if magnetic entity contains more than one atoms
if isinstance(atoms_idx, list):
# iterate over atoms
for atom_idx in atoms_idx:
# coordinates and tag
x, y, z = dh.xyz[atom_idx]
print(
f"[{atom_idx}]{dh.atoms[atom_idx].tag}({orbitals}) {x} {y} {z}"
)
print(f"{tag} {xyz[0]} {xyz[1]} {xyz[2]}")
print("")
print(
@ -351,21 +296,14 @@ def print_output(simulation_parameters, magnetic_entities, pairs, dh, times):
)
# iterate over pairs
for pair in pairs:
# calculate magnetic parameters
J_iso, J_S, D = calculate_exchange_tensor(pair)
J_iso = J_iso * unit_convert("eV", "meV")
J_S = J_S * unit_convert("eV", "meV")
D = D * unit_convert("eV", "meV")
# print pair parameters
print(
print_pair_atomic_indices(pair, magnetic_entities, dh),
f" {pair['Ruc']} d [Ang] Not yet.",
f"{pair['tags'][0]} {pair['tags'][1]} {pair['Ruc']} d [Ang] Not yet."
)
# print magnetic parameters
print("Isotropic: ", J_iso)
print("DMI: ", D)
print("Symmetric-anisotropy: ", J_S)
print("Isotropic: ", pair["J_iso"])
print("DMI: ", pair["D"])
print("Symmetric-anisotropy: ", pair["J_S"])
print("Energies for debugging: ")
pprint(np.array(pair["energies"]))
print(
@ -380,6 +318,9 @@ def print_output(simulation_parameters, magnetic_entities, pairs, dh, times):
print(
"================================================================================================================================================================"
)
def print_runtime_informations(times):
print("Runtime information: ")
print(f"Total runtime: {times['end_time'] - times['start_time']} s")
print(

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save