Programmatic usage ================== Four-state pipeline (from a CIF) -------------------------------- .. code-block:: python from mag4 import ( run_cif_analysis, expand_supercell, find_dimers, build_reference_bath, generate_four_states, find_unique_configs, find_symmetry_ops, ) from mag4.lattice import get_cartesian_coords crystal, couplings = run_cif_analysis("Gd2S3.cif", "Gd", cutoff=7.0, tol=0.01) crystal = expand_supercell(crystal, 2, 1, 1) atoms = crystal.target_species ref_bath = build_reference_bath(len(atoms)) dimers = find_dimers(atoms, crystal.lattice_matrix, couplings, tol=0.05) cart = get_cartesian_coords(atoms, crystal.lattice_matrix) sym_ops = find_symmetry_ops(cart, crystal.lattice_vectors) all_cfgs = [] for name, _ in couplings: if dimers[name]: all_cfgs.extend(generate_four_states(ref_bath, dimers[name][0], name)) unique = find_unique_configs(all_cfgs, sym_ops) print(f"{len(unique)} unique configurations to compute " f"(out of {len(all_cfgs)} raw)") Multi-sublattice LSWT and T_c ----------------------------- .. code-block:: python from pymatgen.core import Structure from mag4.io_cif import get_distance_shells from mag4.magnon import ( get_sublattice_bonds, build_qmesh, build_jq_matrices, compute_eigenvalues_all_q, analyse_ordering, compute_tc, compute_tc_lswt, ) shells = get_distance_shells("Gd2O2S.cif", "Gd", cutoff=7.0) j_values = {"J1": 0.26, "J2": 0.26, "J3": 0.12} bonds = get_sublattice_bonds("Gd2O2S.cif", "Gd", 7.0, shells, j_values) structure = Structure.from_file("Gd2O2S.cif") q_cart, q_frac = build_qmesh(structure, 30, 30, 20) Jq = build_jq_matrices(bonds, q_cart) evals = compute_eigenvalues_all_q(Jq) ordering = analyse_ordering(Jq, evals, q_frac, q_cart, structure) tc_lt = compute_tc(evals, S=3.5, lam0=ordering["lam0"]) tc_sw = compute_tc_lswt(bonds, S=3.5, ordering_lt=ordering, q_cart=q_cart, evals_lt=evals) M – L – M angles ---------------- .. code-block:: python from pymatgen.core import Structure from mag4.analysis import ( group_into_shells, find_bridging_angles, ) from mag4.analysis.bond_angles import get_mm_pairs structure = Structure.from_file("Gd2S3.cif") pairs = get_mm_pairs(structure, "Gd", cutoff=7.0) shells = group_into_shells(pairs) for shell in shells: for p in shell["pairs"]: angles = find_bridging_angles( structure, p["site_i"], p["site_j"], p["image"], ligand_elements=["S"], bond_cutoff=3.5) WIEN2k moment extraction ------------------------ .. code-block:: python from mag4.analysis import find_cases, build_table cases = find_cases(".") table = build_table(cases, atom_indices=list(range(9, 17))) print("\\n".join(table))