Skip to content

Commit

Permalink
update Project.toml (#196)
Browse files Browse the repository at this point in the history
* update Project.toml

* JuliaFormatter Action Bot (#197)

Co-authored-by: eahenle <eahenle@users.noreply.github.com>

* fix compats

* atomsbase interface and printing fix

* fix

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: eahenle <eahenle@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent be09a6d commit 14a4e39
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
16 changes: 8 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Xtals"
uuid = "ede5f01d-793e-4c47-9885-c447d1f18d6d"
authors = ["SimonEnsemble <cory.simon@oregonstate.edu>"]
version = "0.5.0"
version = "0.5.1"

[deps]
AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a"
Expand All @@ -20,17 +20,17 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
Aqua = "0.5"
AtomsBase = "0.2.0"
Bio3DView = "0.1"
AtomsBase = "0.2, 0.3, 0.4"
Bio3DView = "0.1, 1, 2"
CSV = "0.10"
DataFrames = "1.0"
DataFrames = "1"
Graphs = "1.4"
JLD2 = "0.4"
MetaGraphs = "0.7"
PeriodicTable = "1.1"
PrecompileSignatures = "3.0"
StaticArrays = "1.3"
Unitful = "1.11"
PeriodicTable = "1"
PrecompileSignatures = "3"
StaticArrays = "1"
Unitful = "1"
julia = "1.6"

[extras]
Expand Down
46 changes: 37 additions & 9 deletions src/crystal.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# AtomsBase interface things
import Base: position, length, getindex, keys, display, show, print, println
import AtomsBase: velocity, bounding_box, boundary_conditions, atomic_symbol, species_type, atomic_number

"""
SymmetryInfo(symmetry, space_group, is_p1)
Expand Down Expand Up @@ -157,7 +161,7 @@ function Crystal(

# Make sure the space group is P1
if line[1] == "_symmetry_space_group_name_H-M" ||
line[1] == "_space_group_name_Hall" ||
line[1] == "_space_group_name_Hall" ||
line[1] == "_space_group_name_H-M_alt"
# use anonymous function to combine all terms past the first
# to extract space group name
Expand Down Expand Up @@ -1194,7 +1198,31 @@ crystal and adding new ones...\n",
return new_crystal
end

function Base.show(io::IO, crystal::Crystal)
function Base.show(io::IO, mime::MIME"text/plain", system::Crystal)
print(io, system)
end

print(xtal::Crystal) = show(xtal)

print(io::IO, xtal::Crystal) = show(io, xtal)

function println(xtal::Crystal)
println("")
show(xtal)
end

function println(io::IO, xtal::Crystal)
println(io, "")
show(io, xtal)
end

display(xtal::Crystal) = show(xtal)

display(io::IO, xtal::Crystal) = show(io, xtal)

show(xtal::Crystal) = show(stdout, xtal)

function show(io::IO, crystal::Crystal)
println(io, "Name: ", crystal.name)
println(io, crystal.box)
@printf(io, "\t# atoms = %d\n", crystal.atoms.n)
Expand Down Expand Up @@ -1329,20 +1357,20 @@ function Base.:+(
return crystal
end

# AtomsBase interface things
import Base.position
import AtomsBase.velocity
import AtomsBase.bounding_box
import AtomsBase.boundary_conditions
import Base.length, Base.getindex
import AtomsBase.atomic_symbol
keys(xtal::Crystal) = 1:xtal.atoms.n

atomic_number(xtal::Crystal) = [elements[x].number for x in xtal.atoms.species]

species_type(xtal::Crystal) = xtal.atoms.species

length(xtal::Crystal) = xtal.atoms.n

getindex(xtal::Crystal, index::Int) = xtal.atoms[index]

atomic_symbol(atom::Atoms) = atom.species[1]

atomic_symbol(xtal::Crystal) = xtal.atoms.species

function position(crystal::Crystal)
pos = Cart(crystal.atoms.coords, crystal.box).x
return [pos[:, i] for i in 1:size(pos, 2)] * u""
Expand Down

0 comments on commit 14a4e39

Please sign in to comment.