Refine exchange plot labels and induced terminology
Browse filesFiles changed (12)
- app.py+6-6
- docs/IMX-09_UPPASD_CONVENTION_CLOSEOUT.md+2-2
- docs/PHYSICS_LIMITS.md+1-1
- docs/THEORY.md+2-2
- src/induced_exchange/__init__.py+2
- src/induced_exchange/downfolding.py+1-1
- src/induced_exchange/induced.py+11-7
- src/induced_exchange/magnons.py+5-5
- src/induced_exchange/space.py+20-7
- tests/test_induced.py+3-3
- tests/test_magnons.py+1-1
- tests/test_space.py+13
137 unmodified lines1381391401411421431441451461471481491501511521531541551561571585 unmodified lines16416516616716816917027 unmodified lines198199200201202203204137 unmodified linesload_status = gr.Markdown()parsed_summary = gr.Markdown()classification = gr.Dataframe(headers=["site", "atom_type", "moment (mu_B)", "role"], datatype=["number", "str", "number", "str"], type="array", row_count=1, label="Role preview (default: m < 0.5 μB is induced)", interactive=False)induced_site_toggle = gr.CheckboxGroup(choices=[], value=[], label="Induced/slave sites (toggle)", info="Select induced sites explicitly. By default, sites with reference moment m < 0.5 μB are selected; all other sites are robust.")with gr.Row():mesh_size = gr.Slider(4, 16, value=8, step=1, label="Seekpath points per segment", info="The exchange, response, dressed-exchange, and magnon plots use this high-symmetry path. The same value controls the auxiliary 3-D mesh used only for J_eff(r).")analyze_button = gr.Button("Run analysis", variant="primary")with gr.Tab("2 · Raw exchange"):gr.Markdown("### Raw rigid-site exchange\nAll supplied sites and literal UppASD jfile Jij rows are retained. The ordering diagnostic is the largest eigenvalue of J(q) under the UppASD ordered-pair convention `H = −Σᵢ≠ⱼ Jij eᵢ·eⱼ`. The scan is restricted to the seekpath high-symmetry path (or the explicitly labelled fallback path if seekpath cannot classify the structure); it is not a global 3-D ordering search.")raw_ordering = gr.Markdown("Load an input set and run analysis.")with gr.Row():distance_plot = gr.Plot(label="Jij versus distance")raw_plot = gr.Plot(label="J(q) eigenvalue scan · high-symmetry path")shell_table = gr.Dataframe(headers=["shell", "radius", "count", "mean Jij", "min Jij", "max Jij"], row_count=1, label="Radial exchange shells", interactive=False)with gr.Tab("3 · Induced response"):gr.Markdown("### Induced/slave response\nClassify sites explicitly in the Input tab. The induced response is algebraic and instantaneous; induced sites are not independent LLG/LSWT degrees of freedom. The response panel uses a coherent unit-amplitude robust spin spiral along the same seekpath high-symmetry path.")with gr.Row():response_mode = gr.Radio([("J-weighted approximation", "j_weighted"), ("Historical unweighted", "historical")], value="j_weighted", label="Response model")x_override = gr.Textbox(label="X override", placeholder="blank = infer · e.g. 0.12 or 2:0.12, 3:0.08", info="J-weighted mode: X has inverse-energy units and p_ind = X K e, where p_ind = m_ind/|m_ind⁰|.")5 unmodified linesinference_table = gr.Dataframe(headers=["site", "m_ref (mu_B)", "source field (energy)", "X (1/energy)", "warnings"], row_count=1, label="X inference and source-field normalization", interactive=False)with gr.Tab("4 · Dressed exchange"):gr.Markdown("### Robust-space exchange after induced-moment elimination\nThe induced contribution is a model-dependent correction using the selected response approximation. `J_eff(q)` is the Fourier-space matrix in the robust basis; the q-plot shows its leading eigenvalue. For one robust site (such as Fe with Pt treated as induced), this matrix is a scalar. The first real-space plot uses shell means to compare the direct `J_RR(r)`, cross-block `K_RI(r)`, Mryasov/downfolded `J_Mryasov(r)`, and Polesya/slave `J_Polesya(r)` channels. With the same static response model, the last two are numerically equivalent and are shown with separate labels. The induced correction `ΔJ_induced(r)` and its relative value `ΔJ_induced(r) / J_RR(r)` are plotted separately below. Real-space x-axes use the implicit UppASD lattice parameter convention (`alat = 1`), while all curves are reconstructed from a separate complete q mesh; moment normalization remains separate in the magnon calculation. The exported `dressed_jfile` is directly compatible with UppASD's ordered-pair convention.")dressed_info = gr.Markdown()with gr.Row():dressed_plot = gr.Plot(label="Robust-space J_eff(q) · high-symmetry path")27 unmodified lines**Raw rigid-site model.** Every supplied magnetic site is treated as an ordinary rigid moment. This is diagnostic when some sites are physically induced.**Polesya-like slave moments.** Induced moments are eliminated as algebraic variables. The historical mode uses an unweighted local neighbour sum; the selected J-weighted mode evaluates the labelled **J-weighted induced-response approximation**.**Mryasov-like downfolding.** The induced subspace is eliminated variationally from one quadratic energy functional, yielding a robust-space `J_eff(q)`. No induced magnon branches are added.137 unmodified lines1381391401411421431441451461471481491501511521531541551561571585 unmodified lines16416516616716816917027 unmodified lines198199200201202203204137 unmodified linesload_status = gr.Markdown()parsed_summary = gr.Markdown()classification = gr.Dataframe(headers=["site", "atom_type", "moment (mu_B)", "role"], datatype=["number", "str", "number", "str"], type="array", row_count=1, label="Role preview (default: m < 0.5 μB is induced)", interactive=False)induced_site_toggle = gr.CheckboxGroup(choices=[], value=[], label="Induced sites (toggle)", info="Select induced sites explicitly. By default, sites with reference moment m < 0.5 μB are selected; all other sites are robust.")with gr.Row():mesh_size = gr.Slider(4, 16, value=8, step=1, label="Seekpath points per segment", info="The exchange, response, dressed-exchange, and magnon plots use this high-symmetry path. The same value controls the auxiliary 3-D mesh used only for J_eff(r).")analyze_button = gr.Button("Run analysis", variant="primary")with gr.Tab("2 · Raw exchange"):gr.Markdown("### Raw rigid-site exchange\nAll supplied sites and literal UppASD jfile Jij rows are retained. The ordering diagnostic is the largest eigenvalue of J(q) under the UppASD ordered-pair convention `H = −Σᵢ≠ⱼ Jij eᵢ·eⱼ`. The scan is restricted to the seekpath high-symmetry path (or the explicitly labelled fallback path if seekpath cannot classify the structure); it is not a global 3-D ordering search. The distance plot separates `J_MM` (robust–robust, circles), `J_Mm` (robust–induced, squares), and `J_mm` (induced–induced, triangles).")raw_ordering = gr.Markdown("Load an input set and run analysis.")with gr.Row():distance_plot = gr.Plot(label="Raw Jij by subspace · distance")raw_plot = gr.Plot(label="J(q) eigenvalue scan · high-symmetry path")shell_table = gr.Dataframe(headers=["shell", "radius", "count", "mean Jij", "min Jij", "max Jij"], row_count=1, label="Radial exchange shells", interactive=False)with gr.Tab("3 · Induced response"):gr.Markdown("### Induced response\nClassify sites explicitly in the Input tab. The induced response is algebraic and instantaneous; induced sites are not independent LLG/LSWT degrees of freedom. The response panel uses a coherent unit-amplitude robust spin spiral along the same seekpath high-symmetry path.")with gr.Row():response_mode = gr.Radio([("J-weighted approximation", "j_weighted"), ("Historical unweighted", "historical")], value="j_weighted", label="Response model")x_override = gr.Textbox(label="X override", placeholder="blank = infer · e.g. 0.12 or 2:0.12, 3:0.08", info="J-weighted mode: X has inverse-energy units and p_ind = X K e, where p_ind = m_ind/|m_ind⁰|.")5 unmodified linesinference_table = gr.Dataframe(headers=["site", "m_ref (mu_B)", "source field (energy)", "X (1/energy)", "warnings"], row_count=1, label="X inference and source-field normalization", interactive=False)with gr.Tab("4 · Dressed exchange"):gr.Markdown("### Robust-space exchange after induced-moment elimination\nThe induced contribution is a model-dependent correction using the selected response approximation. `J_eff(q)` is the Fourier-space matrix in the robust basis; the q-plot shows its leading eigenvalue. For one robust site (such as Fe with Pt treated as induced), this matrix is a scalar. The first real-space plot uses shell means to compare the direct `J_RR(r)`, cross-block `K_RI(r)`, Mryasov/downfolded `J_Mryasov(r)`, and Polesya-like induced `J_Polesya(r)` channels. With the same static response model, the last two are numerically equivalent and are shown with separate labels. The induced correction `ΔJ_induced(r)` and its relative value `ΔJ_induced(r) / J_RR(r)` are plotted separately below. Real-space x-axes use the implicit UppASD lattice parameter convention (`alat = 1`), while all curves are reconstructed from a separate complete q mesh; moment normalization remains separate in the magnon calculation. The exported `dressed_jfile` is directly compatible with UppASD's ordered-pair convention.")dressed_info = gr.Markdown()with gr.Row():dressed_plot = gr.Plot(label="Robust-space J_eff(q) · high-symmetry path")27 unmodified lines**Raw rigid-site model.** Every supplied magnetic site is treated as an ordinary rigid moment. This is diagnostic when some sites are physically induced.**Polesya-like induced moments.** Induced moments are eliminated as algebraic variables. The historical mode uses an unweighted local neighbour sum; the selected J-weighted mode evaluates the labelled **J-weighted induced-response approximation**.**Mryasov-like downfolding.** The induced subspace is eliminated variationally from one quadratic energy functional, yielding a robust-space `J_eff(q)`. No induced magnon branches are added.
216 unmodified lines217218219220221222223224225226227228216 unmodified lines## 9. Polesya/Mryasov equivalenceThe Polesya/slave response and Mryasov/downfolded result use the same `Xi` andthe same stationary `p*`. Induced sites are not added as independent LLG orLSWT degrees of freedom. Consequently the robust stationary energy and theadiabatic physical magnon spectrum are identical. The application retains thetwo labels to distinguish the representations, not to introduce separateslave branches.## 10. Export and provenance216 unmodified lines217218219220221222223224225226227228216 unmodified lines## 9. Polesya/Mryasov equivalenceThe Polesya-like induced response and Mryasov/downfolded result use the same `Xi` andthe same stationary `p*`. Induced sites are not added as independent LLG orLSWT degrees of freedom. Consequently the robust stationary energy and theadiabatic physical magnon spectrum are identical. The application retains thetwo labels to distinguish the representations, not to introduce separateinduced branches.## 10. Export and provenance
3 unmodified lines456789103 unmodified linesThe program can exactly manipulate the supplied effective spin model: it canFourier transform the supplied Cartesian `Jij`, solve the selected linearslave-response model, and perform the corresponding Schur-complementdownfolding. It cannot determine the true electronic susceptibility from`Jij` alone.3 unmodified lines456789103 unmodified linesThe program can exactly manipulate the supplied effective spin model: it canFourier transform the supplied Cartesian `Jij`, solve the selected linearinduced-response model, and perform the corresponding Schur-complementdownfolding. It cannot determine the true electronic susceptibility from`Jij` alone.
60 unmodified lines6162636465666787 unmodified lines15515615715815916016160 unmodified lines## Induced momentsSites are explicitly classified as **robust** or **induced/slave**. The UIinitially selects moments below 0.5 `mu_B` as induced, but this is only aneditable convenience; the chosen classification, not the threshold, definesthe calculation.87 unmodified linesrows therefore has `4*g*J/m [1-cos(qa)]`.Raw calculations retain all sites; robust-only calculations drop induced sites;dressed calculations first eliminate them. Induced sites never appear as extraindependent magnon branches in a slave-moment calculation.Goldstone behaviour at Gamma, negative modes, and a non-Gamma orderingtendency are reported. A non-FM-compatible result is not presented as a60 unmodified lines6162636465666787 unmodified lines15515615715815916016160 unmodified lines## Induced momentsSites are explicitly classified as **robust** or **induced**. The UIinitially selects moments below 0.5 `mu_B` as induced, but this is only aneditable convenience; the chosen classification, not the threshold, definesthe calculation.87 unmodified linesrows therefore has `4*g*J/m [1-cos(qa)]`.Raw calculations retain all sites; robust-only calculations drop induced sites;dressed calculations first eliminate them. Induced sites never appear as extraindependent magnon branches in an induced-moment calculation.Goldstone behaviour at Gamma, negative modes, and a non-Gamma orderingtendency are reported. A non-FM-compatible result is not presented as a
41 unmodified lines424344454647113 unmodified lines16116216316416516641 unmodified linesSublatticeClassification,XInference,XInferenceResult,instantaneous_slave_moments,)from .downfolding import (113 unmodified lines"SublatticeClassification","XInference","XInferenceResult","instantaneous_slave_moments","DressedExchangeRealSpace","DownfoldingResult",41 unmodified lines42434445464748113 unmodified lines16216316416516616716841 unmodified linesSublatticeClassification,XInference,XInferenceResult,instantaneous_induced_moments,instantaneous_slave_moments,)from .downfolding import (113 unmodified lines"SublatticeClassification","XInference","XInferenceResult","instantaneous_induced_moments","instantaneous_slave_moments","DressedExchangeRealSpace","DownfoldingResult",
287 unmodified lines288289290291292293294287 unmodified linesThe constructor accepts an :class:`InducedMomentResponse`, or a model plusexplicit ``robust_sites`` and ``induced_sites``. In either form the sameclassification, kernel, X values, and approximation label are used by theexplicit slave response and by the downfolded energy."""def __init__(287 unmodified lines288289290291292293294287 unmodified linesThe constructor accepts an :class:`InducedMomentResponse`, or a model plusexplicit ``robust_sites`` and ``induced_sites``. In either form the sameclassification, kernel, X values, and approximation label are used by theexplicit induced response and by the downfolded energy."""def __init__(
1234307 unmodified lines31231331431531631731869 unmodified lines388389390391392393394316 unmodified lines71171271371471571671731 unmodified lines7497507517527537547559 unmodified lines7657667677687697707715 unmodified lines77777877978078178278311 unmodified lines7957967977987998003 unmodified lines804805806807808"""Explicit Polesya-like induced/slave moment response models.This module implements the response layer only. It does not downfold theenergy or create dynamical degrees of freedom for induced sites. The307 unmodified linesclass InducedMomentResponse:"""Evaluate historical or J-weighted instantaneous slave moments.Parameters----------69 unmodified lines@propertydef response_label(self) -> str:return "J-weighted induced-response approximation" if self.mode == "j_weighted" else "historical local/unweighted slave response"@propertydef local_neighbour_matrix(self) -> np.ndarray:316 unmodified lines*,coordinates: str = "fractional",) -> InducedResponseResult:"""Evaluate the instantaneous slave response for supplied q-space e(q).``robust_configuration`` contains dimensionless robust orientationamplitudes and has shape ``(nq, nrobust)`` for scalar amplitudes, or31 unmodified linesreturn InducedResponseResult(response, fields, condition, singular, self.induced_sites, self.mode, tuple(warnings), q_fractional, q_cartesian, hermiticity, self._reference_induced_moments())def response_real_space(self, robust_configuration: Mapping[int, Any] | Sequence[Any] | np.ndarray) -> InducedResponseResult:"""Evaluate normalized slave polarization for a robust configuration.The input is a dimensionless robust orientation configuration. Thiscomputes an algebraic response at one instant. It does not propagate9 unmodified linesreturn InducedResponseResult(result, source, condition, singular, self.induced_sites, self.mode, tuple(warnings), reference_induced_moments=self._reference_induced_moments())def instantaneous_slave_moments(model: MagneticCrystal,robust_configuration: Mapping[int, Any] | Sequence[Any] | np.ndarray,robust_sites: Sequence[int] | Mapping[Hashable, Sequence[int]],5 unmodified linesneighbourhood: str | Sequence[int] | Mapping[int, Sequence[int]] = "first_shell",cutoff: float | None = None,) -> np.ndarray:"""Return only the instantaneous dimensionless slave polarization ``p``."""response = InducedMomentResponse(model,11 unmodified lines# A concise spelling is useful in notebooks and retains the physical name.InducedResponse = InducedMomentResponse__all__ = ["InducedMomentResponse",3 unmodified lines"SublatticeClassification","XInference","XInferenceResult","instantaneous_slave_moments",]1234307 unmodified lines31231331431531631731869 unmodified lines388389390391392393394316 unmodified lines71171271371471571671731 unmodified lines7497507517527537547559 unmodified lines7657667677687697707715 unmodified lines77777877978078178278311 unmodified lines7957967977987998008018028033 unmodified lines807808809810811812"""Explicit Polesya-like induced-moment response models.This module implements the response layer only. It does not downfold theenergy or create dynamical degrees of freedom for induced sites. The307 unmodified linesclass InducedMomentResponse:"""Evaluate historical or J-weighted instantaneous induced moments.Parameters----------69 unmodified lines@propertydef response_label(self) -> str:return "J-weighted induced-response approximation" if self.mode == "j_weighted" else "historical local/unweighted induced response"@propertydef local_neighbour_matrix(self) -> np.ndarray:316 unmodified lines*,coordinates: str = "fractional",) -> InducedResponseResult:"""Evaluate the instantaneous induced response for supplied q-space e(q).``robust_configuration`` contains dimensionless robust orientationamplitudes and has shape ``(nq, nrobust)`` for scalar amplitudes, or31 unmodified linesreturn InducedResponseResult(response, fields, condition, singular, self.induced_sites, self.mode, tuple(warnings), q_fractional, q_cartesian, hermiticity, self._reference_induced_moments())def response_real_space(self, robust_configuration: Mapping[int, Any] | Sequence[Any] | np.ndarray) -> InducedResponseResult:"""Evaluate normalized induced polarization for a robust configuration.The input is a dimensionless robust orientation configuration. Thiscomputes an algebraic response at one instant. It does not propagate9 unmodified linesreturn InducedResponseResult(result, source, condition, singular, self.induced_sites, self.mode, tuple(warnings), reference_induced_moments=self._reference_induced_moments())def instantaneous_induced_moments(model: MagneticCrystal,robust_configuration: Mapping[int, Any] | Sequence[Any] | np.ndarray,robust_sites: Sequence[int] | Mapping[Hashable, Sequence[int]],5 unmodified linesneighbourhood: str | Sequence[int] | Mapping[int, Sequence[int]] = "first_shell",cutoff: float | None = None,) -> np.ndarray:"""Return only the instantaneous dimensionless induced polarization ``p``."""response = InducedMomentResponse(model,11 unmodified lines# A concise spelling is useful in notebooks and retains the physical name.InducedResponse = InducedMomentResponse# Backward-compatible alias for callers of the original API spelling.instantaneous_slave_moments = instantaneous_induced_moments__all__ = ["InducedMomentResponse",3 unmodified lines"SublatticeClassification","XInference","XInferenceResult","instantaneous_induced_moments","instantaneous_slave_moments",]
27 unmodified lines2829303132333422 unmodified lines5758596061626364489 unmodified lines554555556557558559560125 unmodified lines68668768868969069169227 unmodified linesexpressed in mu_B. The eigenvalues of ``D`` are hbar*omega in theexchange-energy unit.Induced sites never enter this dynamical basis. A Polesya/slave calculationuses the dressed robust matrix after analytical elimination, so its physicallow-energy spectrum is directly comparable to the Mryasov/downfolded one."""22 unmodified lines"robust_raw": "robust-only raw","mryasov": "Mryasov-like downfolded robust","downfolded": "Mryasov-like downfolded robust","polesya": "Polesya-like slave, induced variables eliminated","slave": "Polesya-like slave, induced variables eliminated",}489 unmodified lines``model='robust_only'`` retains only explicitly supplied robust sites.``model='mryasov'`` and ``model='polesya'`` both use the robust dressedinteraction after induced variables have been eliminated; the latter namerecords the slave-response representation, not extra slave branches."""selected_model = _normalise_model_name(model)125 unmodified linesdef polesya_fm_magnon_spectrum(source: InducedExchangeDownfolding | InducedMomentResponse | DownfoldingResult, q_points: Sequence[Sequence[float]] | np.ndarray | None = None, **kwargs: Any) -> FMSpinWaveResult:"""Convenience wrapper for the physical Polesya-like slave spectrum."""return fm_magnon_spectrum(source, q_points, model="polesya", **kwargs)27 unmodified lines2829303132333422 unmodified lines5758596061626364489 unmodified lines554555556557558559560125 unmodified lines68668768868969069169227 unmodified linesexpressed in mu_B. The eigenvalues of ``D`` are hbar*omega in theexchange-energy unit.Induced sites never enter this dynamical basis. A Polesya-like induced-variable calculationuses the dressed robust matrix after analytical elimination, so its physicallow-energy spectrum is directly comparable to the Mryasov/downfolded one."""22 unmodified lines"robust_raw": "robust-only raw","mryasov": "Mryasov-like downfolded robust","downfolded": "Mryasov-like downfolded robust","polesya": "Polesya-like induced variables eliminated","slave": "Polesya-like induced variables eliminated",}489 unmodified lines``model='robust_only'`` retains only explicitly supplied robust sites.``model='mryasov'`` and ``model='polesya'`` both use the robust dressedinteraction after induced variables have been eliminated; the latter namerecords the induced-response representation, not extra induced branches."""selected_model = _normalise_model_name(model)125 unmodified linesdef polesya_fm_magnon_spectrum(source: InducedExchangeDownfolding | InducedMomentResponse | DownfoldingResult, q_points: Sequence[Sequence[float]] | np.ndarray | None = None, **kwargs: Any) -> FMSpinWaveResult:"""Convenience wrapper for the physical Polesya-like induced spectrum."""return fm_magnon_spectrum(source, q_points, model="polesya", **kwargs)
758 unmodified lines75976076176276376476576676776876977077176 unmodified lines848849850851852853854158 unmodified lines101310141015101610171018101947 unmodified lines1067106810691070107110721073758 unmodified linesmodel = session.loaded.modeldistances = model.bond_distancesvalues = np.asarray([bond.jij for bond in model.exchange_bonds], dtype=float)if len(distances):ax.scatter(distances, values, s=22, color="#18a999", alpha=0.78)else:ax.text(0.5, 0.5, "No exchange rows", ha="center", va="center")ax.axhline(0.0, color="#8b98a6", linewidth=0.8, label="_nolegend_")ax.set(xlabel="authoritative bond distance", ylabel=f"Jij ({model.units.energy})", title="Raw exchange versus distance")ax.grid(alpha=0.18)fig.tight_layout()plt.close(fig)return fig76 unmodified linesif cross is not None and cross.ndim == 3 and cross.shape[1:] == (1, 1):_plot_shell_series(ax, distances, selections, cross[:, 0, 0], "J_Mm(r) = K_Mm(r)", "#183b56")_plot_shell_series(ax, distances, selections, dressed[:, 0, 0], "J_Mryasov(r)", "#e07a5f")# The Polesya/slave and Mryasov/downfolded curves use the same static# response operator in this package, so retain both labels while# making their numerical equivalence explicit._plot_shell_series(ax, distances, selections, dressed[:, 0, 0], "J_Polesya(r) = J_Mryasov(r)", "#e07a5f", linestyle=":", marker=None)158 unmodified linesfig, ax = plt.subplots(figsize=(8.4, 4.1))colors = {"raw": "#183b56", "robust-only": "#18a999", "dressed": "#e07a5f", "polesya": "#8c5e8a"}labels = {"raw": "Raw all-rigid", "robust-only": "Robust-only raw", "dressed": "Mryasov-like downfolded", "polesya": "Polesya-like slave"}x, tick_positions, tick_labels, source = _path_axis(session, len(next(iter(session.magnons.values())).energies) if session.magnons else 0)linestyles = {"raw": "-", "robust-only": "--", "dressed": "-", "polesya": ":"}for name, spectrum in session.magnons.items():47 unmodified linesreturn "No FM spectrum could be constructed for the current input."path_source = "unknown" if session.path is None else session.path.path.sourcelines = [f"The spectrum is evaluated only along the high-symmetry q path (`{path_source}`); the horizontal axis is Cartesian reciprocal-space path distance."]labels = {"raw": "Raw all-rigid", "robust-only": "Robust-only raw", "dressed": "Mryasov-like downfolded", "polesya": "Polesya-like slave"}for name, spectrum in session.magnons.items():status = "stable/FM-compatible" if spectrum.stable and spectrum.fm_compatible else "UNSTABLE — signed harmonic data only"lines.append(f"**{labels.get(name, name)}:** `{status}` · branches = `{spectrum.energies.shape[1]}` · negative modes = `{len(spectrum.unstable_indices)}`")758 unmodified lines75976076176276376476576676776876977077177277377477577677777877978078178278378476 unmodified lines861862863864865866867158 unmodified lines102610271028102910301031103247 unmodified lines1080108110821083108410851086758 unmodified linesmodel = session.loaded.modeldistances = model.bond_distancesvalues = np.asarray([bond.jij for bond in model.exchange_bonds], dtype=float)robust = set(session.robust_sites)induced = set(session.induced_sites)categories = ((r"$J_{MM}$", lambda bond: bond.i in robust and bond.j in robust, "o", "#18a999"),(r"$J_{Mm}$", lambda bond: (bond.i in robust and bond.j in induced) or (bond.i in induced and bond.j in robust), "s", "#183b56"),(r"$J_{mm}$", lambda bond: bond.i in induced and bond.j in induced, "^", "#e07a5f"),)plotted = Falsefor label, selector, marker, color in categories:selected = np.asarray([selector(bond) for bond in model.exchange_bonds], dtype=bool)if np.any(selected):ax.scatter(distances[selected], values[selected], s=34, color=color, marker=marker, alpha=0.8, label=label)plotted = Trueif not plotted:ax.text(0.5, 0.5, "No exchange rows", ha="center", va="center")ax.axhline(0.0, color="#8b98a6", linewidth=0.8, label="_nolegend_")ax.set(xlabel="authoritative bond distance", ylabel=f"Jij ({model.units.energy})", title="Raw exchange by subspace versus distance")ax.grid(alpha=0.18)if plotted:ax.legend(frameon=False)fig.tight_layout()plt.close(fig)return fig76 unmodified linesif cross is not None and cross.ndim == 3 and cross.shape[1:] == (1, 1):_plot_shell_series(ax, distances, selections, cross[:, 0, 0], "J_Mm(r) = K_Mm(r)", "#183b56")_plot_shell_series(ax, distances, selections, dressed[:, 0, 0], "J_Mryasov(r)", "#e07a5f")# The Polesya-like induced and Mryasov/downfolded curves use the same static# response operator in this package, so retain both labels while# making their numerical equivalence explicit._plot_shell_series(ax, distances, selections, dressed[:, 0, 0], "J_Polesya(r) = J_Mryasov(r)", "#e07a5f", linestyle=":", marker=None)158 unmodified linesfig, ax = plt.subplots(figsize=(8.4, 4.1))colors = {"raw": "#183b56", "robust-only": "#18a999", "dressed": "#e07a5f", "polesya": "#8c5e8a"}labels = {"raw": "Raw all-rigid", "robust-only": "Robust-only raw", "dressed": "Mryasov-like downfolded", "polesya": "Polesya-like induced variables eliminated"}x, tick_positions, tick_labels, source = _path_axis(session, len(next(iter(session.magnons.values())).energies) if session.magnons else 0)linestyles = {"raw": "-", "robust-only": "--", "dressed": "-", "polesya": ":"}for name, spectrum in session.magnons.items():47 unmodified linesreturn "No FM spectrum could be constructed for the current input."path_source = "unknown" if session.path is None else session.path.path.sourcelines = [f"The spectrum is evaluated only along the high-symmetry q path (`{path_source}`); the horizontal axis is Cartesian reciprocal-space path distance."]labels = {"raw": "Raw all-rigid", "robust-only": "Robust-only raw", "dressed": "Mryasov-like downfolded", "polesya": "Polesya-like induced variables eliminated"}for name, spectrum in session.magnons.items():status = "stable/FM-compatible" if spectrum.stable and spectrum.fm_compatible else "UNSTABLE — signed harmonic data only"lines.append(f"**{labels.get(name, name)}:** `{status}` · branches = `{spectrum.energies.shape[1]}` · negative modes = `{len(spectrum.unstable_indices)}`")
7 unmodified lines8910111213148 unmodified lines23242526272829122 unmodified lines1521531541551561571587 unmodified linesMagneticCrystal,MagneticSite,SublatticeClassification,instantaneous_slave_moments,reciprocal_lattice,)from induced_exchange.downfolding import InducedExchangeDownfolding, inverse_fourier_dressed_jij8 unmodified linesreturn MagneticCrystal(np.eye(3), list(sites), list(bonds))def test_one_robust_one_induced_infers_x_and_evaluates_slave_moment():model = crystal([site(1, 3.0), site(2, 1.5)], [ExchangeBond(2, 1, (0, 0, 0), 2.0)])response = InducedMomentResponse(model, [1], [2], mode="j_weighted")122 unmodified linesdef test_convenience_wrapper_is_algebraic_and_does_not_propagate():model = crystal([site(1, 1.0), site(2, 2.0)], [ExchangeBond(2, 1, (0, 0, 0), 3.0)])values = instantaneous_slave_moments(model, [2.0], [1], [2], x={2: 0.5})assert np.allclose(values, [3.0])7 unmodified lines8910111213148 unmodified lines23242526272829122 unmodified lines1521531541551561571587 unmodified linesMagneticCrystal,MagneticSite,SublatticeClassification,instantaneous_induced_moments,reciprocal_lattice,)from induced_exchange.downfolding import InducedExchangeDownfolding, inverse_fourier_dressed_jij8 unmodified linesreturn MagneticCrystal(np.eye(3), list(sites), list(bonds))def test_one_robust_one_induced_infers_x_and_evaluates_induced_moment():model = crystal([site(1, 3.0), site(2, 1.5)], [ExchangeBond(2, 1, (0, 0, 0), 2.0)])response = InducedMomentResponse(model, [1], [2], mode="j_weighted")122 unmodified linesdef test_convenience_wrapper_is_algebraic_and_does_not_propagate():model = crystal([site(1, 1.0), site(2, 2.0)], [ExchangeBond(2, 1, (0, 0, 0), 3.0)])values = instantaneous_induced_moments(model, [2.0], [1], [2], x={2: 0.5})assert np.allclose(values, [3.0])
144 unmodified lines145146147148149150151144 unmodified linesassert stiffness.q_max == 0.25def test_polesya_and_mryasov_physical_spectra_are_identical_without_slave_branches():model = crystal([site(1, 1.0), site(2, 1.0)],[144 unmodified lines145146147148149150151144 unmodified linesassert stiffness.q_max == 0.25def test_polesya_and_mryasov_physical_spectra_are_identical_without_induced_branches():model = crystal([site(1, 1.0), site(2, 1.0)],[
137 unmodified lines138139140141142143137 unmodified linesassert "coherent unit-amplitude" in response_markdown(session)def test_dressed_realspace_plots_separate_induced_correction_and_label_channels():pytest.importorskip("matplotlib.pyplot")loaded = load_uppasd("examples/induced_toy/inpsd.dat", energy_unit="meV")137 unmodified lines138139140141142143144145146147148149150151152153154155156137 unmodified linesassert "coherent unit-amplitude" in response_markdown(session)def test_raw_exchange_plot_separates_robust_cross_and_induced_markers():pytest.importorskip("matplotlib.pyplot")loaded = load_uppasd("examples/induced_toy/inpsd.dat", energy_unit="meV")session = analyse_model(loaded, SublatticeClassification.from_inputs([1], [2]), mesh_size=2, x=0.5)figure = _figure_realspace(session)labels = {r"$J_{MM}$", r"$J_{Mm}$", r"$J_{mm}$"}labelled = [collection for collection in figure.axes[0].collections if collection.get_label() in labels]assert {collection.get_label() for collection in labelled} == labelsmarker_shapes = {tuple(np.round(collection.get_paths()[0].vertices.ravel(), 8)) for collection in labelled}assert len(marker_shapes) == 3def test_dressed_realspace_plots_separate_induced_correction_and_label_channels():pytest.importorskip("matplotlib.pyplot")loaded = load_uppasd("examples/induced_toy/inpsd.dat", energy_unit="meV")
app.py+6-6
docs/IMX-09_UPPASD_CONVENTION_CLOSEOUT.md+2-2
docs/PHYSICS_LIMITS.md+1-1
docs/THEORY.md+2-2
src/induced_exchange/__init__.py+2
src/induced_exchange/downfolding.py+1-1
src/induced_exchange/induced.py+11-7
src/induced_exchange/magnons.py+5-5
src/induced_exchange/space.py+20-7
tests/test_induced.py+3-3
tests/test_magnons.py+1-1
tests/test_space.py+13