diff --git a/src/guessbonds.jl b/src/guessbonds.jl index 20e539d..4ba1a79 100644 --- a/src/guessbonds.jl +++ b/src/guessbonds.jl @@ -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 diff --git a/src/input.jl b/src/input.jl index 584e868..2433c3c 100644 --- a/src/input.jl +++ b/src/input.jl @@ -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}[] @@ -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 @@ -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) diff --git a/src/options.jl b/src/options.jl index 7ba845f..0e326ed 100644 --- a/src/options.jl +++ b/src/options.jl @@ -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 @@ -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 @@ -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, @@ -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 @@ -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,