Skip to content

Commit

Permalink
Errors always throw
Browse files Browse the repository at this point in the history
  • Loading branch information
kbarros committed Jul 23, 2024
1 parent 41a6096 commit cf92da3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/System/OnsiteCoupling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ function set_onsite_coupling!(sys::System, op, i::Int)
onsite = onsite_coupling(sys, CartesianIndex(1,1,1,i), op)

if !is_anisotropy_valid(sys.crystal, i, onsite)
@error """Symmetry-violating anisotropy: $op.
Use `print_site(crystal, $i)` for more information."""
error("Invalid anisotropy.")
error("""Symmetry-violating anisotropy: $op.
Use `print_site(crystal, $i)` for more information.""")
end

cryst = sys.crystal
Expand Down
24 changes: 11 additions & 13 deletions src/System/PairExchange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,18 @@ function set_pair_coupling_aux!(sys::System, scalar::Float64, bilin::Union{Float

# Verify that couplings are symmetry-consistent
if !is_coupling_valid(sys.crystal, bond, bilin)
@error """Symmetry-violating bilinear exchange $bilin.
Use `print_bond(crystal, $bond)` for more information."""
error("""Symmetry-violating bilinear exchange $bilin.
Use `print_bond(crystal, $bond)` for more information.""")
end
if !is_coupling_valid(sys.crystal, bond, biquad)
biquad_str = formatted_matrix(number_to_math_string.(biquad); prefix=" ")
@error """Symmetry-violating biquadratic exchange (written in Stevens basis)
$biquad_str
Use `print_bond(crystal, $bond)` for more information."""
error("""Symmetry-violating biquadratic exchange (written in Stevens basis)
$biquad_str
Use `print_bond(crystal, $bond)` for more information.""")
end
if !is_coupling_valid(sys.crystal, bond, tensordec)
@error """Symmetry-violating coupling. Use `print_bond(crystal, $bond)` for more information."""
error("Interaction violates symmetry.")
error("""Symmetry-violating coupling.
Use `print_bond(crystal, $bond)` for more information.""")
end

# Print a warning if an interaction already exists for bond
Expand Down Expand Up @@ -382,9 +382,8 @@ function sites_to_internal_bond(sys::System{N}, site1::CartesianIndex{4}, site2:
else
cell1 = Tuple(to_cell(site1))
cell2 = Tuple(to_cell(site2))
@error """Cells $cell1 and $cell2 are not compatible with the offset
$n_ref for a system with lattice size $latsize."""
error("Incompatible displacement specified")
error("""Cells $cell1 and $cell2 are not compatible with the offset
$n_ref for a system with lattice size $latsize.""")
end
end

Expand All @@ -406,9 +405,8 @@ function sites_to_internal_bond(sys::System{N}, site1::CartesianIndex{4}, site2:
else
n1 = bonds[perm[1]].n
n2 = bonds[perm[2]].n
@error """Cannot find an obvious offset vector. Possibilities include $n1 and $n2.
Try using a bigger system size, or pass an explicit offset vector."""
error("Ambiguous offset between sites.")
error("""Ambiguous offset vector. Possibilities include $n1 and $n2.
Try using a bigger system size, or pass an explicit offset.""")
end
end

Expand Down

0 comments on commit cf92da3

Please sign in to comment.