From 538f021a159071b241adc24a1a40a28cf0855aa1 Mon Sep 17 00:00:00 2001 From: Kipton Barros Date: Tue, 25 Jul 2023 14:20:18 -0600 Subject: [PATCH] Tweaks --- src/Symmetry/AllowedAnisotropy.jl | 4 ++-- src/Symmetry/Crystal.jl | 4 ++-- src/Symmetry/Parsing.jl | 4 ++-- src/Symmetry/Printing.jl | 2 +- src/System/Interactions.jl | 11 +++++++++++ src/System/OnsiteCoupling.jl | 2 +- src/System/PairExchange.jl | 2 +- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/Symmetry/AllowedAnisotropy.jl b/src/Symmetry/AllowedAnisotropy.jl index d9f6f3eda..28822df3c 100644 --- a/src/Symmetry/AllowedAnisotropy.jl +++ b/src/Symmetry/AllowedAnisotropy.jl @@ -135,7 +135,7 @@ function suggest_frame_for_atom(cryst::Crystal, i::Int) end if isempty(axes_counts) - @warn "Could not find a symmetry axis." + @info "Could not find a symmetry axis." return Mat3(I) end @@ -170,7 +170,7 @@ function suggest_frame_for_atom(cryst::Crystal, i::Int) orthogonal_axes_counts = filter(x -> abs(x[1]⋅z_dir) < 1e-12, axes_counts) if isempty(orthogonal_axes_counts) - @warn "Could not find a symmetry axis orthogonal to $z_dir." + @info "Could not find a symmetry axis orthogonal to $z_dir." x_dir = (z_dir ≈ Vec3(1,0,0)) ? Vec3(0,0,1) : Vec3(1,0,0) x_dir = normalize(x_dir - (x_dir⋅z_dir)*z_dir) else diff --git a/src/Symmetry/Crystal.jl b/src/Symmetry/Crystal.jl index a3fe9028d..c4f9f1615 100644 --- a/src/Symmetry/Crystal.jl +++ b/src/Symmetry/Crystal.jl @@ -136,7 +136,7 @@ end function print_crystal_warnings(latvecs, positions) det(latvecs) < 0 && @warn "Lattice vectors are not right-handed." if length(positions) >= 100 - @warn """This a very large crystallographic cell, which Sunny does not handle well. + @info """This a very large crystallographic cell, which Sunny does not handle well. If the intention is to model chemical inhomogeneity, the recommended procedure is as follows: First, create a small unit cell with an idealized structure. Next, create a perfectly periodic `System` of the desired size. Finally, use `to_inhomogeneous` @@ -492,7 +492,7 @@ function subcrystal(cryst::Crystal, classes::Vararg{Int, N}) where N new_sitesyms = cryst.sitesyms[atoms] if atoms != 1:maximum(atoms) - @warn "Atoms are being renumbered." + @info "Atoms have been renumbered in subcrystal." end ret = Crystal(cryst.latvecs, cryst.prim_latvecs, new_positions, new_types, new_classes, new_sitesyms, diff --git a/src/Symmetry/Parsing.jl b/src/Symmetry/Parsing.jl index e8c4c486e..adb63d830 100644 --- a/src/Symmetry/Parsing.jl +++ b/src/Symmetry/Parsing.jl @@ -108,14 +108,14 @@ function Crystal(filename::AbstractString; symprec=nothing) end (err, i) = findmax(errs) if err < 1e-12 - @warn """Precision parameter is unspecified, but all coordinates seem to be simple fractions. + @info """Precision parameter is unspecified, but all coordinates seem to be simple fractions. Setting symprec=1e-12.""" symprec = 1e-12 elseif 1e-12 < err < 1e-4 symprec = 15err err_str = @sprintf "%.1e" err symprec_str = @sprintf "%.1e" symprec - @warn """Precision parameter is unspecified, but coordinate string '$s' seems to have error $err_str. + @info """Precision parameter is unspecified, but coordinate string '$s' seems to have error $err_str. Setting symprec=$symprec_str.""" else error("Cannot infer precision. Please provide an explicit `symprec` parameter to load '$filename'") diff --git a/src/Symmetry/Printing.jl b/src/Symmetry/Printing.jl index fe3c36722..6536e3a6c 100644 --- a/src/Symmetry/Printing.jl +++ b/src/Symmetry/Printing.jl @@ -282,7 +282,7 @@ function print_allowed_anisotropy(cryst::Crystal, i::Int; R::Mat3, atol, digits, for b in reverse(collect(eachcol(B))) if any(x -> 1e-12 < abs(x) < 1e-6, b) - @warn """Found a very small but nonzero expansion coefficient. + @info """Found a very small but nonzero expansion coefficient. This may indicate a slightly misaligned reference frame.""" end diff --git a/src/System/Interactions.jl b/src/System/Interactions.jl index 383e64c62..47ef6f097 100644 --- a/src/System/Interactions.jl +++ b/src/System/Interactions.jl @@ -4,6 +4,17 @@ function empty_interactions(na, N) end end +# Warn up to `OverrideWarningMax` times about overriding a coupling +OverrideWarningCnt::Int = 0 +OverrideWarningMax::Int = 5 +function warn_coupling_override(str) + global OverrideWarningCnt, OverrideWarningMax + OverrideWarningCnt < OverrideWarningMax && @info str + OverrideWarningCnt += 1 + OverrideWarningCnt == OverrideWarningMax && @info "Suppressing future override notifications." +end + + # Creates a clone of the lists of exchange interactions, which can be mutably # updated. function clone_interactions(ints::Interactions) diff --git a/src/System/OnsiteCoupling.jl b/src/System/OnsiteCoupling.jl index df7984355..54123ab77 100644 --- a/src/System/OnsiteCoupling.jl +++ b/src/System/OnsiteCoupling.jl @@ -152,7 +152,7 @@ function set_onsite_coupling!(sys::System{N}, op::Matrix{ComplexF64}, i::Int) wh (1 <= i <= natoms(sys.crystal)) || error("Atom index $i is out of range.") if !iszero(ints[i].onsite) - @info "Overriding anisotropy for atom $i." + warn_coupling_override("Overriding anisotropy for atom $i.") end onsite = OnsiteCoupling(sys, op, sys.Ns[1,1,1,i]) diff --git a/src/System/PairExchange.jl b/src/System/PairExchange.jl index 54cd4fcec..6a978da2f 100644 --- a/src/System/PairExchange.jl +++ b/src/System/PairExchange.jl @@ -99,7 +99,7 @@ function set_exchange!(sys::System{N}, J, bond::Bond; biquad=0.) where N # Print a warning if an interaction already exists for bond if any(x -> x.bond == bond, ints[bond.i].pair) - @info "Overriding exchange for bond $bond." + warn_coupling_override("Overriding coupling for $bond.") end for i in 1:natoms(sys.crystal)