Skip to content

Commit

Permalink
Reintroduce ignore_homometallic_bonds, split from reduce_homometallic…
Browse files Browse the repository at this point in the history
…_bonds
  • Loading branch information
Liozou committed Feb 28, 2024
1 parent 25fd07f commit dd7af43
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/guessbonds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ function guess_bonds(pos, types, mat, options)
typi = types[i]
#ignoreifmetallic = typi === :C
#ignoreifC = ismetal[atomic_numbers[typi]]
skiphomoatomic = typi options.ignore_homoatomic_bonds #||
# (options.ignore_homometallic_bonds && ismetal[atomic_numbers[typi]])
skiphomoatomic = typi options.ignore_homoatomic_bonds ||
(options.ignore_homometallic_bonds && ismetal[atomic_numbers[typi]])
acceptonlyO = options.structure === StructureType.Zeolite && typi !== :O
acceptallbutO = options.structure === StructureType.Zeolite && typi === :O
for j in (i+1):n
Expand Down
18 changes: 9 additions & 9 deletions src/input.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1184,13 +1184,13 @@ function sanity_checks!(graph, pos, types, mat, options)
end


function _remove_homoatomic_bonds!(graph::PeriodicGraph{D}, types, targets, ignore_homometallic) where D
isempty(targets) && !ignore_homometallic && return Int[]
function _remove_homoatomic_bonds!(graph::PeriodicGraph{D}, types, targets, reduce_homometallic) where D
isempty(targets) && !reduce_homometallic && return Int[]
metallics = Int[]
for i in 1:length(types)
t = types[i]
if t targets
ignore_homometallic && ismetal[atomic_numbers[t]] && push!(metallics, i)
reduce_homometallic && ismetal[atomic_numbers[t]] && push!(metallics, i)
continue
end
rem_edges = PeriodicVertex{D}[]
Expand Down Expand Up @@ -1254,16 +1254,16 @@ function _remove_homometallic_bonds!(graph::PeriodicGraph{D}, types, metallics)
end

"""
remove_homoatomic_bonds!(graph::PeriodicGraph, types, targets, ignore_homometallic)
remove_homoatomic_bonds!(graph::PeriodicGraph, types, targets, reduce_homometallic)
Remove from the graph all bonds of the form X-X where X is an atom in `targets`.
Also remove all such bonds where X is a metal if the two bonded atoms up to third
neighbours otherwise, and if `ignore_homometallic` is `true`.
neighbours otherwise, and if `reduce_homometallic` is `true`.
"""
function remove_homoatomic_bonds!(graph::PeriodicGraph{D}, types, targets, ignore_homometallic) where D
metallics = _remove_homoatomic_bonds!(graph, types, targets, ignore_homometallic)
ignore_homometallic && _remove_homometallic_bonds!(graph, types, metallics)
function remove_homoatomic_bonds!(graph::PeriodicGraph{D}, types, targets, reduce_homometallic) where D
metallics = _remove_homoatomic_bonds!(graph, types, targets, reduce_homometallic)
reduce_homometallic && _remove_homometallic_bonds!(graph, types, metallics)
end


Expand Down Expand Up @@ -1443,7 +1443,7 @@ function finalize_checks(cell::Cell, pos::Vector{SVector{3,Float64}}, types::Vec
end
end

remove_homoatomic_bonds!(graph, types, options.ignore_homoatomic_bonds, options.ignore_homometallic_bonds)
remove_homoatomic_bonds!(graph, types, options.ignore_homoatomic_bonds, options.reduce_homometallic_bonds)
end

if isempty(attributions)
Expand Down
14 changes: 9 additions & 5 deletions src/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ These boolean options have a default value that may be determined by [`Bonding`]
- `authorize_pruning`: remove colliding atoms in the input. Default is true.
- `wider_metallic_bonds`: for bond detections, metals have a radius equal to 1.5× their Van
der Waals radius. Default is false, unless [`StructureType`](@ref) is `MOF` or `Zeolite`.
- `ignore_homometallic_bonds`: when guessing bonds, do not bond two metallic atoms of the
- `ignore_homometallic_bonds`: remove all bonds between two metal atoms of the same kind.
- `reduce_homometallic_bonds`: when guessing bonds, do not bond two metallic atoms of the
same type if they are up to third neighbours anyway.
Default is false, unless [`StructureType`](@ref) is `MOF`.
- `ignore_metal_cluster_bonds`: do not bond two metallic clusters together if they share at
Expand Down Expand Up @@ -399,6 +400,7 @@ struct Options
ignore_atoms::Set{Symbol}
ignore_homoatomic_bonds::Set{Symbol}
ignore_homometallic_bonds::Bool
reduce_homometallic_bonds::Bool
ignore_low_occupancy::Bool
export_input::String
export_trimmed::String
Expand Down Expand Up @@ -443,7 +445,8 @@ struct Options
authorize_pruning=true,
ignore_atoms=Set{Symbol}(),
ignore_homoatomic_bonds=Set{Symbol}(),
ignore_homometallic_bonds=nothing,
ignore_homometallic_bonds=false,
reduce_homometallic_bonds=nothing,
ignore_low_occupancy=false,
export_input=DOEXPORT[],
export_trimmed=false,
Expand Down Expand Up @@ -482,10 +485,10 @@ struct Options
_export_net = ifbooltempdirorempty(export_net)
_export_subnets = ifbooltempdirorempty(export_subnets)

_ignore_homometallic_bonds = if ignore_homometallic_bonds === nothing
_reduce_homometallic_bonds = if reduce_homometallic_bonds === nothing
structure == StructureType.MOF
else
ignore_homometallic_bonds
_reduce_homometallic_bonds
end

_wider_metallic_bonds = if wider_metallic_bonds === nothing
Expand All @@ -503,7 +506,8 @@ struct Options
authorize_pruning,
Set{Symbol}(ignore_atoms),
Set{Symbol}(ignore_homoatomic_bonds),
_ignore_homometallic_bonds,
ignore_homometallic_bonds,
_reduce_homometallic_bonds,
ignore_low_occupancy,
_export_input,
_export_trimmed,
Expand Down

0 comments on commit dd7af43

Please sign in to comment.